Ray Milkey
Committed by Gerrit Code Review

Remove deprecated Flow Rule constructors

Change-Id: I2a078cbfbeb9db4a04ef1c59acde2fb45672a3cf
...@@ -127,11 +127,17 @@ public class LambdaForwarding { ...@@ -127,11 +127,17 @@ public class LambdaForwarding {
127 default: 127 default:
128 } 128 }
129 129
130 - TrafficTreatment treatement = tbuilder.build(); 130 + TrafficTreatment treatment = tbuilder.build();
131 TrafficSelector selector = sbuilder.build(); 131 TrafficSelector selector = sbuilder.build();
132 132
133 - FlowRule f = new DefaultFlowRule(device.id(), selector, 133 + FlowRule f = DefaultFlowRule.builder()
134 - treatement, 100, appId, 600, false); 134 + .forDevice(device.id())
135 + .withSelector(selector)
136 + .withTreatment(treatment)
137 + .withPriority(100)
138 + .fromApp(appId)
139 + .makeTemporary(600)
140 + .build();
135 141
136 flowRuleService.applyFlowRules(f); 142 flowRuleService.applyFlowRules(f);
137 143
......
...@@ -130,8 +130,14 @@ public class MPLSForwarding { ...@@ -130,8 +130,14 @@ public class MPLSForwarding {
130 TrafficTreatment treatement = tbuilder.build(); 130 TrafficTreatment treatement = tbuilder.build();
131 TrafficSelector selector = sbuilder.build(); 131 TrafficSelector selector = sbuilder.build();
132 132
133 - FlowRule f = new DefaultFlowRule(device.id(), selector, 133 + FlowRule f = DefaultFlowRule.builder()
134 - treatement, 100, appId, 600, false); 134 + .forDevice(device.id())
135 + .withSelector(selector)
136 + .withTreatment(treatement)
137 + .withPriority(100)
138 + .fromApp(appId)
139 + .makeTemporary(600)
140 + .build();
135 141
136 flowRuleService.applyFlowRules(f); 142 flowRuleService.applyFlowRules(f);
137 } 143 }
......
...@@ -15,15 +15,25 @@ ...@@ -15,15 +15,25 @@
15 */ 15 */
16 package org.onosproject.demo; 16 package org.onosproject.demo;
17 17
18 -import com.fasterxml.jackson.databind.JsonNode; 18 +import java.util.Collection;
19 -import com.fasterxml.jackson.databind.ObjectMapper; 19 +import java.util.Collections;
20 -import com.fasterxml.jackson.databind.node.ObjectNode; 20 +import java.util.HashSet;
21 -import com.google.common.base.Predicate; 21 +import java.util.Iterator;
22 -import com.google.common.base.Stopwatch; 22 +import java.util.LinkedList;
23 -import com.google.common.collect.FluentIterable; 23 +import java.util.List;
24 -import com.google.common.collect.Lists; 24 +import java.util.Objects;
25 -import com.google.common.collect.Sets; 25 +import java.util.Optional;
26 -import com.google.common.util.concurrent.ThreadFactoryBuilder; 26 +import java.util.Random;
27 +import java.util.Set;
28 +import java.util.concurrent.Callable;
29 +import java.util.concurrent.CountDownLatch;
30 +import java.util.concurrent.ExecutionException;
31 +import java.util.concurrent.ExecutorService;
32 +import java.util.concurrent.Executors;
33 +import java.util.concurrent.Future;
34 +import java.util.concurrent.TimeUnit;
35 +import java.util.concurrent.TimeoutException;
36 +
27 import org.apache.commons.lang.math.RandomUtils; 37 import org.apache.commons.lang.math.RandomUtils;
28 import org.apache.felix.scr.annotations.Activate; 38 import org.apache.felix.scr.annotations.Activate;
29 import org.apache.felix.scr.annotations.Component; 39 import org.apache.felix.scr.annotations.Component;
...@@ -47,6 +57,7 @@ import org.onosproject.net.device.DeviceService; ...@@ -47,6 +57,7 @@ import org.onosproject.net.device.DeviceService;
47 import org.onosproject.net.flow.DefaultFlowRule; 57 import org.onosproject.net.flow.DefaultFlowRule;
48 import org.onosproject.net.flow.DefaultTrafficSelector; 58 import org.onosproject.net.flow.DefaultTrafficSelector;
49 import org.onosproject.net.flow.DefaultTrafficTreatment; 59 import org.onosproject.net.flow.DefaultTrafficTreatment;
60 +import org.onosproject.net.flow.FlowRule;
50 import org.onosproject.net.flow.FlowRuleOperations; 61 import org.onosproject.net.flow.FlowRuleOperations;
51 import org.onosproject.net.flow.FlowRuleOperationsContext; 62 import org.onosproject.net.flow.FlowRuleOperationsContext;
52 import org.onosproject.net.flow.FlowRuleService; 63 import org.onosproject.net.flow.FlowRuleService;
...@@ -59,24 +70,15 @@ import org.onosproject.net.intent.Intent; ...@@ -59,24 +70,15 @@ import org.onosproject.net.intent.Intent;
59 import org.onosproject.net.intent.IntentService; 70 import org.onosproject.net.intent.IntentService;
60 import org.slf4j.Logger; 71 import org.slf4j.Logger;
61 72
62 -import java.util.Collection; 73 +import com.fasterxml.jackson.databind.JsonNode;
63 -import java.util.Collections; 74 +import com.fasterxml.jackson.databind.ObjectMapper;
64 -import java.util.HashSet; 75 +import com.fasterxml.jackson.databind.node.ObjectNode;
65 -import java.util.Iterator; 76 +import com.google.common.base.Predicate;
66 -import java.util.LinkedList; 77 +import com.google.common.base.Stopwatch;
67 -import java.util.List; 78 +import com.google.common.collect.FluentIterable;
68 -import java.util.Objects; 79 +import com.google.common.collect.Lists;
69 -import java.util.Optional; 80 +import com.google.common.collect.Sets;
70 -import java.util.Random; 81 +import com.google.common.util.concurrent.ThreadFactoryBuilder;
71 -import java.util.Set;
72 -import java.util.concurrent.Callable;
73 -import java.util.concurrent.CountDownLatch;
74 -import java.util.concurrent.ExecutionException;
75 -import java.util.concurrent.ExecutorService;
76 -import java.util.concurrent.Executors;
77 -import java.util.concurrent.Future;
78 -import java.util.concurrent.TimeUnit;
79 -import java.util.concurrent.TimeoutException;
80 82
81 import static org.slf4j.LoggerFactory.getLogger; 83 import static org.slf4j.LoggerFactory.getLogger;
82 84
...@@ -557,8 +559,14 @@ public class DemoInstaller implements DemoAPI { ...@@ -557,8 +559,14 @@ public class DemoInstaller implements DemoAPI {
557 559
558 560
559 int randomPriority = RandomUtils.nextInt(); 561 int randomPriority = RandomUtils.nextInt();
560 - DefaultFlowRule f = new DefaultFlowRule(d.id(), sbuilder.build(), treatment, 562 + FlowRule f = DefaultFlowRule.builder()
561 - randomPriority, appId, 10, false); 563 + .forDevice(d.id())
564 + .withSelector(sbuilder.build())
565 + .withTreatment(treatment)
566 + .withPriority(randomPriority)
567 + .fromApp(appId)
568 + .makeTemporary(10)
569 + .build();
562 rules.add(f); 570 rules.add(f);
563 remove.remove(f); 571 remove.remove(f);
564 572
......
...@@ -34,6 +34,7 @@ import org.onosproject.net.device.DeviceService; ...@@ -34,6 +34,7 @@ import org.onosproject.net.device.DeviceService;
34 import org.onosproject.net.flow.DefaultFlowRule; 34 import org.onosproject.net.flow.DefaultFlowRule;
35 import org.onosproject.net.flow.DefaultTrafficSelector; 35 import org.onosproject.net.flow.DefaultTrafficSelector;
36 import org.onosproject.net.flow.DefaultTrafficTreatment; 36 import org.onosproject.net.flow.DefaultTrafficTreatment;
37 +import org.onosproject.net.flow.FlowRule;
37 import org.onosproject.net.flow.FlowRuleOperations; 38 import org.onosproject.net.flow.FlowRuleOperations;
38 import org.onosproject.net.flow.FlowRuleOperationsContext; 39 import org.onosproject.net.flow.FlowRuleOperationsContext;
39 import org.onosproject.net.flow.FlowRuleService; 40 import org.onosproject.net.flow.FlowRuleService;
...@@ -89,10 +90,26 @@ public class AddFlowsCommand extends AbstractShellCommand { ...@@ -89,10 +90,26 @@ public class AddFlowsCommand extends AbstractShellCommand {
89 90
90 91
91 int randomPriority = RandomUtils.nextInt(); 92 int randomPriority = RandomUtils.nextInt();
92 - rules.add(new DefaultFlowRule(d.id(), sbuilder.build(), treatment, 93 +
93 - randomPriority, appId, 10, false)); 94 + FlowRule addRule = DefaultFlowRule.builder()
94 - remove.remove(new DefaultFlowRule(d.id(), sbuilder.build(), treatment, 95 + .forDevice(d.id())
95 - randomPriority, appId, 10, false)); 96 + .withSelector(sbuilder.build())
97 + .withTreatment(treatment)
98 + .withPriority(randomPriority)
99 + .fromApp(appId)
100 + .makeTemporary(10)
101 + .build();
102 + FlowRule removeRule = DefaultFlowRule.builder()
103 + .forDevice(d.id())
104 + .withSelector(sbuilder.build())
105 + .withTreatment(treatment)
106 + .withPriority(randomPriority)
107 + .fromApp(appId)
108 + .makeTemporary(10)
109 + .build();
110 +
111 + rules.add(addRule);
112 + remove.remove(removeRule);
96 113
97 } 114 }
98 } 115 }
......
...@@ -18,7 +18,6 @@ package org.onosproject.net.flow; ...@@ -18,7 +18,6 @@ package org.onosproject.net.flow;
18 import static com.google.common.base.MoreObjects.toStringHelper; 18 import static com.google.common.base.MoreObjects.toStringHelper;
19 import static org.slf4j.LoggerFactory.getLogger; 19 import static org.slf4j.LoggerFactory.getLogger;
20 20
21 -import org.onosproject.net.DeviceId;
22 import org.slf4j.Logger; 21 import org.slf4j.Logger;
23 22
24 public class DefaultFlowEntry extends DefaultFlowRule 23 public class DefaultFlowEntry extends DefaultFlowRule
...@@ -37,21 +36,6 @@ public class DefaultFlowEntry extends DefaultFlowRule ...@@ -37,21 +36,6 @@ public class DefaultFlowEntry extends DefaultFlowRule
37 36
38 private final int errCode; 37 private final int errCode;
39 38
40 -
41 - public DefaultFlowEntry(DeviceId deviceId, TrafficSelector selector,
42 - TrafficTreatment treatment, int priority, FlowEntryState state,
43 - long life, long packets, long bytes, long flowId,
44 - int timeout) {
45 - super(deviceId, selector, treatment, priority, flowId, timeout, false);
46 - this.state = state;
47 - this.life = life;
48 - this.packets = packets;
49 - this.bytes = bytes;
50 - this.errCode = -1;
51 - this.errType = -1;
52 - this.lastSeen = System.currentTimeMillis();
53 - }
54 -
55 public DefaultFlowEntry(FlowRule rule, FlowEntryState state, 39 public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
56 long life, long packets, long bytes) { 40 long life, long packets, long bytes) {
57 super(rule); 41 super(rule);
......
...@@ -45,119 +45,6 @@ public class DefaultFlowRule implements FlowRule { ...@@ -45,119 +45,6 @@ public class DefaultFlowRule implements FlowRule {
45 private final Integer tableId; 45 private final Integer tableId;
46 private final FlowRuleExtPayLoad payLoad; 46 private final FlowRuleExtPayLoad payLoad;
47 47
48 - @Deprecated
49 - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
50 - TrafficTreatment treatment, int priority,
51 - long flowId, int timeout, boolean permanent) {
52 - this.deviceId = deviceId;
53 - this.priority = priority;
54 - this.selector = selector;
55 - this.treatment = treatment;
56 - this.timeout = timeout;
57 - this.permanent = permanent;
58 - this.created = System.currentTimeMillis();
59 -
60 - this.appId = (short) (flowId >>> 48);
61 - this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
62 - this.id = FlowId.valueOf(flowId);
63 - this.tableId = 0;
64 - this.payLoad = null;
65 - }
66 -
67 - @Deprecated
68 - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
69 - TrafficTreatment treatment, int priority,
70 - long flowId, int timeout, boolean permanent,
71 - Type tableType) {
72 - this.deviceId = deviceId;
73 - this.priority = priority;
74 - this.selector = selector;
75 - this.treatment = treatment;
76 - this.timeout = timeout;
77 - this.permanent = permanent;
78 - this.created = System.currentTimeMillis();
79 -
80 - this.appId = (short) (flowId >>> 48);
81 - this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
82 - this.id = FlowId.valueOf(flowId);
83 - this.tableId = tableType.ordinal();
84 -
85 - this.payLoad = null;
86 - }
87 -
88 - @Deprecated
89 - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
90 - TrafficTreatment treatment, int priority,
91 - ApplicationId appId, int timeout, boolean permanent) {
92 - this(deviceId, selector, treatment, priority, appId,
93 - new DefaultGroupId(0), timeout, permanent);
94 - }
95 -
96 - @Deprecated
97 - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
98 - TrafficTreatment treatment, int priority,
99 - ApplicationId appId, int timeout, boolean permanent,
100 - Type type) {
101 -
102 - if (priority < FlowRule.MIN_PRIORITY) {
103 - throw new IllegalArgumentException("Priority cannot be less than "
104 - + MIN_PRIORITY);
105 - }
106 -
107 - this.deviceId = deviceId;
108 - this.priority = priority;
109 - this.selector = selector;
110 - this.treatment = treatment;
111 - this.appId = appId.id();
112 - this.groupId = new DefaultGroupId(0);
113 - this.timeout = timeout;
114 - this.permanent = permanent;
115 - this.created = System.currentTimeMillis();
116 - this.tableId = type.ordinal();
117 -
118 - this.payLoad = null;
119 - /*
120 - * id consists of the following. | appId (16 bits) | groupId (16 bits) |
121 - * flowId (32 bits) |
122 - */
123 - this.id = FlowId.valueOf((((long) this.appId) << 48)
124 - | (((long) this.groupId.id()) << 32)
125 - | (this.hash() & 0xffffffffL));
126 -
127 - }
128 -
129 - @Deprecated
130 - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
131 - TrafficTreatment treatment, int priority,
132 - ApplicationId appId, GroupId groupId, int timeout,
133 - boolean permanent) {
134 -
135 - if (priority < FlowRule.MIN_PRIORITY) {
136 - throw new IllegalArgumentException("Priority cannot be less than "
137 - + MIN_PRIORITY);
138 - }
139 -
140 - this.deviceId = deviceId;
141 - this.priority = priority;
142 - this.selector = selector;
143 - this.treatment = treatment;
144 - this.appId = appId.id();
145 - this.groupId = groupId;
146 - this.timeout = timeout;
147 - this.permanent = permanent;
148 - this.created = System.currentTimeMillis();
149 - this.tableId = 0;
150 - this.payLoad = null;
151 -
152 - /*
153 - * id consists of the following. | appId (16 bits) | groupId (16 bits) |
154 - * flowId (32 bits) |
155 - */
156 - this.id = FlowId.valueOf((((long) this.appId) << 48)
157 - | (((long) this.groupId.id()) << 32)
158 - | (this.hash() & 0xffffffffL));
159 - }
160 -
161 public DefaultFlowRule(FlowRule rule) { 48 public DefaultFlowRule(FlowRule rule) {
162 this.deviceId = rule.deviceId(); 49 this.deviceId = rule.deviceId();
163 this.priority = rule.priority(); 50 this.priority = rule.priority();
...@@ -371,7 +258,7 @@ public class DefaultFlowRule implements FlowRule { ...@@ -371,7 +258,7 @@ public class DefaultFlowRule implements FlowRule {
371 .add("treatment", treatment == null ? "N/A" : treatment.allInstructions()) 258 .add("treatment", treatment == null ? "N/A" : treatment.allInstructions())
372 .add("tableId", tableId) 259 .add("tableId", tableId)
373 .add("created", created) 260 .add("created", created)
374 - .add("payLoad", payLoad).toString() 261 + .add("payLoad", payLoad)
375 .toString(); 262 .toString();
376 } 263 }
377 264
......
...@@ -37,16 +37,17 @@ public class DefaultFlowEntryTest { ...@@ -37,16 +37,17 @@ public class DefaultFlowEntryTest {
37 new IntentTestsMocks.MockTreatment(); 37 new IntentTestsMocks.MockTreatment();
38 38
39 private static DefaultFlowEntry makeFlowEntry(int uniqueValue) { 39 private static DefaultFlowEntry makeFlowEntry(int uniqueValue) {
40 - return new DefaultFlowEntry(did("id" + Integer.toString(uniqueValue)), 40 + FlowRule rule = DefaultFlowRule.builder()
41 - SELECTOR, 41 + .forDevice(did("id" + Integer.toString(uniqueValue)))
42 - TREATMENT, 42 + .withSelector(SELECTOR)
43 - uniqueValue, 43 + .withTreatment(TREATMENT)
44 - FlowEntry.FlowEntryState.ADDED, 44 + .withPriority(uniqueValue)
45 - uniqueValue, 45 + .withCookie(uniqueValue)
46 - uniqueValue, 46 + .makeTemporary(uniqueValue)
47 - uniqueValue, 47 + .build();
48 - uniqueValue, 48 +
49 - uniqueValue); 49 + return new DefaultFlowEntry(rule, FlowEntry.FlowEntryState.ADDED,
50 + uniqueValue, uniqueValue, uniqueValue);
50 } 51 }
51 52
52 final DefaultFlowEntry defaultFlowEntry1 = makeFlowEntry(1); 53 final DefaultFlowEntry defaultFlowEntry1 = makeFlowEntry(1);
......
...@@ -41,10 +41,8 @@ public class DefaultFlowRuleTest { ...@@ -41,10 +41,8 @@ public class DefaultFlowRuleTest {
41 private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b); 41 private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
42 final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad); 42 final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
43 final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad); 43 final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
44 - final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2, payLoad);
45 final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1); 44 final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1);
46 final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1); 45 final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1);
47 - final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2);
48 46
49 /** 47 /**
50 * Checks that the DefaultFlowRule class is immutable but can be inherited 48 * Checks that the DefaultFlowRule class is immutable but can be inherited
...@@ -84,14 +82,20 @@ public class DefaultFlowRuleTest { ...@@ -84,14 +82,20 @@ public class DefaultFlowRuleTest {
84 /** 82 /**
85 * Tests creation of a DefaultFlowRule using a FlowId constructor. 83 * Tests creation of a DefaultFlowRule using a FlowId constructor.
86 */ 84 */
85 +
87 @Test 86 @Test
88 public void testCreationWithFlowId() { 87 public void testCreationWithFlowId() {
89 - final DefaultFlowRule rule = 88 + final FlowRule rule =
90 - new DefaultFlowRule(did("1"), SELECTOR, 89 + DefaultFlowRule.builder()
91 - TREATMENT, 22, 33, 90 + .forDevice(did("1"))
92 - 44, false); 91 + .withSelector(SELECTOR)
92 + .withTreatment(TREATMENT)
93 + .withPriority(22)
94 + .makeTemporary(44)
95 + .fromApp(APP_ID)
96 + .build();
97 +
93 assertThat(rule.deviceId(), is(did("1"))); 98 assertThat(rule.deviceId(), is(did("1")));
94 - assertThat(rule.id().value(), is(33L));
95 assertThat(rule.isPermanent(), is(false)); 99 assertThat(rule.isPermanent(), is(false));
96 assertThat(rule.priority(), is(22)); 100 assertThat(rule.priority(), is(22));
97 assertThat(rule.selector(), is(SELECTOR)); 101 assertThat(rule.selector(), is(SELECTOR));
...@@ -99,6 +103,7 @@ public class DefaultFlowRuleTest { ...@@ -99,6 +103,7 @@ public class DefaultFlowRuleTest {
99 assertThat(rule.timeout(), is(44)); 103 assertThat(rule.timeout(), is(44));
100 } 104 }
101 105
106 +
102 /** 107 /**
103 * Tests creation of a DefaultFlowRule using a PayLoad constructor. 108 * Tests creation of a DefaultFlowRule using a PayLoad constructor.
104 */ 109 */
...@@ -136,10 +141,16 @@ public class DefaultFlowRuleTest { ...@@ -136,10 +141,16 @@ public class DefaultFlowRuleTest {
136 */ 141 */
137 @Test 142 @Test
138 public void testCreationWithAppId() { 143 public void testCreationWithAppId() {
139 - final DefaultFlowRule rule = 144 + final FlowRule rule =
140 - new DefaultFlowRule(did("1"), SELECTOR, 145 + DefaultFlowRule.builder()
141 - TREATMENT, 22, APP_ID, 146 + .forDevice(did("1"))
142 - 44, false); 147 + .withSelector(SELECTOR)
148 + .withTreatment(TREATMENT)
149 + .withPriority(22)
150 + .fromApp(APP_ID)
151 + .makeTemporary(44)
152 + .build();
153 +
143 assertThat(rule.deviceId(), is(did("1"))); 154 assertThat(rule.deviceId(), is(did("1")));
144 assertThat(rule.isPermanent(), is(false)); 155 assertThat(rule.isPermanent(), is(false));
145 assertThat(rule.priority(), is(22)); 156 assertThat(rule.priority(), is(22));
......
...@@ -135,7 +135,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti ...@@ -135,7 +135,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler<LinkCollecti
135 } 135 }
136 136
137 DefaultFlowRule rule = new DefaultFlowRule(deviceId, selector, treatment, 123, appId, 137 DefaultFlowRule rule = new DefaultFlowRule(deviceId, selector, treatment, 123, appId,
138 - new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 0, true); 138 + new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 0, true, null);
139 139
140 rules.add(rule); 140 rules.add(rule);
141 } 141 }
......
...@@ -256,6 +256,13 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { ...@@ -256,6 +256,13 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> {
256 256
257 protected FlowRule createFlowRule(MplsPathIntent intent, DeviceId deviceId, 257 protected FlowRule createFlowRule(MplsPathIntent intent, DeviceId deviceId,
258 TrafficSelector selector, TrafficTreatment treat) { 258 TrafficSelector selector, TrafficTreatment treat) {
259 - return new DefaultFlowRule(deviceId, selector, treat, intent.priority(), appId, 0, true); 259 + return DefaultFlowRule.builder()
260 + .forDevice(deviceId)
261 + .withSelector(selector)
262 + .withTreatment(treat)
263 + .withPriority(intent.priority())
264 + .fromApp(appId)
265 + .makePermanent()
266 + .build();
260 } 267 }
261 } 268 }
......
...@@ -97,7 +97,14 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { ...@@ -97,7 +97,14 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> {
97 } 97 }
98 TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build(); 98 TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build();
99 99
100 - return new DefaultFlowRule(ingress.deviceId(), selector, treatment, 123, appId, 0, true); 100 + return DefaultFlowRule.builder()
101 + .forDevice(ingress.deviceId())
102 + .withSelector(selector)
103 + .withTreatment(treatment)
104 + .withPriority(123)
105 + .fromApp(appId)
106 + .makePermanent()
107 + .build();
101 } 108 }
102 109
103 private boolean isLast(List<Link> links, int i) { 110 private boolean isLast(List<Link> links, int i) {
......
...@@ -144,7 +144,14 @@ public class FlowRuleManagerTest { ...@@ -144,7 +144,14 @@ public class FlowRuleManagerTest {
144 private FlowRule flowRule(int tsval, int trval) { 144 private FlowRule flowRule(int tsval, int trval) {
145 TestSelector ts = new TestSelector(tsval); 145 TestSelector ts = new TestSelector(tsval);
146 TestTreatment tr = new TestTreatment(trval); 146 TestTreatment tr = new TestTreatment(trval);
147 - return new DefaultFlowRule(DID, ts, tr, 10, appId, TIMEOUT, false); 147 + return DefaultFlowRule.builder()
148 + .forDevice(DID)
149 + .withSelector(ts)
150 + .withTreatment(tr)
151 + .withPriority(10)
152 + .fromApp(appId)
153 + .makeTemporary(TIMEOUT)
154 + .build();
148 } 155 }
149 156
150 157
......
...@@ -28,6 +28,7 @@ import org.onlab.util.Bandwidth; ...@@ -28,6 +28,7 @@ import org.onlab.util.Bandwidth;
28 import org.onlab.util.Frequency; 28 import org.onlab.util.Frequency;
29 import org.onosproject.cluster.NodeId; 29 import org.onosproject.cluster.NodeId;
30 import org.onosproject.cluster.RoleInfo; 30 import org.onosproject.cluster.RoleInfo;
31 +import org.onosproject.core.DefaultApplicationId;
31 import org.onosproject.core.DefaultGroupId; 32 import org.onosproject.core.DefaultGroupId;
32 import org.onosproject.mastership.MastershipTerm; 33 import org.onosproject.mastership.MastershipTerm;
33 import org.onosproject.net.Annotations; 34 import org.onosproject.net.Annotations;
...@@ -236,8 +237,15 @@ public class KryoSerializerTest { ...@@ -236,8 +237,15 @@ public class KryoSerializerTest {
236 @Test 237 @Test
237 public void testFlowRuleBatchEntry() { 238 public void testFlowRuleBatchEntry() {
238 final FlowRule rule1 = 239 final FlowRule rule1 =
239 - new DefaultFlowRule(DID1, DefaultTrafficSelector.emptySelector(), 240 + DefaultFlowRule.builder()
240 - DefaultTrafficTreatment.emptyTreatment(), 0, 0, 0, true); 241 + .forDevice(DID1)
242 + .withSelector(DefaultTrafficSelector.emptySelector())
243 + .withTreatment(DefaultTrafficTreatment.emptyTreatment())
244 + .withPriority(0)
245 + .fromApp(new DefaultApplicationId(1, "1"))
246 + .makeTemporary(1)
247 + .build();
248 +
241 final FlowRuleBatchEntry entry1 = 249 final FlowRuleBatchEntry entry1 =
242 new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule1); 250 new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule1);
243 final FlowRuleBatchEntry entry2 = 251 final FlowRuleBatchEntry entry2 =
......