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));
}
}
Aggregations