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 akka.japi.Procedure;
11 import akka.persistence.SnapshotSelectionCriteria;
12 import akka.persistence.UntypedPersistentActor;
13 import com.google.common.base.Preconditions;
16 * A DataPersistenceProvider implementation with persistence enabled.
18 public class PersistentDataProvider implements DataPersistenceProvider {
20 private final UntypedPersistentActor persistentActor;
22 public PersistentDataProvider(UntypedPersistentActor persistentActor) {
23 this.persistentActor = Preconditions.checkNotNull(persistentActor, "persistentActor can't be null");
27 public boolean isRecoveryApplicable() {
32 public <T> void persist(T entry, Procedure<T> procedure) {
33 persistentActor.persist(entry, procedure);
37 public <T> void persistAsync(T entry, Procedure<T> procedure) {
38 persistentActor.persistAsync(entry, procedure);
42 public void saveSnapshot(Object snapshot) {
43 persistentActor.saveSnapshot(snapshot);
47 public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
48 persistentActor.deleteSnapshots(criteria);
52 public void deleteMessages(long sequenceNumber) {
53 persistentActor.deleteMessages(sequenceNumber);
57 public long getLastSequenceNumber() {
58 return persistentActor.lastSequenceNr();