Package org.apache.heron.api.metric
Enum GlobalMetrics
- java.lang.Object
-
- java.lang.Enum<GlobalMetrics>
-
- org.apache.heron.api.metric.GlobalMetrics
-
- All Implemented Interfaces:
Serializable
,Comparable<GlobalMetrics>
public enum GlobalMetrics extends Enum<GlobalMetrics> implements Serializable
Singleton class which exposes a simple globally available counter for heron jobs. Anywhere in the execution of heron job, user can put-GlobalMetrics.incr("mycounter")
to add a counter. There will be no need to explicitly declare the counter before. If the counter doesn't exist it will be created. The creation is lazy which means, unless the counter not being available, it is counted as 0 CounterFactory.init() should be called in prepare and open methods of bolt and spout respectively. The counters will be named __auto__/mycounter (note the __auto__ prefix)
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MultiCountMetric
getUnderlyingCounter()
test-onlystatic void
incr(String counterName)
Not thread safe increment of counterName.static void
incrBy(String counterName, int incrValue)
Not thread safe 'incrementing by' of counterName.static void
init(IMetricsRegister metricsRegister, Duration metricsBucket)
Initialize the counter by registering the metricContainer.protected Object
readResolve()
During serialization don't create a copy of this class.static void
safeIncr(String counterName)
Thread safe created increment of counterName.static void
safeIncrBy(String counterName, int incrValue)
Thread safe created increment of counterName.static GlobalMetrics
valueOf(String name)
Returns the enum constant of this type with the specified name.static GlobalMetrics[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
INSTANCE
public static final GlobalMetrics INSTANCE
-
-
Field Detail
-
ROOT_NAME
public static final String ROOT_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static GlobalMetrics[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (GlobalMetrics c : GlobalMetrics.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static GlobalMetrics valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
incr
public static void incr(String counterName)
Not thread safe increment of counterName. Counter doesn't exist unless incremented once
-
incrBy
public static void incrBy(String counterName, int incrValue)
Not thread safe 'incrementing by' of counterName. Counter doesn't exist unless incremented once
-
safeIncr
public static void safeIncr(String counterName)
Thread safe created increment of counterName. (Slow)
-
safeIncrBy
public static void safeIncrBy(String counterName, int incrValue)
Thread safe created increment of counterName. (Slow)
-
init
public static void init(IMetricsRegister metricsRegister, Duration metricsBucket)
Initialize the counter by registering the metricContainer. Should be done in open/prepare call. TODO: Investigate if it is possible to do this part in ctor. One thing to note is how this will affect the serialization of CounterFactory.
-
getUnderlyingCounter
public static MultiCountMetric getUnderlyingCounter()
test-only
-
readResolve
protected Object readResolve()
During serialization don't create a copy of this class. 'readResolve' is used by reflection for java serialization.
-
-