Do not mark device as connecting when closing it
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / lifecycle / ContextChainImpl.java
index a85b418f604ce4e5b4380705dba7faa8c78f4e42..7a012d6bca22139eb6deda2fff1907942ca26d9c 100644 (file)
@@ -30,7 +30,7 @@ import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMaster
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainStateListener;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.GuardedContext;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
+import org.opendaylight.openflowplugin.api.openflow.lifecycle.ReconciliationFrameworkStep;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -158,7 +158,8 @@ public class ContextChainImpl implements ContextChain {
     }
 
     @Override
-    public boolean isMastered(@Nonnull ContextChainMastershipState mastershipState) {
+    public boolean isMastered(@Nonnull ContextChainMastershipState mastershipState,
+                              boolean inReconciliationFrameworkStep) {
         switch (mastershipState) {
             case INITIAL_SUBMIT:
                 LOG.debug("Device {}, initial submit OK.", deviceInfo);
@@ -189,12 +190,14 @@ public class ContextChainImpl implements ContextChain {
                 break;
         }
 
-        final boolean result = initialGathering.get()
-                && masterStateOnDevice.get()
-                && initialSubmitting.get()
-                && rpcRegistration.get();
+        final boolean result = initialGathering.get() &&
+                masterStateOnDevice.get() &&
+                rpcRegistration.get() &&
+                inReconciliationFrameworkStep || initialSubmitting.get();
 
-        if (result && mastershipState != ContextChainMastershipState.CHECK) {
+        if (!inReconciliationFrameworkStep &&
+                result &&
+                mastershipState != ContextChainMastershipState.CHECK) {
             LOG.info("Device {} is able to work as master{}",
                     deviceInfo,
                     registryFilling.get() ? "." : " WITHOUT flow registry !!!");
@@ -210,23 +213,12 @@ public class ContextChainImpl implements ContextChain {
     }
 
     @Override
-    public boolean isPrepared() {
-        return this.initialGathering.get()
-                && this.masterStateOnDevice.get()
-                && this.rpcRegistration.get();
-    }
-
-    @Override
-    public boolean continueInitializationAfterReconciliation() {
-        final AtomicBoolean initialSubmit = new AtomicBoolean(false);
-
+    public void continueInitializationAfterReconciliation() {
         contexts.forEach(context -> {
-            if (context.map(StatisticsContext.class::isInstance)) {
-                initialSubmit.set(context.map(StatisticsContext.class::cast).initialSubmitAfterReconciliation());
+            if (context.map(ReconciliationFrameworkStep.class::isInstance)) {
+                context.map(ReconciliationFrameworkStep.class::cast).continueInitializationAfterReconciliation();
             }
         });
-
-        return initialSubmit.get() && isMastered(ContextChainMastershipState.INITIAL_SUBMIT);
     }
 
     @Override