Search in sources :

Example 1 with EdenClient

use of com.facebook.buck.eden.EdenClient 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)

Example 2 with EdenClient

use of com.facebook.buck.eden.EdenClient in project buck by facebook.

the class ProjectFilesystemDelegateFactory method newInstance.

/**
   * Must always create a new delegate for the specified {@code root}.
   */
public static ProjectFilesystemDelegate newInstance(Path root, String hgCmd, AutoSparseConfig autoSparseConfig) {
    Optional<EdenClient> client = tryToCreateEdenClient();
    if (client.isPresent()) {
        try {
            EdenMount mount = client.get().getMountFor(root);
            if (mount != null) {
                return new EdenProjectFilesystemDelegate(mount);
            }
        } catch (TException | EdenError e) {
            // If Eden is running but root is not a mount point, Eden getMountFor() should just return
            // null rather than throw an error.
            LOG.error(e, "Failed to find Eden client for %s.", root);
        }
    }
    if (autoSparseConfig.enabled()) {
        // We can't access BuckConfig because that class requires a
        // ProjectFileSystem, which we are in the process of building
        // Access the required info from the Config instead
        HgCmdLineInterface hgCmdLine = new HgCmdLineInterface(new PrintStreamProcessExecutorFactory(), root, hgCmd, ImmutableMap.of());
        AutoSparseState autoSparseState = AbstractAutoSparseFactory.getAutoSparseState(root, hgCmdLine, autoSparseConfig);
        if (autoSparseState != null) {
            LOG.debug("Autosparse enabled, using AutoSparseProjectFilesystemDelegate");
            return new AutoSparseProjectFilesystemDelegate(autoSparseState, root);
        }
    }
    // No Eden or Mercurial info available, use the default
    return new DefaultProjectFilesystemDelegate(root);
}
Also used : TException(com.facebook.thrift.TException) AutoSparseState(com.facebook.buck.util.autosparse.AutoSparseState) EdenClient(com.facebook.buck.eden.EdenClient) EdenMount(com.facebook.buck.eden.EdenMount) EdenError(com.facebook.eden.thrift.EdenError) PrintStreamProcessExecutorFactory(com.facebook.buck.util.PrintStreamProcessExecutorFactory) EdenProjectFilesystemDelegate(com.facebook.buck.eden.EdenProjectFilesystemDelegate) HgCmdLineInterface(com.facebook.buck.util.versioncontrol.HgCmdLineInterface) AutoSparseProjectFilesystemDelegate(com.facebook.buck.util.autosparse.AutoSparseProjectFilesystemDelegate)

Example 3 with EdenClient

use of com.facebook.buck.eden.EdenClient in project buck by facebook.

the class Sha1Command method run.

@Override
public int run() throws EdenError, IOException, TException {
    Optional<EdenClient> client = EdenClient.newInstance();
    if (!client.isPresent()) {
        System.err.println("Could not connect to Eden");
        return 1;
    }
    Path mountPoint = Paths.get(this.mountPoint);
    EdenMount mount = client.get().getMountFor(mountPoint);
    for (String path : paths) {
        Path entry = mountPoint.relativize(Paths.get(path));
        Sha1HashCode sha1 = mount.getSha1(entry);
        System.out.printf("%s %s\n", entry, sha1);
    }
    return 0;
}
Also used : Path(java.nio.file.Path) EdenClient(com.facebook.buck.eden.EdenClient) EdenMount(com.facebook.buck.eden.EdenMount) Sha1HashCode(com.facebook.buck.util.sha1.Sha1HashCode)

Aggregations

EdenClient (com.facebook.buck.eden.EdenClient)3 EdenMount (com.facebook.buck.eden.EdenMount)3 Path (java.nio.file.Path)2 EdenProjectFilesystemDelegate (com.facebook.buck.eden.EdenProjectFilesystemDelegate)1 PrintStreamProcessExecutorFactory (com.facebook.buck.util.PrintStreamProcessExecutorFactory)1 AutoSparseProjectFilesystemDelegate (com.facebook.buck.util.autosparse.AutoSparseProjectFilesystemDelegate)1 AutoSparseState (com.facebook.buck.util.autosparse.AutoSparseState)1 Sha1HashCode (com.facebook.buck.util.sha1.Sha1HashCode)1 HgCmdLineInterface (com.facebook.buck.util.versioncontrol.HgCmdLineInterface)1 EdenError (com.facebook.eden.thrift.EdenError)1 MountInfo (com.facebook.eden.thrift.MountInfo)1 TException (com.facebook.thrift.TException)1