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.JournalProtocol;
14 import akka.persistence.SnapshotProtocol;
15 import akka.persistence.SnapshotSelectionCriteria;
16 import org.opendaylight.controller.cluster.common.actor.ExecuteInSelfActor;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * A DataPersistenceProvider implementation with persistence disabled, essentially a no-op.
23 public class NonPersistentDataProvider implements DataPersistenceProvider {
24 private static final Logger LOG = LoggerFactory.getLogger(NonPersistentDataProvider.class);
26 private final ExecuteInSelfActor actor;
28 public NonPersistentDataProvider(final ExecuteInSelfActor actor) {
29 this.actor = requireNonNull(actor);
33 public boolean isRecoveryApplicable() {
38 public <T> void persist(final T entry, final Procedure<T> procedure) {
39 invokeProcedure(procedure, entry);
43 public <T> void persistAsync(final T entry, final Procedure<T> procedure) {
44 actor.executeInSelf(() -> invokeProcedure(procedure, entry));
48 public void saveSnapshot(final Object snapshot) {
53 public void deleteSnapshots(final SnapshotSelectionCriteria criteria) {
58 public void deleteMessages(final long sequenceNumber) {
63 public long getLastSequenceNumber() {
67 @SuppressWarnings("checkstyle:IllegalCatch")
68 static <T> void invokeProcedure(final Procedure<T> procedure, final T argument) {
70 procedure.apply(argument);
71 } catch (Exception e) {
72 LOG.error("An unexpected error occurred", e);
77 public boolean handleJournalResponse(final JournalProtocol.Response response) {
82 public boolean handleSnapshotResponse(final SnapshotProtocol.Response response) {