Merge "Add unit test for ElectionTermImpl"
[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      * @return false if recovery is not applicable. In that case the provider is not persistent and may not have
21      * anything to be recovered
22      */
23     boolean isRecoveryApplicable();
24
25     /**
26      * Persist a journal entry.
27      *
28      * @param o
29      * @param procedure
30      * @param <T>
31      */
32     <T> void persist(T o, Procedure<T> procedure);
33
34     /**
35      * Save a snapshot
36      *
37      * @param o
38      */
39     void saveSnapshot(Object o);
40
41     /**
42      * Delete snapshots based on the criteria
43      *
44      * @param criteria
45      */
46     void deleteSnapshots(SnapshotSelectionCriteria criteria);
47
48     /**
49      * Delete journal entries up to the sequence number
50      *
51      * @param sequenceNumber
52      */
53     void deleteMessages(long sequenceNumber);
54
55     /**
56      * Returns the last sequence number contained in the journal.
57      */
58     long getLastSequenceNumber();
59 }