Remove deprecated Flow Rule constructors
Change-Id: I2a078cbfbeb9db4a04ef1c59acde2fb45672a3cf
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
index 8eaaa32..f7e7708 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
@@ -18,7 +18,6 @@
import static com.google.common.base.MoreObjects.toStringHelper;
import static org.slf4j.LoggerFactory.getLogger;
-import org.onosproject.net.DeviceId;
import org.slf4j.Logger;
public class DefaultFlowEntry extends DefaultFlowRule
@@ -37,21 +36,6 @@
private final int errCode;
-
- public DefaultFlowEntry(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority, FlowEntryState state,
- long life, long packets, long bytes, long flowId,
- int timeout) {
- super(deviceId, selector, treatment, priority, flowId, timeout, false);
- this.state = state;
- this.life = life;
- this.packets = packets;
- this.bytes = bytes;
- this.errCode = -1;
- this.errType = -1;
- this.lastSeen = System.currentTimeMillis();
- }
-
public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
long life, long packets, long bytes) {
super(rule);
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index 5a68887..293f12f 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -45,119 +45,6 @@
private final Integer tableId;
private final FlowRuleExtPayLoad payLoad;
- @Deprecated
- public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- long flowId, int timeout, boolean permanent) {
- this.deviceId = deviceId;
- this.priority = priority;
- this.selector = selector;
- this.treatment = treatment;
- this.timeout = timeout;
- this.permanent = permanent;
- this.created = System.currentTimeMillis();
-
- this.appId = (short) (flowId >>> 48);
- this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
- this.id = FlowId.valueOf(flowId);
- this.tableId = 0;
- this.payLoad = null;
- }
-
- @Deprecated
- public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- long flowId, int timeout, boolean permanent,
- Type tableType) {
- this.deviceId = deviceId;
- this.priority = priority;
- this.selector = selector;
- this.treatment = treatment;
- this.timeout = timeout;
- this.permanent = permanent;
- this.created = System.currentTimeMillis();
-
- this.appId = (short) (flowId >>> 48);
- this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
- this.id = FlowId.valueOf(flowId);
- this.tableId = tableType.ordinal();
-
- this.payLoad = null;
- }
-
- @Deprecated
- public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- ApplicationId appId, int timeout, boolean permanent) {
- this(deviceId, selector, treatment, priority, appId,
- new DefaultGroupId(0), timeout, permanent);
- }
-
- @Deprecated
- public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- ApplicationId appId, int timeout, boolean permanent,
- Type type) {
-
- if (priority < FlowRule.MIN_PRIORITY) {
- throw new IllegalArgumentException("Priority cannot be less than "
- + MIN_PRIORITY);
- }
-
- this.deviceId = deviceId;
- this.priority = priority;
- this.selector = selector;
- this.treatment = treatment;
- this.appId = appId.id();
- this.groupId = new DefaultGroupId(0);
- this.timeout = timeout;
- this.permanent = permanent;
- this.created = System.currentTimeMillis();
- this.tableId = type.ordinal();
-
- this.payLoad = null;
- /*
- * id consists of the following. | appId (16 bits) | groupId (16 bits) |
- * flowId (32 bits) |
- */
- this.id = FlowId.valueOf((((long) this.appId) << 48)
- | (((long) this.groupId.id()) << 32)
- | (this.hash() & 0xffffffffL));
-
- }
-
- @Deprecated
- public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- ApplicationId appId, GroupId groupId, int timeout,
- boolean permanent) {
-
- if (priority < FlowRule.MIN_PRIORITY) {
- throw new IllegalArgumentException("Priority cannot be less than "
- + MIN_PRIORITY);
- }
-
- this.deviceId = deviceId;
- this.priority = priority;
- this.selector = selector;
- this.treatment = treatment;
- this.appId = appId.id();
- this.groupId = groupId;
- this.timeout = timeout;
- this.permanent = permanent;
- this.created = System.currentTimeMillis();
- this.tableId = 0;
- this.payLoad = null;
-
- /*
- * id consists of the following. | appId (16 bits) | groupId (16 bits) |
- * flowId (32 bits) |
- */
- this.id = FlowId.valueOf((((long) this.appId) << 48)
- | (((long) this.groupId.id()) << 32)
- | (this.hash() & 0xffffffffL));
- }
-
public DefaultFlowRule(FlowRule rule) {
this.deviceId = rule.deviceId();
this.priority = rule.priority();
@@ -371,7 +258,7 @@
.add("treatment", treatment == null ? "N/A" : treatment.allInstructions())
.add("tableId", tableId)
.add("created", created)
- .add("payLoad", payLoad).toString()
+ .add("payLoad", payLoad)
.toString();
}
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java
index f8dc27a..412acb6 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowEntryTest.java
@@ -37,16 +37,17 @@
new IntentTestsMocks.MockTreatment();
private static DefaultFlowEntry makeFlowEntry(int uniqueValue) {
- return new DefaultFlowEntry(did("id" + Integer.toString(uniqueValue)),
- SELECTOR,
- TREATMENT,
- uniqueValue,
- FlowEntry.FlowEntryState.ADDED,
- uniqueValue,
- uniqueValue,
- uniqueValue,
- uniqueValue,
- uniqueValue);
+ FlowRule rule = DefaultFlowRule.builder()
+ .forDevice(did("id" + Integer.toString(uniqueValue)))
+ .withSelector(SELECTOR)
+ .withTreatment(TREATMENT)
+ .withPriority(uniqueValue)
+ .withCookie(uniqueValue)
+ .makeTemporary(uniqueValue)
+ .build();
+
+ return new DefaultFlowEntry(rule, FlowEntry.FlowEntryState.ADDED,
+ uniqueValue, uniqueValue, uniqueValue);
}
final DefaultFlowEntry defaultFlowEntry1 = makeFlowEntry(1);
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
index 7ad8f70..62acd16 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
@@ -41,10 +41,8 @@
private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
- final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2, payLoad);
final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1);
final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1);
- final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2);
/**
* Checks that the DefaultFlowRule class is immutable but can be inherited
@@ -84,14 +82,20 @@
/**
* Tests creation of a DefaultFlowRule using a FlowId constructor.
*/
+
@Test
public void testCreationWithFlowId() {
- final DefaultFlowRule rule =
- new DefaultFlowRule(did("1"), SELECTOR,
- TREATMENT, 22, 33,
- 44, false);
+ final FlowRule rule =
+ DefaultFlowRule.builder()
+ .forDevice(did("1"))
+ .withSelector(SELECTOR)
+ .withTreatment(TREATMENT)
+ .withPriority(22)
+ .makeTemporary(44)
+ .fromApp(APP_ID)
+ .build();
+
assertThat(rule.deviceId(), is(did("1")));
- assertThat(rule.id().value(), is(33L));
assertThat(rule.isPermanent(), is(false));
assertThat(rule.priority(), is(22));
assertThat(rule.selector(), is(SELECTOR));
@@ -99,6 +103,7 @@
assertThat(rule.timeout(), is(44));
}
+
/**
* Tests creation of a DefaultFlowRule using a PayLoad constructor.
*/
@@ -136,10 +141,16 @@
*/
@Test
public void testCreationWithAppId() {
- final DefaultFlowRule rule =
- new DefaultFlowRule(did("1"), SELECTOR,
- TREATMENT, 22, APP_ID,
- 44, false);
+ final FlowRule rule =
+ DefaultFlowRule.builder()
+ .forDevice(did("1"))
+ .withSelector(SELECTOR)
+ .withTreatment(TREATMENT)
+ .withPriority(22)
+ .fromApp(APP_ID)
+ .makeTemporary(44)
+ .build();
+
assertThat(rule.deviceId(), is(did("1")));
assertThat(rule.isPermanent(), is(false));
assertThat(rule.priority(), is(22));
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
index 9085f08..43a7fb7 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java
@@ -135,7 +135,7 @@
}
DefaultFlowRule rule = new DefaultFlowRule(deviceId, selector, treatment, 123, appId,
- new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 0, true);
+ new DefaultGroupId((short) (intent.id().fingerprint() & 0xffff)), 0, true, null);
rules.add(rule);
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
index d6eae35..f9e445a 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
@@ -256,6 +256,13 @@
protected FlowRule createFlowRule(MplsPathIntent intent, DeviceId deviceId,
TrafficSelector selector, TrafficTreatment treat) {
- return new DefaultFlowRule(deviceId, selector, treat, intent.priority(), appId, 0, true);
+ return DefaultFlowRule.builder()
+ .forDevice(deviceId)
+ .withSelector(selector)
+ .withTreatment(treat)
+ .withPriority(intent.priority())
+ .fromApp(appId)
+ .makePermanent()
+ .build();
}
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
index d6187cd..90e3981 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
@@ -97,7 +97,14 @@
}
TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build();
- return new DefaultFlowRule(ingress.deviceId(), selector, treatment, 123, appId, 0, true);
+ return DefaultFlowRule.builder()
+ .forDevice(ingress.deviceId())
+ .withSelector(selector)
+ .withTreatment(treatment)
+ .withPriority(123)
+ .fromApp(appId)
+ .makePermanent()
+ .build();
}
private boolean isLast(List<Link> links, int i) {
diff --git a/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java b/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java
index 5097bb8..520cb8c 100644
--- a/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java
@@ -144,7 +144,14 @@
private FlowRule flowRule(int tsval, int trval) {
TestSelector ts = new TestSelector(tsval);
TestTreatment tr = new TestTreatment(trval);
- return new DefaultFlowRule(DID, ts, tr, 10, appId, TIMEOUT, false);
+ return DefaultFlowRule.builder()
+ .forDevice(DID)
+ .withSelector(ts)
+ .withTreatment(tr)
+ .withPriority(10)
+ .fromApp(appId)
+ .makeTemporary(TIMEOUT)
+ .build();
}
diff --git a/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java b/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
index ac9da38..9795dab 100644
--- a/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
+++ b/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
@@ -28,6 +28,7 @@
import org.onlab.util.Frequency;
import org.onosproject.cluster.NodeId;
import org.onosproject.cluster.RoleInfo;
+import org.onosproject.core.DefaultApplicationId;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.mastership.MastershipTerm;
import org.onosproject.net.Annotations;
@@ -236,8 +237,15 @@
@Test
public void testFlowRuleBatchEntry() {
final FlowRule rule1 =
- new DefaultFlowRule(DID1, DefaultTrafficSelector.emptySelector(),
- DefaultTrafficTreatment.emptyTreatment(), 0, 0, 0, true);
+ DefaultFlowRule.builder()
+ .forDevice(DID1)
+ .withSelector(DefaultTrafficSelector.emptySelector())
+ .withTreatment(DefaultTrafficTreatment.emptyTreatment())
+ .withPriority(0)
+ .fromApp(new DefaultApplicationId(1, "1"))
+ .makeTemporary(1)
+ .build();
+
final FlowRuleBatchEntry entry1 =
new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule1);
final FlowRuleBatchEntry entry2 =