T3: tracing only through flows in ADDED state

Change-Id: Ie6a11d25045e949217ce3575360e27512ba680da
(cherry picked from commit eeeab1f6050fd39ad555f33946af43af2c36bf7a)
diff --git a/apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java b/apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
index e46e260..0ff8906 100644
--- a/apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
+++ b/apps/t3/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
@@ -1001,7 +1001,8 @@
         if (packetVlanIdCriterion.vlanId().equals(entryModVlanIdInstruction.vlanId())) {
             //find a rule on the same table that matches the vlan and
             // also all the other elements of the flow such as input port
-            secondVlanFlow = Lists.newArrayList(flowRuleService.getFlowEntries(in.deviceId()).iterator())
+            secondVlanFlow = Lists.newArrayList(flowRuleService.getFlowEntriesByState(in.deviceId(),
+                    FlowEntry.FlowEntryState.ADDED).iterator())
                     .stream()
                     .filter(entry -> {
                         return entry.table().equals(IndexTableId.of(10));
@@ -1054,8 +1055,9 @@
 
         final Comparator<FlowEntry> comparator = Comparator.comparing((FlowEntry f) -> ((IndexTableId) f.table()).id());
 
-        return Lists.newArrayList(flowRuleService.getFlowEntries(deviceId).iterator())
-                .stream().filter(f -> ((IndexTableId) f.table()).id() > currentId).min(comparator).orElse(null);
+        return Lists.newArrayList(flowRuleService.getFlowEntriesByState(deviceId, FlowEntry.FlowEntryState.ADDED)
+                .iterator()).stream()
+                .filter(f -> ((IndexTableId) f.table()).id() > currentId).min(comparator).orElse(null);
     }
 
     private Builder handleDeferredActions(StaticPacketTrace trace, TrafficSelector packet,
@@ -1290,8 +1292,8 @@
     private FlowEntry matchHighestPriority(TrafficSelector packet, ConnectPoint in, TableId tableId) {
         //Computing the possible match rules.
         final Comparator<FlowEntry> comparator = Comparator.comparing(FlowRule::priority);
-        return Lists.newArrayList(flowRuleService.getFlowEntries(in.deviceId()).iterator())
-                .stream()
+        return Lists.newArrayList(flowRuleService.getFlowEntriesByState(in.deviceId(), FlowEntry.FlowEntryState.ADDED)
+                .iterator()).stream()
                 .filter(flowEntry -> {
                     return flowEntry.table().equals(tableId);
                 })
diff --git a/apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java b/apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
index 12c2321..8ac76c8 100644
--- a/apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
+++ b/apps/t3/src/test/java/org/onosproject/t3/impl/TroubleshootManagerTest.java
@@ -416,7 +416,7 @@
 
     private class TestFlowRuleService extends FlowRuleServiceAdapter {
         @Override
-        public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
+        public Iterable<FlowEntry> getFlowEntriesByState(DeviceId deviceId, FlowEntry.FlowEntryState state) {
             if (deviceId.equals(SINGLE_FLOW_DEVICE)) {
                 return ImmutableList.of(SINGLE_FLOW_ENTRY);
             } else if (deviceId.equals(DUAL_FLOW_DEVICE)) {