WIP: Bump upstreams
[openflowplugin.git] / applications / forwardingrules-manager / src / main / java / org / opendaylight / openflowplugin / applications / frm / impl / ListenerRegistrationHelper.java
index cf64fdf22b1b5cf0697bde431cb160555afc919b..9410feae01261884371fc849b5ecbf80a1cfb4d2 100644 (file)
@@ -20,18 +20,16 @@ import javax.inject.Singleton;
 import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 @Singleton
 public class ListenerRegistrationHelper {
     private static final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationHelper.class);
     private static final long INVENTORY_CHECK_TIMER = 1;
-    private final String operational = "OPERATIONAL";
+
     private final ListeningExecutorService listeningExecutorService;
     private final DataBroker dataBroker;
 
@@ -39,7 +37,7 @@ public class ListenerRegistrationHelper {
     public ListenerRegistrationHelper(final DataBroker dataBroker) {
         this.dataBroker = dataBroker;
         listeningExecutorService = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor(
-                 new ThreadFactoryBuilder()
+            new ThreadFactoryBuilder()
                 .setNameFormat("frm-listener" + "%d")
                 .setDaemon(false)
                 .setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
@@ -47,10 +45,10 @@ public class ListenerRegistrationHelper {
     }
 
     public <T extends DataObject, L extends ClusteredDataTreeChangeListener<T>>
-        ListenableFuture<ListenerRegistration<L>>
-        checkedRegisterListener(DataTreeIdentifier<T> treeId, L listener) {
+            ListenableFuture<ListenerRegistration<L>> checkedRegisterListener(
+                final DataTreeIdentifier<T> treeId, final L listener) {
         return listeningExecutorService.submit(() -> {
-            while (! getInventoryConfigDataStoreStatus().equals(operational)) {
+            while (!getInventoryConfigDataStoreStatus().equals("OPERATIONAL")) {
                 try {
                     LOG.debug("Retrying for datastore to become operational for listener {}", listener);
                     Thread.sleep(INVENTORY_CHECK_TIMER * 1000);
@@ -59,13 +57,11 @@ public class ListenerRegistrationHelper {
                     Thread.currentThread().interrupt();
                 }
             }
-            SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
-                    ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
-            return looper.loopUntilNoException(() -> dataBroker.registerDataTreeChangeListener(treeId, listener));
+            return dataBroker.registerDataTreeChangeListener(treeId, listener);
         });
     }
 
     public void close() throws Exception {
         MoreExecutors.shutdownAndAwaitTermination(listeningExecutorService, 5, TimeUnit.SECONDS);
     }
-}
\ No newline at end of file
+}