com.github.dockerjava.api.command.DockerCmdExecFactory Java Examples

The following examples show how to use com.github.dockerjava.api.command.DockerCmdExecFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockerClientBuilderTest.java    From docker-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testConcurrentClientBuilding() throws Exception {
    // we use it to check instance uniqueness
    final Set<DockerCmdExecFactory> instances = Collections.synchronizedSet(new HashSet<>());

    Runnable runnable = () -> {
        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);
}
 
Example #2
Source File: DockerClientFactory.java    From ethsigner with Apache License 2.0 5 votes vote down vote up
private DockerClient createDockerClient(final DefaultDockerClientConfig config) {
  final DockerCmdExecFactory dockerCmdExecFactory =
      new JerseyDockerCmdExecFactory()
          .withMaxTotalConnections(100)
          .withMaxPerRouteConnections(10)
          .withReadTimeout(7500)
          .withConnectTimeout(7500);

  return DockerClientBuilder.getInstance(config)
      .withDockerCmdExecFactory(dockerCmdExecFactory)
      .build();
}
 
Example #3
Source File: ITTestBase.java    From hudi with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void init() {
  String dockerHost = (OVERRIDDEN_DOCKER_HOST != null) ? OVERRIDDEN_DOCKER_HOST : DEFAULT_DOCKER_HOST;
  // Assuming insecure docker engine
  DockerClientConfig config =
      DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost(dockerHost).build();
  // using jaxrs/jersey implementation here (netty impl is also available)
  DockerCmdExecFactory dockerCmdExecFactory = new JerseyDockerCmdExecFactory().withConnectTimeout(1000)
      .withMaxTotalConnections(100).withMaxPerRouteConnections(10);
  dockerClient = DockerClientBuilder.getInstance(config).withDockerCmdExecFactory(dockerCmdExecFactory).build();
  await().atMost(60, SECONDS).until(this::servicesUp);
}
 
Example #4
Source File: Docker.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
public DockerClient getClient() {
  if (client == null) {
    synchronized (this) {
      if (client == null) {
        execFactory = new JerseyDockerCmdExecFactory();
        DockerCmdExecFactory dockerCmdExecFactory = execFactory.withMaxPerRouteConnections(100);
        client = DockerClientBuilder.getInstance(dockerServerUrl).withDockerCmdExecFactory(dockerCmdExecFactory).build();
      }
    }
  }
  return client;
}
 
Example #5
Source File: DockerClientBuilder.java    From docker-java with Apache License 2.0 5 votes vote down vote up
/**
 * Note that this method overrides {@link DockerHttpClient} if it was previously set
 *
 * @deprecated use {@link #withDockerHttpClient(DockerHttpClient)}
 */
@Deprecated
public DockerClientBuilder withDockerCmdExecFactory(DockerCmdExecFactory dockerCmdExecFactory) {
    this.dockerCmdExecFactory = dockerCmdExecFactory;
    this.dockerHttpClient = null;
    return this;
}
 
Example #6
Source File: DockerClientImpl.java    From docker-java with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated use {@link #getInstance(DockerClientConfig, DockerHttpClient)}
 */
@Deprecated
public DockerClientImpl withDockerCmdExecFactory(DockerCmdExecFactory dockerCmdExecFactory) {
    checkNotNull(dockerCmdExecFactory, "dockerCmdExecFactory was not specified");
    this.dockerCmdExecFactory = dockerCmdExecFactory;
    if (dockerCmdExecFactory instanceof DockerClientConfigAware) {
        ((DockerClientConfigAware) dockerCmdExecFactory).init(dockerClientConfig);
    }
    return this;
}
 
Example #7
Source File: JerseyDockerCmdExecFactory.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public final DockerCmdExecFactory getDockerCmdExecFactory() {
    return dockerCmdExecFactory;
}
 
Example #8
Source File: DockerClientBuilder.java    From docker-java with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @deprecated no replacement, use one of {@link DockerHttpClient}
 */
@Deprecated
public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
    return new JerseyDockerCmdExecFactory();
}
 
Example #9
Source File: DockerCmdExecFactoryDelegate.java    From docker-java with Apache License 2.0 4 votes vote down vote up
DockerCmdExecFactoryDelegate(DockerCmdExecFactory delegate) {
    this.delegate = delegate;
}
 
Example #10
Source File: DockerCmdExecFactoryDelegate.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public final DockerCmdExecFactory getDockerCmdExecFactory() {
    return delegate;
}
 
Example #11
Source File: DockerClientImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Deprecated
private DockerCmdExecFactory getDockerCmdExecFactory() {
    checkNotNull(dockerCmdExecFactory, "dockerCmdExecFactory was not specified");
    return dockerCmdExecFactory;
}
 
Example #12
Source File: OkHttpDockerCmdExecFactory.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public final DockerCmdExecFactory getDockerCmdExecFactory() {
    return dockerCmdExecFactory;
}