當前位置: 首頁>>代碼示例>>Java>>正文


Java Builder類代碼示例

本文整理匯總了Java中com.spotify.docker.client.DefaultDockerClient.Builder的典型用法代碼示例。如果您正苦於以下問題:Java Builder類的具體用法?Java Builder怎麽用?Java Builder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Builder類屬於com.spotify.docker.client.DefaultDockerClient包,在下文中一共展示了Builder類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: providesHttpClient

import com.spotify.docker.client.DefaultDockerClient.Builder; //導入依賴的package包/類
@Provides
@Singleton
@Named(LOCAL_DOWNLOAD_HTTP_CLIENT)
public AsyncHttpClient providesHttpClient(SingularityExecutorConfiguration configuration) {
  AsyncHttpClientConfig.Builder configBldr = new AsyncHttpClientConfig.Builder();
  configBldr.setRequestTimeoutInMs((int) configuration.getLocalDownloadServiceTimeoutMillis());
  configBldr.setIdleConnectionTimeoutInMs((int) configuration.getLocalDownloadServiceTimeoutMillis());
  configBldr.addRequestFilter(new ThrottleRequestFilter(configuration.getLocalDownloadServiceMaxConnections()));

  return new AsyncHttpClient(configBldr.build());
}
 
開發者ID:HubSpot,項目名稱:Singularity,代碼行數:12,代碼來源:SingularityExecutorModule.java

示例2: providesDockerClient

import com.spotify.docker.client.DefaultDockerClient.Builder; //導入依賴的package包/類
@Provides
@Singleton
public DockerClient providesDockerClient(SingularityExecutorConfiguration configuration) {
  Builder dockerClientBuilder = DefaultDockerClient.builder()
    .uri(URI.create("unix://localhost/var/run/docker.sock"))
    .connectionPoolSize(configuration.getDockerClientConnectionPoolSize());

  if(configuration.getDockerAuthConfig().isPresent()) {
    SingularityExecutorDockerAuthConfig authConfig = configuration.getDockerAuthConfig().get();

    if(authConfig.isFromDockerConfig()) {
      try {
        dockerClientBuilder.registryAuth(RegistryAuth.fromDockerConfig().build());

      } catch(IOException e) {
        throw Throwables.propagate(e);
      }
    }
    else {
      dockerClientBuilder.registryAuth(RegistryAuth.builder()
                .email(authConfig.getEmail())
                .username(authConfig.getUsername())
                .password(authConfig.getPassword())
                .serverAddress(authConfig.getServerAddress())
                .build());
    }
  }

  return dockerClientBuilder.build();
}
 
開發者ID:HubSpot,項目名稱:Singularity,代碼行數:31,代碼來源:SingularityExecutorModule.java

示例3: ContainerManagerImpl

import com.spotify.docker.client.DefaultDockerClient.Builder; //導入依賴的package包/類
/**
 * Constructor that creates new docker client instance
 */
public ContainerManagerImpl() throws Exception {
    LOGGER.info("Deployed as \"{}\".", DEPLOY_ENV);
    Builder builder = DefaultDockerClient.fromEnv();
    builder.connectionPoolSize(5000);
    builder.connectTimeoutMillis(1000);
    dockerClient = builder.build();

    String username = System.getenv(USER_NAME_KEY);
    String email = System.getenv(USER_EMAIL_KEY);
    String password = System.getenv(USER_PASSWORD_KEY);
    String registryUrl = System.getenv().containsKey(REGISTRY_URL_KEY) ? System.getenv(REGISTRY_URL_KEY)
            : "git.project-hobbit.eu:4567";
    if ((username != null) && (password != null)) {
        gitlabAuth = RegistryAuth.builder().serverAddress(registryUrl).username(username).password(password)
                .email(email).build();
    } else {
        LOGGER.warn(
                "Couldn't load a username ({}), email ({}) and a security token ({}) to access private repositories. This platform won't be able to pull protected or private images.",
                USER_NAME_KEY, USER_EMAIL_KEY, USER_PASSWORD_KEY);
        gitlabAuth = null;
    }
    gelfAddress = System.getenv(LOGGING_GELF_ADDRESS_KEY);
    if (gelfAddress == null) {
        LOGGER.info(
                "Didn't find a gelf address ({}). Containers created by this platform will use the default logging.",
                LOGGING_GELF_ADDRESS_KEY);
    }
    // try to find hobbit network in existing ones
    List<Network> networks = dockerClient.listNetworks();
    String hobbitNetwork = null;
    for (Network net : networks) {
        if (net.name().equals(HOBBIT_DOCKER_NETWORK)) {
            hobbitNetwork = net.id();
            break;
        }
    }
    // if not found - create new one
    if (hobbitNetwork == null) {
        final NetworkConfig networkConfig = NetworkConfig.builder().name(HOBBIT_DOCKER_NETWORK).build();
        dockerClient.createNetwork(networkConfig);
    }
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:46,代碼來源:ContainerManagerImpl.java


注:本文中的com.spotify.docker.client.DefaultDockerClient.Builder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。