use of com.facebook.buck.distributed.thrift.FinishedBuildingResponse in project buck by facebook.
the class ThriftCoordinatorClient method finishedBuilding.
public FinishedBuildingResponse finishedBuilding(String minionId, int minionExitCode) throws IOException {
LOG.debug(String.format("Minion [%s] is reporting that it finished building.", minionId));
Preconditions.checkNotNull(client, "Client was not started.");
FinishedBuildingRequest request = new FinishedBuildingRequest().setStampedeId(stampedeId).setMinionId(minionId).setBuildExitCode(minionExitCode);
try {
FinishedBuildingResponse response = client.finishedBuilding(request);
return response;
} catch (TException e) {
throw new ThriftException(e);
}
}
use of com.facebook.buck.distributed.thrift.FinishedBuildingResponse in project buck by facebook.
the class ThriftCoordinatorServerIntegrationTest method testThriftServerWithDiamondGraph.
@Test
public void testThriftServerWithDiamondGraph() throws IOException, NoSuchBuildTargetException {
int port = findRandomOpenPortOnAllLocalInterfaces();
BuildTargetsQueue diamondQueue = BuildTargetsQueueTest.createDiamondDependencyQueue();
try (ThriftCoordinatorServer server = new ThriftCoordinatorServer(port, diamondQueue, STAMPEDE_ID);
ThriftCoordinatorClient client = new ThriftCoordinatorClient("localhost", port, STAMPEDE_ID)) {
server.start();
client.start();
GetTargetsToBuildResponse targetsToBuildResponse = client.getTargetsToBuild(MINION_ID);
Assert.assertEquals(GetTargetsToBuildAction.BUILD_TARGETS, targetsToBuildResponse.getAction());
Assert.assertEquals(1, targetsToBuildResponse.getBuildTargetsSize());
FinishedBuildingResponse finishedBuildingResponse = client.finishedBuilding(MINION_ID, 0);
Assert.assertTrue(finishedBuildingResponse.continueBuilding);
targetsToBuildResponse = client.getTargetsToBuild(MINION_ID);
Assert.assertEquals(GetTargetsToBuildAction.BUILD_TARGETS, targetsToBuildResponse.getAction());
Assert.assertEquals(2, targetsToBuildResponse.getBuildTargetsSize());
}
}
use of com.facebook.buck.distributed.thrift.FinishedBuildingResponse in project buck by facebook.
the class MinionModeRunner method runAndReturnExitCode.
@Override
public int runAndReturnExitCode() throws IOException, InterruptedException {
try (ThriftCoordinatorClient client = new ThriftCoordinatorClient(coordinatorAddress, coordinatorPort, stampedeId)) {
client.start();
final String minionId = generateNewMinionId();
while (true) {
GetTargetsToBuildResponse response = client.getTargetsToBuild(minionId);
switch(response.getAction()) {
case BUILD_TARGETS:
List<String> targetsToBuild = Lists.newArrayList(response.getBuildTargets());
LOG.debug(String.format("Minion [%s] is about to build [%d] targets: [%s]", minionId, targetsToBuild.size(), Joiner.on(", ").join(targetsToBuild)));
int buildExitCode = builder.buildLocallyAndReturnExitCode(targetsToBuild);
LOG.debug(String.format("Minion [%s] finished with exit code [%d].", minionId, buildExitCode));
FinishedBuildingResponse finishedResponse = client.finishedBuilding(minionId, buildExitCode);
if (!finishedResponse.isContinueBuilding()) {
return 0;
}
break;
case RETRY_LATER:
try {
Thread.sleep(RETRY_BACKOFF_MILLIS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
break;
case CLOSE_CLIENT:
return 0;
case UNKNOWN:
default:
throw new RuntimeException(String.format("CoordinatorClient received unexpected action [%s].", response.getAction()));
}
}
}
}
Aggregations