Added getCriterion method to TrafficSelector
Change-Id: I72d89d878e1fae95d1e16d9ed473b7711895e478
Showing
4 changed files
with
37 additions
and
6 deletions
... | @@ -55,6 +55,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -55,6 +55,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
55 | } | 55 | } |
56 | 56 | ||
57 | @Override | 57 | @Override |
58 | + public Criterion getCriterion(Criterion.Type type) { | ||
59 | + for (Criterion c : criteria) { | ||
60 | + if (c.type() == type) { | ||
61 | + return c; | ||
62 | + } | ||
63 | + } | ||
64 | + return null; | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
58 | public int hashCode() { | 68 | public int hashCode() { |
59 | return Objects.hash(criteria); | 69 | return Objects.hash(criteria); |
60 | } | 70 | } | ... | ... |
... | @@ -39,6 +39,15 @@ public interface TrafficSelector { | ... | @@ -39,6 +39,15 @@ public interface TrafficSelector { |
39 | Set<Criterion> criteria(); | 39 | Set<Criterion> criteria(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | + * Returns the selection criterion for a particular type, if it exists in | ||
43 | + * this traffic selector. | ||
44 | + * | ||
45 | + * @param type criterion type to look up | ||
46 | + * @return the criterion of the specified type if one exists, otherwise null | ||
47 | + */ | ||
48 | + Criterion getCriterion(Criterion.Type type); | ||
49 | + | ||
50 | + /** | ||
42 | * Builder of traffic selector entities. | 51 | * Builder of traffic selector entities. |
43 | */ | 52 | */ |
44 | public interface Builder { | 53 | public interface Builder { | ... | ... |
... | @@ -6,12 +6,11 @@ import static org.junit.Assert.assertNotNull; | ... | @@ -6,12 +6,11 @@ import static org.junit.Assert.assertNotNull; |
6 | import static org.junit.Assert.assertTrue; | 6 | import static org.junit.Assert.assertTrue; |
7 | import static org.junit.Assert.fail; | 7 | import static org.junit.Assert.fail; |
8 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADDED; | 8 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADDED; |
9 | +import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADD_REQUESTED; | ||
9 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVED; | 10 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVED; |
11 | +import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVE_REQUESTED; | ||
10 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_UPDATED; | 12 | import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_UPDATED; |
11 | 13 | ||
12 | - | ||
13 | -import static org.onlab.onos.net.flow.FlowRuleEvent.Type.*; | ||
14 | - | ||
15 | import java.util.ArrayList; | 14 | import java.util.ArrayList; |
16 | import java.util.Collections; | 15 | import java.util.Collections; |
17 | import java.util.HashMap; | 16 | import java.util.HashMap; |
... | @@ -39,6 +38,7 @@ import org.onlab.onos.net.Port; | ... | @@ -39,6 +38,7 @@ import org.onlab.onos.net.Port; |
39 | import org.onlab.onos.net.PortNumber; | 38 | import org.onlab.onos.net.PortNumber; |
40 | import org.onlab.onos.net.device.DeviceListener; | 39 | import org.onlab.onos.net.device.DeviceListener; |
41 | import org.onlab.onos.net.device.DeviceService; | 40 | import org.onlab.onos.net.device.DeviceService; |
41 | +import org.onlab.onos.net.flow.BatchOperation; | ||
42 | import org.onlab.onos.net.flow.CompletedBatchOperation; | 42 | import org.onlab.onos.net.flow.CompletedBatchOperation; |
43 | import org.onlab.onos.net.flow.DefaultFlowEntry; | 43 | import org.onlab.onos.net.flow.DefaultFlowEntry; |
44 | import org.onlab.onos.net.flow.DefaultFlowRule; | 44 | import org.onlab.onos.net.flow.DefaultFlowRule; |
... | @@ -58,7 +58,6 @@ import org.onlab.onos.net.flow.TrafficSelector; | ... | @@ -58,7 +58,6 @@ import org.onlab.onos.net.flow.TrafficSelector; |
58 | import org.onlab.onos.net.flow.TrafficTreatment; | 58 | import org.onlab.onos.net.flow.TrafficTreatment; |
59 | import org.onlab.onos.net.flow.criteria.Criterion; | 59 | import org.onlab.onos.net.flow.criteria.Criterion; |
60 | import org.onlab.onos.net.flow.instructions.Instruction; | 60 | import org.onlab.onos.net.flow.instructions.Instruction; |
61 | -import org.onlab.onos.net.flow.BatchOperation; | ||
62 | import org.onlab.onos.net.provider.AbstractProvider; | 61 | import org.onlab.onos.net.provider.AbstractProvider; |
63 | import org.onlab.onos.net.provider.ProviderId; | 62 | import org.onlab.onos.net.provider.ProviderId; |
64 | import org.onlab.onos.store.trivial.impl.SimpleFlowRuleStore; | 63 | import org.onlab.onos.store.trivial.impl.SimpleFlowRuleStore; |
... | @@ -583,6 +582,12 @@ public class FlowRuleManagerTest { | ... | @@ -583,6 +582,12 @@ public class FlowRuleManagerTest { |
583 | } | 582 | } |
584 | 583 | ||
585 | @Override | 584 | @Override |
585 | + public Criterion getCriterion( | ||
586 | + org.onlab.onos.net.flow.criteria.Criterion.Type type) { | ||
587 | + return null; | ||
588 | + } | ||
589 | + | ||
590 | + @Override | ||
586 | public int hashCode() { | 591 | public int hashCode() { |
587 | return testval; | 592 | return testval; |
588 | } | 593 | } |
... | @@ -594,6 +599,7 @@ public class FlowRuleManagerTest { | ... | @@ -594,6 +599,7 @@ public class FlowRuleManagerTest { |
594 | } | 599 | } |
595 | return false; | 600 | return false; |
596 | } | 601 | } |
602 | + | ||
597 | } | 603 | } |
598 | 604 | ||
599 | private class TestTreatment implements TrafficTreatment { | 605 | private class TestTreatment implements TrafficTreatment { | ... | ... |
1 | package org.onlab.onos.net.intent; | 1 | package org.onlab.onos.net.intent; |
2 | 2 | ||
3 | +import static org.onlab.onos.net.NetTestTools.createPath; | ||
4 | + | ||
3 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
4 | import java.util.Arrays; | 6 | import java.util.Arrays; |
5 | import java.util.Collections; | 7 | import java.util.Collections; |
... | @@ -12,12 +14,11 @@ import org.onlab.onos.net.Path; | ... | @@ -12,12 +14,11 @@ import org.onlab.onos.net.Path; |
12 | import org.onlab.onos.net.flow.TrafficSelector; | 14 | import org.onlab.onos.net.flow.TrafficSelector; |
13 | import org.onlab.onos.net.flow.TrafficTreatment; | 15 | import org.onlab.onos.net.flow.TrafficTreatment; |
14 | import org.onlab.onos.net.flow.criteria.Criterion; | 16 | import org.onlab.onos.net.flow.criteria.Criterion; |
17 | +import org.onlab.onos.net.flow.criteria.Criterion.Type; | ||
15 | import org.onlab.onos.net.flow.instructions.Instruction; | 18 | import org.onlab.onos.net.flow.instructions.Instruction; |
16 | import org.onlab.onos.net.topology.LinkWeight; | 19 | import org.onlab.onos.net.topology.LinkWeight; |
17 | import org.onlab.onos.net.topology.PathService; | 20 | import org.onlab.onos.net.topology.PathService; |
18 | 21 | ||
19 | -import static org.onlab.onos.net.NetTestTools.createPath; | ||
20 | - | ||
21 | /** | 22 | /** |
22 | * Common mocks used by the intent framework tests. | 23 | * Common mocks used by the intent framework tests. |
23 | */ | 24 | */ |
... | @@ -30,6 +31,11 @@ public class IntentTestsMocks { | ... | @@ -30,6 +31,11 @@ public class IntentTestsMocks { |
30 | public Set<Criterion> criteria() { | 31 | public Set<Criterion> criteria() { |
31 | return new HashSet<>(); | 32 | return new HashSet<>(); |
32 | } | 33 | } |
34 | + | ||
35 | + @Override | ||
36 | + public Criterion getCriterion(Type type) { | ||
37 | + return null; | ||
38 | + } | ||
33 | } | 39 | } |
34 | 40 | ||
35 | /** | 41 | /** | ... | ... |
-
Please register or login to post a comment