More robust P4Runtime group handling
This patch solves the PENDING_UPDATE and PENDING_ADD_RETRY issue
observed on the ONS EU topology.
The P4Runtime action profile group handling has been re-implemented to
be robust against inconsistencies of the device mirror, which is now
periodically synchronized with the device state. Similarly, we implement
a routine in the P4RuntimeClient to cleanup unused action profile
members.
This patch includes also:
- Refactor PI handle classes to allow creating handles without the
entity instance
- Use list instead of collections in P4RuntimeClient methods, as order
of updates sent and/or entities received from the device is important
Change-Id: I2e7964ce90f43d66680131b47ab52aca32ab55d2
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java
index 4c87f1f..6969714 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java
@@ -20,6 +20,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.pi.model.PiActionProfileId;
/**
* Global identifier of a PI action group applied to a device, uniquely defined
@@ -28,8 +29,13 @@
@Beta
public final class PiActionGroupHandle extends PiHandle<PiActionGroup> {
+ private final PiActionProfileId actionProfileId;
+ private final PiActionGroupId groupId;
+
private PiActionGroupHandle(DeviceId deviceId, PiActionGroup group) {
- super(deviceId, group);
+ super(deviceId);
+ actionProfileId = group.actionProfileId();
+ groupId = group.id();
}
/**
@@ -45,10 +51,15 @@
}
@Override
+ public PiEntityType entityType() {
+ return PiEntityType.GROUP;
+ }
+
+ @Override
public int hashCode() {
return Objects.hashCode(deviceId(),
- piEntity().actionProfileId(),
- piEntity().id());
+ actionProfileId,
+ groupId);
}
@Override
@@ -61,17 +72,17 @@
}
PiActionGroupHandle that = (PiActionGroupHandle) o;
return Objects.equal(deviceId(), that.deviceId()) &&
- Objects.equal(piEntity().actionProfileId(),
- that.piEntity().actionProfileId()) &&
- Objects.equal(piEntity().id(), that.piEntity().id());
+ Objects.equal(actionProfileId,
+ that.actionProfileId) &&
+ Objects.equal(groupId, that.groupId);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("deviceId", deviceId())
- .add("actionProfileId", piEntity().actionProfileId())
- .add("groupId", piEntity().id())
+ .add("actionProfileId", actionProfileId)
+ .add("groupId", groupId)
.toString();
}
}