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.JournalProtocol;
13 import akka.persistence.SnapshotProtocol;
14 import akka.persistence.SnapshotSelectionCriteria;
15 import org.eclipse.jdt.annotation.NonNull;
18 * DataPersistenceProvider provides methods to persist data and is an abstraction of the akka-persistence persistence
21 public interface DataPersistenceProvider {
24 * Returns whether or not persistence recovery is applicable/enabled.
26 * @return true if recovery is applicable, otherwise false, in which case the provider is not persistent and may
27 * not have anything to be recovered
29 boolean isRecoveryApplicable();
32 * Persists an entry to the applicable journal synchronously.
34 * @param entry the journal entry to persist
35 * @param procedure the callback when persistence is complete
36 * @param <T> the type of the journal entry
38 <T> void persist(T entry, Procedure<T> procedure);
41 * Persists an entry to the applicable journal asynchronously.
43 * @param entry the journal entry to persist
44 * @param procedure the callback when persistence is complete
45 * @param <T> the type of the journal entry
47 <T> void persistAsync(T entry, Procedure<T> procedure);
52 * @param snapshot the snapshot object to save
54 void saveSnapshot(Object snapshot);
57 * Deletes snapshots based on the given criteria.
59 * @param criteria the search criteria
61 void deleteSnapshots(SnapshotSelectionCriteria criteria);
64 * Deletes journal entries up to the given sequence number.
66 * @param sequenceNumber the sequence number
68 void deleteMessages(long sequenceNumber);
71 * Returns the last sequence number contained in the journal.
73 * @return the last sequence number
75 long getLastSequenceNumber();
78 * Receive and potentially handle a {@link JournalProtocol} response.
80 * @param response A {@link JournalProtocol} response
81 * @return {@code true} if the response was handled
83 boolean handleJournalResponse(JournalProtocol.@NonNull Response response);
86 * Receive and potentially handle a {@link SnapshotProtocol} response.
88 * @param response A {@link SnapshotProtocol} response
89 * @return {@code true} if the response was handled
91 boolean handleSnapshotResponse(SnapshotProtocol.@NonNull Response response);