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;
}
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;
}
}
}
Aggregations