Restart downed nodes.
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / PersistentDataProvider.java
1 /*
2  * Copyright (c) 2015 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 package org.opendaylight.controller.cluster;
9
10 import static java.util.Objects.requireNonNull;
11
12 import akka.japi.Procedure;
13 import akka.persistence.AbstractPersistentActor;
14 import akka.persistence.SnapshotSelectionCriteria;
15
16 /**
17  * A DataPersistenceProvider implementation with persistence enabled.
18  */
19 public class PersistentDataProvider implements DataPersistenceProvider {
20
21     private final AbstractPersistentActor persistentActor;
22
23     public PersistentDataProvider(AbstractPersistentActor persistentActor) {
24         this.persistentActor = requireNonNull(persistentActor, "persistentActor can't be null");
25     }
26
27     @Override
28     public boolean isRecoveryApplicable() {
29         return true;
30     }
31
32     @Override
33     public <T> void persist(T entry, Procedure<T> procedure) {
34         persistentActor.persist(entry, procedure);
35     }
36
37     @Override
38     public <T> void persistAsync(T entry, Procedure<T> procedure) {
39         persistentActor.persistAsync(entry, procedure);
40     }
41
42     @Override
43     public void saveSnapshot(Object snapshot) {
44         persistentActor.saveSnapshot(snapshot);
45     }
46
47     @Override
48     public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
49         persistentActor.deleteSnapshots(criteria);
50     }
51
52     @Override
53     public void deleteMessages(long sequenceNumber) {
54         persistentActor.deleteMessages(sequenceNumber);
55     }
56
57     @Override
58     public long getLastSequenceNumber() {
59         return persistentActor.lastSequenceNr();
60     }
61 }