diff options
author | buchgr <buchgr@google.com> | 2017-07-12 10:29:27 +0200 |
---|---|---|
committer | László Csomor <laszlocsomor@google.com> | 2017-07-12 10:52:22 +0200 |
commit | 226510b85b9c0b1465aa860bc6cdd792b01b3412 (patch) | |
tree | 7d512eb26f18dfa918c20ccf931be8c654107134 /src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java | |
parent | 7a1e3a534efccc86dd86ba9d253f0a6801df7158 (diff) |
remote: Rewrite Chunker
- Remove the Chunker.Builder and use the Chunker constructors instead.
- Fix a correctness bug, where the chunker would ignore the return value
of InputStream.read(byte[]).
- Have Chunk.getData() return a ByteString as opposed to a byte[]. All
callsides need ByteString objects and this change makes the subsequent
change possible.
- Have the Chunker use a preallocated byte[] in order to avoid
allocating a new one on every call to next().
RELNOTES: None.
PiperOrigin-RevId: 161637158
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java index 615e9f83d7..5b21e249b5 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java @@ -27,7 +27,6 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ActionInputFileCache; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; -import com.google.devtools.build.lib.remote.Chunker.SingleSourceBuilder; import com.google.devtools.build.lib.remote.Digests.ActionKey; import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode; import com.google.devtools.build.lib.util.Preconditions; @@ -172,14 +171,13 @@ public class GrpcRemoteCache implements RemoteActionCache { } uploadBlob(command.toByteArray()); if (!actionInputs.isEmpty()) { - List<Chunker.SingleSourceBuilder> inputsToUpload = new ArrayList<>(); + List<Chunker> inputsToUpload = new ArrayList<>(); ActionInputFileCache inputFileCache = repository.getInputFileCache(); for (ActionInput actionInput : actionInputs) { Digest digest = Digests.getDigestFromInputCache(actionInput, inputFileCache); if (missingDigests.contains(digest)) { - Chunker.SingleSourceBuilder builder = - new Chunker.SingleSourceBuilder().input(actionInput, inputFileCache, execRoot); - inputsToUpload.add(builder); + Chunker chunker = new Chunker(actionInput, inputFileCache, execRoot); + inputsToUpload.add(chunker); } } @@ -323,7 +321,7 @@ public class GrpcRemoteCache implements RemoteActionCache { throws IOException, InterruptedException { ArrayList<Digest> digests = new ArrayList<>(); ImmutableSet<Digest> digestsToUpload = getMissingDigests(digests); - List<Chunker.SingleSourceBuilder> filesToUpload = new ArrayList<>(digestsToUpload.size()); + List<Chunker> filesToUpload = new ArrayList<>(digestsToUpload.size()); for (Path file : files) { if (!file.exists()) { // We ignore requested results that have not been generated by the action. @@ -339,8 +337,8 @@ public class GrpcRemoteCache implements RemoteActionCache { digests.add(digest); if (digestsToUpload.contains(digest)) { - Chunker.SingleSourceBuilder chunkerBuilder = new SingleSourceBuilder().input(file); - filesToUpload.add(chunkerBuilder); + Chunker chunker = new Chunker(file); + filesToUpload.add(chunker); } } @@ -379,7 +377,7 @@ public class GrpcRemoteCache implements RemoteActionCache { Digest digest = Digests.computeDigest(file); ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); if (!missing.isEmpty()) { - uploader.uploadBlob(new Chunker.SingleSourceBuilder().input(file)); + uploader.uploadBlob(new Chunker(file)); } return digest; } @@ -395,7 +393,7 @@ public class GrpcRemoteCache implements RemoteActionCache { Digest digest = Digests.getDigestFromInputCache(input, inputCache); ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); if (!missing.isEmpty()) { - uploader.uploadBlob(new Chunker.SingleSourceBuilder().input(input, inputCache, execRoot)); + uploader.uploadBlob(new Chunker(input, inputCache, execRoot)); } return digest; } @@ -404,7 +402,7 @@ public class GrpcRemoteCache implements RemoteActionCache { Digest digest = Digests.computeDigest(blob); ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); if (!missing.isEmpty()) { - uploader.uploadBlob(new Chunker.SingleSourceBuilder().input(blob)); + uploader.uploadBlob(new Chunker(blob)); } return digest; } |