Convert sal-distributed-datastore to OSGi DS
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / AbstractDataStore.java
index 8537c85..d6958a7 100644 (file)
@@ -253,13 +253,9 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
 
         final Duration toWait = initialSettleTime();
         try {
-            if (toWait.isFinite()) {
-                if (!waitTillReadyCountDownLatch.await(toWait.toNanos(), TimeUnit.NANOSECONDS)) {
-                    LOG.error("Shard leaders failed to settle in {}, giving up", toWait);
-                    return;
-                }
-            } else {
-                waitTillReadyCountDownLatch.await();
+            if (!awaitReadiness(toWait)) {
+                LOG.error("Shard leaders failed to settle in {}, giving up", toWait);
+                return;
             }
         } catch (InterruptedException e) {
             LOG.error("Interrupted while waiting for shards to settle", e);
@@ -269,6 +265,21 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
         LOG.debug("Data store {} is now ready", identifier);
     }
 
+    @Beta
+    public boolean awaitReadiness() throws InterruptedException {
+        return awaitReadiness(initialSettleTime());
+    }
+
+    @Beta
+    public boolean awaitReadiness(final Duration toWait) throws InterruptedException {
+        if (toWait.isFinite()) {
+            return waitTillReadyCountDownLatch.await(toWait.toNanos(), TimeUnit.NANOSECONDS);
+        }
+
+        waitTillReadyCountDownLatch.await();
+        return true;
+    }
+
     @Beta
     public void awaitReadiness(final long timeout, final TimeUnit unit) throws InterruptedException, TimeoutException {
         if (!waitTillReadyCountDownLatch.await(timeout, unit)) {
@@ -301,6 +312,7 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
         return waitTillReadyCountDownLatch;
     }
 
+    @Override
     @SuppressWarnings("unchecked")
     public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerProxyListener(
             final YangInstanceIdentifier shardLookup, final YangInstanceIdentifier insideShard,
@@ -324,10 +336,10 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
         return (ListenerRegistration<L>) listenerRegistrationProxy;
     }
 
+    @Override
     @SuppressWarnings("unchecked")
     public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerShardConfigListener(
-            final YangInstanceIdentifier internalPath,
-            final DOMDataTreeChangeListener delegate) {
+            final YangInstanceIdentifier internalPath, final DOMDataTreeChangeListener delegate) {
         requireNonNull(delegate, "delegate should not be null");
 
         LOG.debug("Registering a listener for the configuration shard: {}", internalPath);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.