Search in sources :

Example 1 with AsyncSnapshotPersistor

use of org.wso2.siddhi.core.util.snapshot.AsyncSnapshotPersistor in project siddhi by wso2.

the class SiddhiAppRuntime method persist.

public PersistenceReference persist() {
    try {
        // first, pause all the event sources
        sourceMap.values().forEach(list -> list.forEach(Source::pause));
        // take snapshots of execution units
        byte[] snapshots = siddhiAppContext.getSnapshotService().snapshot();
        // start the snapshot persisting task asynchronously
        AsyncSnapshotPersistor asyncSnapshotPersistor = new AsyncSnapshotPersistor(snapshots, siddhiAppContext.getSiddhiContext().getPersistenceStore(), siddhiAppContext.getName());
        String revision = asyncSnapshotPersistor.getRevision();
        Future future = siddhiAppContext.getExecutorService().submit(asyncSnapshotPersistor);
        return new PersistenceReference(future, revision);
    } finally {
        // at the end, resume the event sources
        sourceMap.values().forEach(list -> list.forEach(Source::resume));
    }
}
Also used : AsyncSnapshotPersistor(org.wso2.siddhi.core.util.snapshot.AsyncSnapshotPersistor) Future(java.util.concurrent.Future) PersistenceReference(org.wso2.siddhi.core.util.snapshot.PersistenceReference)

Aggregations

Future (java.util.concurrent.Future)1 AsyncSnapshotPersistor (org.wso2.siddhi.core.util.snapshot.AsyncSnapshotPersistor)1 PersistenceReference (org.wso2.siddhi.core.util.snapshot.PersistenceReference)1