All-dpns are not getting listed in the 05/85205/5
authorShweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Fri, 18 Oct 2019 11:32:10 +0000 (17:02 +0530)
committerShweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Fri, 7 Feb 2020 04:05:59 +0000 (09:35 +0530)
output of display all-dpns in cics

Signed-off-by: Shweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Change-Id: Id4198d385fd636c5cedefbbf16a99b852ba36265

applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java

index 6aff7710ba3e136577ef92f2b36d3fbdcd06d57f..2cc863e733b302bd85c7f304cca18781013e8faf 100644 (file)
@@ -223,13 +223,13 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
 
                     /* Open a new bundle on the switch */
                     ListenableFuture<RpcResult<ControlBundleOutput>> openBundle =
-                        Futures.transformAsync(closeBundle,
-                            rpcResult -> salBundleService.controlBundle(openBundleInput),
-                                service);
+                            Futures.transformAsync(closeBundle,
+                                rpcResult -> salBundleService.controlBundle(openBundleInput),
+                                    service);
 
                     /* Push groups and flows via bundle add messages */
-                    ListenableFuture<RpcResult<AddBundleMessagesOutput>> deleteAllFlowGroupsFuture
-                            Futures.transformAsync(openBundle, rpcResult -> {
+                    ListenableFuture<RpcResult<AddBundleMessagesOutput>> deleteAllFlowGroupsFuture =
+                            Futures.transformAsync(openBundle, rpcResult -> {
                                 if (rpcResult.isSuccessful()) {
                                     return salBundleService.addBundleMessages(deleteAllFlowGroupsInput);
                                 }
@@ -238,8 +238,8 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
 
                     /* Push flows and groups via bundle add messages */
                     Optional<FlowCapableNode> finalFlowNode = flowNode;
-                    ListenableFuture<List<RpcResult<AddBundleMessagesOutput>>> addbundlesFuture
-                            Futures.transformAsync(deleteAllFlowGroupsFuture, rpcResult -> {
+                    ListenableFuture<List<RpcResult<AddBundleMessagesOutput>>> addbundlesFuture =
+                            Futures.transformAsync(deleteAllFlowGroupsFuture, rpcResult -> {
                                 if (rpcResult.isSuccessful()) {
                                     LOG.debug("Adding delete all flow/group message is successful for device {}",dpnId);
                                     return Futures.allAsList(addBundleMessages(finalFlowNode.get(), bundleIdValue,
@@ -281,13 +281,13 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
                             return false;
                         }
                     } catch (InterruptedException | ExecutionException e) {
-                        LOG.error("Error while doing bundle based reconciliation for device ID:{}", dpnId);
+                        LOG.error("Error while doing bundle based reconciliation for device ID:{}", dpnId, e);
                         return false;
                     }
                 }
                 LOG.error("FlowNode not present for Datapath ID {}", dpnId);
                 return false;
-            }  finally {
+            } finally {
                 service.shutdown();
             }
         }
index 2e6e5bb625a2ce0d782626197b29b28929f45379..e2f9e2b881134743d4bf63b2a4f9800300600199 100644 (file)
@@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory;
 public class ConnectionManagerImpl implements ConnectionManager {
 
     private static final Logger LOG = LoggerFactory.getLogger(ConnectionManagerImpl.class);
+    private static final Logger OF_EVENT_LOG = LoggerFactory.getLogger("OfEventLog");
     private static final boolean BITMAP_NEGOTIATION_ENABLED = true;
     private final ThreadFactory threadFactory = new ThreadFactoryBuilder()
             .setNameFormat("ConnectionHandler-%d")
@@ -90,6 +91,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
     @Override
     public void onSwitchConnected(final ConnectionAdapter connectionAdapter) {
         connectionAdapter.setExecutorService(executorsService);
+        OF_EVENT_LOG.debug("OnSwitchConnected event received for device {}", connectionAdapter.getRemoteAddress());
         LOG.trace("prepare connection context");
         final ConnectionContext connectionContext = new ConnectionContextImpl(connectionAdapter,
                 deviceConnectionStatusProvider);
index 45f99f65f4836fa5d43da7f702095b0a2c1811fd..07fd81f548262f5ae9133e3db2fb2c4e3d31827b 100644 (file)
@@ -12,9 +12,11 @@ import io.netty.util.HashedWheelTimer;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
@@ -36,6 +38,7 @@ import org.opendaylight.openflowplugin.impl.connection.OutboundQueueProviderImpl
 import org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProvider;
 import org.opendaylight.openflowplugin.impl.device.listener.OpenflowProtocolListenerFullImpl;
 import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtil;
+import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
@@ -52,7 +55,9 @@ import org.slf4j.LoggerFactory;
 public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProviderKeeper {
 
     private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerImpl.class);
+    private static final Logger OF_EVENT_LOG = LoggerFactory.getLogger("OfEventLog");
     private static final int SPY_RATE = 10;
+    private static final long REMOVE_DEVICE_FROM_DS_TIMEOUT = 5000L;
 
     private final OpenflowProviderConfig config;
     private final DataBroker dataBroker;
@@ -212,7 +217,16 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         if (LOG.isDebugEnabled()) {
             LOG.debug("Device context removed for node {}", deviceInfo);
         }
-
+        final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier =
+                DeviceStateUtil.createNodeInstanceIdentifier(deviceInfo.getNodeId());
+        try {
+            this.removeDeviceFromOperationalDS(nodeInstanceIdentifier)
+                    .get(REMOVE_DEVICE_FROM_DS_TIMEOUT, TimeUnit.MILLISECONDS);
+        } catch (TimeoutException | ExecutionException | NullPointerException | InterruptedException e) {
+            LOG.error("Not able to remove device {} from operational DS. ", deviceInfo.getDatapathId(), e);
+        }
+        OF_EVENT_LOG.debug("Node removed from Oper DS, Node: {}",
+                nodeInstanceIdentifier.firstKeyOf(Node.class).getId().getValue());
         this.updatePacketInRateLimiters();
     }
 
index 05b4ab4ccdbb354955c048a82f5364b2a3a0fe06..e273a70c450989087a61363f0f3c1f416b27da30 100644 (file)
@@ -61,9 +61,8 @@ import org.slf4j.LoggerFactory;
 public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker {
     private static final Logger LOG = LoggerFactory.getLogger(ContextChainHolderImpl.class);
     private static final Logger OF_EVENT_LOG = LoggerFactory.getLogger("OfEventLog");
-
-    private static final String CONTEXT_CREATED_FOR_CONNECTION = " context created for connection: {}";
     private static final long REMOVE_DEVICE_FROM_DS_TIMEOUT = 5000L;
+    private static final String CONTEXT_CREATED_FOR_CONNECTION = " context created for connection: {}";
     private static final String ASYNC_SERVICE_ENTITY_TYPE = "org.opendaylight.mdsal.AsyncServiceCloseEntityType";
     private static final String SEPARATOR = ":";
     private final Map<DeviceInfo, ContextChain> contextChainMap = new ConcurrentHashMap<>();
@@ -109,7 +108,6 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
     @VisibleForTesting
     void createContextChain(final ConnectionContext connectionContext) {
         final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
-
         final DeviceContext deviceContext = deviceManager.createContext(connectionContext);
         deviceContext.registerMastershipWatcher(this);
         LOG.debug("Device" + CONTEXT_CREATED_FOR_CONNECTION, deviceInfo);
@@ -200,7 +198,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
     @Override
     public void onNotAbleToStartMastership(@NonNull final DeviceInfo deviceInfo, @NonNull final String reason,
                                            final boolean mandatory) {
-        LOG.warn("Not able to set MASTER role on device {}, reason: {}", deviceInfo, reason);
+        LOG.error("Not able to set MASTER role on device {}, reason: {}", deviceInfo, reason);
 
         if (!mandatory) {
             return;
@@ -240,7 +238,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
 
     @Override
     public void onSlaveRoleNotAcquired(final DeviceInfo deviceInfo, final String reason) {
-        LOG.warn("Not able to set SLAVE role on device {}, reason: {}", deviceInfo, reason);
+        LOG.error("Not able to set SLAVE role on device {}, reason: {}", deviceInfo, reason);
         Optional.ofNullable(contextChainMap.get(deviceInfo)).ifPresent(contextChain -> destroyContextChain(deviceInfo));
     }
 
@@ -274,6 +272,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
         copyOfChains.keySet().forEach(this::destroyContextChain);
         copyOfChains.clear();
         contextChainMap.clear();
+        OF_EVENT_LOG.debug("EOS registration closed for all devices");
         eosListenerRegistration.close();
         OF_EVENT_LOG.debug("EOS registration closed for all devices");
     }
@@ -371,7 +370,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
                     contextChain.continueInitializationAfterReconciliation();
                 } else {
                     OF_EVENT_LOG.debug("Reconciliation framework failure for device {}", deviceInfo);
-                    LOG.warn("Reconciliation framework failure for device {}", deviceInfo);
+                    LOG.warn("Reconciliation framework failure for device {} with resultState {}", deviceInfo, result);
                     destroyContextChain(deviceInfo);
                 }
             }
@@ -380,7 +379,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
             public void onFailure(final Throwable throwable) {
                 OF_EVENT_LOG.debug("Reconciliation framework failure for device {} with error {}", deviceInfo,
                         throwable.getMessage());
-                LOG.warn("Reconciliation framework failure.");
+                LOG.warn("Reconciliation framework failure for device {}", deviceInfo, throwable);
                 destroyContextChain(deviceInfo);
             }
         };
index b5c691047ba098df6bc7b22c14c035854c70ac74..21d8c32a33a5ef947718185d6c51d33d1c2bb8c6 100644 (file)
@@ -75,7 +75,7 @@ public class ContextChainImpl implements ContextChain {
             contexts.forEach(OFPContext::instantiateServiceInstance);
             LOG.info("Started clustering services for node {}", deviceInfo);
         } catch (final Exception ex) {
-            LOG.warn("Not able to start clustering services for node {}", deviceInfo);
+            LOG.error("Not able to start clustering services for node {}", deviceInfo);
             executorService.execute(() -> contextChainMastershipWatcher
                     .onNotAbleToStartMastershipMandatory(deviceInfo, ex.toString()));
         }
index 59157d89adf1e353f9978963652f19d5135ad382..9f32b47e753711ff3792f8dcb3a6566f392dfeca 100644 (file)
@@ -258,7 +258,6 @@ public class ContextChainHolderImplTest {
                 EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NO_OWNER
         );
         contextChainHolder.ownershipChanged(ownershipChange);
-        Mockito.verify(deviceManager).removeDeviceFromOperationalDS(Mockito.any());
     }
 
     @Test