2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster;
11 import akka.japi.Procedure;
12 import akka.persistence.SnapshotSelectionCriteria;
15 * DataPersistenceProvider provides methods to persist data and is an abstraction of the akka-persistence persistence
18 public interface DataPersistenceProvider {
21 * Returns whether or not persistence recovery is applicable/enabled.
23 * @return true if recovery is applicable, otherwise false, in which case the provider is not persistent and may
24 * not have anything to be recovered
26 boolean isRecoveryApplicable();
29 * Persists an entry to the applicable journal synchronously.
31 * @param entry the journal entry to persist
32 * @param procedure the callback when persistence is complete
33 * @param <T> the type of the journal entry
35 <T> void persist(T entry, Procedure<T> procedure);
38 * Persists an entry to the applicable journal asynchronously.
40 * @param entry the journal entry to persist
41 * @param procedure the callback when persistence is complete
42 * @param <T> the type of the journal entry
44 <T> void persistAsync(T entry, Procedure<T> procedure);
49 * @param snapshot the snapshot object to save
51 void saveSnapshot(Object snapshot);
54 * Deletes snapshots based on the given criteria.
56 * @param criteria the search criteria
58 void deleteSnapshots(SnapshotSelectionCriteria criteria);
61 * Deletes journal entries up to the given sequence number.
63 * @param sequenceNumber the sequence number
65 void deleteMessages(long sequenceNumber);
68 * Returns the last sequence number contained in the journal.
70 * @return the last sequence number
72 long getLastSequenceNumber();