All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.common.monitoring.MonitorableEntitiesDataStore Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package com.alachisoft.ncache.common.monitoring;

import Alachisoft.NCache.Common.DataStructures.Enumerator;
import Alachisoft.NCache.Common.DataStructures.SlidingIndex;
import java.util.Map;

public class MonitorableEntitiesDataStore implements AutoCloseable {
    private SlidingIndex> _statsIndex;
    private SlidingIndex _logIndex;

    public MonitorableEntitiesDataStore(int interval)
    {
        _statsIndex = new SlidingIndex>(interval);
        _logIndex = new SlidingIndex(interval);
    }

    public final void AddCounterData(IntervalCounterDataCollection CounterDataCollection)
    {
        MutableKeyValuePair tempVar = new MutableKeyValuePair();
        tempVar.setKey(CounterDataCollection);
        tempVar.setValue(true);
        _statsIndex.AddToIndex(tempVar);
    }

    public final java.util.ArrayList GetStatsData(tangible.RefObject startTime)
    {
        synchronized (_statsIndex)
        {
            Enumerator> en = _statsIndex.GetCurrentData(startTime, false);
            java.util.ArrayList list = new java.util.ArrayList();
            while (en.MoveNext())
            {
                MutableKeyValuePair current = en.getCurrent();
                if (current.getValue())
                {
                    IntervalCounterDataCollection present = current.getKey();
                    list.add(present);
                    current.setValue(false);
                }
            }

            return list;
        }
    }

    public final void AddToLogIndex(Object obj)
    {
        _logIndex.AddToIndex(obj);

    }

    public final void AddToAPILogIndex(Object obj)
    {

    }


    @Override
    public void close() throws Exception {
        if(_statsIndex !=null)
            _statsIndex.close();
        if(_logIndex !=null)
            _logIndex.close();
    }
}