From: Anil Vishnoi Date: Wed, 7 Dec 2016 20:14:43 +0000 (-0800) Subject: Revert the functional behavior change introduced through X-Git-Tag: release/boron-sr2~1^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F49106%2F1;p=openflowplugin.git Revert the functional behavior change introduced through https://git.opendaylight.org/gerrit/#/c/47138/3 Signed-off-by: Anil Vishnoi Change-Id: I0b8fc5b1e0763bb2b91302647037e1153fd41dc1 --- 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 06d496161c..ac14caeca6 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 @@ -285,18 +285,13 @@ public final class StatisticsGatheringUtils { final short tableId = flowStat.getTableId(); final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(flowBuilder.build()); - final FlowDescriptor flowDescriptor = registry.retrieveIdForFlow(flowRegistryKey); - - if(Objects.nonNull(flowDescriptor)) { - final FlowId flowId = flowDescriptor.getFlowId(); - final FlowKey flowKey = new FlowKey(flowId); - flowBuilder.setKey(flowKey); - final TableKey tableKey = new TableKey(tableId); - final InstanceIdentifier flowIdent = fNodeIdent.child(Table.class, tableKey).child(Flow.class, flowKey); - txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); - } else { - LOG.debug("Skip write statistics. Flow hash: {} not present in DeviceFlowRegistry", flowRegistryKey.hashCode()); - } + final FlowId flowId = registry.storeIfNecessary(flowRegistryKey); + + final FlowKey flowKey = new FlowKey(flowId); + flowBuilder.setKey(flowKey); + final TableKey tableKey = new TableKey(tableId); + final InstanceIdentifier flowIdent = fNodeIdent.child(Table.class, tableKey).child(Flow.class, flowKey); + txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); } } } catch (Exception e) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java index 2268326526..e6d11dae11 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java @@ -455,11 +455,9 @@ public class StatisticsGatheringUtilsTest { final KeyedInstanceIdentifier flowPath = tablePath.child(Flow.class, new FlowKey(flowId)); verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.>any()); - verify(deviceFlowRegistry).retrieveIdForFlow(FlowRegistryKeyFactory.create(flowBld.build())); final InOrder inOrder = Mockito.inOrder(txFacade); inOrder.verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(tablePath), Matchers.any(Table.class)); - inOrder.verify(txFacade).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(flowPath), Matchers.any(Flow.class)); } @Test