aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote
diff options
context:
space:
mode:
authorGravatar olaola <olaola@google.com>2017-04-20 17:14:31 +0200
committerGravatar Vladimir Moskva <vladmos@google.com>2017-04-24 16:47:42 +0200
commit3f5442da4f9b8d4e01bf80ea134c05245e6551e0 (patch)
treeb3b48db6deeaea25dbe8f80931e711e863f2b971 /src/main/java/com/google/devtools/build/lib/remote
parent27a136b9bbb4d73b0a343d407b5da9f890175aea (diff)
Enabling chunking of outputs in the RemoteWorker downloadBlob. This fixes the bug that the RemoteWorker would fail to upload outputs that were too big to send in a single gRPC message.
Fixes #2822. RELNOTES: n/a PiperOrigin-RevId: 153710733
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/ChannelOptions.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteUtils.java8
3 files changed, 24 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/ChannelOptions.java b/src/main/java/com/google/devtools/build/lib/remote/ChannelOptions.java
index 45d76fc832..a6b992b866 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/ChannelOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/ChannelOptions.java
@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import io.grpc.CallCredentials;
import io.grpc.auth.MoreCallCredentials;
+import io.grpc.internal.GrpcUtil;
import io.grpc.netty.GrpcSslContexts;
import io.netty.handler.ssl.SslContext;
import java.io.File;
@@ -32,20 +33,24 @@ import javax.net.ssl.SSLException;
/** Instantiate all authentication helpers from build options. */
@ThreadSafe
public final class ChannelOptions {
+ private final int maxMessageSize;
private final boolean tlsEnabled;
private final SslContext sslContext;
private final String tlsAuthorityOverride;
private final CallCredentials credentials;
+ private static final int CHUNK_MESSAGE_OVERHEAD = 1024;
private ChannelOptions(
boolean tlsEnabled,
SslContext sslContext,
String tlsAuthorityOverride,
- CallCredentials credentials) {
+ CallCredentials credentials,
+ int maxMessageSize) {
this.tlsEnabled = tlsEnabled;
this.sslContext = sslContext;
this.tlsAuthorityOverride = tlsAuthorityOverride;
this.credentials = credentials;
+ this.maxMessageSize = maxMessageSize;
}
public boolean tlsEnabled() {
@@ -64,6 +69,10 @@ public final class ChannelOptions {
return sslContext;
}
+ public int maxMessageSize() {
+ return maxMessageSize;
+ }
+
public static ChannelOptions create(RemoteOptions options) {
try {
return create(
@@ -107,6 +116,11 @@ public final class ChannelOptions {
"Failed initializing auth credentials for remote cache/execution " + e);
}
}
- return new ChannelOptions(tlsEnabled, sslContext, tlsAuthorityOverride, credentials);
+ final int maxMessageSize =
+ Math.max(
+ GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE,
+ options.grpcMaxChunkSizeBytes + CHUNK_MESSAGE_OVERHEAD);
+ return new ChannelOptions(
+ tlsEnabled, sslContext, tlsAuthorityOverride, credentials, maxMessageSize);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
index fa3647aba0..0c76aa3106 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
@@ -73,9 +73,9 @@ public final class RemoteOptions extends OptionsBase {
@Option(
name = "grpc_max_chunk_size_bytes",
- defaultValue = "400000", // <4MB. Bounded by the gRPC size limit on the overall message.
+ defaultValue = "16000",
category = "remote",
- help = "The maximal number of bytes to be sent in a single message."
+ help = "The maximal number of data bytes to be sent in a single message."
)
public int grpcMaxChunkSizeBytes;
@@ -83,7 +83,7 @@ public final class RemoteOptions extends OptionsBase {
name = "grpc_max_batch_inputs",
defaultValue = "100",
category = "remote",
- help = "The maximal number of input file to be sent in a single batch."
+ help = "The maximal number of input files to be sent in a single batch."
)
public int grpcMaxBatchInputs;
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteUtils.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteUtils.java
index d890829142..845f5411fe 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteUtils.java
@@ -23,9 +23,11 @@ import io.grpc.netty.NettyChannelBuilder;
@ThreadSafe
public final class RemoteUtils {
public static ManagedChannel createChannel(String target, ChannelOptions channelOptions) {
- NettyChannelBuilder builder = NettyChannelBuilder.forTarget(target);
- builder.negotiationType(
- channelOptions.tlsEnabled() ? NegotiationType.TLS : NegotiationType.PLAINTEXT);
+ NettyChannelBuilder builder =
+ NettyChannelBuilder.forTarget(target)
+ .negotiationType(
+ channelOptions.tlsEnabled() ? NegotiationType.TLS : NegotiationType.PLAINTEXT)
+ .maxMessageSize(channelOptions.maxMessageSize());
if (channelOptions.getSslContext() != null) {
builder.sslContext(channelOptions.getSslContext());
if (channelOptions.getTlsAuthorityOverride() != null) {