本文整理汇总了Java中com.github.dockerjava.api.command.DockerCmdExecFactory类的典型用法代码示例。如果您正苦于以下问题:Java DockerCmdExecFactory类的具体用法?Java DockerCmdExecFactory怎么用?Java DockerCmdExecFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DockerCmdExecFactory类属于com.github.dockerjava.api.command包,在下文中一共展示了DockerCmdExecFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupDockerClient
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
private void setupDockerClient() throws
InvalidCredentialsException {
if (dockerClient != null) {
return;
}
final DockerClientConfig config = createClientConfig();
final DockerCmdExecFactory dockerCmdExecFactory = new JerseyDockerCmdExecFactory();
dockerClient = DockerClientBuilder.getInstance(config)
.withDockerCmdExecFactory(dockerCmdExecFactory)
.build();
// Check if client was successfully created
final AuthResponse response = dockerClient.authCmd().exec();
if (!response.getStatus().equalsIgnoreCase("Login Succeeded")) {
throw new InvalidCredentialsException("Could not create DockerClient");
}
}
示例2: createDockerClient
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
private static DockerClient createDockerClient(String dockerUrl, String dockerVersion, String dockerCertPath,
AuthConfig authConfig) {
// TODO JENKINS-26512
SSLConfig dummySSLConf = (new SSLConfig() {
public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException,
NoSuchAlgorithmException, KeyStoreException {
return null;
}
});
if (dockerCertPath != null) {
dummySSLConf = new LocalDirectorySSLConfig(dockerCertPath);
}
DefaultDockerClientConfig.Builder configBuilder = new DefaultDockerClientConfig.Builder().withDockerHost(dockerUrl)
.withApiVersion(dockerVersion).withCustomSslConfig(dummySSLConf);
if (authConfig != null) {
configBuilder.withRegistryUsername(authConfig.getUsername())
.withRegistryEmail(authConfig.getEmail())
.withRegistryPassword(authConfig.getPassword())
.withRegistryUrl(authConfig.getRegistryAddress());
}
// using jaxrs/jersey implementation here (netty impl is also available)
DockerCmdExecFactory dockerCmdExecFactory = new DockerCmdExecFactoryImpl()
.withConnectTimeout(1000)
.withMaxTotalConnections(1)
.withMaxPerRouteConnections(1);
return DockerClientBuilder.getInstance(configBuilder).withDockerCmdExecFactory(dockerCmdExecFactory).build();
}
示例3: testConcurrentClientBuilding
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
@Test
public void testConcurrentClientBuilding() throws Exception {
// we use it to check instance uniqueness
final Set<DockerCmdExecFactory> instances = Collections.synchronizedSet(new HashSet<DockerCmdExecFactory>());
Runnable runnable = new Runnable() {
@Override
public void run() {
DockerCmdExecFactory factory = DockerClientBuilder.getDefaultDockerCmdExecFactory();
// factory created
assertNotNull(factory);
// and is unique
assertFalse(instances.contains(factory));
instances.add(factory);
}
};
parallel(AMOUNT, runnable);
// set contains all required unique instances
assertEquals(instances.size(), AMOUNT);
}
示例4: get
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
@SuppressWarnings("resource")
@Override
public DockerCmdExecFactory get() {
JerseyDockerCmdExecFactory factory = new JerseyDockerCmdExecFactory()
.withMaxTotalConnections(config.getMaxTotalConnections())
.withMaxPerRouteConnections(config.getMaxPerRouteConnections())
.withClientRequestFilters(config.getClientRequestFilters())
.withClientResponseFilters(config.getClientResponseFilters());
config.getReadTimeout().ifPresent(value -> factory.withReadTimeout(value));
config.getConnectTimeout().ifPresent(value -> factory.withConnectTimeout(value));
config.getConnectionRequestTimeout().ifPresent(value -> factory.withConnectionRequestTimeout(value));
return factory;
}
示例5: getDockerClient
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
@Bean
public DockerClient getDockerClient () {
logger.info( "Creating pooled docker: {} ", docker.toString() );
DockerClient client = null;
try {
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
.withDockerHost( docker.getUrl() )
.build();
DockerCmdExecFactory dockerCmdExecFactory = new JerseyDockerCmdExecFactory()
.withReadTimeout( docker.getReadTimeoutSeconds() *1000 )
.withConnectTimeout( docker.getConnectionTimeoutSeconds() *1000 )
.withMaxTotalConnections( docker.getConnectionPool() )
.withMaxPerRouteConnections( 3 );
// DockerCmdExecFactory dockerCmdExecFactory = new NettyDockerCmdExecFactory()
// .withConnectTimeout( docker.getReadTimeoutSeconds() *1000 ) ;
client = DockerClientBuilder
.getInstance( config )
.withDockerCmdExecFactory( dockerCmdExecFactory )
.build();
// client = DefaultDockerClient.builder()
// .uri( docker.getUrl() )
// .connectionPoolSize( docker.getConnectionPool() )
// .build();
} catch (Throwable t) {
logger.warn( "Failed connecting to docker: {}", CSAP.getCsapFilteredStackTrace( t ) );
}
return client;
}
示例6: configure
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
@Override
protected void configure() {
requireBinding(Config.class);
bind(DockerCmdExecFactory.class).toProvider(DockerCmdExecFactoryProvider.class).in(Singleton.class);
bind(DockerClient.class).toProvider(DockerClientProvider.class).in(Singleton.class);
bind(DockerHostProvider.class).in(Singleton.class);
bind(DockerHost.class).toProvider(DockerHostProvider.class);
bind(DockerFacade.class).to(DockerFacadeImpl.class);
bind(ContainerFacade.class).to(ContainerFacadeImpl.class);
bind(ImageFacade.class).to(ImageFacadeImpl.class);
bind(InfoFacade.class).to(InfoFacadeImpl.class);
bind(NetworkingFacade.class).to(NetworkFacadeImpl.class);
}
示例7: DockerClientFactory
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
@Inject
protected DockerClientFactory(DockerCmdExecFactory cmdExecFactory) {
super();
this.cmdExecFactory = cmdExecFactory;
}
示例8: withDockerCmdExecFactory
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
public DockerClientImpl withDockerCmdExecFactory(DockerCmdExecFactory dockerCmdExecFactory) {
checkNotNull(dockerCmdExecFactory, "dockerCmdExecFactory was not specified");
this.dockerCmdExecFactory = dockerCmdExecFactory;
this.dockerCmdExecFactory.init(dockerClientConfig);
return this;
}
示例9: getDockerCmdExecFactory
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
private DockerCmdExecFactory getDockerCmdExecFactory() {
checkNotNull(dockerCmdExecFactory, "dockerCmdExecFactory was not specified");
return dockerCmdExecFactory;
}
示例10: getDefaultDockerCmdExecFactory
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
return new JerseyDockerCmdExecFactory();
}
示例11: withDockerCmdExecFactory
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
public DockerClientBuilder withDockerCmdExecFactory(DockerCmdExecFactory dockerCmdExecFactory) {
this.dockerCmdExecFactory = dockerCmdExecFactory;
return this;
}
示例12: TestDockerCmdExecFactory
import com.github.dockerjava.api.command.DockerCmdExecFactory; //导入依赖的package包/类
public TestDockerCmdExecFactory(DockerCmdExecFactory delegate) {
this.delegate = delegate;
}