Bug 7499 - ensure statistics scheduler does not die and keep trying while the control... 50/50150/6
authorJon Castro <castro.jon@gmail.com>
Thu, 2 Feb 2017 01:57:49 +0000 (12:57 +1100)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 2 Feb 2017 08:38:27 +0000 (00:38 -0800)
Change-Id: Ia5923f200b6c7a8888d4e3c96fdf8358603d4ac9
Signed-off-by: Jon Castro <castro.jon@gmail.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInV10TranslatorTest.java

index eab57c27958dd96bb539a608fb38a525553115a9..4b5b7be9ca84ba0be030879e7521eb8b4a6821ab 100644 (file)
@@ -30,6 +30,7 @@ import javax.annotation.Nullable;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.mdsal.common.api.TransactionChainClosedException;
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.openflowplugin.api.ConnectionException;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
@@ -276,7 +277,7 @@ class StatisticsContextImpl implements StatisticsContext {
             final String errMsg = String.format("Device connection is closed for Node : %s.",
                     getDeviceInfo().getNodeId());
             LOG.debug(errMsg);
-            resultFuture.setException(new IllegalStateException(errMsg));
+            resultFuture.setException(new ConnectionException(errMsg));
             return;
         }
         if ( ! iterator.hasNext()) {
index 35a0d73778b3b4ab96f40a552cfc840500cbb7ec..d93f87b978b54e7f2c826a966f9ab22c8de79932 100644 (file)
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.ConnectionException;
 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
@@ -155,9 +156,16 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
                     LOG.trace("Gathering for node {} failure: ", deviceInfo.getLOGValue(), throwable);
                 }
                 calculateTimerDelay(timeCounter);
-                if (throwable instanceof IllegalStateException) {
+                if (throwable instanceof ConnectionException) {
+                    // ConnectionException is raised by StatisticsContextImpl class when the connections
+                    // move to RIP state. In this particular case, there is no need to reschedule
+                    // because this statistics manager should be closed soon
+                    LOG.warn("Node {} is no more connected, stopping the statistics collection",
+                            deviceInfo.getLOGValue(),throwable);
                     stopScheduling(deviceInfo);
                 } else {
+                    LOG.warn("Unexpected error occurred during statistics collection for node {}, rescheduling " +
+                            "statistics collections", deviceInfo.getLOGValue(),throwable);
                     scheduleNextPolling(deviceState, deviceInfo, statisticsContext, timeCounter);
                 }
             }
index ee4216f69c7364911f296211a33f2ff0c4dfb5c8..797dbc98d8feee2bc6a85e0f0a22ad42479e5425 100644 (file)
@@ -182,7 +182,7 @@ public class PacketInV10TranslatorTest {
                 + message.getInPort().toString()\r
                 + "]]]]}], _packetInReason=class org.opendaylight.yang.gen.v1.urn.opendaylight."\r
                 + "packet.service.rev130709.SendToController, _payload=[115, 101, 110, 100, 79, 117,"\r
-                + " 116, 112, 117, 116, 77, 115, 103, 95, 84, 69, 83, 84], augmentation=[]]]";\r
+                + " 116, 112, 117, 116, 77, 115, 103, 95, 84, 69, 83, 84], augmentation=[]]]";\r
         Assert.assertEquals(expectedString, salPacketIn.toString());\r
         LOG.debug("Test translate done.");\r
     }\r