Search in sources :

Example 1 with MountInfo

use of com.facebook.eden.thrift.MountInfo in project buck by facebook.

the class EdenMountTest method getSha1DelegatesToThriftClient.

@Test
public void getSha1DelegatesToThriftClient() throws EdenError, TException {
    List<MountInfo> mountInfos = ImmutableList.of(new MountInfo("/home/mbolin/src/buck", /* edenClientPath */
    ""));
    EdenService.Client thriftClient = createMock(EdenService.Client.class);
    expect(thriftClient.listMounts()).andReturn(mountInfos);
    FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
    Path entry = fs.getPath("LICENSE");
    HashCode hash = HashCode.fromString("2b8b815229aa8a61e483fb4ba0588b8b6c491890");
    SHA1Result sha1Result = new SHA1Result();
    sha1Result.setSha1(hash.asBytes());
    expect(thriftClient.getSHA1("/home/mbolin/src/buck", ImmutableList.of("LICENSE"))).andReturn(ImmutableList.of(sha1Result));
    replay(thriftClient);
    EdenClient client = new EdenClient(thriftClient);
    Path pathToBuck = fs.getPath("/home/mbolin/src/buck");
    EdenMount mount = client.getMountFor(pathToBuck);
    assertNotNull("Should find mount for path.", mount);
    assertEquals(Sha1HashCode.fromHashCode(hash), mount.getSha1(entry));
    verify(thriftClient);
}
Also used : Path(java.nio.file.Path) HashCode(com.google.common.hash.HashCode) Sha1HashCode(com.facebook.buck.util.sha1.Sha1HashCode) FileSystem(java.nio.file.FileSystem) MountInfo(com.facebook.eden.thrift.MountInfo) EdenService(com.facebook.eden.thrift.EdenService) SHA1Result(com.facebook.eden.thrift.SHA1Result) Test(org.junit.Test)

Example 2 with MountInfo

use of com.facebook.eden.thrift.MountInfo in project buck by facebook.

the class MountsCommand method run.

@Override
public int run() throws EdenError, IOException, TException {
    Optional<EdenClient> clientOptional = EdenClient.newInstance();
    if (!clientOptional.isPresent()) {
        System.err.println("Could not connect to Eden");
        return 1;
    }
    EdenClient client = clientOptional.get();
    List<MountInfo> mountInfos = client.getMountInfos();
    System.out.printf("Number of mounts: %d\n", mountInfos.size());
    for (MountInfo info : mountInfos) {
        System.out.println(info.mountPoint);
        EdenMount mount = client.getMountFor(Paths.get(info.mountPoint));
        List<Path> bindMounts = mount.getBindMounts();
        System.out.printf("    Number of bind mounts: %d\n", bindMounts.size());
        for (Path bindMount : bindMounts) {
            System.out.printf("    %s\n", bindMount);
        }
    }
    return 0;
}
Also used : Path(java.nio.file.Path) EdenClient(com.facebook.buck.eden.EdenClient) EdenMount(com.facebook.buck.eden.EdenMount) MountInfo(com.facebook.eden.thrift.MountInfo)

Aggregations

MountInfo (com.facebook.eden.thrift.MountInfo)2 Path (java.nio.file.Path)2 EdenClient (com.facebook.buck.eden.EdenClient)1 EdenMount (com.facebook.buck.eden.EdenMount)1 Sha1HashCode (com.facebook.buck.util.sha1.Sha1HashCode)1 EdenService (com.facebook.eden.thrift.EdenService)1 SHA1Result (com.facebook.eden.thrift.SHA1Result)1 HashCode (com.google.common.hash.HashCode)1 FileSystem (java.nio.file.FileSystem)1 Test (org.junit.Test)1