Rehost Chunked{ByteArray,InputStream,OutputStream}
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / DataPersistenceProvider.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster;
10
11 import akka.japi.Procedure;
12 import akka.persistence.SnapshotSelectionCriteria;
13
14 /**
15  * DataPersistenceProvider provides methods to persist data and is an abstraction of the akka-persistence persistence
16  * API.
17  */
18 public interface DataPersistenceProvider {
19
20     /**
21      * Returns whether or not persistence recovery is applicable/enabled.
22      *
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
25      */
26     boolean isRecoveryApplicable();
27
28     /**
29      * Persists an entry to the applicable journal synchronously.
30      *
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
34      */
35     <T> void persist(T entry, Procedure<T> procedure);
36
37     /**
38      * Persists an entry to the applicable journal asynchronously.
39      *
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
43      */
44     <T> void persistAsync(T entry, Procedure<T> procedure);
45
46     /**
47      * Saves a snapshot.
48      *
49      * @param snapshot the snapshot object to save
50      */
51     void saveSnapshot(Object snapshot);
52
53     /**
54      * Deletes snapshots based on the given criteria.
55      *
56      * @param criteria the search criteria
57      */
58     void deleteSnapshots(SnapshotSelectionCriteria criteria);
59
60     /**
61      * Deletes journal entries up to the given sequence number.
62      *
63      * @param sequenceNumber the sequence number
64      */
65     void deleteMessages(long sequenceNumber);
66
67     /**
68      * Returns the last sequence number contained in the journal.
69      *
70      * @return the last sequence number
71      */
72     long getLastSequenceNumber();
73 }