trying to fix flow state
Change-Id: I62845842c66cb99cb14bd54bc9602edf7c0cae39
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
index fae1fe3..62e331f 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
@@ -15,19 +15,20 @@
private final FlowId id;
private final long created;
private final long life;
- private final long idle;
private final long packets;
private final long bytes;
+ private final FlowRuleState state;
public DefaultFlowRule(DeviceId deviceId,
- TrafficSelector selector, TrafficTreatment treatment, int priority) {
+ TrafficSelector selector, TrafficTreatment treatment,
+ int priority, FlowRuleState state) {
this.deviceId = deviceId;
this.priority = priority;
this.selector = selector;
this.treatment = treatment;
+ this.state = state;
this.life = 0;
- this.idle = 0;
this.packets = 0;
this.bytes = 0;
this.id = FlowId.valueOf(this.hashCode());
@@ -35,22 +36,32 @@
}
public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- long life, long idle, long packets, long bytes, Integer flowId) {
+ TrafficTreatment treatment, int priority, FlowRuleState state,
+ long life, long packets, long bytes, Integer flowId) {
this.deviceId = deviceId;
this.priority = priority;
this.selector = selector;
this.treatment = treatment;
+ this.state = state;
this.id = FlowId.valueOf(flowId);
this.life = life;
- this.idle = idle;
this.packets = packets;
this.bytes = bytes;
this.created = System.currentTimeMillis();
}
+ public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+ TrafficTreatment treatement, int priority) {
+ this(deviceId, selector, treatement, priority, FlowRuleState.CREATED);
+ }
+
+ public DefaultFlowRule(FlowRule rule, FlowRuleState state) {
+ this(rule.deviceId(), rule.selector(), rule.treatment(),
+ rule.priority(), state);
+ }
+
@Override
public FlowId id() {
@@ -83,11 +94,6 @@
}
@Override
- public long idleMillis() {
- return idle;
- }
-
- @Override
public long packets() {
return packets;
}
@@ -98,6 +104,12 @@
}
@Override
+ public FlowRuleState state() {
+ return this.state;
+ }
+
+
+ @Override
/*
* The priority and statistics can change on a given treatment and selector
*
@@ -116,19 +128,14 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
- if (obj instanceof FlowRule) {
- DefaultFlowRule that = (DefaultFlowRule) obj;
- if (!this.deviceId().equals(that.deviceId())) {
- return false;
- }
- if (!this.treatment().equals(that.treatment())) {
- return false;
- }
- if (!this.selector().equals(that.selector())) {
- return false;
- }
+ if (this == obj) {
return true;
}
+ if (obj instanceof FlowRule) {
+ FlowRule that = (FlowRule) obj;
+ return Objects.equals(deviceId, that.deviceId()) &&
+ Objects.equals(id, that.id());
+ }
return false;
}
@@ -144,5 +151,4 @@
.toString();
}
-
}