blob: 6d670b1795b7ea50fe76d2291585498dfd4cd2ee (
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 2017 Yahoo Holdings. 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);
}
}
|