ONOS-7898 Action profile group/member refactoring

Also includes:
- New abstract P4Runtime codec implementation. Currently used for action
profile members/groups encoding/deconding, the plan is to handle all
other codecs via this.
- Improved read requests in P4RuntimeClientImpl
- Removed handling of max group size in P4Runtime driver. Instead, added
modified group translator to specify a max group size by using
information from the pipeline model.

Change-Id: I684bae0184d683bb448ba19863c561f9848479d2
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 5417d44..443d407 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
@@ -32,14 +32,17 @@
     private final PiActionProfileId id;
     private final ImmutableSet<PiTableId> tables;
     private final boolean hasSelector;
-    private final long maxSize;
+    private final long size;
+    private final int maxGroupSize;
 
     P4ActionProfileModel(PiActionProfileId id,
-                         ImmutableSet<PiTableId> tables, boolean hasSelector, long maxSize) {
+                         ImmutableSet<PiTableId> tables, boolean hasSelector,
+                         long size, int maxGroupSize) {
         this.id = id;
         this.tables = tables;
         this.hasSelector = hasSelector;
-        this.maxSize = maxSize;
+        this.size = size;
+        this.maxGroupSize = maxGroupSize;
     }
 
     @Override
@@ -58,13 +61,18 @@
     }
 
     @Override
-    public long maxSize() {
-        return maxSize;
+    public long size() {
+        return size;
+    }
+
+    @Override
+    public int maxGroupSize() {
+        return maxGroupSize;
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(id, tables, hasSelector, maxSize);
+        return Objects.hash(id, tables, hasSelector, size, maxGroupSize);
     }
 
     @Override
@@ -79,6 +87,7 @@
         return Objects.equals(this.id, other.id)
                 && Objects.equals(this.tables, other.tables)
                 && Objects.equals(this.hasSelector, other.hasSelector)
-                && Objects.equals(this.maxSize, other.maxSize);
+                && Objects.equals(this.size, other.size)
+                && Objects.equals(this.maxGroupSize, other.maxGroupSize);
     }
 }
diff --git a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java
index ff49928..ef8cb36 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java
@@ -332,7 +332,8 @@
                             PiActionProfileId.of(actProfileMsg.getPreamble().getName()),
                             tableIdSetBuilder.build(),
                             actProfileMsg.getWithSelector(),
-                            actProfileMsg.getSize()));
+                            actProfileMsg.getSize(),
+                            actProfileMsg.getMaxGroupSize()));
         }
         return actProfileMap;
     }
diff --git a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ActionProfileModelTest.java b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ActionProfileModelTest.java
index 3042414..021d341 100644
--- a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ActionProfileModelTest.java
+++ b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4ActionProfileModelTest.java
@@ -21,7 +21,6 @@
 import org.onosproject.net.pi.model.PiActionProfileId;
 import org.onosproject.net.pi.model.PiTableId;
 
-
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
 
 /**
@@ -52,17 +51,17 @@
     private final PiActionProfileId id2 = PiActionProfileId.of("name2");
 
     private final P4ActionProfileModel metadataModel = new P4ActionProfileModel(id, tables,
-                                                                                true, 64);
+                                                                                true, 64, 10);
     private final P4ActionProfileModel sameAsMetadataModel = new P4ActionProfileModel(id, sameAsTables,
-                                                                                      true, 64);
+                                                                                      true, 64, 10);
     private final P4ActionProfileModel metadataModel2 = new P4ActionProfileModel(id, tables2,
-                                                                                 true, 64);
+                                                                                 true, 64, 10);
     private final P4ActionProfileModel metadataModel3 = new P4ActionProfileModel(id2, tables,
-                                                                                 true, 64);
+                                                                                 true, 64, 10);
     private final P4ActionProfileModel metadataModel4 = new P4ActionProfileModel(id, tables,
-                                                                                 false, 64);
+                                                                                 false, 64, 10);
     private final P4ActionProfileModel metadataModel5 = new P4ActionProfileModel(id, tables,
-                                                                                 true, 32);
+                                                                                 true, 32, 5);
 
     /**
      * Checks that the P4ActionProfileModel class is immutable.
@@ -85,4 +84,4 @@
                 .addEqualityGroup(metadataModel5)
                 .testEquals();
     }
-}
\ No newline at end of file
+}
diff --git a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4InfoParserTest.java b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4InfoParserTest.java
index 3a803d4..9d696e2 100644
--- a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4InfoParserTest.java
+++ b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4InfoParserTest.java
@@ -70,6 +70,7 @@
 
     private static final Long DEFAULT_MAX_TABLE_SIZE = 1024L;
     private static final Long DEFAULT_MAX_ACTION_PROFILE_SIZE = 64L;
+    private static final int DEFAULT_MAX_GROUP_SIZE = 0;
 
     /**
      * Tests parse method.
@@ -205,7 +206,8 @@
         ImmutableSet<PiTableId> tableIds = new ImmutableSet.Builder<PiTableId>().add(tableId).build();
         PiActionProfileId actionProfileId = PiActionProfileId.of("wcmp_control.wcmp_selector");
         PiActionProfileModel wcmpSelector3 = new P4ActionProfileModel(actionProfileId, tableIds,
-                                                                      true, DEFAULT_MAX_ACTION_PROFILE_SIZE);
+                                                                      true, DEFAULT_MAX_ACTION_PROFILE_SIZE,
+                                                                      DEFAULT_MAX_GROUP_SIZE);
         PiActionProfileModel wcmpSelector = model.actionProfiles(actionProfileId).orElse(null);
         PiActionProfileModel wcmpSelector2 = model2.actionProfiles(actionProfileId).orElse(null);
 
diff --git a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java
index da10762..8576e84 100644
--- a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java
+++ b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java
@@ -75,12 +75,17 @@
     private static final long ACTION_MAX_SIZE_1 = 100;
     private static final long ACTION_MAX_SIZE_2 = 200;
 
+    private static final int ACTION_MAX_GROUP_SIZE_1 = 10;
+    private static final int ACTION_MAX_GROUP_SIZE_2 = 20;
+
     private static final PiActionProfileModel P4_ACTION_PROFILE_MODEL_1 =
             new P4ActionProfileModel(PI_ACTION_PROFILE_ID_1, ACTION_TABLES_1,
-                                     ACTION_HAS_SELECTOR_1, ACTION_MAX_SIZE_1);
+                                     ACTION_HAS_SELECTOR_1, ACTION_MAX_SIZE_1,
+                                     ACTION_MAX_GROUP_SIZE_1);
     private static final PiActionProfileModel P4_ACTION_PROFILE_MODEL_2 =
             new P4ActionProfileModel(PI_ACTION_PROFILE_ID_2, ACTION_TABLES_2,
-                                     ACTION_HAS_SELECTOR_2, ACTION_MAX_SIZE_2);
+                                     ACTION_HAS_SELECTOR_2, ACTION_MAX_SIZE_2,
+                                     ACTION_MAX_GROUP_SIZE_2);
 
     /* Counters */
     private static final PiCounterId PI_COUNTER_ID_1 = PiCounterId.of("Counter1");
diff --git a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4TableModelTest.java b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4TableModelTest.java
index 89b10d0..797abe4 100644
--- a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4TableModelTest.java
+++ b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4TableModelTest.java
@@ -67,12 +67,17 @@
     private static final long ACTION_MAX_SIZE_1 = 100;
     private static final long ACTION_MAX_SIZE_2 = 200;
 
+    private static final int ACTION_MAX_GROUP_SIZE_1 = 10;
+    private static final int ACTION_MAX_GROUP_SIZE_2 = 20;
+
     private static final PiActionProfileModel P4_ACTION_PROFILE_MODEL_1 =
             new P4ActionProfileModel(PI_ACTION_PROFILE_ID_1, ACTION_TABLES_1,
-                                     ACTION_HAS_SELECTOR_1, ACTION_MAX_SIZE_1);
+                                     ACTION_HAS_SELECTOR_1, ACTION_MAX_SIZE_1,
+                                     ACTION_MAX_GROUP_SIZE_1);
     private static final PiActionProfileModel P4_ACTION_PROFILE_MODEL_2 =
             new P4ActionProfileModel(PI_ACTION_PROFILE_ID_2, ACTION_TABLES_2,
-                                     ACTION_HAS_SELECTOR_2, ACTION_MAX_SIZE_2);
+                                     ACTION_HAS_SELECTOR_2, ACTION_MAX_SIZE_2,
+                                     ACTION_MAX_GROUP_SIZE_2);
 
     /* Counters */
     private static final PiCounterId PI_COUNTER_ID_1 = PiCounterId.of("Counter1");