2 * Copyright (c) 2015 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
8 package org.opendaylight.controller.cluster;
10 import static java.util.Objects.requireNonNull;
12 import akka.japi.Procedure;
13 import akka.persistence.AbstractPersistentActor;
14 import akka.persistence.SnapshotSelectionCriteria;
17 * A DataPersistenceProvider implementation with persistence enabled.
19 public class PersistentDataProvider implements DataPersistenceProvider {
21 private final AbstractPersistentActor persistentActor;
23 public PersistentDataProvider(AbstractPersistentActor persistentActor) {
24 this.persistentActor = requireNonNull(persistentActor, "persistentActor can't be null");
28 public boolean isRecoveryApplicable() {
33 public <T> void persist(T entry, Procedure<T> procedure) {
34 persistentActor.persist(entry, procedure);
38 public <T> void persistAsync(T entry, Procedure<T> procedure) {
39 persistentActor.persistAsync(entry, procedure);
43 public void saveSnapshot(Object snapshot) {
44 persistentActor.saveSnapshot(snapshot);
48 public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
49 persistentActor.deleteSnapshots(criteria);
53 public void deleteMessages(long sequenceNumber) {
54 persistentActor.deleteMessages(sequenceNumber);
58 public long getLastSequenceNumber() {
59 return persistentActor.lastSequenceNr();