aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/worker
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-04-19 05:41:44 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-19 05:42:58 -0700
commit29e306d66cc4c441f0321a62101077647a4c95dc (patch)
treecabcf23c53c9cdcfe501bc5f17531f73e81c5a30 /src/main/java/com/google/devtools/build/lib/worker
parent9566f677a1093e3a3c0ddaed3f9ab34dd98e5e26 (diff)
Rename SpawnExecutionPolicy -> SpawnExecutionContext.
This class will be used to tie a Spawn to a SpawnRunner, and isn't really a policy object. It will carry state such as the expanded inputs and expanded command line. Currently a context can be passed between different SpawnRunners. This will be addressed independently, so a context is tied to a particular spawn runner. PiperOrigin-RevId: 193501918
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/worker')
-rw-r--r--src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java
index a615cf76cd..7efe410b19 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java
@@ -96,7 +96,7 @@ final class WorkerSpawnRunner implements SpawnRunner {
}
@Override
- public SpawnResult exec(Spawn spawn, SpawnExecutionPolicy policy)
+ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
throws ExecException, IOException, InterruptedException {
if (!spawn.getExecutionInfo().containsKey(ExecutionRequirements.SUPPORTS_WORKERS)
|| !spawn.getExecutionInfo().get(ExecutionRequirements.SUPPORTS_WORKERS).equals("1")) {
@@ -105,19 +105,19 @@ final class WorkerSpawnRunner implements SpawnRunner {
reporter.handle(
Event.warn(
String.format(ERROR_MESSAGE_PREFIX + REASON_NO_EXECUTION_INFO, spawn.getMnemonic())));
- return fallbackRunner.exec(spawn, policy);
+ return fallbackRunner.exec(spawn, context);
}
- policy.report(ProgressStatus.SCHEDULING, getName());
+ context.report(ProgressStatus.SCHEDULING, getName());
ActionExecutionMetadata owner = spawn.getResourceOwner();
try (ResourceHandle handle =
ResourceManager.instance().acquireResources(owner, spawn.getLocalResources())) {
- policy.report(ProgressStatus.EXECUTING, getName());
- return actuallyExec(spawn, policy);
+ context.report(ProgressStatus.EXECUTING, getName());
+ return actuallyExec(spawn, context);
}
}
- private SpawnResult actuallyExec(Spawn spawn, SpawnExecutionPolicy policy)
+ private SpawnResult actuallyExec(Spawn spawn, SpawnExecutionContext context)
throws ExecException, IOException, InterruptedException {
if (Iterables.isEmpty(spawn.getToolFiles())) {
throw new UserExecException(
@@ -132,15 +132,15 @@ final class WorkerSpawnRunner implements SpawnRunner {
ImmutableList<String> workerArgs = splitSpawnArgsIntoWorkerArgsAndFlagFiles(spawn, flagFiles);
ImmutableMap<String, String> env = spawn.getEnvironment();
- ActionInputFileCache inputFileCache = policy.getActionInputFileCache();
+ ActionInputFileCache inputFileCache = context.getActionInputFileCache();
SortedMap<PathFragment, HashCode> workerFiles =
WorkerFilesHash.getWorkerFilesWithHashes(
- spawn, policy.getArtifactExpander(), policy.getActionInputFileCache());
+ spawn, context.getArtifactExpander(), context.getActionInputFileCache());
HashCode workerFilesCombinedHash = WorkerFilesHash.getCombinedHash(workerFiles);
- Map<PathFragment, Path> inputFiles = SandboxHelpers.getInputFiles(spawn, policy, execRoot);
+ Map<PathFragment, Path> inputFiles = SandboxHelpers.getInputFiles(spawn, context, execRoot);
Set<PathFragment> outputFiles = SandboxHelpers.getOutputFiles(spawn);
WorkerKey key =
@@ -151,15 +151,15 @@ final class WorkerSpawnRunner implements SpawnRunner {
spawn.getMnemonic(),
workerFilesCombinedHash,
workerFiles,
- policy.speculating());
+ context.speculating());
- WorkRequest workRequest = createWorkRequest(spawn, policy, flagFiles, inputFileCache);
+ WorkRequest workRequest = createWorkRequest(spawn, context, flagFiles, inputFileCache);
long startTime = System.currentTimeMillis();
- WorkResponse response = execInWorker(key, workRequest, policy, inputFiles, outputFiles);
+ WorkResponse response = execInWorker(key, workRequest, context, inputFiles, outputFiles);
Duration wallTime = Duration.ofMillis(System.currentTimeMillis() - startTime);
- FileOutErr outErr = policy.getFileOutErr();
+ FileOutErr outErr = context.getFileOutErr();
response.getOutputBytes().writeTo(outErr.getErrorStream());
int exitCode = response.getExitCode();
@@ -202,7 +202,7 @@ final class WorkerSpawnRunner implements SpawnRunner {
private WorkRequest createWorkRequest(
Spawn spawn,
- SpawnExecutionPolicy policy,
+ SpawnExecutionContext context,
List<String> flagfiles,
ActionInputFileCache inputFileCache)
throws IOException {
@@ -212,7 +212,7 @@ final class WorkerSpawnRunner implements SpawnRunner {
}
List<ActionInput> inputs =
- ActionInputHelper.expandArtifacts(spawn.getInputFiles(), policy.getArtifactExpander());
+ ActionInputHelper.expandArtifacts(spawn.getInputFiles(), context.getArtifactExpander());
for (ActionInput input : inputs) {
byte[] digestBytes = inputFileCache.getMetadata(input).getDigest();
@@ -258,7 +258,7 @@ final class WorkerSpawnRunner implements SpawnRunner {
private WorkResponse execInWorker(
WorkerKey key,
WorkRequest request,
- SpawnExecutionPolicy policy,
+ SpawnExecutionContext context,
Map<PathFragment, Path> inputFiles,
Set<PathFragment> outputFiles)
throws InterruptedException, ExecException {
@@ -327,7 +327,7 @@ final class WorkerSpawnRunner implements SpawnRunner {
.toString());
}
- policy.lockOutputFiles();
+ context.lockOutputFiles();
if (response == null) {
throw new UserExecException(