use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashes in project buck by facebook.
the class DistBuildService method uploadMissingFiles.
public ListenableFuture<Void> uploadMissingFiles(final List<BuildJobStateFileHashes> fileHashes, ListeningExecutorService executorService) {
List<FileInfo> requiredFiles = new ArrayList<>();
for (BuildJobStateFileHashes filesystem : fileHashes) {
if (!filesystem.isSetEntries()) {
continue;
}
for (BuildJobStateFileHashEntry file : filesystem.entries) {
if (file.isSetRootSymLink()) {
LOG.info("File with path [%s] is a symlink. Skipping upload..", file.path.getPath());
continue;
} else if (file.isIsDirectory()) {
LOG.info("Path [%s] is a directory. Skipping upload..", file.path.getPath());
continue;
} else if (file.isPathIsAbsolute()) {
LOG.info("Path [%s] is absolute. Skipping upload..", file.path.getPath());
continue;
}
// TODO(shivanker): Eventually, we won't have file contents in BuildJobState.
// Then change this code to load file contents inline (only for missing files)
FileInfo fileInfo = new FileInfo();
fileInfo.setContent(file.getContents());
fileInfo.setContentHash(file.getHashCode());
requiredFiles.add(fileInfo);
}
}
return uploadMissingFilesFromList(requiredFiles, executorService);
}
use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashes in project buck by facebook.
the class DistBuildState method createMaterializerAndPreload.
public ProjectFileHashCache createMaterializerAndPreload(ProjectFileHashCache decoratedCache, FileContentsProvider provider) throws IOException {
BuildJobStateFileHashes remoteFileHashes = fileHashes.get(decoratedCache.getFilesystem());
if (remoteFileHashes == null) {
// decorated.
return decoratedCache;
}
MaterializerProjectFileHashCache materializer = new MaterializerProjectFileHashCache(decoratedCache, remoteFileHashes, provider);
// Create all symlinks and touch all other files.
// TODO(alisdair04): remove this once action graph doesn't read from file system.
materializer.preloadAllFiles();
return materializer;
}
use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashes in project buck by facebook.
the class DistBuildFileHashesTest method cacheMaterializes.
@Test
public void cacheMaterializes() throws Exception {
SingleFileFixture f = new SingleFileFixture(tempDir);
List<BuildJobStateFileHashes> fileHashes = f.distributedBuildFileHashes.getFileHashes();
ProjectFilesystem readProjectFilesystem = new ProjectFilesystem(tempDir.newFolder("read_hashes").toPath().toRealPath());
ProjectFileHashCache mockCache = EasyMock.createMock(ProjectFileHashCache.class);
EasyMock.expect(mockCache.getFilesystem()).andReturn(readProjectFilesystem).anyTimes();
EasyMock.replay(mockCache);
ProjectFileHashCache fileHashCache = DistBuildFileHashes.createFileHashCache(mockCache, fileHashes.get(0));
assertThat(fileHashCache.willGet(readProjectFilesystem.resolve("src/A.java")), Matchers.equalTo(true));
assertThat(fileHashCache.get(readProjectFilesystem.resolve("src/A.java")), Matchers.equalTo(f.writtenHashCode));
}
use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashes in project buck by facebook.
the class DistBuildFileHashesTest method recordsFileHashes.
@Test
public void recordsFileHashes() throws Exception {
SingleFileFixture f = new SingleFileFixture(tempDir);
List<BuildJobStateFileHashes> recordedHashes = f.distributedBuildFileHashes.getFileHashes();
assertThat(recordedHashes, Matchers.hasSize(3));
BuildJobStateFileHashes rootCellHashes = getRootCellHashes(recordedHashes);
assertThat(rootCellHashes.entries, Matchers.hasSize(1));
BuildJobStateFileHashEntry fileHashEntry = rootCellHashes.entries.get(0);
// It's intentional that we hardcode the path as a string here as we expect the thrift data
// to contain unix-formated paths.
assertThat(fileHashEntry.getPath().getPath(), Matchers.equalTo("src/A.java"));
assertFalse(fileHashEntry.isPathIsAbsolute());
assertFalse(fileHashEntry.isIsDirectory());
}
use of com.facebook.buck.distributed.thrift.BuildJobStateFileHashes in project buck by facebook.
the class DistBuildFileHashesTest method cacheReadsHashesForFiles.
@Test
public void cacheReadsHashesForFiles() throws Exception {
SingleFileFixture f = new SingleFileFixture(tempDir);
List<BuildJobStateFileHashes> fileHashes = f.distributedBuildFileHashes.getFileHashes();
ProjectFilesystem readProjectFilesystem = new ProjectFilesystem(tempDir.newFolder("read_hashes").toPath().toRealPath());
ProjectFileHashCache mockCache = EasyMock.createMock(ProjectFileHashCache.class);
EasyMock.expect(mockCache.getFilesystem()).andReturn(readProjectFilesystem).anyTimes();
EasyMock.replay(mockCache);
ProjectFileHashCache fileHashCache = DistBuildFileHashes.createFileHashCache(mockCache, fileHashes.get(0));
assertThat(fileHashCache.willGet(readProjectFilesystem.resolve(f.javaSrcPath)), Matchers.equalTo(true));
assertThat(fileHashCache.get(readProjectFilesystem.resolve(f.javaSrcPath)), Matchers.equalTo(f.writtenHashCode));
}
Aggregations