Remove Itemlifecycle
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / lifecycle / ContextChainImpl.java
index c60d5d77145186b2db2f45582da159a0e3dcf386..39a349ca1c8208a11efe285ae239d90bbf9375b0 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;
 
@@ -68,8 +68,8 @@ public class ContextChainImpl implements ContextChain {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void instantiateServiceInstance() {
-
         try {
             contexts.forEach(OFPContext::instantiateServiceInstance);
             LOG.info("Started clustering services for node {}", deviceInfo);
@@ -104,6 +104,7 @@ public class ContextChainImpl implements ContextChain {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void close() {
         if (ContextChainState.CLOSED.equals(contextChainState.get())) {
             LOG.debug("ContextChain for node {} is already in TERMINATION state.", deviceInfo);
@@ -156,7 +157,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);
@@ -178,16 +180,23 @@ public class ContextChainImpl implements ContextChain {
                 // Flow registry fill is not mandatory to work as a master
                 LOG.debug("Device {}, initial registry filling OK.", deviceInfo);
                 this.registryFilling.set(true);
+                break;
             case CHECK:
+                // no operation
+                break;
             default:
+                // no operation
+                break;
         }
 
         final boolean result = initialGathering.get() &&
                 masterStateOnDevice.get() &&
-                initialSubmitting.get() &&
-                rpcRegistration.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 !!!");
@@ -203,23 +212,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