Пример #1
0
  HeliosSoloDeployment(final Builder builder) {
    final String username = Optional.fromNullable(builder.heliosUsername).or(randomString());

    this.dockerClient = checkNotNull(builder.dockerClient, "dockerClient");
    this.dockerHost = Optional.fromNullable(builder.dockerHost).or(DockerHost.fromEnv());
    this.containerDockerHost =
        Optional.fromNullable(builder.containerDockerHost).or(containerDockerHostFromEnv());
    this.namespace = Optional.fromNullable(builder.namespace).or(randomString());
    this.env = containerEnv();
    this.binds = containerBinds();

    final String heliosHost;
    final String heliosPort;
    // TODO(negz): Determine and propagate NetworkManager DNS servers?
    try {
      assertDockerReachableFromContainer();
      if (dockerHost.address().equals("localhost") || dockerHost.address().equals("127.0.0.1")) {
        heliosHost = containerGateway();
      } else {
        heliosHost = dockerHost.address();
      }
      this.heliosContainerId = deploySolo(heliosHost);
      heliosPort = getHostPort(this.heliosContainerId, HELIOS_MASTER_PORT);
    } catch (HeliosDeploymentException e) {
      throw new AssertionError("Unable to deploy helios-solo container.", e);
    }

    // Running the String host:port through HostAndPort does some validation for us.
    this.heliosClient =
        HeliosClient.newBuilder()
            .setUser(username)
            .setEndpoints(
                "http://" + HostAndPort.fromString(dockerHost.address() + ":" + heliosPort))
            .build();
  }
Пример #2
0
 protected HeliosClient client(final String user, final String endpoint) {
   final HeliosClient client =
       HeliosClient.newBuilder()
           .setUser(user)
           .setEndpoints(singletonList(URI.create(endpoint)))
           .build();
   clients.add(client);
   return client;
 }
Пример #3
0
 /**
  * Create a new helios client as a specific user, connecting to a helios master cluster in a
  * specific domain.
  *
  * @param domain The target domain.
  * @param user The user to identify as.
  * @return A helios client.
  */
 public static HeliosClient create(final String domain, final String user) {
   return HeliosClient.newBuilder().setDomain(domain).setUser(user).build();
 }