Search in sources :

Example 1 with StandaloneSpawnStrategy

use of com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy 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);
    }
}
Also used : ActionExecutionMetadata(com.google.devtools.build.lib.actions.ActionExecutionMetadata) Executor(com.google.devtools.build.lib.actions.Executor) ResourceHandle(com.google.devtools.build.lib.actions.ResourceManager.ResourceHandle) StandaloneSpawnStrategy(com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy) EventBus(com.google.common.eventbus.EventBus)

Example 2 with StandaloneSpawnStrategy

use of com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy in project bazel by bazelbuild.

the class SandboxHelpers method fallbackToNonSandboxedExecution.

static void fallbackToNonSandboxedExecution(Spawn spawn, ActionExecutionContext actionExecutionContext, Executor executor) throws ExecException, InterruptedException {
    StandaloneSpawnStrategy standaloneStrategy = Preconditions.checkNotNull(executor.getContext(StandaloneSpawnStrategy.class));
    standaloneStrategy.exec(spawn, actionExecutionContext);
}
Also used : StandaloneSpawnStrategy(com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy)

Aggregations

StandaloneSpawnStrategy (com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy)2 EventBus (com.google.common.eventbus.EventBus)1 ActionExecutionMetadata (com.google.devtools.build.lib.actions.ActionExecutionMetadata)1 Executor (com.google.devtools.build.lib.actions.Executor)1 ResourceHandle (com.google.devtools.build.lib.actions.ResourceManager.ResourceHandle)1