use of com.facebook.buck.util.cache.ProjectFileHashCache in project buck by facebook.
the class DistBuildSlaveExecutor method createStackOfDefaultFileHashCache.
private StackedFileHashCache createStackOfDefaultFileHashCache() throws IOException {
ImmutableList.Builder<ProjectFileHashCache> allCachesBuilder = ImmutableList.builder();
Cell rootCell = args.getState().getRootCell();
// 1. Add all cells (including the root cell).
for (Path cellPath : rootCell.getKnownRoots()) {
Cell cell = rootCell.getCell(cellPath);
allCachesBuilder.add(DefaultFileHashCache.createDefaultFileHashCache(cell.getFilesystem()));
}
// 2. Add the Operating System roots.
allCachesBuilder.addAll(DefaultFileHashCache.createOsRootDirectoriesCaches());
return new StackedFileHashCache(allCachesBuilder.build());
}
use of com.facebook.buck.util.cache.ProjectFileHashCache in project buck by facebook.
the class DistBuildFileHashesIntegrationTest method createDistBuildFileHashes.
private DistBuildFileHashes createDistBuildFileHashes(TargetGraph targetGraph, Cell rootCell) throws IOException {
ActionGraphCache cache = new ActionGraphCache(new BroadcastEventListener());
ActionGraphAndResolver actionGraphAndResolver = cache.getActionGraph(BuckEventBusFactory.newInstance(), true, false, targetGraph, KEY_SEED);
BuildRuleResolver ruleResolver = actionGraphAndResolver.getResolver();
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder);
DistBuildCellIndexer cellIndexer = new DistBuildCellIndexer(rootCell);
ImmutableList.Builder<ProjectFileHashCache> allCaches = ImmutableList.builder();
allCaches.add(DefaultFileHashCache.createDefaultFileHashCache(rootCell.getFilesystem()));
for (Path cellPath : rootCell.getKnownRoots()) {
Cell cell = rootCell.getCell(cellPath);
allCaches.add(DefaultFileHashCache.createDefaultFileHashCache(cell.getFilesystem()));
}
allCaches.addAll(DefaultFileHashCache.createOsRootDirectoriesCaches());
StackedFileHashCache stackedCache = new StackedFileHashCache(allCaches.build());
return new DistBuildFileHashes(actionGraphAndResolver.getActionGraph(), sourcePathResolver, ruleFinder, stackedCache, cellIndexer, MoreExecutors.newDirectExecutorService(), /* keySeed */
KEY_SEED, rootCell);
}
use of com.facebook.buck.util.cache.ProjectFileHashCache 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.util.cache.ProjectFileHashCache 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));
}
use of com.facebook.buck.util.cache.ProjectFileHashCache in project buck by facebook.
the class DistBuildFileHashesTest method readsHashesForArchiveMembers.
@Test
public void readsHashesForArchiveMembers() throws Exception {
try (ArchiveFilesFixture f = ArchiveFilesFixture.create(archiveTempDir)) {
List<BuildJobStateFileHashes> recordedHashes = 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, recordedHashes.get(0));
ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(readProjectFilesystem.resolve(f.archivePath), f.archiveMemberPath);
assertThat(fileHashCache.willGet(archiveMemberPath), Matchers.is(true));
assertThat(fileHashCache.get(archiveMemberPath), Matchers.is(f.archiveMemberHash));
}
}
Aggregations