From: Jon Castro Date: Thu, 2 Feb 2017 01:57:49 +0000 (+1100) Subject: Bug 7499 - ensure statistics scheduler does not die and keep trying while the control... X-Git-Tag: release/boron-sr3~18 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=32a99fdf314b35f62610b733b10fd25d5793e177;p=openflowplugin.git Bug 7499 - ensure statistics scheduler does not die and keep trying while the controller keeps the ownership of the device Change-Id: Ia5923f200b6c7a8888d4e3c96fdf8358603d4ac9 Signed-off-by: Jon Castro --- diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java index eab57c2795..4b5b7be9ca 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java @@ -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()) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java index 35a0d73778..d93f87b978 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java @@ -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); } } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInV10TranslatorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInV10TranslatorTest.java index ee4216f69c..797dbc98d8 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInV10TranslatorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInV10TranslatorTest.java @@ -182,7 +182,7 @@ public class PacketInV10TranslatorTest { + message.getInPort().toString() + "]]]]}], _packetInReason=class org.opendaylight.yang.gen.v1.urn.opendaylight." + "packet.service.rev130709.SendToController, _payload=[115, 101, 110, 100, 79, 117," - + " 116, 112, 117, 116, 77, 115, 103, 95, 84, 69, 83, 84], augmentation=[]]]"; + + " 116, 112, 117, 116, 77, 115, 103, 95, 84, 69, 83, 84], , augmentation=[]]]"; Assert.assertEquals(expectedString, salPacketIn.toString()); LOG.debug("Test translate done."); }