本文整理汇总了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());
}
示例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();
}
示例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);
}
}