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/PiMeterHandle.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMeterHandle.java
index ad2af9d..4baa6fa 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMeterHandle.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiMeterHandle.java
@@ -21,33 +21,56 @@
import com.google.common.base.Objects;
import org.onosproject.net.DeviceId;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
- * Global identifier of a PI meter cell configuration applied to a device, uniquely defined
- * by a device ID and meter cell ID.
+ * Global identifier of a PI meter cell configuration applied to a device,
+ * uniquely defined by a device ID and meter cell ID.
*/
@Beta
public final class PiMeterHandle extends PiHandle<PiMeterCellConfig> {
- private PiMeterHandle(DeviceId deviceId, PiMeterCellConfig meterCellConfig) {
- super(deviceId, meterCellConfig);
+ private final PiMeterCellId cellId;
+
+ private PiMeterHandle(DeviceId deviceId, PiMeterCellId meterCellId) {
+ super(deviceId);
+ this.cellId = meterCellId;
}
/**
- * Creates a new handle for the given device ID and PI meter cell configuration.
+ * Creates a new handle for the given device ID and PI meter cell ID.
*
- * @param deviceId device ID
+ * @param deviceId device ID
+ * @param meterCellId meter cell ID
+ * @return PI meter handle
+ */
+ public static PiMeterHandle of(DeviceId deviceId,
+ PiMeterCellId meterCellId) {
+ return new PiMeterHandle(deviceId, meterCellId);
+ }
+
+ /**
+ * Creates a new handle for the given device ID and PI meter cell
+ * configuration.
+ *
+ * @param deviceId device ID
* @param meterCellConfig meter config
* @return PI meter handle
*/
public static PiMeterHandle of(DeviceId deviceId,
PiMeterCellConfig meterCellConfig) {
- return new PiMeterHandle(deviceId, meterCellConfig);
+ checkNotNull(meterCellConfig);
+ return new PiMeterHandle(deviceId, meterCellConfig.cellId());
+ }
+
+ @Override
+ public PiEntityType entityType() {
+ return PiEntityType.METER_CELL_CONFIG;
}
@Override
public int hashCode() {
- return Objects.hashCode(deviceId(),
- piEntity().cellId());
+ return Objects.hashCode(deviceId(), cellId);
}
@Override
@@ -60,15 +83,14 @@
}
PiMeterHandle that = (PiMeterHandle) o;
return Objects.equal(deviceId(), that.deviceId()) &&
- Objects.equal(piEntity().cellId(),
- that.piEntity().cellId());
+ Objects.equal(cellId, that.cellId);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("deviceId", deviceId())
- .add("meterCellId", piEntity().cellId())
+ .add("meterCellId", cellId)
.toString();
}
-}
\ No newline at end of file
+}