Bug 7058 - [Helium Plugin]Stats collection issue when controller disconnect the device 43/47843/1
authorAnil Vishnoi <vishnoianil@gmail.com>
Fri, 28 Oct 2016 15:58:06 +0000 (17:58 +0200)
committerShuva Jyoti Kar <shuva.jyoti.kar@ericsson.com>
Wed, 2 Nov 2016 14:59:42 +0000 (14:59 +0000)
Change-Id: I50164bf9c3f09097d211b9f40a3f2325dee38d45
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatPermCollectorImpl.java
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatRpcMsgManagerImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java

index 34eae4b88799dcbb385ed9fe135db0e4763e3b0c..0bb4e0291e73c7100e73e2654a031ac6f2bd7e80 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -62,6 +63,7 @@ public class StatPermCollectorImpl implements StatPermCollector {
         for loading all Nodes to Operational/DS
      */
     private static final long WAIT_BEFORE_COLLECTING_STATS = 5000;
+    private static final TransactionId FAKE_TX_ID = new TransactionId(new BigInteger("FFFFFFFFFFFFFFFF", 16));
 
     private final ExecutorService statNetCollectorServ;
     private final StatisticsManager manager;
@@ -407,7 +409,8 @@ public class StatPermCollectorImpl implements StatPermCollector {
 
     private boolean checkTransactionId(final TransactionId xid) {
         synchronized (transNotifyLock) {
-            return actualTransactionId != null && actualTransactionId.equals(xid);
+            return actualTransactionId != null
+                    && (actualTransactionId.equals(xid) || actualTransactionId.equals(FAKE_TX_ID));
         }
     }
 
@@ -416,5 +419,9 @@ public class StatPermCollectorImpl implements StatPermCollector {
             actualTransactionId = transactionId;
         }
     }
+
+    public static TransactionId getFakeTxId() {
+        return FAKE_TX_ID;
+    }
 }
 
index 43074a70bf82f626c4abbf2a6665ac7edb11adc3..4c3f573ccca6cbadbab4e2213cb1daa9e78d8d66 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
 
+import java.math.BigInteger;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.BlockingQueue;
@@ -16,6 +17,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatRpcMsgManager;
 import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
@@ -207,7 +209,13 @@ public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
             public void onFailure(final Throwable t) {
                 LOG.warn("Response Registration for Statistics RPC call fail!", t);
                 if (resultTransId != null) {
-                    resultTransId.setException(t);
+                    if (t instanceof DOMRpcImplementationNotAvailableException) {
+                        //If encountered with RPC not availabe exception, retry till
+                        // stats manager remove the node from the stats collector pool
+                        resultTransId.set(StatPermCollectorImpl.getFakeTxId());
+                    } else {
+                        resultTransId.setException(t);
+                    }
                 }
             }
         }
index a62ae837eef8bae29f48c7f909d5d25feaadd2d2..d878aeb369da9bad30a2a6ce85bc6973ef0ff29b 100644 (file)
@@ -399,14 +399,18 @@ public class OfEntityManager implements TransactionChainListener{
         //Node added notification need to be sent irrespective of whether
         // *this* instance is owner of the entity or not. Because yang notifications
         // are local, and we should maintain the behavior across the application.
-        LOG.info("sendNodeAddedNotification: Node Added notification is sent for ModelDrivenSwitch {}",
-                entityMetadata.getOfSwitch().getNodeId().getValue());
+        if (entityMetadata != null && entityMetadata.getOfSwitch() != null) {
+            LOG.info("sendNodeAddedNotification: Node Added notification is sent for ModelDrivenSwitch {}",
+                    entityMetadata.getOfSwitch().getNodeId().getValue());
 
-        entityMetadata.getContext().getNotificationEnqueuer().enqueueNotification(
-                entityMetadata.getWrappedNotification());
+            entityMetadata.getContext().getNotificationEnqueuer().enqueueNotification(
+                    entityMetadata.getWrappedNotification());
 
-        //Send multipart request to get other details of the switch.
-        entityMetadata.getOfSwitch().requestSwitchDetails();
+            //Send multipart request to get other details of the switch.
+            entityMetadata.getOfSwitch().requestSwitchDetails();
+        } else {
+            LOG.debug("Switch got disconnected, skip node added notification.");
+        }
     }
 
     private void setDeviceOwnershipState(Entity entity, boolean isMaster) {