com.github.dockerjava.netty.NettyDockerCmdExecFactory Java Examples
The following examples show how to use
com.github.dockerjava.netty.NettyDockerCmdExecFactory.
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: CmdIT.java From docker-java with Apache License 2.0 | 5 votes |
@Override public DockerClientImpl createDockerClient(DockerClientConfig config) { return (DockerClientImpl) DockerClientBuilder.getInstance(config) .withDockerCmdExecFactory( new NettyDockerCmdExecFactory() .withConnectTimeout(30 * 1000) ) .build(); }
Example #2
Source File: DockerAPI.java From docker-plugin with MIT License | 5 votes |
/** * Creates a new {@link DockerClient}. * It's the caller's responsibility to dispose of the result. */ @SuppressWarnings("resource") private static SharableDockerClient makeClient(final String dockerUri, final String credentialsId, final Integer readTimeoutInMillisecondsOrNull, final Integer connectTimeoutInMillisecondsOrNull) { NettyDockerCmdExecFactory cmdExecFactory = null; DockerClient actualClient = null; try { cmdExecFactory = new NettyDockerCmdExecFactory() .withReadTimeout(readTimeoutInMillisecondsOrNull) .withConnectTimeout(connectTimeoutInMillisecondsOrNull); final DefaultDockerClientConfig.Builder configBuilder = new DefaultDockerClientConfig.Builder() .withDockerHost(dockerUri) .withCustomSslConfig(toSSlConfig(credentialsId)); actualClient = DockerClientBuilder.getInstance(configBuilder) .withDockerCmdExecFactory(cmdExecFactory) .build(); final SharableDockerClient multiUsageClient = new SharableDockerClient(actualClient); // if we've got this far, we're going to succeed, so we need to ensure that we // don't close the resources we're returning. cmdExecFactory = null; actualClient = null; return multiUsageClient; } finally { // these will no-op if we're successfully returning a value, but in any error // cases we should ensure that we don't leak precious resources. closeAndLogAnyExceptions(cmdExecFactory); closeAndLogAnyExceptions(actualClient); } }