BUG 2134 : Make persistence configurable at the datastore level
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / DataPersistenceProviderMonitor.java
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/DataPersistenceProviderMonitor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/DataPersistenceProviderMonitor.java
new file mode 100644 (file)
index 0000000..33d4056
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.cluster.datastore;
+
+import akka.japi.Procedure;
+import akka.persistence.SnapshotSelectionCriteria;
+import org.opendaylight.controller.cluster.DataPersistenceProvider;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * This class is intended for testing purposes. It just triggers CountDownLatch's in each method.
+ * This class really should be under src/test/java but it was problematic trying to uses it in other projects.
+ */
+public class DataPersistenceProviderMonitor implements DataPersistenceProvider {
+
+    private CountDownLatch persistLatch = new CountDownLatch(1);
+    private CountDownLatch saveSnapshotLatch = new CountDownLatch(1);
+    private CountDownLatch deleteSnapshotsLatch = new CountDownLatch(1);;
+    private CountDownLatch deleteMessagesLatch = new CountDownLatch(1);;
+
+    @Override
+    public boolean isRecoveryApplicable() {
+        return false;
+    }
+
+    @Override
+    public <T> void persist(T o, Procedure<T> procedure) {
+        persistLatch.countDown();
+    }
+
+    @Override
+    public void saveSnapshot(Object o) {
+        saveSnapshotLatch.countDown();
+    }
+
+    @Override
+    public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
+        deleteSnapshotsLatch.countDown();
+    }
+
+    @Override
+    public void deleteMessages(long sequenceNumber) {
+        deleteMessagesLatch.countDown();
+    }
+
+    public void setPersistLatch(CountDownLatch persistLatch) {
+        this.persistLatch = persistLatch;
+    }
+
+    public void setSaveSnapshotLatch(CountDownLatch saveSnapshotLatch) {
+        this.saveSnapshotLatch = saveSnapshotLatch;
+    }
+
+    public void setDeleteSnapshotsLatch(CountDownLatch deleteSnapshotsLatch) {
+        this.deleteSnapshotsLatch = deleteSnapshotsLatch;
+    }
+
+    public void setDeleteMessagesLatch(CountDownLatch deleteMessagesLatch) {
+        this.deleteMessagesLatch = deleteMessagesLatch;
+    }
+}