use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry in project buck by facebook.
the class RecordingProjectFileHashCache method record.
private synchronized void record(Path relPath, Optional<String> memRelPath, HashCode hashCode, List<PathWithUnixSeparators> children) {
LOG.verbose("Recording path: [%s]", projectFilesystem.resolve(relPath).toAbsolutePath());
Optional<Path> pathRelativeToProjectRoot = projectFilesystem.getPathRelativeToProjectRoot(relPath);
BuildJobStateFileHashEntry fileHashEntry = new BuildJobStateFileHashEntry();
boolean pathIsAbsolute = allRecordedPathsAreAbsolute;
fileHashEntry.setPathIsAbsolute(pathIsAbsolute);
Path entryKey = pathIsAbsolute ? projectFilesystem.resolve(relPath).toAbsolutePath() : pathRelativeToProjectRoot.get();
boolean isDirectory = projectFilesystem.isDirectory(relPath);
Path realPath = findRealPath(relPath);
boolean realPathInsideProject = projectFilesystem.getPathRelativeToProjectRoot(realPath).isPresent();
// meta-data about this before it is re-materialized. See findSymlinkRoot() for more details.
if (!realPathInsideProject && !pathIsAbsolute) {
Pair<Path, Path> symLinkRootAndTarget = findSymlinkRoot(projectFilesystem.resolve(relPath).toAbsolutePath());
Path symLinkRoot = projectFilesystem.getPathRelativeToProjectRoot(symLinkRootAndTarget.getFirst()).get();
fileHashEntry.setRootSymLink(new PathWithUnixSeparators(MorePaths.pathWithUnixSeparators(symLinkRoot)));
fileHashEntry.setRootSymLinkTarget(new PathWithUnixSeparators(MorePaths.pathWithUnixSeparators(symLinkRootAndTarget.getSecond().toAbsolutePath())));
}
fileHashEntry.setIsDirectory(isDirectory);
fileHashEntry.setHashCode(hashCode.toString());
fileHashEntry.setPath(new PathWithUnixSeparators(MorePaths.pathWithUnixSeparators(entryKey)));
if (memRelPath.isPresent()) {
fileHashEntry.setArchiveMemberPath(memRelPath.get().toString());
}
if (!isDirectory && !pathIsAbsolute && realPathInsideProject) {
try {
// TODO(shivanker, ruibm): Don't read everything in memory right away.
Path absPath = projectFilesystem.resolve(relPath).toAbsolutePath();
fileHashEntry.setContents(Files.readAllBytes(absPath));
fileHashEntry.setIsExecutable(absPath.toFile().canExecute());
} catch (IOException e) {
throw new RuntimeException(e);
}
} else if (isDirectory && !pathIsAbsolute && realPathInsideProject) {
fileHashEntry.setChildren(children);
}
fileHashEntry.setMaterializeDuringPreloading(materializeCurrentFileDuringPreloading);
// TODO(alisdair04): handling for symlink to internal directory (including infinite loop).
remoteFileHashes.addEntry(fileHashEntry);
}
use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry 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;
});
}
Aggregations