Committed by
Gerrit Code Review
adding group id to flowrules
Change-Id: Idb660d98f145b1645e9781fab79fbfb81bdce775
Showing
3 changed files
with
33 additions
and
1 deletions
| ... | @@ -40,6 +40,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -40,6 +40,7 @@ public class DefaultFlowRule implements FlowRule { |
| 40 | 40 | ||
| 41 | private final int timeout; | 41 | private final int timeout; |
| 42 | private final boolean permanent; | 42 | private final boolean permanent; |
| 43 | + private final short groupId; | ||
| 43 | 44 | ||
| 44 | 45 | ||
| 45 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | 46 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, |
| ... | @@ -54,12 +55,19 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -54,12 +55,19 @@ public class DefaultFlowRule implements FlowRule { |
| 54 | this.created = System.currentTimeMillis(); | 55 | this.created = System.currentTimeMillis(); |
| 55 | 56 | ||
| 56 | this.appId = (short) (flowId >>> 48); | 57 | this.appId = (short) (flowId >>> 48); |
| 58 | + this.groupId = (short) ((flowId >>> 32) & 0xFFFF); | ||
| 57 | this.id = FlowId.valueOf(flowId); | 59 | this.id = FlowId.valueOf(flowId); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | 62 | public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, |
| 61 | TrafficTreatment treatment, int priority, ApplicationId appId, | 63 | TrafficTreatment treatment, int priority, ApplicationId appId, |
| 62 | int timeout, boolean permanent) { | 64 | int timeout, boolean permanent) { |
| 65 | + this(deviceId, selector, treatment, priority, appId, (short) 0, timeout, permanent); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, | ||
| 69 | + TrafficTreatment treatment, int priority, ApplicationId appId, | ||
| 70 | + short groupId, int timeout, boolean permanent) { | ||
| 63 | 71 | ||
| 64 | if (priority < FlowRule.MIN_PRIORITY) { | 72 | if (priority < FlowRule.MIN_PRIORITY) { |
| 65 | throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY); | 73 | throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY); |
| ... | @@ -70,11 +78,17 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -70,11 +78,17 @@ public class DefaultFlowRule implements FlowRule { |
| 70 | this.selector = selector; | 78 | this.selector = selector; |
| 71 | this.treatment = treatment; | 79 | this.treatment = treatment; |
| 72 | this.appId = appId.id(); | 80 | this.appId = appId.id(); |
| 81 | + this.groupId = groupId; | ||
| 73 | this.timeout = timeout; | 82 | this.timeout = timeout; |
| 74 | this.permanent = permanent; | 83 | this.permanent = permanent; |
| 75 | this.created = System.currentTimeMillis(); | 84 | this.created = System.currentTimeMillis(); |
| 76 | 85 | ||
| 77 | - this.id = FlowId.valueOf((((long) this.appId) << 48) | (this.hash() & 0x0000ffffffffL)); | 86 | + /* |
| 87 | + * id consists of the following. | ||
| 88 | + * | appId (16 bits) | groupId (16 bits) | flowId (32 bits) | | ||
| 89 | + */ | ||
| 90 | + this.id = FlowId.valueOf((((long) this.appId) << 48) | (((long) this.groupId) << 32) | ||
| 91 | + | (this.hash() & 0xffffffffL)); | ||
| 78 | } | 92 | } |
| 79 | 93 | ||
| 80 | public DefaultFlowRule(FlowRule rule) { | 94 | public DefaultFlowRule(FlowRule rule) { |
| ... | @@ -83,6 +97,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -83,6 +97,7 @@ public class DefaultFlowRule implements FlowRule { |
| 83 | this.selector = rule.selector(); | 97 | this.selector = rule.selector(); |
| 84 | this.treatment = rule.treatment(); | 98 | this.treatment = rule.treatment(); |
| 85 | this.appId = rule.appId(); | 99 | this.appId = rule.appId(); |
| 100 | + this.groupId = rule.groupId(); | ||
| 86 | this.id = rule.id(); | 101 | this.id = rule.id(); |
| 87 | this.timeout = rule.timeout(); | 102 | this.timeout = rule.timeout(); |
| 88 | this.permanent = rule.isPermanent(); | 103 | this.permanent = rule.isPermanent(); |
| ... | @@ -102,6 +117,11 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -102,6 +117,11 @@ public class DefaultFlowRule implements FlowRule { |
| 102 | } | 117 | } |
| 103 | 118 | ||
| 104 | @Override | 119 | @Override |
| 120 | + public short groupId() { | ||
| 121 | + return groupId; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + @Override | ||
| 105 | public int priority() { | 125 | public int priority() { |
| 106 | return priority; | 126 | return priority; |
| 107 | } | 127 | } | ... | ... |
| ... | @@ -42,6 +42,13 @@ public interface FlowRule extends BatchOperationTarget { | ... | @@ -42,6 +42,13 @@ public interface FlowRule extends BatchOperationTarget { |
| 42 | short appId(); | 42 | short appId(); |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | + * Returns the group id of this flow. | ||
| 46 | + * | ||
| 47 | + * @return an groupId | ||
| 48 | + */ | ||
| 49 | + short groupId(); | ||
| 50 | + | ||
| 51 | + /** | ||
| 45 | * Returns the flow rule priority given in natural order; higher numbers | 52 | * Returns the flow rule priority given in natural order; higher numbers |
| 46 | * mean higher priorities. | 53 | * mean higher priorities. |
| 47 | * | 54 | * | ... | ... |
| ... | @@ -297,6 +297,11 @@ public class IntentTestsMocks { | ... | @@ -297,6 +297,11 @@ public class IntentTestsMocks { |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | @Override | 299 | @Override |
| 300 | + public short groupId() { | ||
| 301 | + return 0; | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + @Override | ||
| 300 | public int priority() { | 305 | public int priority() { |
| 301 | return priority; | 306 | return priority; |
| 302 | } | 307 | } | ... | ... |
-
Please register or login to post a comment