X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2FDataPersistenceProvider.java;h=44afa634ccfc0b812761e9bb9fe97c6be9061900;hb=HEAD;hp=db4bf3143898f2e73ecb03d7f29b28fbb1165b82;hpb=cd81eb73b7abf677571b2366425ccbc8d794f4b6;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/DataPersistenceProvider.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/DataPersistenceProvider.java index db4bf31438..44afa634cc 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/DataPersistenceProvider.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/DataPersistenceProvider.java @@ -9,47 +9,84 @@ package org.opendaylight.controller.cluster; import akka.japi.Procedure; +import akka.persistence.JournalProtocol; +import akka.persistence.SnapshotProtocol; import akka.persistence.SnapshotSelectionCriteria; +import org.eclipse.jdt.annotation.NonNull; /** * DataPersistenceProvider provides methods to persist data and is an abstraction of the akka-persistence persistence * API. */ public interface DataPersistenceProvider { + /** - * @return false if recovery is not applicable. In that case the provider is not persistent and may not have - * anything to be recovered + * Returns whether or not persistence recovery is applicable/enabled. + * + * @return true if recovery is applicable, otherwise false, in which case the provider is not persistent and may + * not have anything to be recovered */ boolean isRecoveryApplicable(); /** - * Persist a journal entry. + * Persists an entry to the applicable journal synchronously. * - * @param o - * @param procedure - * @param + * @param entry the journal entry to persist + * @param procedure the callback when persistence is complete + * @param the type of the journal entry */ - void persist(T o, Procedure procedure); + void persist(T entry, Procedure procedure); /** - * Save a snapshot + * Persists an entry to the applicable journal asynchronously. * - * @param o + * @param entry the journal entry to persist + * @param procedure the callback when persistence is complete + * @param the type of the journal entry */ - void saveSnapshot(Object o); + void persistAsync(T entry, Procedure procedure); /** - * Delete snapshots based on the criteria + * Saves a snapshot. * - * @param criteria + * @param snapshot the snapshot object to save + */ + void saveSnapshot(Object snapshot); + + /** + * Deletes snapshots based on the given criteria. + * + * @param criteria the search criteria */ void deleteSnapshots(SnapshotSelectionCriteria criteria); /** - * Delete journal entries up to the sequence number + * Deletes journal entries up to the given sequence number. * - * @param sequenceNumber + * @param sequenceNumber the sequence number */ void deleteMessages(long sequenceNumber); + /** + * Returns the last sequence number contained in the journal. + * + * @return the last sequence number + */ + long getLastSequenceNumber(); + + /** + * Receive and potentially handle a {@link JournalProtocol} response. + * + * @param response A {@link JournalProtocol} response + * @return {@code true} if the response was handled + */ + boolean handleJournalResponse(JournalProtocol.@NonNull Response response); + + /** + * Receive and potentially handle a {@link SnapshotProtocol} response. + * + * @param response A {@link SnapshotProtocol} response + * @return {@code true} if the response was handled + */ + boolean handleSnapshotResponse(SnapshotProtocol.@NonNull Response response); }