Module org.elasticsearch.xcore
Class Counters
java.lang.Object
org.elasticsearch.xpack.core.watcher.common.stats.Counters
- All Implemented Interfaces:
Writeable
Helper class to create simple usage stat counters based on longs
Internally this is a map mapping from String to a long, which is the counter
Calling toNestedMap() will create a nested map, where each dot of the key name will nest deeper
The main reason for this class is that the stats producer should not be worried about how the map is actually nested
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongbooleanvoidIncrement the counter by onevoidIncrement the counter by configured numberstatic CountersvoidSets a counter.longsize()Convert the counters to a nested map, using the "." as a splitter to create deeper mapsvoidwriteTo(StreamOutput out)
-
Constructor Details
-
Counters
- Throws:
IOException
-
Counters
-
-
Method Details
-
set
Sets a counter. This ensures that the counter is there, even though it is never incremented.- Parameters:
name- Name of the counter
-
inc
Increment the counter by one- Parameters:
name- Name of the counter
-
inc
Increment the counter by configured number- Parameters:
name- The name of the countercount- Incremental value
-
get
-
size
public long size() -
hasCounters
public boolean hasCounters() -
toNestedMap
Convert the counters to a nested map, using the "." as a splitter to create deeper maps- Returns:
- A nested map with all the current configured counters
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
merge
-