FlowRule api no longer uses TableTypes. Existing usages are converted to
integer representations via Type.ordinal() call
Change-Id: Ie2a26c5ced166e12f0e1ea22e39cd5195455a1ad
diff --git a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
index 2b74c58..32c51d0 100644
--- a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
@@ -137,7 +137,7 @@
.put("bytes", flow.bytes())
.put("packets", flow.packets())
.put("life", flow.life())
- .put("tableId", flow.type().toString())
+ .put("tableId", flow.tableId())
.put("appId", appName);
result.set("selector", crit);
result.set("treatment", instr);
@@ -192,7 +192,7 @@
if (!empty) {
for (FlowEntry f : flows) {
print(FMT, Long.toHexString(f.id().value()), f.state(),
- f.bytes(), f.packets(), f.life(), f.priority(), f.type(),
+ f.bytes(), f.packets(), f.life(), f.priority(), f.tableId(),
coreService.getAppId(f.appId()).name());
print(SFMT, f.selector().criteria());
print(TFMT, f.treatment());
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 63baa68..7d3525c 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
@@ -42,7 +42,6 @@
private final boolean permanent;
private final GroupId groupId;
- private final Type type;
private final Integer tableId;
@@ -61,7 +60,6 @@
this.appId = (short) (flowId >>> 48);
this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
this.id = FlowId.valueOf(flowId);
- this.type = Type.DEFAULT;
this.tableId = 0;
}
@@ -80,8 +78,7 @@
this.appId = (short) (flowId >>> 48);
this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
this.id = FlowId.valueOf(flowId);
- this.type = tableType;
- this.tableId = 0;
+ this.tableId = tableType.ordinal();
}
@@ -111,8 +108,7 @@
this.timeout = timeout;
this.permanent = permanent;
this.created = System.currentTimeMillis();
- this.type = type;
- this.tableId = 0;
+ this.tableId = type.ordinal();
/*
* id consists of the following.
@@ -141,7 +137,6 @@
this.timeout = timeout;
this.permanent = permanent;
this.created = System.currentTimeMillis();
- this.type = Type.DEFAULT;
this.tableId = 0;
/*
@@ -163,7 +158,6 @@
this.timeout = rule.timeout();
this.permanent = rule.isPermanent();
this.created = System.currentTimeMillis();
- this.type = rule.type();
this.tableId = rule.tableId();
}
@@ -187,7 +181,6 @@
//FIXME: fields below will be removed.
this.groupId = null;
- this.type = null;
}
@@ -235,11 +228,11 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
public int hashCode() {
- return Objects.hash(deviceId, selector, priority, type, tableId);
+ return Objects.hash(deviceId, selector, priority, tableId);
}
public int hash() {
- return Objects.hash(deviceId, selector, treatment, type);
+ return Objects.hash(deviceId, selector, treatment, tableId);
}
@Override
@@ -258,8 +251,7 @@
return Objects.equals(deviceId, that.deviceId) &&
Objects.equals(priority, that.priority) &&
Objects.equals(selector, that.selector) &&
- Objects.equals(tableId, that.tableId) &&
- Objects.equals(type, that.type);
+ Objects.equals(tableId, that.tableId);
}
return false;
@@ -273,7 +265,7 @@
.add("priority", priority)
.add("selector", selector.criteria())
.add("treatment", treatment == null ? "N/A" : treatment.allInstructions())
- .add("table type", type)
+ .add("tableId", tableId)
.add("created", created)
.toString();
}
@@ -289,11 +281,6 @@
}
@Override
- public Type type() {
- return type;
- }
-
- @Override
public int tableId() {
return tableId;
}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
index a126f18..3499bae 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
@@ -127,14 +127,6 @@
boolean isPermanent();
/**
- * Returns the flow rule type.
- *
- * @return flow rule type
- */
- @Deprecated
- Type type();
-
- /**
* Returns the table id for this rule.
*
* @return an integer.
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 7457274..be7f790 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -333,13 +333,13 @@
static int nextId = 0;
int priority;
- Type type;
+ int tableId;
long timestamp;
int id;
public MockFlowRule(int priority) {
this.priority = priority;
- this.type = Type.DEFAULT;
+ this.tableId = 0;
this.timestamp = System.currentTimeMillis();
this.id = nextId++;
}
@@ -408,13 +408,8 @@
}
@Override
- public Type type() {
- return type;
- }
-
- @Override
public int tableId() {
- return 0;
+ return tableId;
}
}
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
index f0ce1f4..30711ad 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
@@ -124,7 +124,7 @@
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
- .setTableId(TableId.of(flowRule().type().ordinal()))
+ .setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
@@ -161,7 +161,7 @@
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
- .setTableId(TableId.of(flowRule().type().ordinal()))
+ .setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
@@ -180,7 +180,7 @@
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
- .setTableId(TableId.of(flowRule().type().ordinal()))
+ .setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
index d19a231..32042fe 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -144,11 +144,11 @@
private void applyRule(FlowRule flowRule) {
OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri()));
- if (flowRule.type() == FlowRule.Type.DEFAULT) {
+ if (flowRule.tableId() == 0) {
sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(),
Optional.empty()).buildFlowAdd());
} else {
- OpenFlowSwitch.TableType type = getTableType(flowRule.type());
+ OpenFlowSwitch.TableType type = getTableType(flowRule.tableId());
sw.transformAndSendMsg(FlowModBuilder.builder(flowRule, sw.factory(),
Optional.empty()).buildFlowAdd(),
type);
@@ -166,12 +166,12 @@
private void removeRule(FlowRule flowRule) {
OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri()));
- if (flowRule.type() == FlowRule.Type.DEFAULT) {
+ if (flowRule.tableId() == 0) {
sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(),
Optional.empty()).buildFlowDel());
} else {
sw.transformAndSendMsg(FlowModBuilder.builder(flowRule, sw.factory(),
- Optional.empty()).buildFlowDel(), getTableType(flowRule.type()));
+ Optional.empty()).buildFlowDel(), getTableType(flowRule.tableId()));
}
}
@@ -211,10 +211,10 @@
fbe.operator(), fbe);
continue;
}
- if (fbe.target().type() == FlowRule.Type.DEFAULT) {
+ if (fbe.target().tableId() == 0) {
sw.sendMsg(mod);
} else {
- sw.transformAndSendMsg(mod, getTableType(fbe.target().type()));
+ sw.transformAndSendMsg(mod, getTableType(fbe.target().tableId()));
}
}
OFBarrierRequest.Builder builder = sw.factory()
@@ -223,8 +223,8 @@
sw.sendMsg(builder.build());
}
- private OpenFlowSwitch.TableType getTableType(FlowRule.Type type) {
- switch (type) {
+ private OpenFlowSwitch.TableType getTableType(int type) {
+ switch (FlowRule.Type.values()[type]) {
case DEFAULT:
return OpenFlowSwitch.TableType.NONE;
diff --git a/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java
index 8e70bd5..a460385 100644
--- a/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java
@@ -147,13 +147,13 @@
}
@Override
- public short appId() {
- return 2;
+ public GroupId groupId() {
+ return new DefaultGroupId(3);
}
@Override
- public GroupId groupId() {
- return new DefaultGroupId(3);
+ public short appId() {
+ return 2;
}
@Override
@@ -187,11 +187,6 @@
}
@Override
- public Type type() {
- return Type.DEFAULT;
- }
-
- @Override
public int tableId() {
return 0;
}