use of com.google.devtools.build.lib.actions.ActionExecutionMetadata in project bazel by bazelbuild.
the class WorkerSpawnStrategy method exec.
@Override
public void exec(Spawn spawn, ActionExecutionContext actionExecutionContext, AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
if (!spawn.getExecutionInfo().containsKey("supports-workers") || !spawn.getExecutionInfo().get("supports-workers").equals("1")) {
StandaloneSpawnStrategy standaloneStrategy = Preconditions.checkNotNull(executor.getContext(StandaloneSpawnStrategy.class));
executor.getEventHandler().handle(Event.warn(String.format(ERROR_MESSAGE_PREFIX + REASON_NO_EXECUTION_INFO, spawn.getMnemonic())));
standaloneStrategy.exec(spawn, actionExecutionContext);
return;
}
EventBus eventBus = actionExecutionContext.getExecutor().getEventBus();
ActionExecutionMetadata owner = spawn.getResourceOwner();
eventBus.post(ActionStatusMessage.schedulingStrategy(owner));
try (ResourceHandle handle = ResourceManager.instance().acquireResources(owner, spawn.getLocalResources())) {
eventBus.post(ActionStatusMessage.runningStrategy(spawn.getResourceOwner(), "worker"));
actuallyExec(spawn, actionExecutionContext, writeOutputFiles);
}
}
use of com.google.devtools.build.lib.actions.ActionExecutionMetadata in project bazel by bazelbuild.
the class ExperimentalStateTrackerTest method testActionStrategyVisible.
@Test
public void testActionStrategyVisible() throws Exception {
// verify that, if a strategy was reported for a shown action, it is visible
// in the progress bar.
String strategy = "verySpecialStrategy";
String primaryOutput = "some/path/to/a/file";
ManualClock clock = new ManualClock();
Path path = outputBase.getRelative(new PathFragment(primaryOutput));
Artifact artifact = new Artifact(path, Root.asSourceRoot(path));
ActionExecutionMetadata actionMetadata = Mockito.mock(ActionExecutionMetadata.class);
when(actionMetadata.getOwner()).thenReturn(Mockito.mock(ActionOwner.class));
when(actionMetadata.getPrimaryOutput()).thenReturn(artifact);
ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
stateTracker.actionStarted(new ActionStartedEvent(mockAction("Some random action", primaryOutput), clock.nanoTime()));
stateTracker.actionStatusMessage(ActionStatusMessage.runningStrategy(actionMetadata, strategy));
LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
true);
stateTracker.writeProgressBar(terminalWriter);
String output = terminalWriter.getTranscript();
assertTrue("Output should mention strategy '" + strategy + "', but was: " + output, output.contains(strategy));
}
use of com.google.devtools.build.lib.actions.ActionExecutionMetadata in project bazel by bazelbuild.
the class StandaloneSpawnStrategy method exec.
/**
* Executes the given {@code spawn}.
*/
@Override
public void exec(Spawn spawn, ActionExecutionContext actionExecutionContext) throws ExecException, InterruptedException {
EventBus eventBus = actionExecutionContext.getExecutor().getEventBus();
ActionExecutionMetadata owner = spawn.getResourceOwner();
eventBus.post(ActionStatusMessage.schedulingStrategy(owner));
try (ResourceHandle handle = resourceManager.acquireResources(owner, spawn.getLocalResources())) {
eventBus.post(ActionStatusMessage.runningStrategy(owner, "standalone"));
actuallyExec(spawn, actionExecutionContext);
}
}
use of com.google.devtools.build.lib.actions.ActionExecutionMetadata in project bazel by bazelbuild.
the class DarwinSandboxedStrategy method exec.
@Override
public void exec(Spawn spawn, ActionExecutionContext actionExecutionContext, AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
// Certain actions can't run remotely or in a sandbox - pass them on to the standalone strategy.
if (!spawn.isRemotable() || spawn.hasNoSandbox()) {
SandboxHelpers.fallbackToNonSandboxedExecution(spawn, actionExecutionContext, executor);
return;
}
EventBus eventBus = actionExecutionContext.getExecutor().getEventBus();
ActionExecutionMetadata owner = spawn.getResourceOwner();
eventBus.post(ActionStatusMessage.schedulingStrategy(owner));
try (ResourceHandle handle = ResourceManager.instance().acquireResources(owner, spawn.getLocalResources())) {
SandboxHelpers.postActionStatusMessage(eventBus, spawn);
actuallyExec(spawn, actionExecutionContext, writeOutputFiles);
}
}
use of com.google.devtools.build.lib.actions.ActionExecutionMetadata in project bazel by bazelbuild.
the class LinuxSandboxedStrategy method exec.
@Override
public void exec(Spawn spawn, ActionExecutionContext actionExecutionContext, AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
// Certain actions can't run remotely or in a sandbox - pass them on to the standalone strategy.
if (!spawn.isRemotable() || spawn.hasNoSandbox()) {
SandboxHelpers.fallbackToNonSandboxedExecution(spawn, actionExecutionContext, executor);
return;
}
EventBus eventBus = actionExecutionContext.getExecutor().getEventBus();
ActionExecutionMetadata owner = spawn.getResourceOwner();
eventBus.post(ActionStatusMessage.schedulingStrategy(owner));
try (ResourceHandle handle = ResourceManager.instance().acquireResources(owner, spawn.getLocalResources())) {
SandboxHelpers.postActionStatusMessage(eventBus, spawn);
actuallyExec(spawn, actionExecutionContext, writeOutputFiles);
}
}
Aggregations