[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/P4ControlMetadataModel.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ControlMetadataModel.java
index a6e2a43..19a6fa7 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ControlMetadataModel.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4ControlMetadataModel.java
@@ -21,6 +21,8 @@
import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Implementation of PiPacketMetadataModel for P4Runtime.
*/
@@ -61,4 +63,12 @@
return Objects.equals(this.id, other.id)
&& Objects.equals(this.bitWidth, other.bitWidth);
}
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", id)
+ .add("bitWidth", bitWidth)
+ .toString();
+ }
}