2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.datastore;
11 import akka.japi.Procedure;
12 import akka.persistence.SnapshotSelectionCriteria;
13 import org.opendaylight.controller.cluster.DataPersistenceProvider;
15 import java.util.concurrent.CountDownLatch;
18 * This class is intended for testing purposes. It just triggers CountDownLatch's in each method.
19 * This class really should be under src/test/java but it was problematic trying to uses it in other projects.
21 public class DataPersistenceProviderMonitor implements DataPersistenceProvider {
23 private CountDownLatch persistLatch = new CountDownLatch(1);
24 private CountDownLatch saveSnapshotLatch = new CountDownLatch(1);
25 private CountDownLatch deleteSnapshotsLatch = new CountDownLatch(1);;
26 private CountDownLatch deleteMessagesLatch = new CountDownLatch(1);;
29 public boolean isRecoveryApplicable() {
34 public <T> void persist(T o, Procedure<T> procedure) {
35 persistLatch.countDown();
39 public void saveSnapshot(Object o) {
40 saveSnapshotLatch.countDown();
44 public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
45 deleteSnapshotsLatch.countDown();
49 public void deleteMessages(long sequenceNumber) {
50 deleteMessagesLatch.countDown();
53 public void setPersistLatch(CountDownLatch persistLatch) {
54 this.persistLatch = persistLatch;
57 public void setSaveSnapshotLatch(CountDownLatch saveSnapshotLatch) {
58 this.saveSnapshotLatch = saveSnapshotLatch;
61 public void setDeleteSnapshotsLatch(CountDownLatch deleteSnapshotsLatch) {
62 this.deleteSnapshotsLatch = deleteSnapshotsLatch;
65 public void setDeleteMessagesLatch(CountDownLatch deleteMessagesLatch) {
66 this.deleteMessagesLatch = deleteMessagesLatch;