Fix NPE in YangTextSchemaSourceSerializationProxy#getRepresentation
[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 akka.japi.Procedure;
11 import akka.persistence.SnapshotSelectionCriteria;
12 import akka.persistence.UntypedPersistentActor;
13 import com.google.common.base.Preconditions;
14
15 /**
16  * A DataPersistenceProvider implementation with persistence enabled.
17  */
18 public class PersistentDataProvider implements DataPersistenceProvider {
19
20     private final UntypedPersistentActor persistentActor;
21
22     public PersistentDataProvider(UntypedPersistentActor persistentActor) {
23         this.persistentActor = Preconditions.checkNotNull(persistentActor, "persistentActor can't be null");
24     }
25
26     @Override
27     public boolean isRecoveryApplicable() {
28         return true;
29     }
30
31     @Override
32     public <T> void persist(T entry, Procedure<T> procedure) {
33         persistentActor.persist(entry, procedure);
34     }
35
36     @Override
37     public <T> void persistAsync(T entry, Procedure<T> procedure) {
38         persistentActor.persistAsync(entry, procedure);
39     }
40
41     @Override
42     public void saveSnapshot(Object snapshot) {
43         persistentActor.saveSnapshot(snapshot);
44     }
45
46     @Override
47     public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
48         persistentActor.deleteSnapshots(criteria);
49     }
50
51     @Override
52     public void deleteMessages(long sequenceNumber) {
53         persistentActor.deleteMessages(sequenceNumber);
54     }
55
56     @Override
57     public long getLastSequenceNumber() {
58         return persistentActor.lastSequenceNr();
59     }
60 }