Search in sources :

Example 1 with BuildJobStateFileHashes

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);
}
Also used : BuildJobStateFileHashEntry(com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry) BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes) FileInfo(com.facebook.buck.distributed.thrift.FileInfo) ArrayList(java.util.ArrayList)

Example 2 with BuildJobStateFileHashes

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;
}
Also used : BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes)

Example 3 with BuildJobStateFileHashes

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));
}
Also used : BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes) ProjectFileHashCache(com.facebook.buck.util.cache.ProjectFileHashCache) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 4 with BuildJobStateFileHashes

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());
}
Also used : BuildJobStateFileHashEntry(com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry) BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes) Test(org.junit.Test)

Example 5 with BuildJobStateFileHashes

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));
}
Also used : BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes) ProjectFileHashCache(com.facebook.buck.util.cache.ProjectFileHashCache) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Aggregations

BuildJobStateFileHashes (com.facebook.buck.distributed.thrift.BuildJobStateFileHashes)21 Test (org.junit.Test)14 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)12 BuildJobStateFileHashEntry (com.facebook.buck.distributed.thrift.BuildJobStateFileHashEntry)11 ProjectFileHashCache (com.facebook.buck.util.cache.ProjectFileHashCache)9 Path (java.nio.file.Path)9 ArchiveMemberPath (com.facebook.buck.io.ArchiveMemberPath)6 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)4 FrontendRequest (com.facebook.buck.distributed.thrift.FrontendRequest)3 FakeProjectFileHashCache (com.facebook.buck.testutil.FakeProjectFileHashCache)3 ArrayList (java.util.ArrayList)3 BuckConfig (com.facebook.buck.cli.BuckConfig)2 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)2 FrontendResponse (com.facebook.buck.distributed.thrift.FrontendResponse)2 BroadcastEventListener (com.facebook.buck.event.listener.BroadcastEventListener)2 Parser (com.facebook.buck.parser.Parser)2 ParserConfig (com.facebook.buck.parser.ParserConfig)2 ArchiveMemberSourcePath (com.facebook.buck.rules.ArchiveMemberSourcePath)2 Cell (com.facebook.buck.rules.Cell)2 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)2