Increase gRPC inbound msg size for P4Runtime client
Change-Id: I51bb790a7b16c6e34066978e7044d51971f1b9d4
diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java
index cb413bc..a140491 100644
--- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java
+++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java
@@ -61,6 +61,10 @@
extends AbstractListenerManager<P4RuntimeEvent, P4RuntimeEventListener>
implements P4RuntimeController {
+ // Getting the pipeline config from the device can take tens of MBs.
+ private static final int MAX_INBOUND_MSG_SIZE = 256; // Megabytes.
+ private static final int MEGABYTES = 1024 * 1024;
+
private final Logger log = getLogger(getClass());
private final Map<DeviceId, ClientKey> clientKeys = Maps.newHashMap();
@@ -121,7 +125,7 @@
final ClientKey existingKey = clientKeys.get(deviceId);
if (clientKey.equals(existingKey)) {
log.debug("Not creating client for {} as it already exists (server={}:{}, p4DeviceId={})...",
- deviceId, serverAddr, serverPort, p4DeviceId);
+ deviceId, serverAddr, serverPort, p4DeviceId);
return true;
} else {
log.info("Requested client for {} with new " +
@@ -141,7 +145,8 @@
ManagedChannelBuilder channelBuilder = NettyChannelBuilder
.forAddress(serverAddr, serverPort)
- .usePlaintext(true);
+ .maxInboundMessageSize(MAX_INBOUND_MSG_SIZE * MEGABYTES)
+ .usePlaintext();
ManagedChannel channel;
try {