com.hazelcast.internal.metrics.impl
Class MetricsRegistryImpl

java.lang.Object
  extended by com.hazelcast.internal.metrics.impl.MetricsRegistryImpl
All Implemented Interfaces:
MetricsRegistry

public class MetricsRegistryImpl
extends Object
implements MetricsRegistry

The MetricsRegistry implementation.


Constructor Summary
MetricsRegistryImpl(ILogger logger)
          Creates a MetricsRegistryImpl instance.
 
Method Summary
<S> void
deregister(S source)
          Deregisters and scans object with probe annotations.
 Gauge getGauge(String name)
          Gets the Gauge for a given name.
 Set<String> getNames()
          Gets a set of all current metric names.
 int modCount()
          Returns the modCount.
<S> void
register(S source, String name, DoubleProbe<S> input)
          Registers a probe If a Metric with the given name already has an input, that input will be overwritten.
<S> void
register(S source, String name, LongProbe<S> input)
          Registers a probe.
<S> void
scanAndRegister(S source, String namePrefix)
          Scans the source object for any fields/methods that have been annotated with Probe annotation, and registering these fields/methods as metrics.
 void scheduleAtFixedRate(Runnable publisher, long period, TimeUnit timeUnit)
          Schedules a publisher to be executed at a fixed rate.
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetricsRegistryImpl

public MetricsRegistryImpl(ILogger logger)
Creates a MetricsRegistryImpl instance. Automatically registers the com.hazelcast.internal.metrics.metricpacks.

Parameters:
logger - the ILogger used
Throws:
NullPointerException - if logger is null
Method Detail

modCount

public int modCount()
Description copied from interface: MetricsRegistry
Returns the modCount. Every time a Metric is added or removed, the modCount is increased. Returned modCount will always be equal or larger than 0.

Specified by:
modCount in interface MetricsRegistry
Returns:
the modCount.

getNames

public Set<String> getNames()
Description copied from interface: MetricsRegistry
Gets a set of all current metric names.

Specified by:
getNames in interface MetricsRegistry
Returns:
set of all current names.

scanAndRegister

public <S> void scanAndRegister(S source,
                                String namePrefix)
Description copied from interface: MetricsRegistry
Scans the source object for any fields/methods that have been annotated with Probe annotation, and registering these fields/methods as metrics. If metrics with the same name already exist, there source/inputs will be updated. So multiple registrations if the same object are ignored. If an object has no @Gauge annotations, the call is ignored.

Specified by:
scanAndRegister in interface MetricsRegistry
Parameters:
source - the object to scan.
namePrefix - the name prefix.

register

public <S> void register(S source,
                         String name,
                         LongProbe<S> input)
Description copied from interface: MetricsRegistry
Registers a probe. If a Metric with the given name already has an input, that input will be overwritten.

Specified by:
register in interface MetricsRegistry
name - the name of the metric.
input - the input for the metric.

register

public <S> void register(S source,
                         String name,
                         DoubleProbe<S> input)
Description copied from interface: MetricsRegistry
Registers a probe If a Metric with the given name already has an input, that input will be overwritten.

Specified by:
register in interface MetricsRegistry
name - the name of the metric.
input - the input for the metric.

getGauge

public Gauge getGauge(String name)
Description copied from interface: MetricsRegistry
Gets the Gauge for a given name. If no gauge exists for the name, it will be created but no input is set. The reason to do so is that you don't want to depend on the order of registration. Perhaps you want to read out e.g. operations.count gauge, but the OperationService has not started yet and the metric is not yet available.

Specified by:
getGauge in interface MetricsRegistry
Parameters:
name - the name
Returns:
the Gauge. Multiple calls with the same name, return the same Metric instance.

deregister

public <S> void deregister(S source)
Description copied from interface: MetricsRegistry
Deregisters and scans object with probe annotations. All metrics that were for this given source object are removed. If the object already is deregistered, the call is ignored. If the object was never registered, the call is ignored.

Specified by:
deregister in interface MetricsRegistry
Parameters:
source - the object to deregister

scheduleAtFixedRate

public void scheduleAtFixedRate(Runnable publisher,
                                long period,
                                TimeUnit timeUnit)
Description copied from interface: MetricsRegistry
Schedules a publisher to be executed at a fixed rate. Probably this method will be removed in the future, but we need a mechanism for complex gauges that require some calculation to provide their values.

Specified by:
scheduleAtFixedRate in interface MetricsRegistry
Parameters:
publisher - the published task that needs to be executed
period - the time between executions
timeUnit - the timeunit for period

shutdown

public void shutdown()


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.