aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
diff options
context:
space:
mode:
authorGravatar olaola <olaola@google.com>2018-02-22 10:33:28 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-22 10:35:26 -0800
commitec0855331c8f81b8eff738669d800b6d7f34271d (patch)
tree865e56ebb1eee02eeb76b6cf89cc20e8f36ff068 /src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
parentfe13ee3df1181c9054f338f712e3b60ef68b65e3 (diff)
Adding a property name to the SpawnRunner. Most runners already had it, I just add it to the interface, and include it in the SpawnResult. This will be used to categorize/aggregate spawns executed by various runners.
Also, minor refinement to the cacheHit property of the SpawnResult with remote execution. RELNOTES: None TESTED=presubmit, next cl PiperOrigin-RevId: 186637978
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.java16
1 files changed, 14 insertions, 2 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 0d0ae9a9e5..a061bedcf0 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
@@ -110,13 +110,18 @@ class RemoteSpawnRunner implements SpawnRunner {
}
@Override
+ public String getName() {
+ return "remote";
+ }
+
+ @Override
public SpawnResult exec(Spawn spawn, SpawnExecutionPolicy policy)
throws ExecException, InterruptedException, IOException {
if (!Spawns.mayBeExecutedRemotely(spawn) || remoteCache == null) {
return fallbackRunner.exec(spawn, policy);
}
- policy.report(ProgressStatus.EXECUTING, "remote");
+ policy.report(ProgressStatus.EXECUTING, getName());
// Temporary hack: the TreeNodeRepository should be created and maintained upstream!
ActionInputFileCache inputFileCache = policy.getActionInputFileCache();
TreeNodeRepository repository = new TreeNodeRepository(execRoot, inputFileCache, digestUtil);
@@ -182,6 +187,7 @@ class RemoteSpawnRunner implements SpawnRunner {
}
final ActionResult result;
+ boolean remoteCacheHit = false;
try {
ExecuteRequest.Builder request =
ExecuteRequest.newBuilder()
@@ -190,12 +196,16 @@ class RemoteSpawnRunner implements SpawnRunner {
.setSkipCacheLookup(!acceptCachedResult);
ExecuteResponse reply = remoteExecutor.executeRemotely(request.build());
result = reply.getResult();
+ remoteCacheHit = reply.getCachedResult();
} catch (IOException e) {
return execLocallyOrFail(spawn, policy, inputMap, actionKey, uploadLocalResults, e);
}
try {
- return downloadRemoteResults(result, policy.getFileOutErr()).build();
+ return downloadRemoteResults(result, policy.getFileOutErr())
+ .setRunnerName(remoteCacheHit ? "" : getName())
+ .setCacheHit(remoteCacheHit)
+ .build();
} catch (IOException e) {
return execLocallyOrFail(spawn, policy, inputMap, actionKey, uploadLocalResults, e);
}
@@ -238,6 +248,7 @@ class RemoteSpawnRunner implements SpawnRunner {
out.write(msg.getBytes(StandardCharsets.UTF_8));
}
return new SpawnResult.Builder()
+ .setRunnerName(getName())
.setStatus(Status.TIMEOUT)
.setExitCode(POSIX_TIMEOUT_EXIT_CODE)
.build();
@@ -255,6 +266,7 @@ class RemoteSpawnRunner implements SpawnRunner {
throw new SpawnExecException(
Throwables.getStackTraceAsString(exception),
new SpawnResult.Builder()
+ .setRunnerName(getName())
.setStatus(status)
.setExitCode(ExitCode.REMOTE_ERROR.getNumericExitCode())
.build(),