Bug 2327: Handle binary data in NormalizedNode streaming
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / DataPersistenceProviderMonitor.java
1 /*
2  * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.datastore;
10
11 import akka.japi.Procedure;
12 import akka.persistence.SnapshotSelectionCriteria;
13 import org.opendaylight.controller.cluster.DataPersistenceProvider;
14
15 import java.util.concurrent.CountDownLatch;
16
17 /**
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.
20  */
21 public class DataPersistenceProviderMonitor implements DataPersistenceProvider {
22
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);;
27
28     @Override
29     public boolean isRecoveryApplicable() {
30         return false;
31     }
32
33     @Override
34     public <T> void persist(T o, Procedure<T> procedure) {
35         persistLatch.countDown();
36     }
37
38     @Override
39     public void saveSnapshot(Object o) {
40         saveSnapshotLatch.countDown();
41     }
42
43     @Override
44     public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
45         deleteSnapshotsLatch.countDown();
46     }
47
48     @Override
49     public void deleteMessages(long sequenceNumber) {
50         deleteMessagesLatch.countDown();
51     }
52
53     public void setPersistLatch(CountDownLatch persistLatch) {
54         this.persistLatch = persistLatch;
55     }
56
57     public void setSaveSnapshotLatch(CountDownLatch saveSnapshotLatch) {
58         this.saveSnapshotLatch = saveSnapshotLatch;
59     }
60
61     public void setDeleteSnapshotsLatch(CountDownLatch deleteSnapshotsLatch) {
62         this.deleteSnapshotsLatch = deleteSnapshotsLatch;
63     }
64
65     public void setDeleteMessagesLatch(CountDownLatch deleteMessagesLatch) {
66         this.deleteMessagesLatch = deleteMessagesLatch;
67     }
68 }