blob: 6ad3f484d79017fce5a994f7661e76b2f9f43996 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.statistics;
import com.yahoo.container.StatisticsConfig;
/**
* Interface used for registering statistics values and counters for logging.
*
* @author steinar
* @author tonytv
*/
public interface Statistics {
/**
* Add a new handle to be scheduled for periodic logging. If a handle
* already exists with the same name, it will be cancelled and removed from
* the internal state of this object.
*/
void register(Handle h);
/**
* Remove a named handler from the set of working handlers.
*/
void remove(String name);
/**
* Get current config used. This may be a null reference, depending on how
* the instance was constructed.
*/
StatisticsConfig getConfig();
/**
* Purges all cancelled Handles from internal Map and Timer.
*
* @return return value from java.util.Timer.purge()
*/
int purge();
/** A null implementation which ignores all calls and returns the default config */
public static Statistics nullImplementation=new NullImplementation();
static class NullImplementation implements Statistics {
private StatisticsConfig nullConfig=new StatisticsConfig(new StatisticsConfig.Builder());
@Override
public void register(Handle h) { }
@Override
public void remove(String name) { }
@Override
public StatisticsConfig getConfig() { return nullConfig; }
@Override
public int purge() { return 0; }
}
}
|