Search in sources :

Example 1 with FinishedBuildingResponse

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);
    }
}
Also used : FinishedBuildingResponse(com.facebook.buck.distributed.thrift.FinishedBuildingResponse) TException(org.apache.thrift.TException) ThriftException(com.facebook.buck.slb.ThriftException) FinishedBuildingRequest(com.facebook.buck.distributed.thrift.FinishedBuildingRequest)

Example 2 with FinishedBuildingResponse

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());
    }
}
Also used : FinishedBuildingResponse(com.facebook.buck.distributed.thrift.FinishedBuildingResponse) GetTargetsToBuildResponse(com.facebook.buck.distributed.thrift.GetTargetsToBuildResponse) Test(org.junit.Test)

Example 3 with FinishedBuildingResponse

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()));
            }
        }
    }
}
Also used : FinishedBuildingResponse(com.facebook.buck.distributed.thrift.FinishedBuildingResponse) GetTargetsToBuildResponse(com.facebook.buck.distributed.thrift.GetTargetsToBuildResponse)

Aggregations

FinishedBuildingResponse (com.facebook.buck.distributed.thrift.FinishedBuildingResponse)3 GetTargetsToBuildResponse (com.facebook.buck.distributed.thrift.GetTargetsToBuildResponse)2 FinishedBuildingRequest (com.facebook.buck.distributed.thrift.FinishedBuildingRequest)1 ThriftException (com.facebook.buck.slb.ThriftException)1 TException (org.apache.thrift.TException)1 Test (org.junit.Test)1