Alachisoft.NCache.MetricsAgents.JMX.Metrics.CounterStore Maven / Gradle / Ivy
The newest version!
package Alachisoft.NCache.MetricsAgents.JMX.Metrics;
import com.alachisoft.ncache.runtime.Disposable;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class CounterStore implements Disposable {
private Object _metricsLock = new Object();
private Map _metrics;
public CounterStore(){
_metrics = new HashMap<>();
}
public boolean ContainsInstance(String instanceId)
{
synchronized (_metricsLock)
{
return _metrics.containsKey(instanceId);
}
}
public CountersMBean GetJMXMBeanInstance(String instanceId)
{
synchronized (_metricsLock)
{
return _metrics.get(instanceId);
}
}
public void RemoveJMXBeanInstance(String instanceId)
{
synchronized (_metricsLock)
{
_metrics.remove(instanceId);
}
}
public boolean IsEmpty()
{
synchronized (_metricsLock)
{
return _metrics.size() < 1;
}
}
public void AddJMXMBeanInstance(String instanceId, CountersMBean counterCollection)
{
synchronized (_metricsLock)
{
_metrics.put(instanceId, counterCollection);
}
}
@Override
public void dispose() {
}
}