aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-08-02 11:44:26 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-02 11:46:47 -0700
commitd1a203bbdd2033ec8049b39242189e1cc76a9e8e (patch)
tree44a286b58e717f5f8fe43c07ca99c4e9540d1edf /src/main/java/com/google/devtools
parent6d07c367fc912819312834267a6ba7e28b05ac0e (diff)
Add support for VirtualActionInputs to the remote cache.
RELNOTES: None PiperOrigin-RevId: 207137932
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/Chunker.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java23
2 files changed, 11 insertions, 17 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 fb3202c214..7e960ac43d 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
@@ -22,6 +22,7 @@ import com.google.common.base.Throwables;
import com.google.common.io.ByteStreams;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.MetadataProvider;
+import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.remoteexecution.v1test.Digest;
@@ -146,6 +147,10 @@ public final class Chunker {
this(actionInput, inputCache, execRoot, getDefaultChunkSize(), digestUtil);
}
+ public Chunker(VirtualActionInput actionInput, DigestUtil digestUtil) throws IOException {
+ this(actionInput.getBytes().toByteArray(), digestUtil);
+ }
+
public Chunker(
ActionInput actionInput,
MetadataProvider inputCache,
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 253ab41d83..c1755599a0 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
@@ -28,6 +28,7 @@ import com.google.common.util.concurrent.SettableFuture;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ExecException;
import com.google.devtools.build.lib.actions.MetadataProvider;
+import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.remote.Retrier.RetryException;
import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode;
@@ -169,7 +170,11 @@ public class GrpcRemoteCache extends AbstractRemoteActionCache {
if (!missingActionInputs.isEmpty()) {
MetadataProvider inputFileCache = repository.getInputFileCache();
for (ActionInput actionInput : missingActionInputs) {
- toUpload.add(new Chunker(actionInput, inputFileCache, execRoot, digestUtil));
+ if (actionInput instanceof VirtualActionInput) {
+ toUpload.add(new Chunker((VirtualActionInput) actionInput, digestUtil));
+ } else {
+ toUpload.add(new Chunker(actionInput, inputFileCache, execRoot, digestUtil));
+ }
}
}
uploader.uploadBlobs(toUpload, true);
@@ -326,22 +331,6 @@ public class GrpcRemoteCache extends AbstractRemoteActionCache {
return digest;
}
- /**
- * Put the file contents cache if it is not already in it. No-op if the file is already stored in
- * cache. The given path must be a full absolute path.
- *
- * @return The key for fetching the file contents blob from cache.
- */
- Digest uploadFileContents(ActionInput input, Path execRoot, MetadataProvider inputCache)
- throws IOException, InterruptedException {
- Digest digest = DigestUtil.getFromInputCache(input, inputCache);
- ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest));
- if (!missing.isEmpty()) {
- uploader.uploadBlob(new Chunker(input, inputCache, execRoot, digestUtil), true);
- }
- return digest;
- }
-
Digest uploadBlob(byte[] blob) throws IOException, InterruptedException {
Digest digest = digestUtil.compute(blob);
ImmutableSet<Digest> missing = getMissingDigests(ImmutableList.of(digest));