public enum PerformanceCounterContainer extends java.lang.Enum<PerformanceCounterContainer> implements Stoppable
PerformanceCounter
If there is a need for a performance counter, the user of this class should create an implementation of that interface and then register it in this container.
Note that the container will only start working after the first registration of a Performance Counter. That means that setting the timeouts is only relevant if done before the first registration of a Performance Counter.
The container will go through all the registered Performance Counters and will trigger their 'report' method. By default the container will start reporting after 5 minutes and will continue doing so every 1 minute.
The user of this class can add (register), remove (unregister) a performance counter while the container is working.
The container will be stopped automatically when the application exists.
Created by gupele on 3/3/2015.
Enum Constant and Description |
---|
INSTANCE |
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_COLLECTION_FREQUENCY_IN_SEC |
Modifier and Type | Method and Description |
---|---|
long |
getCollectionFrequencyInSec()
Gets the timeout in milliseconds that the container will wait between collections of Performance Counters.
|
long |
getStartCollectingDelayInMillis()
Gets the timeout in milliseconds that the container will wait before the first collection of Performance Counters.
|
boolean |
register(PerformanceCounter performanceCounter)
/**
Registers a
PerformanceCounter that can collect data. |
void |
setCollectionFrequencyInSec(long collectionFrequencyInSec)
Sets the timeout to wait between collection of Performance Counters.
|
void |
setPlugin(PerformanceCountersCollectionPlugin plugin) |
void |
stop(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Stopping the collection of performance data.
|
void |
unregister(PerformanceCounter performanceCounter)
Un-registers a performance counter.
|
void |
unregister(java.lang.String id)
Un-registers a performance counter by its id.
|
static PerformanceCounterContainer |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static PerformanceCounterContainer[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final PerformanceCounterContainer INSTANCE
public static final long DEFAULT_COLLECTION_FREQUENCY_IN_SEC
public static PerformanceCounterContainer[] values()
for (PerformanceCounterContainer c : PerformanceCounterContainer.values()) System.out.println(c);
public static PerformanceCounterContainer valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic boolean register(PerformanceCounter performanceCounter)
PerformanceCounter
that can collect data.performanceCounter
- The Performance Counter.public void unregister(PerformanceCounter performanceCounter)
performanceCounter
- The Performance Counter.public void unregister(java.lang.String id)
id
- The Performance Counter's id.public long getStartCollectingDelayInMillis()
public long getCollectionFrequencyInSec()
public void stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
public void setCollectionFrequencyInSec(long collectionFrequencyInSec)
The number must be a positive number
Note that the method will be effective if called before the first call to the 'register' method.
collectionFrequencyInSec
- The timeout to wait between collection of Performance Counters.public void setPlugin(PerformanceCountersCollectionPlugin plugin)