illegalArgument exception for priority
Change-Id: I9bce0b677b937ee691ac24c13c88a632cfb2339e
Showing
7 changed files
with
32 additions
and
16 deletions
| ... | @@ -39,6 +39,7 @@ import org.slf4j.Logger; | ... | @@ -39,6 +39,7 @@ import org.slf4j.Logger; |
| 39 | public class ReactiveForwarding { | 39 | public class ReactiveForwarding { |
| 40 | 40 | ||
| 41 | private static final int TIMEOUT = 10; | 41 | private static final int TIMEOUT = 10; |
| 42 | + private static final int PRIORITY = 10; | ||
| 42 | 43 | ||
| 43 | private final Logger log = getLogger(getClass()); | 44 | private final Logger log = getLogger(getClass()); |
| 44 | 45 | ||
| ... | @@ -194,7 +195,7 @@ public class ReactiveForwarding { | ... | @@ -194,7 +195,7 @@ public class ReactiveForwarding { |
| 194 | treat.setOutput(portNumber); | 195 | treat.setOutput(portNumber); |
| 195 | 196 | ||
| 196 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), | 197 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), |
| 197 | - builder.build(), treat.build(), 0, appId, TIMEOUT); | 198 | + builder.build(), treat.build(), PRIORITY, appId, TIMEOUT); |
| 198 | 199 | ||
| 199 | flowRuleService.applyFlowRules(f); | 200 | flowRuleService.applyFlowRules(f); |
| 200 | } | 201 | } | ... | ... |
| ... | @@ -96,7 +96,7 @@ public class FlowsListCommand extends AbstractShellCommand { | ... | @@ -96,7 +96,7 @@ public class FlowsListCommand extends AbstractShellCommand { |
| 96 | } | 96 | } |
| 97 | for (FlowRule f : flows) { | 97 | for (FlowRule f : flows) { |
| 98 | print(FMT, Long.toHexString(f.id().value()), f.state(), f.bytes(), | 98 | print(FMT, Long.toHexString(f.id().value()), f.state(), f.bytes(), |
| 99 | - f.packets(), f.lifeMillis(), f.priority()); | 99 | + f.packets(), f.life(), f.priority()); |
| 100 | print(SFMT, f.selector().criteria()); | 100 | print(SFMT, f.selector().criteria()); |
| 101 | print(TFMT, f.treatment().instructions()); | 101 | print(TFMT, f.treatment().instructions()); |
| 102 | } | 102 | } | ... | ... |
| ... | @@ -29,9 +29,23 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -29,9 +29,23 @@ public class DefaultFlowRule implements FlowRule { |
| 29 | 29 | ||
| 30 | private final int timeout; | 30 | private final int timeout; |
| 31 | 31 | ||
| 32 | + /** | ||
| 33 | + * Creates a flow rule given the following paremeters. | ||
| 34 | + * @param deviceId the device where the rule should be installed | ||
| 35 | + * @param selector the traffic selection | ||
| 36 | + * @param treatment how the seleted traffic should be handled | ||
| 37 | + * @param priority the rule priority cannot be less than FlowRule.MIN_PRIORITY | ||
| 38 | + * @param state the state in which the rule is | ||
| 39 | + * @param life how long it has existed for (ms) | ||
| 40 | + * @param packets number of packets it has seen | ||
| 41 | + * @param bytes number of bytes it has seen | ||
| 42 | + * @param flowId the identifier | ||
| 43 | + * @param timeout the rule's timeout (idle) not to exceed | ||
| 44 | + * FlowRule.MAX_TIMEOUT of idle time | ||
| 45 | + */ | ||
| 32 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | 46 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, |
| 33 | TrafficTreatment treatment, int priority, FlowRuleState state, | 47 | TrafficTreatment treatment, int priority, FlowRuleState state, |
| 34 | - long life, long packets, long bytes, long flowId, boolean expired, | 48 | + long life, long packets, long bytes, long flowId, |
| 35 | int timeout) { | 49 | int timeout) { |
| 36 | this.deviceId = deviceId; | 50 | this.deviceId = deviceId; |
| 37 | this.priority = priority; | 51 | this.priority = priority; |
| ... | @@ -50,8 +64,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -50,8 +64,7 @@ public class DefaultFlowRule implements FlowRule { |
| 50 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | 64 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, |
| 51 | TrafficTreatment treatement, int priority, ApplicationId appId, | 65 | TrafficTreatment treatement, int priority, ApplicationId appId, |
| 52 | int timeout) { | 66 | int timeout) { |
| 53 | - | 67 | + this(deviceId, selector, treatement, priority, |
| 54 | - this(deviceId, selector, treatement, priority == 0 ? 1 : priority, | ||
| 55 | FlowRuleState.CREATED, appId, timeout); | 68 | FlowRuleState.CREATED, appId, timeout); |
| 56 | } | 69 | } |
| 57 | 70 | ||
| ... | @@ -65,6 +78,9 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -65,6 +78,9 @@ public class DefaultFlowRule implements FlowRule { |
| 65 | TrafficSelector selector, TrafficTreatment treatment, | 78 | TrafficSelector selector, TrafficTreatment treatment, |
| 66 | int priority, FlowRuleState state, ApplicationId appId, | 79 | int priority, FlowRuleState state, ApplicationId appId, |
| 67 | int timeout) { | 80 | int timeout) { |
| 81 | + if (priority < MIN_PRIORITY) { | ||
| 82 | + throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY); | ||
| 83 | + } | ||
| 68 | this.deviceId = deviceId; | 84 | this.deviceId = deviceId; |
| 69 | this.priority = priority; | 85 | this.priority = priority; |
| 70 | this.selector = selector; | 86 | this.selector = selector; |
| ... | @@ -131,7 +147,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -131,7 +147,7 @@ public class DefaultFlowRule implements FlowRule { |
| 131 | } | 147 | } |
| 132 | 148 | ||
| 133 | @Override | 149 | @Override |
| 134 | - public long lifeMillis() { | 150 | + public long life() { |
| 135 | return life; | 151 | return life; |
| 136 | } | 152 | } |
| 137 | 153 | ... | ... |
| ... | @@ -10,6 +10,7 @@ import org.onlab.onos.net.DeviceId; | ... | @@ -10,6 +10,7 @@ import org.onlab.onos.net.DeviceId; |
| 10 | public interface FlowRule { | 10 | public interface FlowRule { |
| 11 | 11 | ||
| 12 | static final int MAX_TIMEOUT = 60; | 12 | static final int MAX_TIMEOUT = 60; |
| 13 | + static final int MIN_PRIORITY = 0; | ||
| 13 | 14 | ||
| 14 | public enum FlowRuleState { | 15 | public enum FlowRuleState { |
| 15 | /** | 16 | /** |
| ... | @@ -96,7 +97,7 @@ public interface FlowRule { | ... | @@ -96,7 +97,7 @@ public interface FlowRule { |
| 96 | * | 97 | * |
| 97 | * @return number of millis | 98 | * @return number of millis |
| 98 | */ | 99 | */ |
| 99 | - long lifeMillis(); | 100 | + long life(); |
| 100 | 101 | ||
| 101 | /** | 102 | /** |
| 102 | * Returns the number of packets this flow rule has matched. | 103 | * Returns the number of packets this flow rule has matched. | ... | ... |
| 1 | package org.onlab.onos.net.intent.impl; | 1 | package org.onlab.onos.net.intent.impl; |
| 2 | 2 | ||
| 3 | +import java.util.Iterator; | ||
| 4 | + | ||
| 3 | import org.apache.felix.scr.annotations.Activate; | 5 | import org.apache.felix.scr.annotations.Activate; |
| 4 | import org.apache.felix.scr.annotations.Component; | 6 | import org.apache.felix.scr.annotations.Component; |
| 5 | import org.apache.felix.scr.annotations.Deactivate; | 7 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -19,8 +21,6 @@ import org.onlab.onos.net.intent.IntentExtensionService; | ... | @@ -19,8 +21,6 @@ import org.onlab.onos.net.intent.IntentExtensionService; |
| 19 | import org.onlab.onos.net.intent.IntentInstaller; | 21 | import org.onlab.onos.net.intent.IntentInstaller; |
| 20 | import org.onlab.onos.net.intent.PathIntent; | 22 | import org.onlab.onos.net.intent.PathIntent; |
| 21 | 23 | ||
| 22 | -import java.util.Iterator; | ||
| 23 | - | ||
| 24 | /** | 24 | /** |
| 25 | * Installer for {@link PathIntent path connectivity intents}. | 25 | * Installer for {@link PathIntent path connectivity intents}. |
| 26 | */ | 26 | */ |
| ... | @@ -60,7 +60,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { | ... | @@ -60,7 +60,7 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { |
| 60 | 60 | ||
| 61 | FlowRule rule = new DefaultFlowRule(link.src().deviceId(), | 61 | FlowRule rule = new DefaultFlowRule(link.src().deviceId(), |
| 62 | builder.build(), treat.build(), | 62 | builder.build(), treat.build(), |
| 63 | - 0, appId, 30); | 63 | + 10, appId, 30); |
| 64 | flowRuleService.applyFlowRules(rule); | 64 | flowRuleService.applyFlowRules(rule); |
| 65 | 65 | ||
| 66 | prev = link.dst(); | 66 | prev = link.dst(); | ... | ... |
| ... | @@ -100,7 +100,7 @@ public class FlowRuleManagerTest { | ... | @@ -100,7 +100,7 @@ public class FlowRuleManagerTest { |
| 100 | private FlowRule flowRule(int tsval, int trval) { | 100 | private FlowRule flowRule(int tsval, int trval) { |
| 101 | TestSelector ts = new TestSelector(tsval); | 101 | TestSelector ts = new TestSelector(tsval); |
| 102 | TestTreatment tr = new TestTreatment(trval); | 102 | TestTreatment tr = new TestTreatment(trval); |
| 103 | - return new DefaultFlowRule(DID, ts, tr, 0, appId, TIMEOUT); | 103 | + return new DefaultFlowRule(DID, ts, tr, 10, appId, TIMEOUT); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | private FlowRule flowRule(FlowRule rule, FlowRuleState state) { | 106 | private FlowRule flowRule(FlowRule rule, FlowRuleState state) { | ... | ... |
| ... | @@ -18,7 +18,6 @@ import org.onlab.packet.IpPrefix; | ... | @@ -18,7 +18,6 @@ import org.onlab.packet.IpPrefix; |
| 18 | import org.onlab.packet.MacAddress; | 18 | import org.onlab.packet.MacAddress; |
| 19 | import org.onlab.packet.VlanId; | 19 | import org.onlab.packet.VlanId; |
| 20 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; | 20 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
| 21 | -import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason; | ||
| 22 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | 21 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 23 | import org.projectfloodlight.openflow.protocol.OFInstructionType; | 22 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
| 24 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 23 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| ... | @@ -76,17 +75,16 @@ public class FlowRuleBuilder { | ... | @@ -76,17 +75,16 @@ public class FlowRuleBuilder { |
| 76 | if (addedRule) { | 75 | if (addedRule) { |
| 77 | return new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), | 76 | return new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), |
| 78 | buildSelector(), buildTreatment(), stat.getPriority(), | 77 | buildSelector(), buildTreatment(), stat.getPriority(), |
| 79 | - FlowRuleState.ADDED, stat.getDurationNsec() / 1000000, | 78 | + FlowRuleState.ADDED, stat.getDurationSec(), |
| 80 | stat.getPacketCount().getValue(), stat.getByteCount().getValue(), | 79 | stat.getPacketCount().getValue(), stat.getByteCount().getValue(), |
| 81 | - stat.getCookie().getValue(), false, stat.getIdleTimeout()); | 80 | + stat.getCookie().getValue(), stat.getIdleTimeout()); |
| 82 | } else { | 81 | } else { |
| 83 | // TODO: revisit potentially. | 82 | // TODO: revisit potentially. |
| 84 | return new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), | 83 | return new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), |
| 85 | buildSelector(), null, removed.getPriority(), | 84 | buildSelector(), null, removed.getPriority(), |
| 86 | - FlowRuleState.REMOVED, removed.getDurationNsec() / 1000000, | 85 | + FlowRuleState.REMOVED, stat.getDurationSec(), |
| 87 | removed.getPacketCount().getValue(), removed.getByteCount().getValue(), | 86 | removed.getPacketCount().getValue(), removed.getByteCount().getValue(), |
| 88 | removed.getCookie().getValue(), | 87 | removed.getCookie().getValue(), |
| 89 | - removed.getReason() == OFFlowRemovedReason.IDLE_TIMEOUT.ordinal(), | ||
| 90 | stat.getIdleTimeout()); | 88 | stat.getIdleTimeout()); |
| 91 | } | 89 | } |
| 92 | } | 90 | } | ... | ... |
-
Please register or login to post a comment