Bug 6745 Improve compression queue locking and handle InterruptedException
[openflowplugin.git] / applications / forwardingrules-sync / src / main / java / org / opendaylight / openflowplugin / applications / frsync / impl / AbstractFrmSyncListener.java
index 4d1e53a6932ff16f9fc5671122eb19639aa5a49f..835823fba7fe5692a345cfd47076e7591c20a91f 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.applications.frsync.NodeListener;
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -27,35 +26,34 @@ import org.slf4j.LoggerFactory;
  * Abstract Listener for node changes.
  */
 public abstract class AbstractFrmSyncListener<T extends DataObject> implements NodeListener<T> {
+
     private static final Logger LOG = LoggerFactory.getLogger(AbstractFrmSyncListener.class);
 
     @Override
     public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<T>> modifications) {
         for (DataTreeModification<T> modification : modifications) {
             final NodeId nodeId = PathUtil.digNodeId(modification.getRootPath().getRootIdentifier());
-
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("DataTreeModification of {} in {} datastore", nodeId.getValue(), dsType());
+            }
             try {
                 final Optional<ListenableFuture<Boolean>> optFuture = processNodeModification(modification);
                 if (optFuture.isPresent()) {
                     final ListenableFuture<Boolean> future = optFuture.get();
-                    final Boolean ret = future.get(15000, TimeUnit.MILLISECONDS);
-                    LOG.debug("syncup ret {} {} {} thread:{}", dsType(), ret, nodeId, threadName());
+                    future.get(15000, TimeUnit.MILLISECONDS);
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Syncup for {} return from {} listener", nodeId.getValue(), dsType());
+                    }
                 }
-            } catch (InterruptedException e) {
-                LOG.warn("permit for forwarding rules sync not acquired: {}", nodeId);
             } catch (Exception e) {
-                LOG.error("error processing inventory node modification: {}", nodeId, e);
+                LOG.error("Error processing inventory node modification: {}, {}", nodeId.getValue(), e);
             }
         }
     }
 
     protected abstract Optional<ListenableFuture<Boolean>> processNodeModification(
-            DataTreeModification<T> modification) throws ReadFailedException, InterruptedException;
+            final DataTreeModification<T> modification);
 
-    public abstract LogicalDatastoreType dsType();
+    protected abstract LogicalDatastoreType dsType();
 
-    static String threadName() {
-        final Thread currentThread = Thread.currentThread();
-        return currentThread.getName();
-    }
 }