aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Ola Rozenfeld <olaola@google.com>2016-11-07 14:39:15 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-11-08 09:13:18 +0000
commit1396286e3d8ad398b923c460fba8823876f652a8 (patch)
tree88f154f796c645ba492d43fa58834f503489f071 /src/main/java/com/google/devtools
parent943d3cf92648f71c5aa6420aa275e674c82c6a4d (diff)
Upload empty files to remote execution. I was too eager to optimize empty files
away -- Bazel should still work with remote execution servers that don't have that optimization. -- MOS_MIGRATED_REVID=138384785
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/GrpcActionCache.java32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcActionCache.java
index 84a09ff3b5..5004748b00 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/GrpcActionCache.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcActionCache.java
@@ -17,6 +17,7 @@ package com.google.devtools.build.lib.remote;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterators;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
@@ -123,7 +124,7 @@ public final class GrpcActionCache implements RemoteActionCache {
@Override
public boolean hasNext() {
- return currentBlob != null && offset < currentBlob.length;
+ return currentBlob != null;
}
@Override
@@ -138,8 +139,10 @@ public final class GrpcActionCache implements RemoteActionCache {
chunk.setOffset(offset);
}
int size = Math.min(currentBlob.length - offset, maxChunkSizeBytes);
- chunk.setData(ByteString.copyFrom(currentBlob, offset, size));
- offset += size;
+ if (size > 0) {
+ chunk.setData(ByteString.copyFrom(currentBlob, offset, size));
+ offset += size;
+ }
if (offset >= currentBlob.length) {
advanceInput();
}
@@ -162,8 +165,8 @@ public final class GrpcActionCache implements RemoteActionCache {
}
public BlobChunkFileIterator(Path file) throws IOException {
- fileIterator = null;
- digests = null;
+ fileIterator = Iterators.singletonIterator(file);
+ digests = ImmutableSet.of(ContentDigests.computeDigest(file));
advanceInput();
}
@@ -184,7 +187,7 @@ public final class GrpcActionCache implements RemoteActionCache {
@Override
public boolean hasNext() {
- return bytesLeft > 0;
+ return currentStream != null;
}
@Override
@@ -192,8 +195,6 @@ public final class GrpcActionCache implements RemoteActionCache {
if (!hasNext()) {
throw new NoSuchElementException();
}
- byte[] blob = new byte[(int) Math.min(bytesLeft, (long) maxChunkSizeBytes)];
- currentStream.read(blob);
BlobChunk.Builder chunk = BlobChunk.newBuilder();
long offset = digest.getSizeBytes() - bytesLeft;
if (offset == 0) {
@@ -201,8 +202,12 @@ public final class GrpcActionCache implements RemoteActionCache {
} else {
chunk.setOffset(offset);
}
- chunk.setData(ByteString.copyFrom(blob));
- bytesLeft -= blob.length;
+ if (bytesLeft > 0) {
+ byte[] blob = new byte[(int) Math.min(bytesLeft, (long) maxChunkSizeBytes)];
+ currentStream.read(blob);
+ chunk.setData(ByteString.copyFrom(blob));
+ bytesLeft -= blob.length;
+ }
if (bytesLeft == 0) {
currentStream.close();
advanceInput();
@@ -238,12 +243,7 @@ public final class GrpcActionCache implements RemoteActionCache {
}
private ImmutableSet<ContentDigest> getMissingDigests(Iterable<ContentDigest> digests) {
- CasLookupRequest.Builder request = CasLookupRequest.newBuilder();
- for (ContentDigest digest : digests) {
- if (digest.getSizeBytes() > 0) {
- request.addDigest(digest); // We handle empty blobs locally.
- }
- }
+ CasLookupRequest.Builder request = CasLookupRequest.newBuilder().addAllDigest(digests);
if (request.getDigestCount() == 0) {
return ImmutableSet.of();
}