Consolidated FlowEntry into FlowRule
Change-Id: I349d73abba3336f4c79429efb5717e0a8c374a30
Showing
11 changed files
with
120 additions
and
195 deletions
... | @@ -169,7 +169,7 @@ public class ReactiveForwarding { | ... | @@ -169,7 +169,7 @@ public class ReactiveForwarding { |
169 | treat.add(Instructions.createOutput(portNumber)); | 169 | treat.add(Instructions.createOutput(portNumber)); |
170 | 170 | ||
171 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), | 171 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), |
172 | - builder.build(), treat.build()); | 172 | + builder.build(), treat.build(), 0); |
173 | 173 | ||
174 | flowRuleService.applyFlowRules(f); | 174 | flowRuleService.applyFlowRules(f); |
175 | } | 175 | } | ... | ... |
1 | -package org.onlab.onos.net.flow; | ||
2 | - | ||
3 | -import static com.google.common.base.MoreObjects.toStringHelper; | ||
4 | - | ||
5 | -import org.onlab.onos.net.DeviceId; | ||
6 | - | ||
7 | -public class DefaultFlowEntry extends DefaultFlowRule implements FlowEntry { | ||
8 | - | ||
9 | - private final int priority; | ||
10 | - private final long created; | ||
11 | - private final FlowId id; | ||
12 | - | ||
13 | - public DefaultFlowEntry(DefaultFlowEntry entry) { | ||
14 | - super(entry.deviceId(), entry.selector(), entry.treatment()); | ||
15 | - this.priority = entry.priority; | ||
16 | - this.created = entry.created; | ||
17 | - this.id = entry.id; | ||
18 | - } | ||
19 | - | ||
20 | - public DefaultFlowEntry(DeviceId deviceId, TrafficSelector selector, | ||
21 | - TrafficTreatment treatment, int priority) { | ||
22 | - super(deviceId, selector, treatment); | ||
23 | - this.priority = priority; | ||
24 | - this.created = System.currentTimeMillis(); | ||
25 | - this.id = FlowId.valueOf(this.hashCode()); | ||
26 | - } | ||
27 | - | ||
28 | - @Override | ||
29 | - public FlowId id() { | ||
30 | - return null; | ||
31 | - } | ||
32 | - | ||
33 | - @Override | ||
34 | - public int priority() { | ||
35 | - return priority; | ||
36 | - } | ||
37 | - | ||
38 | - @Override | ||
39 | - public long lifeMillis() { | ||
40 | - return (created - System.currentTimeMillis()); | ||
41 | - } | ||
42 | - | ||
43 | - @Override | ||
44 | - public long idleMillis() { | ||
45 | - return 0; | ||
46 | - } | ||
47 | - | ||
48 | - @Override | ||
49 | - public long packets() { | ||
50 | - return 0; | ||
51 | - } | ||
52 | - | ||
53 | - @Override | ||
54 | - public long bytes() { | ||
55 | - return 0; | ||
56 | - } | ||
57 | - | ||
58 | - @Override | ||
59 | - /* | ||
60 | - * currently uses the parts that definitely have a defined hashcode... | ||
61 | - * | ||
62 | - * (non-Javadoc) | ||
63 | - * @see java.lang.Object#hashCode() | ||
64 | - */ | ||
65 | - public int hashCode() { | ||
66 | - final int prime = 31; | ||
67 | - int result = prime * this.deviceId().hashCode(); | ||
68 | - result = prime * result + this.priority; | ||
69 | - result = prime * result + this.selector().hashCode(); | ||
70 | - result = prime * result + this.treatment().hashCode(); | ||
71 | - return result; | ||
72 | - } | ||
73 | - | ||
74 | - @Override | ||
75 | - /* | ||
76 | - * The priority and statistics can change on a given treatment and selector | ||
77 | - * | ||
78 | - * (non-Javadoc) | ||
79 | - * @see java.lang.Object#equals(java.lang.Object) | ||
80 | - */ | ||
81 | - public boolean equals(Object obj) { | ||
82 | - if (obj instanceof DefaultFlowEntry) { | ||
83 | - DefaultFlowEntry that = (DefaultFlowEntry) obj; | ||
84 | - if (!this.deviceId().equals(that.deviceId())) { | ||
85 | - return false; | ||
86 | - } | ||
87 | - if (!(this.priority == that.priority)) { | ||
88 | - return false; | ||
89 | - } | ||
90 | - return super.equals(obj); | ||
91 | - } | ||
92 | - return false; | ||
93 | - } | ||
94 | - | ||
95 | - @Override | ||
96 | - public String toString() { | ||
97 | - return toStringHelper(this) | ||
98 | - .add("id", id) | ||
99 | - .add("deviceId", deviceId()) | ||
100 | - .add("priority", priority) | ||
101 | - .add("selector", selector()) | ||
102 | - .add("treatment", treatment()) | ||
103 | - .toString(); | ||
104 | - } | ||
105 | - | ||
106 | -} |
1 | package org.onlab.onos.net.flow; | 1 | package org.onlab.onos.net.flow; |
2 | 2 | ||
3 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
4 | + | ||
3 | import org.onlab.onos.net.DeviceId; | 5 | import org.onlab.onos.net.DeviceId; |
4 | 6 | ||
5 | public class DefaultFlowRule implements FlowRule { | 7 | public class DefaultFlowRule implements FlowRule { |
6 | 8 | ||
9 | + private final DeviceId deviceId; | ||
10 | + private final int priority; | ||
7 | private final TrafficSelector selector; | 11 | private final TrafficSelector selector; |
8 | private final TrafficTreatment treatment; | 12 | private final TrafficTreatment treatment; |
9 | - private final DeviceId deviceId; | 13 | + private final FlowId id; |
14 | + private final long created; | ||
15 | + | ||
10 | 16 | ||
11 | public DefaultFlowRule(DeviceId deviceId, | 17 | public DefaultFlowRule(DeviceId deviceId, |
12 | - TrafficSelector selector, TrafficTreatment treatment) { | 18 | + TrafficSelector selector, TrafficTreatment treatment, int priority) { |
13 | - this.treatment = treatment; | ||
14 | - this.selector = selector; | ||
15 | this.deviceId = deviceId; | 19 | this.deviceId = deviceId; |
20 | + this.priority = priority; | ||
21 | + this.selector = selector; | ||
22 | + this.treatment = treatment; | ||
23 | + this.id = FlowId.valueOf(this.hashCode()); | ||
24 | + this.created = System.currentTimeMillis(); | ||
25 | + } | ||
26 | + | ||
27 | + @Override | ||
28 | + public FlowId id() { | ||
29 | + return id; | ||
16 | } | 30 | } |
17 | 31 | ||
18 | @Override | 32 | @Override |
19 | public int priority() { | 33 | public int priority() { |
20 | - // is this supposed to be 0? | 34 | + return priority; |
21 | - return 0; | ||
22 | } | 35 | } |
23 | 36 | ||
24 | @Override | 37 | @Override |
... | @@ -37,6 +50,35 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -37,6 +50,35 @@ public class DefaultFlowRule implements FlowRule { |
37 | } | 50 | } |
38 | 51 | ||
39 | @Override | 52 | @Override |
53 | + public long lifeMillis() { | ||
54 | + return (created - System.currentTimeMillis()); | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public long idleMillis() { | ||
59 | + // TODO Auto-generated method stub | ||
60 | + return 0; | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public long packets() { | ||
65 | + // TODO Auto-generated method stub | ||
66 | + return 0; | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public long bytes() { | ||
71 | + // TODO Auto-generated method stub | ||
72 | + return 0; | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + /* | ||
77 | + * The priority and statistics can change on a given treatment and selector | ||
78 | + * | ||
79 | + * (non-Javadoc) | ||
80 | + * @see java.lang.Object#equals(java.lang.Object) | ||
81 | + */ | ||
40 | public int hashCode() { | 82 | public int hashCode() { |
41 | final int prime = 31; | 83 | final int prime = 31; |
42 | int result = prime * this.deviceId().hashCode(); | 84 | int result = prime * this.deviceId().hashCode(); |
... | @@ -69,5 +111,16 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -69,5 +111,16 @@ public class DefaultFlowRule implements FlowRule { |
69 | return false; | 111 | return false; |
70 | } | 112 | } |
71 | 113 | ||
114 | + @Override | ||
115 | + public String toString() { | ||
116 | + return toStringHelper(this) | ||
117 | + .add("id", id) | ||
118 | + .add("deviceId", deviceId) | ||
119 | + .add("priority", priority) | ||
120 | + .add("selector", selector) | ||
121 | + .add("treatment", treatment) | ||
122 | + .add("created", created) | ||
123 | + .toString(); | ||
124 | + } | ||
72 | 125 | ||
73 | } | 126 | } | ... | ... |
1 | -package org.onlab.onos.net.flow; | ||
2 | - | ||
3 | -/** | ||
4 | - * Represents a flow rule and its associated accumulated metrics. | ||
5 | - */ | ||
6 | -public interface FlowEntry extends FlowRule { | ||
7 | - | ||
8 | - /** | ||
9 | - * Returns the ID of this flow. | ||
10 | - * | ||
11 | - * @return the flow ID | ||
12 | - */ | ||
13 | - FlowId id(); | ||
14 | - | ||
15 | - /** | ||
16 | - * Returns the number of milliseconds this flow rule has been applied. | ||
17 | - * | ||
18 | - * @return number of millis | ||
19 | - */ | ||
20 | - long lifeMillis(); | ||
21 | - | ||
22 | - /** | ||
23 | - * Returns the number of milliseconds this flow rule has been idle. | ||
24 | - * | ||
25 | - * @return number of millis | ||
26 | - */ | ||
27 | - long idleMillis(); | ||
28 | - | ||
29 | - /** | ||
30 | - * Returns the number of packets this flow rule has matched. | ||
31 | - * | ||
32 | - * @return number of packets | ||
33 | - */ | ||
34 | - long packets(); | ||
35 | - | ||
36 | - /** | ||
37 | - * Returns the number of bytes this flow rule has matched. | ||
38 | - * | ||
39 | - * @return number of bytes | ||
40 | - */ | ||
41 | - long bytes(); | ||
42 | - | ||
43 | -} |
... | @@ -9,6 +9,12 @@ import org.onlab.onos.net.DeviceId; | ... | @@ -9,6 +9,12 @@ import org.onlab.onos.net.DeviceId; |
9 | public interface FlowRule { | 9 | public interface FlowRule { |
10 | 10 | ||
11 | //TODO: build cookie value | 11 | //TODO: build cookie value |
12 | + /** | ||
13 | + * Returns the ID of this flow. | ||
14 | + * | ||
15 | + * @return the flow ID | ||
16 | + */ | ||
17 | + FlowId id(); | ||
12 | 18 | ||
13 | /** | 19 | /** |
14 | * Returns the flow rule priority given in natural order; higher numbers | 20 | * Returns the flow rule priority given in natural order; higher numbers |
... | @@ -40,4 +46,32 @@ public interface FlowRule { | ... | @@ -40,4 +46,32 @@ public interface FlowRule { |
40 | */ | 46 | */ |
41 | TrafficTreatment treatment(); | 47 | TrafficTreatment treatment(); |
42 | 48 | ||
49 | + /** | ||
50 | + * Returns the number of milliseconds this flow rule has been applied. | ||
51 | + * | ||
52 | + * @return number of millis | ||
53 | + */ | ||
54 | + long lifeMillis(); | ||
55 | + | ||
56 | + /** | ||
57 | + * Returns the number of milliseconds this flow rule has been idle. | ||
58 | + * | ||
59 | + * @return number of millis | ||
60 | + */ | ||
61 | + long idleMillis(); | ||
62 | + | ||
63 | + /** | ||
64 | + * Returns the number of packets this flow rule has matched. | ||
65 | + * | ||
66 | + * @return number of packets | ||
67 | + */ | ||
68 | + long packets(); | ||
69 | + | ||
70 | + /** | ||
71 | + * Returns the number of bytes this flow rule has matched. | ||
72 | + * | ||
73 | + * @return number of bytes | ||
74 | + */ | ||
75 | + long bytes(); | ||
76 | + | ||
43 | } | 77 | } | ... | ... |
... | @@ -34,6 +34,6 @@ public interface FlowRuleProvider extends Provider { | ... | @@ -34,6 +34,6 @@ public interface FlowRuleProvider extends Provider { |
34 | * @param deviceId device identifier | 34 | * @param deviceId device identifier |
35 | * @return collection of flow entries | 35 | * @return collection of flow entries |
36 | */ | 36 | */ |
37 | - Iterable<FlowEntry> getFlowMetrics(DeviceId deviceId); | 37 | + Iterable<FlowRule> getFlowMetrics(DeviceId deviceId); |
38 | 38 | ||
39 | } | 39 | } | ... | ... |
... | @@ -21,7 +21,7 @@ public interface FlowRuleService { | ... | @@ -21,7 +21,7 @@ public interface FlowRuleService { |
21 | * @param deviceId device identifier | 21 | * @param deviceId device identifier |
22 | * @return collection of flow rules | 22 | * @return collection of flow rules |
23 | */ | 23 | */ |
24 | - Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); | 24 | + Iterable<FlowRule> getFlowEntries(DeviceId deviceId); |
25 | 25 | ||
26 | // TODO: add createFlowRule factory method and execute operations method | 26 | // TODO: add createFlowRule factory method and execute operations method |
27 | 27 | ||
... | @@ -34,7 +34,7 @@ public interface FlowRuleService { | ... | @@ -34,7 +34,7 @@ public interface FlowRuleService { |
34 | * throws SomeKindOfException that indicates which ones were applied and | 34 | * throws SomeKindOfException that indicates which ones were applied and |
35 | * which ones failed | 35 | * which ones failed |
36 | */ | 36 | */ |
37 | - List<FlowEntry> applyFlowRules(FlowRule... flowRules); | 37 | + List<FlowRule> applyFlowRules(FlowRule... flowRules); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Removes the specified flow rules from their respective devices. If the | 40 | * Removes the specified flow rules from their respective devices. If the | ... | ... |
... | @@ -16,7 +16,6 @@ import org.onlab.onos.event.EventDeliveryService; | ... | @@ -16,7 +16,6 @@ import org.onlab.onos.event.EventDeliveryService; |
16 | import org.onlab.onos.net.Device; | 16 | import org.onlab.onos.net.Device; |
17 | import org.onlab.onos.net.DeviceId; | 17 | import org.onlab.onos.net.DeviceId; |
18 | import org.onlab.onos.net.device.DeviceService; | 18 | import org.onlab.onos.net.device.DeviceService; |
19 | -import org.onlab.onos.net.flow.FlowEntry; | ||
20 | import org.onlab.onos.net.flow.FlowRule; | 19 | import org.onlab.onos.net.flow.FlowRule; |
21 | import org.onlab.onos.net.flow.FlowRuleEvent; | 20 | import org.onlab.onos.net.flow.FlowRuleEvent; |
22 | import org.onlab.onos.net.flow.FlowRuleListener; | 21 | import org.onlab.onos.net.flow.FlowRuleListener; |
... | @@ -63,13 +62,13 @@ implements FlowRuleService, FlowRuleProviderRegistry { | ... | @@ -63,13 +62,13 @@ implements FlowRuleService, FlowRuleProviderRegistry { |
63 | } | 62 | } |
64 | 63 | ||
65 | @Override | 64 | @Override |
66 | - public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { | 65 | + public Iterable<FlowRule> getFlowEntries(DeviceId deviceId) { |
67 | return store.getFlowEntries(deviceId); | 66 | return store.getFlowEntries(deviceId); |
68 | } | 67 | } |
69 | 68 | ||
70 | @Override | 69 | @Override |
71 | - public List<FlowEntry> applyFlowRules(FlowRule... flowRules) { | 70 | + public List<FlowRule> applyFlowRules(FlowRule... flowRules) { |
72 | - List<FlowEntry> entries = new ArrayList<FlowEntry>(); | 71 | + List<FlowRule> entries = new ArrayList<FlowRule>(); |
73 | 72 | ||
74 | for (int i = 0; i < flowRules.length; i++) { | 73 | for (int i = 0; i < flowRules.length; i++) { |
75 | FlowRule f = flowRules[i]; | 74 | FlowRule f = flowRules[i]; | ... | ... |
1 | package org.onlab.onos.net.trivial.flow.impl; | 1 | package org.onlab.onos.net.trivial.flow.impl; |
2 | 2 | ||
3 | import org.onlab.onos.net.DeviceId; | 3 | import org.onlab.onos.net.DeviceId; |
4 | -import org.onlab.onos.net.flow.DefaultFlowEntry; | 4 | +import org.onlab.onos.net.flow.DefaultFlowRule; |
5 | -import org.onlab.onos.net.flow.FlowEntry; | ||
6 | import org.onlab.onos.net.flow.FlowRule; | 5 | import org.onlab.onos.net.flow.FlowRule; |
7 | import org.onlab.onos.net.flow.FlowRuleEvent; | 6 | import org.onlab.onos.net.flow.FlowRuleEvent; |
8 | 7 | ||
... | @@ -18,7 +17,7 @@ import static org.onlab.onos.net.flow.FlowRuleEvent.Type.*; | ... | @@ -18,7 +17,7 @@ import static org.onlab.onos.net.flow.FlowRuleEvent.Type.*; |
18 | public class SimpleFlowRuleStore { | 17 | public class SimpleFlowRuleStore { |
19 | 18 | ||
20 | // store entries as a pile of rules, no info about device tables | 19 | // store entries as a pile of rules, no info about device tables |
21 | - private final Multimap<DeviceId, FlowEntry> flowEntries = HashMultimap.create(); | 20 | + private final Multimap<DeviceId, FlowRule> flowEntries = HashMultimap.create(); |
22 | 21 | ||
23 | /** | 22 | /** |
24 | * Returns the flow entries associated with a device. | 23 | * Returns the flow entries associated with a device. |
... | @@ -26,19 +25,19 @@ public class SimpleFlowRuleStore { | ... | @@ -26,19 +25,19 @@ public class SimpleFlowRuleStore { |
26 | * @param deviceId the device ID | 25 | * @param deviceId the device ID |
27 | * @return the flow entries | 26 | * @return the flow entries |
28 | */ | 27 | */ |
29 | - Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { | 28 | + Iterable<FlowRule> getFlowEntries(DeviceId deviceId) { |
30 | return ImmutableSet.copyOf(flowEntries.get(deviceId)); | 29 | return ImmutableSet.copyOf(flowEntries.get(deviceId)); |
31 | } | 30 | } |
32 | 31 | ||
33 | /** | 32 | /** |
34 | - * Stores a new flow rule, and generates a FlowEntry for it. | 33 | + * Stores a new flow rule, and generates a FlowRule for it. |
35 | * | 34 | * |
36 | * @param rule the flow rule to add | 35 | * @param rule the flow rule to add |
37 | * @return a flow entry | 36 | * @return a flow entry |
38 | */ | 37 | */ |
39 | - FlowEntry storeFlowRule(FlowRule rule) { | 38 | + FlowRule storeFlowRule(FlowRule rule) { |
40 | DeviceId did = rule.deviceId(); | 39 | DeviceId did = rule.deviceId(); |
41 | - FlowEntry entry = new DefaultFlowEntry(did, | 40 | + FlowRule entry = new DefaultFlowRule(did, |
42 | rule.selector(), rule.treatment(), rule.priority()); | 41 | rule.selector(), rule.treatment(), rule.priority()); |
43 | flowEntries.put(did, entry); | 42 | flowEntries.put(did, entry); |
44 | return entry; | 43 | return entry; |
... | @@ -53,20 +52,14 @@ public class SimpleFlowRuleStore { | ... | @@ -53,20 +52,14 @@ public class SimpleFlowRuleStore { |
53 | FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) { | 52 | FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) { |
54 | DeviceId did = rule.deviceId(); | 53 | DeviceId did = rule.deviceId(); |
55 | 54 | ||
56 | - FlowEntry entry = new DefaultFlowEntry( | ||
57 | - did, | ||
58 | - rule.selector(), | ||
59 | - rule.treatment(), | ||
60 | - rule.priority()); | ||
61 | - | ||
62 | // check if this new rule is an update to an existing entry | 55 | // check if this new rule is an update to an existing entry |
63 | - for (FlowEntry fe : flowEntries.get(did)) { | 56 | + for (FlowRule fe : flowEntries.get(did)) { |
64 | - if (entry.equals(fe)) { | 57 | + if (rule.equals(fe)) { |
65 | - // TODO update the stats on this flowEntry? | 58 | + // TODO update the stats on this FlowRule? |
66 | return null; | 59 | return null; |
67 | } | 60 | } |
68 | } | 61 | } |
69 | - flowEntries.put(did, entry); | 62 | + flowEntries.put(did, rule); |
70 | return new FlowRuleEvent(RULE_ADDED, rule); | 63 | return new FlowRuleEvent(RULE_ADDED, rule); |
71 | } | 64 | } |
72 | 65 | ||
... | @@ -77,10 +70,8 @@ public class SimpleFlowRuleStore { | ... | @@ -77,10 +70,8 @@ public class SimpleFlowRuleStore { |
77 | */ | 70 | */ |
78 | FlowRuleEvent removeFlowRule(FlowRule rule) { | 71 | FlowRuleEvent removeFlowRule(FlowRule rule) { |
79 | 72 | ||
80 | - FlowEntry rem = new DefaultFlowEntry(rule.deviceId(), | ||
81 | - rule.selector(), rule.treatment(), rule.priority()); | ||
82 | synchronized (this) { | 73 | synchronized (this) { |
83 | - if (flowEntries.remove(rem.deviceId(), rem)) { | 74 | + if (flowEntries.remove(rule.deviceId(), rule)) { |
84 | return new FlowRuleEvent(RULE_REMOVED, rule); | 75 | return new FlowRuleEvent(RULE_REMOVED, rule); |
85 | } else { | 76 | } else { |
86 | return null; | 77 | return null; | ... | ... |
... | @@ -21,9 +21,7 @@ import org.onlab.onos.net.Port; | ... | @@ -21,9 +21,7 @@ import org.onlab.onos.net.Port; |
21 | import org.onlab.onos.net.PortNumber; | 21 | import org.onlab.onos.net.PortNumber; |
22 | import org.onlab.onos.net.device.DeviceListener; | 22 | import org.onlab.onos.net.device.DeviceListener; |
23 | import org.onlab.onos.net.device.DeviceService; | 23 | import org.onlab.onos.net.device.DeviceService; |
24 | -import org.onlab.onos.net.flow.DefaultFlowEntry; | ||
25 | import org.onlab.onos.net.flow.DefaultFlowRule; | 24 | import org.onlab.onos.net.flow.DefaultFlowRule; |
26 | -import org.onlab.onos.net.flow.FlowEntry; | ||
27 | import org.onlab.onos.net.flow.FlowRule; | 25 | import org.onlab.onos.net.flow.FlowRule; |
28 | import org.onlab.onos.net.flow.FlowRuleEvent; | 26 | import org.onlab.onos.net.flow.FlowRuleEvent; |
29 | import org.onlab.onos.net.flow.FlowRuleListener; | 27 | import org.onlab.onos.net.flow.FlowRuleListener; |
... | @@ -91,7 +89,7 @@ public class SimpleFlowRuleManagerTest { | ... | @@ -91,7 +89,7 @@ public class SimpleFlowRuleManagerTest { |
91 | private FlowRule flowRule(int tsval, int trval) { | 89 | private FlowRule flowRule(int tsval, int trval) { |
92 | TestSelector ts = new TestSelector(tsval); | 90 | TestSelector ts = new TestSelector(tsval); |
93 | TestTreatment tr = new TestTreatment(trval); | 91 | TestTreatment tr = new TestTreatment(trval); |
94 | - return new DefaultFlowRule(DID, ts, tr); | 92 | + return new DefaultFlowRule(DID, ts, tr, 0); |
95 | } | 93 | } |
96 | 94 | ||
97 | private void addFlowRule(int hval) { | 95 | private void addFlowRule(int hval) { |
... | @@ -142,14 +140,14 @@ public class SimpleFlowRuleManagerTest { | ... | @@ -142,14 +140,14 @@ public class SimpleFlowRuleManagerTest { |
142 | FlowRule r3 = flowRule(1, 3); | 140 | FlowRule r3 = flowRule(1, 3); |
143 | 141 | ||
144 | //current FlowRules always return 0. FlowEntries inherit the value | 142 | //current FlowRules always return 0. FlowEntries inherit the value |
145 | - FlowEntry e1 = new DefaultFlowEntry(DID, ts, r1.treatment(), 0); | 143 | + FlowRule e1 = new DefaultFlowRule(DID, ts, r1.treatment(), 0); |
146 | - FlowEntry e2 = new DefaultFlowEntry(DID, ts, r2.treatment(), 0); | 144 | + FlowRule e2 = new DefaultFlowRule(DID, ts, r2.treatment(), 0); |
147 | - FlowEntry e3 = new DefaultFlowEntry(DID, ts, r3.treatment(), 0); | 145 | + FlowRule e3 = new DefaultFlowRule(DID, ts, r3.treatment(), 0); |
148 | - List<FlowEntry> fel = Lists.newArrayList(e1, e2, e3); | 146 | + List<FlowRule> fel = Lists.newArrayList(e1, e2, e3); |
149 | 147 | ||
150 | assertTrue("store should be empty", | 148 | assertTrue("store should be empty", |
151 | Sets.newHashSet(service.getFlowEntries(DID)).isEmpty()); | 149 | Sets.newHashSet(service.getFlowEntries(DID)).isEmpty()); |
152 | - List<FlowEntry> ret = mgr.applyFlowRules(r1, r2, r3); | 150 | + List<FlowRule> ret = mgr.applyFlowRules(r1, r2, r3); |
153 | assertEquals("3 rules should exist", 3, flowCount()); | 151 | assertEquals("3 rules should exist", 3, flowCount()); |
154 | assertTrue("3 entries should result", fel.containsAll(ret)); | 152 | assertTrue("3 entries should result", fel.containsAll(ret)); |
155 | } | 153 | } |
... | @@ -256,7 +254,7 @@ public class SimpleFlowRuleManagerTest { | ... | @@ -256,7 +254,7 @@ public class SimpleFlowRuleManagerTest { |
256 | } | 254 | } |
257 | 255 | ||
258 | @Override | 256 | @Override |
259 | - public Iterable<FlowEntry> getFlowMetrics(DeviceId deviceId) { | 257 | + public Iterable<FlowRule> getFlowMetrics(DeviceId deviceId) { |
260 | return null; | 258 | return null; |
261 | } | 259 | } |
262 | 260 | ... | ... |
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
... | @@ -11,7 +11,6 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -11,7 +11,6 @@ import org.apache.felix.scr.annotations.Reference; |
11 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 11 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
12 | import org.onlab.onos.net.DeviceId; | 12 | import org.onlab.onos.net.DeviceId; |
13 | import org.onlab.onos.net.flow.DefaultFlowRule; | 13 | import org.onlab.onos.net.flow.DefaultFlowRule; |
14 | -import org.onlab.onos.net.flow.FlowEntry; | ||
15 | import org.onlab.onos.net.flow.FlowRule; | 14 | import org.onlab.onos.net.flow.FlowRule; |
16 | import org.onlab.onos.net.flow.FlowRuleProvider; | 15 | import org.onlab.onos.net.flow.FlowRuleProvider; |
17 | import org.onlab.onos.net.flow.FlowRuleProviderRegistry; | 16 | import org.onlab.onos.net.flow.FlowRuleProviderRegistry; |
... | @@ -96,7 +95,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -96,7 +95,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
96 | } | 95 | } |
97 | 96 | ||
98 | @Override | 97 | @Override |
99 | - public Iterable<FlowEntry> getFlowMetrics(DeviceId deviceId) { | 98 | + public Iterable<FlowRule> getFlowMetrics(DeviceId deviceId) { |
100 | // TODO Auto-generated method stub | 99 | // TODO Auto-generated method stub |
101 | return null; | 100 | return null; |
102 | } | 101 | } |
... | @@ -133,7 +132,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -133,7 +132,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
133 | case FLOW_REMOVED: | 132 | case FLOW_REMOVED: |
134 | //TODO: make this better | 133 | //TODO: make this better |
135 | OFFlowRemoved removed = (OFFlowRemoved) msg; | 134 | OFFlowRemoved removed = (OFFlowRemoved) msg; |
136 | - FlowRule fr = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), null, null); | 135 | + FlowRule fr = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), null, null, 0); |
137 | providerService.flowRemoved(fr); | 136 | providerService.flowRemoved(fr); |
138 | break; | 137 | break; |
139 | case STATS_REPLY: | 138 | case STATS_REPLY: | ... | ... |
-
Please register or login to post a comment