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 java.util.concurrent.CountDownLatch;
14 import org.opendaylight.controller.cluster.DataPersistenceProvider;
17 * This class is intended for testing purposes. It just triggers CountDownLatch's in each method.
18 * This class really should be under src/test/java but it was problematic trying to uses it in other projects.
20 public class DataPersistenceProviderMonitor implements DataPersistenceProvider {
22 private CountDownLatch persistLatch = new CountDownLatch(1);
23 private CountDownLatch saveSnapshotLatch = new CountDownLatch(1);
24 private CountDownLatch deleteSnapshotsLatch = new CountDownLatch(1);;
25 private CountDownLatch deleteMessagesLatch = new CountDownLatch(1);;
28 public boolean isRecoveryApplicable() {
33 public <T> void persist(T o, Procedure<T> procedure) {
34 persistLatch.countDown();
38 public void saveSnapshot(Object o) {
39 saveSnapshotLatch.countDown();
43 public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
44 deleteSnapshotsLatch.countDown();
48 public void deleteMessages(long sequenceNumber) {
49 deleteMessagesLatch.countDown();
52 public void setPersistLatch(CountDownLatch persistLatch) {
53 this.persistLatch = persistLatch;
56 public void setSaveSnapshotLatch(CountDownLatch saveSnapshotLatch) {
57 this.saveSnapshotLatch = saveSnapshotLatch;
60 public void setDeleteSnapshotsLatch(CountDownLatch deleteSnapshotsLatch) {
61 this.deleteSnapshotsLatch = deleteSnapshotsLatch;
64 public void setDeleteMessagesLatch(CountDownLatch deleteMessagesLatch) {
65 this.deleteMessagesLatch = deleteMessagesLatch;
69 public long getLastSequenceNumber() {