Search in sources :

Example 21 with FrontendRequest

use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.

the class DistBuildService method uploadTargetGraph.

public ListenableFuture<Void> uploadTargetGraph(final BuildJobState buildJobStateArg, final StampedeId stampedeId, ListeningExecutorService executorService) {
    // TODO(shivanker): We shouldn't be doing this. Fix after we stop reading all files into memory.
    final BuildJobState buildJobState = buildJobStateArg.deepCopy();
    return executorService.submit(() -> {
        // Get rid of file contents from buildJobState
        for (BuildJobStateFileHashes cell : buildJobState.getFileHashes()) {
            if (!cell.isSetEntries()) {
                continue;
            }
            for (BuildJobStateFileHashEntry file : cell.getEntries()) {
                file.unsetContents();
            }
        }
        // Now serialize and send the whole buildJobState
        StoreBuildGraphRequest storeBuildGraphRequest = new StoreBuildGraphRequest();
        storeBuildGraphRequest.setStampedeId(stampedeId);
        storeBuildGraphRequest.setBuildGraph(BuildJobStateSerializer.serialize(buildJobState));
        FrontendRequest request = new FrontendRequest();
        request.setType(FrontendRequestType.STORE_BUILD_GRAPH);
        request.setStoreBuildGraphRequest(storeBuildGraphRequest);
        makeRequestChecked(request);
        // No response expected.
        return null;
    });
}
Also used : BuildJobStateFileHashEntry(com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry) BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes) StoreBuildGraphRequest(com.facebook.buck.distributed.thrift.StoreBuildGraphRequest) BuildJobState(com.facebook.buck.distributed.thrift.BuildJobState) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest)

Example 22 with FrontendRequest

use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.

the class DistBuildService method createBuild.

public BuildJob createBuild() throws IOException {
    // Tell server to create the build and get the build id.
    CreateBuildRequest createTimeRequest = new CreateBuildRequest();
    createTimeRequest.setCreateTimestampMillis(System.currentTimeMillis());
    FrontendRequest request = new FrontendRequest();
    request.setType(FrontendRequestType.CREATE_BUILD);
    request.setCreateBuildRequest(createTimeRequest);
    FrontendResponse response = makeRequestChecked(request);
    return response.getCreateBuildResponse().getBuildJob();
}
Also used : FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) CreateBuildRequest(com.facebook.buck.distributed.thrift.CreateBuildRequest)

Example 23 with FrontendRequest

use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.

the class DistBuildService method fetchBuildJobState.

public BuildJobState fetchBuildJobState(StampedeId stampedeId) throws IOException {
    FrontendRequest request = createFetchBuildGraphRequest(stampedeId);
    FrontendResponse response = makeRequestChecked(request);
    Preconditions.checkState(response.isSetFetchBuildGraphResponse());
    Preconditions.checkState(response.getFetchBuildGraphResponse().isSetBuildGraph());
    Preconditions.checkState(response.getFetchBuildGraphResponse().getBuildGraph().length > 0);
    return BuildJobStateSerializer.deserialize(response.getFetchBuildGraphResponse().getBuildGraph());
}
Also used : FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest)

Example 24 with FrontendRequest

use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.

the class DistBuildService method fetchSlaveLogLines.

public MultiGetBuildSlaveRealTimeLogsResponse fetchSlaveLogLines(final StampedeId stampedeId, final List<LogLineBatchRequest> logLineRequests) throws IOException {
    MultiGetBuildSlaveRealTimeLogsRequest getLogLinesRequest = new MultiGetBuildSlaveRealTimeLogsRequest();
    getLogLinesRequest.setStampedeId(stampedeId);
    getLogLinesRequest.setBatches(logLineRequests);
    FrontendRequest request = new FrontendRequest();
    request.setType(FrontendRequestType.GET_BUILD_SLAVE_REAL_TIME_LOGS);
    request.setMultiGetBuildSlaveRealTimeLogsRequest(getLogLinesRequest);
    FrontendResponse response = makeRequestChecked(request);
    return response.getMultiGetBuildSlaveRealTimeLogsResponse();
}
Also used : MultiGetBuildSlaveRealTimeLogsRequest(com.facebook.buck.distributed.thrift.MultiGetBuildSlaveRealTimeLogsRequest) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest)

Example 25 with FrontendRequest

use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.

the class DistBuildService method uploadMissingFilesFromList.

private ListenableFuture<Void> uploadMissingFilesFromList(final List<FileInfo> fileList, ListeningExecutorService executorService) {
    return executorService.submit(() -> {
        Map<String, FileInfo> sha1ToFileInfo = new HashMap<>();
        for (FileInfo file : fileList) {
            sha1ToFileInfo.put(file.getContentHash(), file);
        }
        List<String> contentHashes = ImmutableList.copyOf(sha1ToFileInfo.keySet());
        CASContainsRequest containsReq = new CASContainsRequest();
        containsReq.setContentSha1s(contentHashes);
        FrontendRequest request = new FrontendRequest();
        request.setType(FrontendRequestType.CAS_CONTAINS);
        request.setCasContainsRequest(containsReq);
        FrontendResponse response = makeRequestChecked(request);
        Preconditions.checkState(response.getCasContainsResponse().exists.size() == contentHashes.size());
        List<Boolean> isPresent = response.getCasContainsResponse().exists;
        List<FileInfo> filesToBeUploaded = new LinkedList<>();
        for (int i = 0; i < isPresent.size(); ++i) {
            if (isPresent.get(i)) {
                continue;
            }
            filesToBeUploaded.add(sha1ToFileInfo.get(contentHashes.get(i)));
        }
        LOG.info("%d out of %d files already exist in the cache. Uploading %d files..", sha1ToFileInfo.size() - filesToBeUploaded.size(), sha1ToFileInfo.size(), filesToBeUploaded.size());
        request = new FrontendRequest();
        StoreLocalChangesRequest storeReq = new StoreLocalChangesRequest();
        storeReq.setFiles(filesToBeUploaded);
        request.setType(FrontendRequestType.STORE_LOCAL_CHANGES);
        request.setStoreLocalChangesRequest(storeReq);
        makeRequestChecked(request);
        // No response expected.
        return null;
    });
}
Also used : CASContainsRequest(com.facebook.buck.distributed.thrift.CASContainsRequest) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList) FileInfo(com.facebook.buck.distributed.thrift.FileInfo) StoreLocalChangesRequest(com.facebook.buck.distributed.thrift.StoreLocalChangesRequest) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest)

Aggregations

FrontendRequest (com.facebook.buck.distributed.thrift.FrontendRequest)25 FrontendResponse (com.facebook.buck.distributed.thrift.FrontendResponse)18 Test (org.junit.Test)9 BuildJob (com.facebook.buck.distributed.thrift.BuildJob)5 StampedeId (com.facebook.buck.distributed.thrift.StampedeId)5 IOException (java.io.IOException)4 BuildJobStateFileHashes (com.facebook.buck.distributed.thrift.BuildJobStateFileHashes)3 Announcement (com.facebook.buck.distributed.thrift.Announcement)2 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)2 BuildJobStateFileHashEntry (com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry)2 BuildStatusRequest (com.facebook.buck.distributed.thrift.BuildStatusRequest)2 FileInfo (com.facebook.buck.distributed.thrift.FileInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ArrayList (java.util.ArrayList)2 BuckConfig (com.facebook.buck.cli.BuckConfig)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 FrontendService (com.facebook.buck.distributed.FrontendService)1 AnnouncementRequest (com.facebook.buck.distributed.thrift.AnnouncementRequest)1 AnnouncementResponse (com.facebook.buck.distributed.thrift.AnnouncementResponse)1 BuildJobStateTargetGraph (com.facebook.buck.distributed.thrift.BuildJobStateTargetGraph)1