From 9bc4dedd6b89e712f7b8f3b9928b559ffa700502 Mon Sep 17 00:00:00 2001 From: Jon Castro Date: Thu, 2 Feb 2017 12:57:49 +1100 Subject: [PATCH] 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 --- .../impl/statistics/StatisticsContextImpl.java | 3 ++- .../impl/statistics/StatisticsManagerImpl.java | 10 +++++++++- .../md/core/translator/PacketInV10TranslatorTest.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) 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 7dd492d592..8f49fd7fe4 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 @@ -26,6 +26,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."); } -- 2.36.6