Search in sources :

Example 1 with DistBuildSlaveExecutor

use of com.facebook.buck.distributed.DistBuildSlaveExecutor in project buck by facebook.

the class DistBuildFactory method createDistBuildExecutor.

public static DistBuildSlaveExecutor createDistBuildExecutor(BuildJobState jobState, CommandRunnerParams params, WeightedListeningExecutorService executorService, DistBuildService service, DistBuildMode mode, int coordinatorPort, Optional<StampedeId> stampedeId, Optional<Path> globalCacheDir) throws IOException {
    DistBuildState state = DistBuildState.load(Optional.of(params.getBuckConfig()), jobState, params.getCell(), params.getKnownBuildRuleTypesFactory());
    Preconditions.checkArgument(state.getCells().size() > 0);
    // Create a cache factory which uses a combination of the distributed build config,
    // overridden with the local buck config (i.e. the build slave).
    Cell rootCell = Preconditions.checkNotNull(state.getCells().get(0));
    ArtifactCacheFactory distBuildArtifactCacheFactory = params.getArtifactCacheFactory().cloneWith(rootCell.getBuckConfig());
    DistBuildSlaveExecutor executor = new DistBuildSlaveExecutor(DistBuildExecutorArgs.builder().setBuckEventBus(params.getBuckEventBus()).setPlatform(params.getPlatform()).setClock(params.getClock()).setArtifactCache(distBuildArtifactCacheFactory.newInstance(true)).setState(state).setObjectMapper(params.getObjectMapper()).setRootCell(params.getCell()).setParser(params.getParser()).setExecutorService(executorService).setActionGraphCache(params.getActionGraphCache()).setCacheKeySeed(params.getBuckConfig().getKeySeed()).setConsole(params.getConsole()).setProvider(new MultiSourceContentsProvider(service, globalCacheDir)).setExecutors(params.getExecutors()).setDistBuildMode(mode).setCoordinatorPort(coordinatorPort).setStampedeId(stampedeId.orElse(new StampedeId().setId("LOCAL_FILE"))).setVersionedTargetGraphCache(params.getVersionedTargetGraphCache()).build());
    return executor;
}
Also used : MultiSourceContentsProvider(com.facebook.buck.distributed.MultiSourceContentsProvider) StampedeId(com.facebook.buck.distributed.thrift.StampedeId) DistBuildState(com.facebook.buck.distributed.DistBuildState) Cell(com.facebook.buck.rules.Cell) ArtifactCacheFactory(com.facebook.buck.artifact_cache.ArtifactCacheFactory) DistBuildSlaveExecutor(com.facebook.buck.distributed.DistBuildSlaveExecutor)

Example 2 with DistBuildSlaveExecutor

use of com.facebook.buck.distributed.DistBuildSlaveExecutor in project buck by facebook.

the class DistBuildRunCommand method runWithoutHelp.

@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    Console console = params.getConsole();
    try (DistBuildService service = DistBuildFactory.newDistBuildService(params)) {
        Pair<BuildJobState, String> jobStateAndBuildName = getBuildJobStateAndBuildName(params.getCell().getFilesystem(), console, service);
        BuildJobState jobState = jobStateAndBuildName.getFirst();
        String buildName = jobStateAndBuildName.getSecond();
        console.getStdOut().println(String.format("BuildJob depends on a total of [%d] input deps.", jobState.getFileHashesSize()));
        try (CommandThreadManager pool = new CommandThreadManager(getClass().getName(), getConcurrencyLimit(params.getBuckConfig()))) {
            DistBuildSlaveExecutor distBuildExecutor = DistBuildFactory.createDistBuildExecutor(jobState, params, pool.getExecutor(), service, Preconditions.checkNotNull(distBuildMode), coordinatorPort, getStampedeIdOptional(), getGlobalCacheDirOptional());
            int returnCode = distBuildExecutor.buildAndReturnExitCode();
            if (returnCode == 0) {
                console.printSuccess(String.format("Successfully ran distributed build [%s] in [%d millis].", buildName, stopwatch.elapsed(TimeUnit.MILLISECONDS)));
            } else {
                console.printErrorText("Failed distributed build [%s] in [%d millis].", buildName, stopwatch.elapsed(TimeUnit.MILLISECONDS));
            }
            return returnCode;
        }
    }
}
Also used : Stopwatch(com.google.common.base.Stopwatch) Console(com.facebook.buck.util.Console) BuildJobState(com.facebook.buck.distributed.thrift.BuildJobState) DistBuildService(com.facebook.buck.distributed.DistBuildService) DistBuildSlaveExecutor(com.facebook.buck.distributed.DistBuildSlaveExecutor)

Aggregations

DistBuildSlaveExecutor (com.facebook.buck.distributed.DistBuildSlaveExecutor)2 ArtifactCacheFactory (com.facebook.buck.artifact_cache.ArtifactCacheFactory)1 DistBuildService (com.facebook.buck.distributed.DistBuildService)1 DistBuildState (com.facebook.buck.distributed.DistBuildState)1 MultiSourceContentsProvider (com.facebook.buck.distributed.MultiSourceContentsProvider)1 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)1 StampedeId (com.facebook.buck.distributed.thrift.StampedeId)1 Cell (com.facebook.buck.rules.Cell)1 Console (com.facebook.buck.util.Console)1 Stopwatch (com.google.common.base.Stopwatch)1