[SDFAB-271] Change the default max inbound metadata size for grpc channels

The default size is set to 8KB which can be easily exceed even by batch
of 100 flows. When this happens ONOS closes the channel as consequence
of the HTTP2Exception thrown by Netty. With this patch we set the size
to 40MB which should avoid any problem even with batch larger than 100k
flows.

Change-Id: I3f1ccbf20275898798e039531d1871991d99d952
(cherry picked from commit cf5dabd3dd6b1a94fb718da6fe8d5e95ef1e5479)
diff --git a/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/GrpcChannelControllerImpl.java b/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/GrpcChannelControllerImpl.java
index ca43cac..b5b10db 100644
--- a/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/GrpcChannelControllerImpl.java
+++ b/protocols/grpc/ctl/src/main/java/org/onosproject/grpc/ctl/GrpcChannelControllerImpl.java
@@ -70,6 +70,14 @@
     private static final String GRPCS = "grpcs";
 
     private static final int DEFAULT_MAX_INBOUND_MSG_SIZE = 256; // Megabytes.
+    // The maximum metadata size in Megabytes that a P4Runtime client should accept.
+    // This is necessary, because the P4Runtime protocol returns individual errors to
+    // requests in a batch all wrapped in a single status, which counts towards the
+    // metadata size limit.  For large batches, this easily exceeds the default of
+    // 8KB. According to the tests done with Stratum, 4MB will support batches of
+    // around 40000 entries, assuming 100 bytes per error, without exceeding the
+    // maximum metadata size. Setting here 10 times higher.
+    private static final int DEFAULT_MAX_INBOUND_META_SIZE = 40;
     private static final int MEGABYTES = 1024 * 1024;
 
     private static final PickFirstLoadBalancerProvider PICK_FIRST_LOAD_BALANCER_PROVIDER =
@@ -184,7 +192,9 @@
                 .defaultLoadBalancingPolicy(
                         PICK_FIRST_LOAD_BALANCER_PROVIDER.getPolicyName())
                 .maxInboundMessageSize(
-                        DEFAULT_MAX_INBOUND_MSG_SIZE * MEGABYTES);
+                        DEFAULT_MAX_INBOUND_MSG_SIZE * MEGABYTES)
+                .maxInboundMetadataSize(
+                        DEFAULT_MAX_INBOUND_META_SIZE * MEGABYTES);
 
         if (useTls) {
             try {