Merge all action input prefetchers into a single one.
It seems unnecessary to pass these lists around, so this should simplify the
APIs. Also, I want to move the action input prefetcher setup to the serverInit
call.
--
MOS_MIGRATED_REVID=139304928
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
index c96c5a0..e437180 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
@@ -20,6 +20,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.EventBus;
+import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.PackageRootResolver;
import com.google.devtools.build.lib.actions.cache.ActionCache;
import com.google.devtools.build.lib.actions.cache.CompactPersistentActionCache;
@@ -90,7 +91,7 @@
private PathFragment relativeWorkingDirectory = PathFragment.EMPTY_FRAGMENT;
private long commandStartTime;
private OutputService outputService;
- private ImmutableList<ActionInputPrefetcher> actionInputPrefetchers = ImmutableList.of();
+ private ActionInputPrefetcher actionInputPrefetcher;
private Path workingDirectory;
private String commandName;
@@ -344,8 +345,8 @@
return outputService;
}
- public ImmutableList<ActionInputPrefetcher> getActionInputPrefetchers() {
- return actionInputPrefetchers;
+ public ActionInputPrefetcher getActionInputPrefetcher() {
+ return actionInputPrefetcher == null ? ActionInputPrefetcher.NONE : actionInputPrefetcher;
}
public ActionCache getPersistentActionCache() throws IOException {
@@ -564,7 +565,16 @@
prefetchersBuilder.add(actionInputPrefetcher);
}
}
- actionInputPrefetchers = prefetchersBuilder.build();
+ final ImmutableList<ActionInputPrefetcher> actionInputPrefetchers = prefetchersBuilder.build();
+ actionInputPrefetcher =
+ new ActionInputPrefetcher() {
+ @Override
+ public void prefetchFile(ActionInput input) {
+ for (ActionInputPrefetcher prefetcher : actionInputPrefetchers) {
+ prefetcher.prefetchFile(input);
+ }
+ }
+ };
SkyframeExecutor skyframeExecutor = getSkyframeExecutor();
skyframeExecutor.setOutputService(outputService);