Bump upstreams
[openflowplugin.git] / applications / forwardingrules-manager / src / main / java / org / opendaylight / openflowplugin / applications / frm / impl / ListenerRegistrationHelper.java
index 46f73d1872379ad2edd310155ca6dac22d22ea5b..9410feae01261884371fc849b5ecbf80a1cfb4d2 100644 (file)
@@ -5,7 +5,6 @@
  * 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.openflowplugin.applications.frm.impl;
 
 import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getInventoryConfigDataStoreStatus;
@@ -18,30 +17,27 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
 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;
 
     @Inject
-    public ListenerRegistrationHelper(@Reference final DataBroker dataBroker) {
+    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))
@@ -49,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);
@@ -61,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
+}