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

com.alachisoft.ncache.client.internal.communication.PersistenceManager Maven / Gradle / Ivy

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.alachisoft.ncache.client.internal.communication;

import Alachisoft.NCache.Caching.EventId;
import Alachisoft.NCache.Common.DataStructures.SlidingIndex;

class PersistenceManager {
    private SlidingIndex _index = new SlidingIndex(30);

    private boolean isStoreEventsEnabled = false;

    private java.util.HashMap _duplicateEventLog;
    private boolean _checkEventDuplication = false;
    private java.util.Date _eventDuplicationStartTime = new java.util.Date(0);

    public PersistenceManager(int interval) {
        _index = new SlidingIndex(interval, true);
    }

    public final void StartEventDuplicationCheck() {

    }

    public final boolean StopEventDuplicationCheck() {


        return false;
    }



    private boolean CheckEventDuplication(EventId eventId) {
        synchronized (this) {
            if (_checkEventDuplication && !StopEventDuplicationCheck()) {
                if (_duplicateEventLog.containsKey(eventId)) {
                    return true;
                } else {
                    _duplicateEventLog.put(eventId, null);
                }
            }
            return false;
        }
    }

    public final boolean PersistEvent(EventId evtId) {

        if (evtId != null) {
            return _index.AddToIndex(evtId);
        }

        return true;

    }

    public final java.util.ArrayList GetPersistedEventsList() {
        java.util.Iterator en = _index.GetCurrentData();
        Alachisoft.NCache.Caching.EventId evtId;
        java.util.ArrayList events = new java.util.ArrayList();

        while (en.hasNext()) {
            evtId = (Alachisoft.NCache.Caching.EventId) en.next();
            events.add(evtId);
        }
        return events;
    }

    public final void dispose() {
        _index = null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy