[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/P4PipelineModel.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java
index ce9ec13..28e5372 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java
@@ -35,6 +35,8 @@
 import java.util.Objects;
 import java.util.Optional;
 
+import static com.google.common.base.MoreObjects.toStringHelper;
+
 /**
  * Implementation of PiPipelineModel for P4Runtime.
  */
@@ -46,6 +48,7 @@
     private final ImmutableMap<PiRegisterId, PiRegisterModel> registers;
     private final ImmutableMap<PiActionProfileId, PiActionProfileModel> actionProfiles;
     private final ImmutableMap<PiPacketOperationType, PiPacketOperationModel> packetOperations;
+    private final int fingerprint;
 
     P4PipelineModel(
             ImmutableMap<PiTableId, PiTableModel> tables,
@@ -53,13 +56,15 @@
             ImmutableMap<PiMeterId, PiMeterModel> meters,
             ImmutableMap<PiRegisterId, PiRegisterModel> registers,
             ImmutableMap<PiActionProfileId, PiActionProfileModel> actionProfiles,
-            ImmutableMap<PiPacketOperationType, PiPacketOperationModel> packetOperations) {
+            ImmutableMap<PiPacketOperationType, PiPacketOperationModel> packetOperations,
+            int fingerprint) {
         this.tables = tables;
         this.counters = counters;
         this.meters = meters;
         this.registers = registers;
         this.actionProfiles = actionProfiles;
         this.packetOperations = packetOperations;
+        this.fingerprint = fingerprint;
     }
 
     @Override
@@ -120,7 +125,11 @@
 
     @Override
     public int hashCode() {
-        return Objects.hash(tables, counters, meters, actionProfiles, packetOperations);
+        // NOTE: that the fingerprint is derived by hashing the p4Info file
+        //       this because the hashcode is not deterministic across multiple
+        //       JVMs instance. This hashcode is also used to derive the fingerprint
+        //       of the pipeconf.
+        return fingerprint;
     }
 
     @Override
@@ -135,7 +144,22 @@
         return Objects.equals(this.tables, other.tables)
                 && Objects.equals(this.counters, other.counters)
                 && Objects.equals(this.meters, other.meters)
+                && Objects.equals(this.registers, other.registers)
                 && Objects.equals(this.actionProfiles, other.actionProfiles)
-                && Objects.equals(this.packetOperations, other.packetOperations);
+                && Objects.equals(this.packetOperations, other.packetOperations)
+                && this.fingerprint == other.fingerprint;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this)
+                .add("tables", tables.values())
+                .add("counters", counters.values())
+                .add("meters", meters.values())
+                .add("registers", registers.values())
+                .add("actionProfiles", actionProfiles.values())
+                .add("packetOperations", packetOperations.values())
+                .add("fingerprint", fingerprint)
+                .toString();
     }
 }