Merge "Add LeadershipChangeCount to ShardStats"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / NonPersistentDataProvider.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 org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 /**
16  * A DataPersistenceProvider implementation with persistence disabled, essentially a no-op.
17  */
18 public class NonPersistentDataProvider implements DataPersistenceProvider {
19     private static final Logger LOG = LoggerFactory.getLogger(NonPersistentDataProvider.class);
20
21     @Override
22     public boolean isRecoveryApplicable() {
23         return false;
24     }
25
26     @Override
27     public <T> void persist(T o, Procedure<T> procedure) {
28         try {
29             procedure.apply(o);
30         } catch (Exception e) {
31             LOG.error("An unexpected error occurred", e);
32         }
33     }
34
35     @Override
36     public void saveSnapshot(Object o) {
37     }
38
39     @Override
40     public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
41     }
42
43     @Override
44     public void deleteMessages(long sequenceNumber) {
45     }
46
47     @Override
48     public long getLastSequenceNumber() {
49         return -1;
50     }
51 }