use of com.facebook.buck.distributed.thrift.GetTargetsToBuildResponse in project buck by facebook.
the class ThriftCoordinatorServerIntegrationTest method testMakingSimpleRequest.
@Test
public void testMakingSimpleRequest() throws IOException {
int port = findRandomOpenPortOnAllLocalInterfaces();
try (ThriftCoordinatorServer server = new ThriftCoordinatorServer(port, BuildTargetsQueue.newEmptyQueue(), STAMPEDE_ID);
ThriftCoordinatorClient client = new ThriftCoordinatorClient("localhost", port, STAMPEDE_ID)) {
server.start();
client.start();
GetTargetsToBuildResponse response = client.getTargetsToBuild(MINION_ID);
Assert.assertNotNull(response);
Assert.assertEquals(GetTargetsToBuildAction.CLOSE_CLIENT, response.getAction());
}
}
use of com.facebook.buck.distributed.thrift.GetTargetsToBuildResponse 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.GetTargetsToBuildResponse 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()));
}
}
}
}
use of com.facebook.buck.distributed.thrift.GetTargetsToBuildResponse in project buck by facebook.
the class ThriftCoordinatorClient method getTargetsToBuild.
public GetTargetsToBuildResponse getTargetsToBuild(String minionId) throws IOException {
LOG.debug(String.format("Minion [%s] is requesting targets to build.", minionId));
Preconditions.checkNotNull(client, "Client was not started.");
GetTargetsToBuildRequest request = new GetTargetsToBuildRequest().setMinionId(minionId).setStampedeId(stampedeId);
try {
GetTargetsToBuildResponse response = client.getTargetsToBuild(request);
return response;
} catch (TException e) {
throw new ThriftException(e);
}
}
Aggregations