[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/P4PacketOperationModel.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PacketOperationModel.java
index e29553f..3421e70 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PacketOperationModel.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PacketOperationModel.java
@@ -24,6 +24,8 @@
import java.util.List;
import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Implementation of PiPacketOperationModel for P4Runtime.
*/
@@ -33,7 +35,7 @@
private final ImmutableList<PiPacketMetadataModel> metadatas;
P4PacketOperationModel(PiPacketOperationType type,
- ImmutableList<PiPacketMetadataModel> metadatas) {
+ ImmutableList<PiPacketMetadataModel> metadatas) {
this.type = type;
this.metadatas = metadatas;
}
@@ -65,4 +67,12 @@
return Objects.equals(this.type, other.type)
&& Objects.equals(this.metadatas, other.metadatas);
}
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("type", type)
+ .add("metadatas", metadatas)
+ .toString();
+ }
}