aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
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/remote/RemoteSpawnRunner.java
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/remote/RemoteSpawnRunner.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
index cbbae37dfa..df20b4220d 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
@@ -120,17 +120,17 @@ class RemoteSpawnRunner implements SpawnRunner {
}
@Override
- public SpawnResult exec(Spawn spawn, SpawnExecutionPolicy policy)
+ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
throws ExecException, InterruptedException, IOException {
if (!Spawns.mayBeExecutedRemotely(spawn) || remoteCache == null) {
- return fallbackRunner.exec(spawn, policy);
+ return fallbackRunner.exec(spawn, context);
}
- policy.report(ProgressStatus.EXECUTING, getName());
+ context.report(ProgressStatus.EXECUTING, getName());
// Temporary hack: the TreeNodeRepository should be created and maintained upstream!
- ActionInputFileCache inputFileCache = policy.getActionInputFileCache();
+ ActionInputFileCache inputFileCache = context.getActionInputFileCache();
TreeNodeRepository repository = new TreeNodeRepository(execRoot, inputFileCache, digestUtil);
- SortedMap<PathFragment, ActionInput> inputMap = policy.getInputMapping();
+ SortedMap<PathFragment, ActionInput> inputMap = context.getInputMapping();
TreeNode inputRoot = repository.buildFromActionInputs(inputMap);
repository.computeMerkleDigests(inputRoot);
Command command = buildCommand(spawn.getArguments(), spawn.getEnvironment());
@@ -140,7 +140,7 @@ class RemoteSpawnRunner implements SpawnRunner {
digestUtil.compute(command),
repository.getMerkleDigest(inputRoot),
spawn.getExecutionPlatform(),
- policy.getTimeout(),
+ context.getTimeout(),
Spawns.mayBeCached(spawn));
// Look up action cache, and reuse the action output if it is found.
@@ -165,7 +165,7 @@ class RemoteSpawnRunner implements SpawnRunner {
+ actionKey.getDigest());
}
try {
- return downloadRemoteResults(cachedResult, policy.getFileOutErr())
+ return downloadRemoteResults(cachedResult, context.getFileOutErr())
.setCacheHit(true)
.setRunnerName("remote cache hit")
.build();
@@ -176,19 +176,19 @@ class RemoteSpawnRunner implements SpawnRunner {
}
}
} catch (IOException e) {
- return execLocallyOrFail(spawn, policy, inputMap, actionKey, uploadLocalResults, e);
+ return execLocallyOrFail(spawn, context, inputMap, actionKey, uploadLocalResults, e);
}
if (remoteExecutor == null) {
// Remote execution is disabled and so execute the spawn on the local machine.
- return execLocally(spawn, policy, inputMap, uploadLocalResults, remoteCache, actionKey);
+ return execLocally(spawn, context, inputMap, uploadLocalResults, remoteCache, actionKey);
}
try {
// Upload the command and all the inputs into the remote cache.
remoteCache.ensureInputsPresent(repository, execRoot, inputRoot, command);
} catch (IOException e) {
- return execLocallyOrFail(spawn, policy, inputMap, actionKey, uploadLocalResults, e);
+ return execLocallyOrFail(spawn, context, inputMap, actionKey, uploadLocalResults, e);
}
final ActionResult result;
@@ -204,16 +204,16 @@ class RemoteSpawnRunner implements SpawnRunner {
result = reply.getResult();
remoteCacheHit = reply.getCachedResult();
} catch (IOException e) {
- return execLocallyOrFail(spawn, policy, inputMap, actionKey, uploadLocalResults, e);
+ return execLocallyOrFail(spawn, context, inputMap, actionKey, uploadLocalResults, e);
}
try {
- return downloadRemoteResults(result, policy.getFileOutErr())
+ return downloadRemoteResults(result, context.getFileOutErr())
.setRunnerName(remoteCacheHit ? "remote cache hit" : getName())
.setCacheHit(remoteCacheHit)
.build();
} catch (IOException e) {
- return execLocallyOrFail(spawn, policy, inputMap, actionKey, uploadLocalResults, e);
+ return execLocallyOrFail(spawn, context, inputMap, actionKey, uploadLocalResults, e);
}
} finally {
withMetadata.detach(previous);
@@ -257,7 +257,7 @@ class RemoteSpawnRunner implements SpawnRunner {
private SpawnResult execLocallyOrFail(
Spawn spawn,
- SpawnExecutionPolicy policy,
+ SpawnExecutionContext context,
SortedMap<PathFragment, ActionInput> inputMap,
ActionKey actionKey,
boolean uploadLocalResults,
@@ -271,9 +271,9 @@ class RemoteSpawnRunner implements SpawnRunner {
if (options.remoteLocalFallback
&& !(cause instanceof RetryException
&& RemoteRetrierUtils.causedByExecTimeout((RetryException) cause))) {
- return execLocally(spawn, policy, inputMap, uploadLocalResults, remoteCache, actionKey);
+ return execLocally(spawn, context, inputMap, uploadLocalResults, remoteCache, actionKey);
}
- return handleError(cause, policy.getFileOutErr(), actionKey);
+ return handleError(cause, context.getFileOutErr(), actionKey);
}
private SpawnResult handleError(IOException exception, FileOutErr outErr, ActionKey actionKey)
@@ -412,28 +412,28 @@ class RemoteSpawnRunner implements SpawnRunner {
*/
private SpawnResult execLocally(
Spawn spawn,
- SpawnExecutionPolicy policy,
+ SpawnExecutionContext context,
SortedMap<PathFragment, ActionInput> inputMap,
boolean uploadToCache,
@Nullable AbstractRemoteActionCache remoteCache,
@Nullable ActionKey actionKey)
throws ExecException, IOException, InterruptedException {
if (uploadToCache && remoteCache != null && actionKey != null) {
- return execLocallyAndUpload(spawn, policy, inputMap, remoteCache, actionKey);
+ return execLocallyAndUpload(spawn, context, inputMap, remoteCache, actionKey);
}
- return fallbackRunner.exec(spawn, policy);
+ return fallbackRunner.exec(spawn, context);
}
@VisibleForTesting
SpawnResult execLocallyAndUpload(
Spawn spawn,
- SpawnExecutionPolicy policy,
+ SpawnExecutionContext context,
SortedMap<PathFragment, ActionInput> inputMap,
AbstractRemoteActionCache remoteCache,
ActionKey actionKey)
throws ExecException, IOException, InterruptedException {
Map<Path, Long> ctimesBefore = getInputCtimes(inputMap);
- SpawnResult result = fallbackRunner.exec(spawn, policy);
+ SpawnResult result = fallbackRunner.exec(spawn, context);
Map<Path, Long> ctimesAfter = getInputCtimes(inputMap);
for (Map.Entry<Path, Long> e : ctimesBefore.entrySet()) {
// Skip uploading to remote cache, because an input was modified during execution.
@@ -447,7 +447,7 @@ class RemoteSpawnRunner implements SpawnRunner {
Spawns.mayBeCached(spawn)
&& Status.SUCCESS.equals(result.status())
&& result.exitCode() == 0;
- remoteCache.upload(actionKey, execRoot, outputFiles, policy.getFileOutErr(), uploadAction);
+ remoteCache.upload(actionKey, execRoot, outputFiles, context.getFileOutErr(), uploadAction);
} catch (IOException e) {
if (verboseFailures) {
report(Event.debug("Upload to remote cache failed: " + e.getMessage()));