X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDataPersistenceProviderMonitor.java;fp=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDataPersistenceProviderMonitor.java;h=33d405639538cac69c3554851c1b99e74fd5aeaa;hb=cd81eb73b7abf677571b2366425ccbc8d794f4b6;hp=0000000000000000000000000000000000000000;hpb=37036770b1cf71c888530adbda097feeea6cdf02;p=controller.git 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 index 0000000000..33d4056395 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/DataPersistenceProviderMonitor.java @@ -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 void persist(T o, Procedure 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; + } +}