diff options
author | 2017-06-30 02:17:43 +0200 | |
---|---|---|
committer | 2017-06-30 13:01:04 +0200 | |
commit | 5f00cd2b1cde682f77a47439e9dc631349992f9e (patch) | |
tree | 943e3f662afd4c017c09692874b2ef2a508e7ef3 /src/main/java/com/google/devtools/build/lib | |
parent | 5dda1bed046cf96cdc191adfa09a60f77c1d3e44 (diff) |
Slight refactoring, functional noop: uploadChunks will need to get a Chunker.Builder in my next change, so all the from factory methods are removed.
TESTED=unit test
PiperOrigin-RevId: 160594730
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/Chunker.java | 39 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/GrpcActionCache.java | 16 |
2 files changed, 7 insertions, 48 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/Chunker.java b/src/main/java/com/google/devtools/build/lib/remote/Chunker.java index 499c86533e..6b068bbaf2 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/Chunker.java +++ b/src/main/java/com/google/devtools/build/lib/remote/Chunker.java @@ -237,45 +237,6 @@ public final class Chunker { }; } - /** - * Create a Chunker from a given ActionInput, taking its digest from the provided - * ActionInputFileCache. - */ - public static Chunker from( - ActionInput input, int chunkSize, ActionInputFileCache inputCache, Path execRoot) - throws IOException { - return new Chunker(toItem(input, inputCache, execRoot), chunkSize); - } - - /** - * Create a Chunker from a given ActionInput, taking its digest from the provided - * ActionInputFileCache. - */ - public static Chunker from(ActionInput input, ActionInputFileCache inputCache, Path execRoot) - throws IOException { - return from(input, getDefaultChunkSize(), inputCache, execRoot); - } - - /** Create a Chunker from a given blob and chunkSize. */ - public static Chunker from(byte[] blob, int chunkSize) throws IOException { - return new Chunker(toItem(blob), chunkSize); - } - - /** Create a Chunker from a given blob. */ - public static Chunker from(byte[] blob) throws IOException { - return from(blob, getDefaultChunkSize()); - } - - /** Create a Chunker from a given Path and chunkSize. */ - public static Chunker from(Path file, int chunkSize) throws IOException { - return new Chunker(toItem(file), chunkSize); - } - - /** Create a Chunker from a given Path. */ - public static Chunker from(Path file) throws IOException { - return from(file, getDefaultChunkSize()); - } - private static class MemberOf implements Predicate<Item> { private final Set<Digest> digests; 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 0f3f6045d2..7f0a04812f 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 @@ -21,7 +21,6 @@ import com.google.bytestream.ByteStreamProto.ReadRequest; import com.google.bytestream.ByteStreamProto.ReadResponse; import com.google.bytestream.ByteStreamProto.WriteRequest; import com.google.bytestream.ByteStreamProto.WriteResponse; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; @@ -74,7 +73,6 @@ public class GrpcActionCache implements RemoteActionCache { private final ChannelOptions channelOptions; private final Channel channel; - @VisibleForTesting public GrpcActionCache(Channel channel, ChannelOptions channelOptions, RemoteOptions options) { this.options = options; this.channelOptions = channelOptions; @@ -188,8 +186,7 @@ public class GrpcActionCache implements RemoteActionCache { actionInputs.size(), new Chunker.Builder() .addAllInputs(actionInputs, repository.getInputFileCache(), execRoot) - .onlyUseDigests(missingDigests) - .build()); + .onlyUseDigests(missingDigests)); } } @@ -315,7 +312,7 @@ public class GrpcActionCache implements RemoteActionCache { } ImmutableSet<Digest> missing = getMissingDigests(digests); if (!missing.isEmpty()) { - uploadChunks(missing.size(), b.onlyUseDigests(missing).build()); + uploadChunks(missing.size(), b.onlyUseDigests(missing)); } int index = 0; for (Path file : files) { @@ -348,7 +345,7 @@ public class GrpcActionCache implements RemoteActionCache { Digest digest = Digests.computeDigest(file); ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); if (!missing.isEmpty()) { - uploadChunks(1, Chunker.from(file)); + uploadChunks(1, new Chunker.Builder().addInput(file)); } return digest; } @@ -365,12 +362,12 @@ public class GrpcActionCache implements RemoteActionCache { Digest digest = Digests.getDigestFromInputCache(input, inputCache); ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); if (!missing.isEmpty()) { - uploadChunks(1, Chunker.from(input, inputCache, execRoot)); + uploadChunks(1, new Chunker.Builder().addInput(input, inputCache, execRoot)); } return digest; } - private void uploadChunks(int numItems, Chunker chunker) + private void uploadChunks(int numItems, Chunker.Builder chunkerBuilder) throws InterruptedException, IOException { final CountDownLatch finishLatch = new CountDownLatch(numItems); final AtomicReference<RuntimeException> exception = new AtomicReference<>(null); @@ -379,6 +376,7 @@ public class GrpcActionCache implements RemoteActionCache { if (!options.remoteInstanceName.isEmpty()) { resourceName += options.remoteInstanceName + "/"; } + Chunker chunker = chunkerBuilder.build(); while (chunker.hasNext()) { Chunker.Chunk chunk = chunker.next(); final Digest digest = chunk.getDigest(); @@ -449,7 +447,7 @@ public class GrpcActionCache implements RemoteActionCache { ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest)); try { if (!missing.isEmpty()) { - uploadChunks(1, Chunker.from(blob)); + uploadChunks(1, new Chunker.Builder().addInput(blob)); } return digest; } catch (IOException e) { |