blob: 91ce3d0c2a742b1c88ac21aaaf034e93fdb8fee2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.state;
/**
* A metric which is counting an accumulative value
*
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
*/
public final class CountMetric extends MetricValue {
private long count;
private CountMetric(long count) {
this.count = count;
}
@Override
void add(Number num) {
this.count += num.longValue();
}
@Override
void add(MetricValue value) {
CountMetric rhs = (CountMetric)value;
this.count += rhs.count;
}
/** Returns the accumulated count of this metric in the time interval */
public long getCount() {
return count;
}
public static CountMetric newSingleValue(Number val) {
long lval = val.longValue();
return new CountMetric(lval);
}
public static CountMetric newInstance(long val) {
return new CountMetric(val);
}
}
|