Revert the functional behavior change introduced through 59/49159/2
authorAnil Vishnoi <vishnoianil@gmail.com>
Wed, 7 Dec 2016 20:14:43 +0000 (12:14 -0800)
committerShuva Jyoti Kar <shuva.jyoti.kar@ericsson.com>
Tue, 13 Dec 2016 07:14:47 +0000 (07:14 +0000)
https://git.opendaylight.org/gerrit/#/c/47138/3

Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
Change-Id: I0b8fc5b1e0763bb2b91302647037e1153fd41dc1
(cherry picked from commit 43b49485d25ebdf0dca58d46c14100a4aa7c6324)

openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java

index 06d496161cf8d429f88da099e9c5cae978c9cee8..ac14caeca660dacbe414901f4de94299e120a457 100644 (file)
@@ -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<Flow> 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<Flow> flowIdent = fNodeIdent.child(Table.class, tableKey).child(Flow.class, flowKey);
+                    txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
                 }
             }
         } catch (Exception e) {
index 2268326526c4cbb1161f66c09805ecb64595720a..e6d11dae1126f73fd7bc725ea531ee72e6451fbc 100644 (file)
@@ -455,11 +455,9 @@ public class StatisticsGatheringUtilsTest {
         final KeyedInstanceIdentifier<Flow, FlowKey> flowPath =  tablePath.child(Flow.class, new FlowKey(flowId));
 
         verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>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