Skip to content

Commit

Permalink
test3
Browse files Browse the repository at this point in the history
  • Loading branch information
excitoon committed Apr 25, 2019
1 parent 6aab0c2 commit e530f68
Showing 1 changed file with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import build.bazel.remote.execution.v2.Action;
import build.bazel.remote.execution.v2.ActionResult;
import build.bazel.remote.execution.v2.Command;
import build.bazel.remote.execution.v2.OutputFile;
import build.bazel.remote.execution.v2.Platform;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ExecException;
Expand Down Expand Up @@ -46,9 +47,11 @@
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
import java.util.stream.Collectors;
import javax.annotation.Nullable;

/** A remote {@link SpawnCache} implementation. */
Expand Down Expand Up @@ -143,20 +146,29 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
result = remoteCache.getCachedActionResult(actionKey);
}
if (result != null) {
// We don't cache failed actions, so we know the outputs exist.
// For now, download all outputs locally; in the future, we can reuse the digests to
// just update the TreeNodeRepository and continue the build.
try (SilentCloseable c = Profiler.instance().profile("RemoteCache.download")) {
remoteCache.download(result, execRoot, context.getFileOutErr());
List<String> expectedPaths = spawn.getOutputFiles().stream().map(
(actionInput) -> actionInput.getExecPathString()
).collect(Collectors.toList());

This comment has been minimized.

Copy link
@buchgr

buchgr Apr 25, 2019

Contributor

Take a look at the Action message and RemoteSpawnRunner.buildAction(...). The Action message contains the output files that it expects (and also output directories). Maybe take them as "expectedPaths" and compare that with the actual paths?

This comment has been minimized.

Copy link
@excitoon

excitoon Apr 26, 2019

Author Contributor

It's in Command now.

Set<String> actualPaths = result.getOutputFilesList().stream().map(
(outputFile) -> outputFile.getPath()
).collect(Collectors.toSet());
if (actualPaths.containsAll(expectedPaths)) // What a miss otherwise!
{
// We don't cache failed actions, so we know the outputs exist.
// For now, download all outputs locally; in the future, we can reuse the digests to
// just update the TreeNodeRepository and continue the build.
try (SilentCloseable c = Profiler.instance().profile("RemoteCache.download")) {
remoteCache.download(result, execRoot, context.getFileOutErr());
}
SpawnResult spawnResult =
new SpawnResult.Builder()
.setStatus(Status.SUCCESS)
.setExitCode(result.getExitCode())
.setCacheHit(true)
.setRunnerName("remote cache hit")
.build();
return SpawnCache.success(spawnResult);
}
SpawnResult spawnResult =
new SpawnResult.Builder()
.setStatus(Status.SUCCESS)
.setExitCode(result.getExitCode())
.setCacheHit(true)
.setRunnerName("remote cache hit")
.build();
return SpawnCache.success(spawnResult);
}
} catch (CacheNotFoundException e) {
// Intentionally left blank
Expand Down

0 comments on commit e530f68

Please sign in to comment.