[AETHER-1104] Calculate PiPipeconf fingerprint in a deterministic way
New master after taking over a switch was pushing again the pipeline
and all the flows and groups. This was happening because DefaultPiPipeconf
fingerprint was not calculated in a deterministic way across the cluster.
This patch introduces the following changes:
- Implements toString method in each abstraction representing a pipeline
- Hashes the p4Info file to generate a consistent hash of the pipeline model
- Uses a sorted collection to generate a consistent hash of the extensions
Change-Id: I792283b0a9b821284add36b3aba52843f33527c3
diff --git a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ActionProfileModel.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ActionProfileModel.java
index 443d407..5059bce 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ActionProfileModel.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ActionProfileModel.java
@@ -24,6 +24,8 @@
import java.util.Collection;
import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Implementation of PiActionProfileModel for P4Runtime.
*/
@@ -90,4 +92,15 @@
&& Objects.equals(this.size, other.size)
&& Objects.equals(this.maxGroupSize, other.maxGroupSize);
}
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", id)
+ .add("tables", tables)
+ .add("hasSelector", hasSelector)
+ .add("size", size)
+ .add("maxGroupSize", maxGroupSize)
+ .toString();
+ }
}