Jonathan Hart
Committed by Gerrit Code Review

Minor tweaks to the flow layer.

Prevent DistributedStatistics store from logging "rule has no output" for
rules that transition to other tables.

Change-Id: I85e86965f5609df608cbc19551632153960a5c5b
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper;
19 -
20 -import java.util.Objects;
21 -
22 import org.onosproject.core.ApplicationId; 18 import org.onosproject.core.ApplicationId;
23 import org.onosproject.core.DefaultGroupId; 19 import org.onosproject.core.DefaultGroupId;
24 import org.onosproject.core.GroupId; 20 import org.onosproject.core.GroupId;
25 import org.onosproject.net.DeviceId; 21 import org.onosproject.net.DeviceId;
26 22
23 +import java.util.Objects;
24 +
25 +import static com.google.common.base.MoreObjects.toStringHelper;
26 +
27 public class DefaultFlowRule implements FlowRule { 27 public class DefaultFlowRule implements FlowRule {
28 28
29 private final DeviceId deviceId; 29 private final DeviceId deviceId;
...@@ -233,7 +233,7 @@ public class DefaultFlowRule implements FlowRule { ...@@ -233,7 +233,7 @@ public class DefaultFlowRule implements FlowRule {
233 .add("deviceId", deviceId) 233 .add("deviceId", deviceId)
234 .add("priority", priority) 234 .add("priority", priority)
235 .add("selector", selector.criteria()) 235 .add("selector", selector.criteria())
236 - .add("treatment", treatment == null ? "N/A" : treatment.instructions()) 236 + .add("treatment", treatment == null ? "N/A" : treatment.allInstructions())
237 .add("table type", type) 237 .add("table type", type)
238 .add("created", created) 238 .add("created", created)
239 .toString(); 239 .toString();
......
...@@ -18,6 +18,7 @@ package org.onosproject.net.flow; ...@@ -18,6 +18,7 @@ package org.onosproject.net.flow;
18 import com.google.common.base.MoreObjects; 18 import com.google.common.base.MoreObjects;
19 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
20 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
21 +import org.apache.commons.collections.ListUtils;
21 import org.onlab.packet.IpAddress; 22 import org.onlab.packet.IpAddress;
22 import org.onlab.packet.MacAddress; 23 import org.onlab.packet.MacAddress;
23 import org.onlab.packet.MplsLabel; 24 import org.onlab.packet.MplsLabel;
...@@ -84,6 +85,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -84,6 +85,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
84 } 85 }
85 86
86 @Override 87 @Override
88 + public List<Instruction> allInstructions() {
89 + return ListUtils.union(immediate, deferred);
90 + }
91 +
92 + @Override
87 public Instructions.TableTypeTransition tableTransition() { 93 public Instructions.TableTypeTransition tableTransition() {
88 return table; 94 return table;
89 } 95 }
......
...@@ -54,6 +54,14 @@ public interface TrafficTreatment { ...@@ -54,6 +54,14 @@ public interface TrafficTreatment {
54 List<Instruction> immediate(); 54 List<Instruction> immediate();
55 55
56 /** 56 /**
57 + * Returns the list of all instructions in the treatment, both immediate and
58 + * deferred.
59 + *
60 + * @return list of treatment instructions
61 + */
62 + List<Instruction> allInstructions();
63 +
64 + /**
57 * Returns the next table in the pipeline. 65 * Returns the next table in the pipeline.
58 * @return a table transition; may be null. 66 * @return a table transition; may be null.
59 */ 67 */
......
...@@ -15,21 +15,8 @@ ...@@ -15,21 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.intent; 16 package org.onosproject.net.intent;
17 17
18 -import static org.onosproject.net.NetTestTools.createPath; 18 +import com.google.common.base.MoreObjects;
19 -import static org.onosproject.net.NetTestTools.did; 19 +import com.google.common.collect.ImmutableSet;
20 -import static org.onosproject.net.NetTestTools.link;
21 -
22 -import java.util.ArrayList;
23 -import java.util.Arrays;
24 -import java.util.Collection;
25 -import java.util.Collections;
26 -import java.util.HashSet;
27 -import java.util.LinkedList;
28 -import java.util.List;
29 -import java.util.Objects;
30 -import java.util.Set;
31 -import java.util.concurrent.atomic.AtomicLong;
32 -
33 import org.onosproject.core.DefaultGroupId; 20 import org.onosproject.core.DefaultGroupId;
34 import org.onosproject.core.GroupId; 21 import org.onosproject.core.GroupId;
35 import org.onosproject.net.DeviceId; 22 import org.onosproject.net.DeviceId;
...@@ -67,8 +54,20 @@ import org.onosproject.net.topology.PathService; ...@@ -67,8 +54,20 @@ import org.onosproject.net.topology.PathService;
67 import org.onosproject.net.topology.TopologyVertex; 54 import org.onosproject.net.topology.TopologyVertex;
68 import org.onosproject.store.Timestamp; 55 import org.onosproject.store.Timestamp;
69 56
70 -import com.google.common.base.MoreObjects; 57 +import java.util.ArrayList;
71 -import com.google.common.collect.ImmutableSet; 58 +import java.util.Arrays;
59 +import java.util.Collection;
60 +import java.util.Collections;
61 +import java.util.HashSet;
62 +import java.util.LinkedList;
63 +import java.util.List;
64 +import java.util.Objects;
65 +import java.util.Set;
66 +import java.util.concurrent.atomic.AtomicLong;
67 +
68 +import static org.onosproject.net.NetTestTools.createPath;
69 +import static org.onosproject.net.NetTestTools.did;
70 +import static org.onosproject.net.NetTestTools.link;
72 71
73 /** 72 /**
74 * Common mocks used by the intent framework tests. 73 * Common mocks used by the intent framework tests.
...@@ -109,6 +108,11 @@ public class IntentTestsMocks { ...@@ -109,6 +108,11 @@ public class IntentTestsMocks {
109 } 108 }
110 109
111 @Override 110 @Override
111 + public List<Instruction> allInstructions() {
112 + return null;
113 + }
114 +
115 + @Override
112 public Instructions.TableTypeTransition tableTransition() { 116 public Instructions.TableTypeTransition tableTransition() {
113 return null; 117 return null;
114 } 118 }
......
...@@ -15,19 +15,12 @@ ...@@ -15,19 +15,12 @@
15 */ 15 */
16 package org.onosproject.net.flow.impl; 16 package org.onosproject.net.flow.impl;
17 17
18 -import java.util.ArrayList; 18 +import com.google.common.collect.ImmutableList;
19 -import java.util.Arrays; 19 +import com.google.common.collect.ImmutableMap;
20 -import java.util.Collections; 20 +import com.google.common.collect.Lists;
21 -import java.util.HashMap; 21 +import com.google.common.collect.Sets;
22 -import java.util.List; 22 +import com.google.common.util.concurrent.ListenableFuture;
23 -import java.util.Map; 23 +import com.google.common.util.concurrent.MoreExecutors;
24 -import java.util.Set;
25 -import java.util.concurrent.ExecutionException;
26 -import java.util.concurrent.Executor;
27 -import java.util.concurrent.TimeUnit;
28 -import java.util.concurrent.TimeoutException;
29 -import java.util.concurrent.atomic.AtomicLong;
30 -
31 import org.junit.After; 24 import org.junit.After;
32 import org.junit.Before; 25 import org.junit.Before;
33 import org.junit.Test; 26 import org.junit.Test;
...@@ -68,12 +61,18 @@ import org.onosproject.net.provider.AbstractProvider; ...@@ -68,12 +61,18 @@ import org.onosproject.net.provider.AbstractProvider;
68 import org.onosproject.net.provider.ProviderId; 61 import org.onosproject.net.provider.ProviderId;
69 import org.onosproject.store.trivial.impl.SimpleFlowRuleStore; 62 import org.onosproject.store.trivial.impl.SimpleFlowRuleStore;
70 63
71 -import com.google.common.collect.ImmutableList; 64 +import java.util.ArrayList;
72 -import com.google.common.collect.ImmutableMap; 65 +import java.util.Arrays;
73 -import com.google.common.collect.Lists; 66 +import java.util.Collections;
74 -import com.google.common.collect.Sets; 67 +import java.util.HashMap;
75 -import com.google.common.util.concurrent.ListenableFuture; 68 +import java.util.List;
76 -import com.google.common.util.concurrent.MoreExecutors; 69 +import java.util.Map;
70 +import java.util.Set;
71 +import java.util.concurrent.ExecutionException;
72 +import java.util.concurrent.Executor;
73 +import java.util.concurrent.TimeUnit;
74 +import java.util.concurrent.TimeoutException;
75 +import java.util.concurrent.atomic.AtomicLong;
77 76
78 import static org.junit.Assert.assertEquals; 77 import static org.junit.Assert.assertEquals;
79 import static org.junit.Assert.assertFalse; 78 import static org.junit.Assert.assertFalse;
...@@ -573,6 +572,11 @@ public class FlowRuleManagerTest { ...@@ -573,6 +572,11 @@ public class FlowRuleManagerTest {
573 } 572 }
574 573
575 @Override 574 @Override
575 + public List<Instruction> allInstructions() {
576 + return null;
577 + }
578 +
579 + @Override
576 public Instructions.TableTypeTransition tableTransition() { 580 public Instructions.TableTypeTransition tableTransition() {
577 return null; 581 return null;
578 } 582 }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 package org.onosproject.store.statistic.impl; 16 package org.onosproject.store.statistic.impl;
17 17
18 import com.google.common.collect.Sets; 18 import com.google.common.collect.Sets;
19 -import org.apache.commons.collections.ListUtils;
20 import org.apache.felix.scr.annotations.Activate; 19 import org.apache.felix.scr.annotations.Activate;
21 import org.apache.felix.scr.annotations.Component; 20 import org.apache.felix.scr.annotations.Component;
22 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
...@@ -45,7 +44,6 @@ import org.slf4j.Logger; ...@@ -45,7 +44,6 @@ import org.slf4j.Logger;
45 import java.io.IOException; 44 import java.io.IOException;
46 import java.util.Collections; 45 import java.util.Collections;
47 import java.util.HashSet; 46 import java.util.HashSet;
48 -import java.util.List;
49 import java.util.Map; 47 import java.util.Map;
50 import java.util.Set; 48 import java.util.Set;
51 import java.util.concurrent.ConcurrentHashMap; 49 import java.util.concurrent.ConcurrentHashMap;
...@@ -290,15 +288,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -290,15 +288,7 @@ public class DistributedStatisticStore implements StatisticStore {
290 private ConnectPoint buildConnectPoint(FlowRule rule) { 288 private ConnectPoint buildConnectPoint(FlowRule rule) {
291 PortNumber port = getOutput(rule); 289 PortNumber port = getOutput(rule);
292 290
293 - boolean hasGoto = rule.treatment().instructions()
294 - .stream()
295 - .anyMatch(i -> (i instanceof Instructions.GroupInstruction)
296 - || (i instanceof Instructions.TableTypeTransition));
297 -
298 if (port == null) { 291 if (port == null) {
299 - if (!hasGoto) {
300 - log.debug("Rule {} has no output.", rule);
301 - }
302 return null; 292 return null;
303 } 293 }
304 ConnectPoint cp = new ConnectPoint(rule.deviceId(), port); 294 ConnectPoint cp = new ConnectPoint(rule.deviceId(), port);
...@@ -306,9 +296,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -306,9 +296,7 @@ public class DistributedStatisticStore implements StatisticStore {
306 } 296 }
307 297
308 private PortNumber getOutput(FlowRule rule) { 298 private PortNumber getOutput(FlowRule rule) {
309 - List<Instruction> all = ListUtils.union(rule.treatment().immediate(), 299 + for (Instruction i : rule.treatment().allInstructions()) {
310 - rule.treatment().deferred());
311 - for (Instruction i : all) {
312 if (i.type() == Instruction.Type.OUTPUT) { 300 if (i.type() == Instruction.Type.OUTPUT) {
313 Instructions.OutputInstruction out = (Instructions.OutputInstruction) i; 301 Instructions.OutputInstruction out = (Instructions.OutputInstruction) i;
314 return out.port(); 302 return out.port();
......
...@@ -172,8 +172,9 @@ public class FlowEntryBuilder { ...@@ -172,8 +172,9 @@ public class FlowEntryBuilder {
172 private List<OFInstruction> getInstructions(OFFlowMod entry) { 172 private List<OFInstruction> getInstructions(OFFlowMod entry) {
173 switch (entry.getVersion()) { 173 switch (entry.getVersion()) {
174 case OF_10: 174 case OF_10:
175 - return Lists.newArrayList( 175 + return Lists.newArrayList(OFFactoryVer13.INSTANCE.instructions()
176 - OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions())); 176 + .applyActions(
177 + entry.getActions()));
177 case OF_11: 178 case OF_11:
178 case OF_12: 179 case OF_12:
179 case OF_13: 180 case OF_13:
...@@ -316,6 +317,9 @@ public class FlowEntryBuilder { ...@@ -316,6 +317,9 @@ public class FlowEntryBuilder {
316 case POP_VLAN: 317 case POP_VLAN:
317 builder.popVlan(); 318 builder.popVlan();
318 break; 319 break;
320 + case PUSH_VLAN:
321 + builder.pushVlan();
322 + break;
319 case STRIP_VLAN: 323 case STRIP_VLAN:
320 builder.stripVlan(); 324 builder.stripVlan();
321 break; 325 break;
...@@ -323,7 +327,6 @@ public class FlowEntryBuilder { ...@@ -323,7 +327,6 @@ public class FlowEntryBuilder {
323 case SET_TP_SRC: 327 case SET_TP_SRC:
324 case POP_PBB: 328 case POP_PBB:
325 case PUSH_PBB: 329 case PUSH_PBB:
326 - case PUSH_VLAN:
327 case SET_MPLS_LABEL: 330 case SET_MPLS_LABEL:
328 case SET_MPLS_TC: 331 case SET_MPLS_TC:
329 case SET_MPLS_TTL: 332 case SET_MPLS_TTL:
......
...@@ -84,7 +84,7 @@ public class GroupBucketEntryBuilder { ...@@ -84,7 +84,7 @@ public class GroupBucketEntryBuilder {
84 /** 84 /**
85 * Builds a GroupBuckets. 85 * Builds a GroupBuckets.
86 * 86 *
87 - * @return GroupBuckets object, a list of GroupBuck 87 + * @return GroupBuckets object, a list of GroupBuckets
88 */ 88 */
89 public GroupBuckets build() { 89 public GroupBuckets build() {
90 List<GroupBucket> bucketList = Lists.newArrayList(); 90 List<GroupBucket> bucketList = Lists.newArrayList();
......