Merge "Bug 6088 - Threads problem on gathering statistics"
[openflowplugin.git] / applications / forwardingrules-sync / src / main / java / org / opendaylight / openflowplugin / applications / frsync / impl / SimplifiedConfigListener.java
index 94265eccfc737c3c4c3248429039e538c146bfa9..298fb6d15df4505c3286139f4088d2afe912882c 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -23,15 +24,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to config changes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapableNode> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedConfigListener.class);
-    protected final SyncReactor reactor;
+    private final SyncReactor reactor;
     private final FlowCapableNodeSnapshotDao configSnaphot;
     private final FlowCapableNodeDao operationalDao;
 
@@ -65,7 +63,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
         final Optional<FlowCapableNode> operationalNode = operationalDao.loadByNodeId(nodeId);
         if (!operationalNode.isPresent()) {
             LOG.info("Skip syncup, {} operational is not present", nodeId.getValue());
-            return Optional.absent();// we try to reconfigure switch is alive
+            return Optional.absent();
         }
 
         final DataObjectModification<FlowCapableNode> configModification = modification.getRootNode();
@@ -97,9 +95,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
             FlowCapableNode dataBefore, FlowCapableNode dataAfter, FlowCapableNode operationalNode)
                     throws InterruptedException {
         LOG.trace("onNodeAdded {}", nodePath);
-        
-        final ListenableFuture<Boolean> endResult =
-                reactor.syncup(nodePath, dataAfter, operationalNode);
+        final ListenableFuture<Boolean> endResult = reactor.syncup(nodePath, dataAfter, operationalNode, dsType());
         return endResult;
     }
 
@@ -114,9 +110,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
             FlowCapableNode dataBefore, FlowCapableNode dataAfter, FlowCapableNode operationalNodeNode)
                     throws InterruptedException {
         LOG.trace("onNodeUpdated {}", nodePath);
-        
-        final ListenableFuture<Boolean> endResult =
-                reactor.syncup(nodePath, dataAfter, dataBefore);
+        final ListenableFuture<Boolean> endResult = reactor.syncup(nodePath, dataAfter, dataBefore, dsType());
         return endResult;
     }
 
@@ -128,9 +122,7 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapabl
     protected ListenableFuture<Boolean> onNodeDeleted(InstanceIdentifier<FlowCapableNode> nodePath,
             FlowCapableNode dataBefore, FlowCapableNode operationalNode) throws InterruptedException {
         LOG.trace("onNodeDeleted {}", nodePath);
-        
-        final ListenableFuture<Boolean> endResult =
-                reactor.syncup(nodePath, null, dataBefore);
+        final ListenableFuture<Boolean> endResult = reactor.syncup(nodePath, null, dataBefore, dsType());
         return endResult;
     }