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