From: Martin Bobak Date: Mon, 4 May 2015 08:08:58 +0000 (+0200) Subject: process flows statistics in one commit tx only when device is synchronized X-Git-Tag: release/lithium~249^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=e2e15be6d7e29a1b315317fb459feac1fa0c46a7;p=openflowplugin.git process flows statistics in one commit tx only when device is synchronized Change-Id: I1d3490686445836299e3058a3102889e5c67549c Signed-off-by: Martin Bobak --- diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java index be98bbfa83..2e38123504 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java @@ -186,9 +186,11 @@ public final class StatisticsGatheringUtils { final InstanceIdentifier nodeIdent = InstanceIdentifier.create(Nodes.class) .child(Node.class, new NodeKey(flowsStatistics.getId())); - deviceContext.startGatheringOperationsToOneTransaction(); - deleteAllKnownFlows(deviceContext, nodeIdent); + if (deviceContext.getDeviceState().isValid()) { + deviceContext.startGatheringOperationsToOneTransaction(); + } + deleteAllKnownFlows(deviceContext, nodeIdent); for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) { final FlowBuilder flowBuilder = new FlowBuilder(flowStat); @@ -212,7 +214,9 @@ public final class StatisticsGatheringUtils { deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); } - deviceContext.commitOperationsGatheredInOneTransaction(); + if (deviceContext.getDeviceState().isValid()) { + deviceContext.commitOperationsGatheredInOneTransaction(); + } } private static void deleteAllKnownFlows(final DeviceContext deviceContext, final InstanceIdentifier nodeIdent) {