Package org.mandas.docker.client.builder
Class BaseDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- java.lang.Object
-
- org.mandas.docker.client.builder.BaseDockerClientBuilder<B>
-
- Type Parameters:
B
- the type of the builder
- All Implemented Interfaces:
DockerClientBuilder<B>
- Direct Known Subclasses:
JerseyDockerClientBuilder
,ResteasyDockerClientBuilder
public abstract class BaseDockerClientBuilder<B extends BaseDockerClientBuilder<B>> extends Object implements DockerClientBuilder<B>
A convenience base class for implementingDockerClientBuilder
s- Author:
- Dimitris Mandalidis
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.mandas.docker.client.builder.DockerClientBuilder
DockerClientBuilder.EntityProcessing
-
-
Field Summary
Fields Modifier and Type Field Description protected String
apiVersion
protected javax.ws.rs.client.Client
client
protected int
connectionPoolSize
protected long
connectTimeoutMillis
protected long
DEFAULT_CONNECT_TIMEOUT_MILLIS
protected int
DEFAULT_CONNECTION_POOL_SIZE
protected long
DEFAULT_READ_TIMEOUT_MILLIS
protected DockerCertificatesStore
dockerCertificatesStore
protected DockerClientBuilder.EntityProcessing
entityProcessing
protected String
ERROR_MESSAGE
protected Map<String,Object>
headers
protected javax.ws.rs.client.Client
noTimeoutClient
protected String
NPIPE_SCHEME
protected long
readTimeoutMillis
protected RegistryAuthSupplier
registryAuthSupplier
protected String
UNIX_SCHEME
protected URI
uri
protected boolean
useProxy
-
Constructor Summary
Constructors Constructor Description BaseDockerClientBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description B
apiVersion(String apiVersion)
Set the Docker API version that will be used in the HTTP requests to Docker daemon.DefaultDockerClient
build()
B
connectionPoolSize(int connectionPoolSize)
Set the size of the connection pool for connections to Docker.B
connectTimeoutMillis(long connectTimeoutMillis)
Set the timeout in milliseconds until a connection to Docker is established.protected abstract javax.ws.rs.client.Client
createClient()
protected abstract javax.ws.rs.client.Client
createNoTimeoutClient()
B
dockerCertificates(DockerCertificatesStore dockerCertificatesStore)
Provide certificates to secure the connection to Docker.B
entityProcessing(DockerClientBuilder.EntityProcessing entityProcessing)
Allows setting transfer encoding.B
fromEnv()
Sets or overwritesuri()
anddockerCertificates(DockerCertificatesStore)
according to the values present in DOCKER_HOST and DOCKER_CERT_PATH environment variables.protected org.apache.http.conn.HttpClientConnectionManager
getConnectionManager(URI uri, org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> schemeRegistry, int connectionPoolSize)
protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory>
getSchemeRegistry(URI uri, DockerCertificatesStore certificateStore)
B
header(String name, Object value)
Adds additional headers to be sent in all requests to the Docker Remote API.protected ProxyConfiguration
proxyFromEnv()
B
readTimeoutMillis(long readTimeoutMillis)
Set the SO_TIMEOUT in milliseconds.B
registryAuthSupplier(RegistryAuthSupplier registryAuthSupplier)
URI
uri()
B
uri(String uri)
Set the URI for connections to Docker.B
uri(URI uri)
B
useProxy(boolean useProxy)
Allows connecting to Docker Daemon using HTTP proxy.
-
-
-
Field Detail
-
UNIX_SCHEME
protected String UNIX_SCHEME
-
NPIPE_SCHEME
protected String NPIPE_SCHEME
-
DEFAULT_CONNECT_TIMEOUT_MILLIS
protected long DEFAULT_CONNECT_TIMEOUT_MILLIS
-
DEFAULT_READ_TIMEOUT_MILLIS
protected long DEFAULT_READ_TIMEOUT_MILLIS
-
DEFAULT_CONNECTION_POOL_SIZE
protected int DEFAULT_CONNECTION_POOL_SIZE
-
ERROR_MESSAGE
protected String ERROR_MESSAGE
-
uri
protected URI uri
-
apiVersion
protected String apiVersion
-
connectTimeoutMillis
protected long connectTimeoutMillis
-
readTimeoutMillis
protected long readTimeoutMillis
-
connectionPoolSize
protected int connectionPoolSize
-
dockerCertificatesStore
protected DockerCertificatesStore dockerCertificatesStore
-
useProxy
protected boolean useProxy
-
registryAuthSupplier
protected RegistryAuthSupplier registryAuthSupplier
-
client
protected javax.ws.rs.client.Client client
-
noTimeoutClient
protected javax.ws.rs.client.Client noTimeoutClient
-
entityProcessing
protected DockerClientBuilder.EntityProcessing entityProcessing
-
-
Method Detail
-
fromEnv
public B fromEnv() throws DockerCertificateException
Sets or overwritesuri()
anddockerCertificates(DockerCertificatesStore)
according to the values present in DOCKER_HOST and DOCKER_CERT_PATH environment variables.- Specified by:
fromEnv
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Returns:
- Modifies a builder that can be used to further customize and then build the client.
- Throws:
DockerCertificateException
- if we could not build a DockerCertificates object
-
uri
public B uri(URI uri)
- Specified by:
uri
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
-
uri
public B uri(String uri)
Set the URI for connections to Docker.- Specified by:
uri
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
uri
- URI String for connections to Docker- Returns:
- Builder
-
apiVersion
public B apiVersion(String apiVersion)
Set the Docker API version that will be used in the HTTP requests to Docker daemon.- Specified by:
apiVersion
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
apiVersion
- String for Docker API version- Returns:
- Builder
-
connectTimeoutMillis
public B connectTimeoutMillis(long connectTimeoutMillis)
Description copied from interface:DockerClientBuilder
Set the timeout in milliseconds until a connection to Docker is established. A timeout value of zero is interpreted as an infinite timeout.- Specified by:
connectTimeoutMillis
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
connectTimeoutMillis
- connection timeout to Docker daemon in milliseconds- Returns:
- Builder
-
readTimeoutMillis
public B readTimeoutMillis(long readTimeoutMillis)
Description copied from interface:DockerClientBuilder
Set the SO_TIMEOUT in milliseconds. This is the maximum period of inactivity between receiving two consecutive data packets from Docker.- Specified by:
readTimeoutMillis
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
readTimeoutMillis
- read timeout to Docker daemon in milliseconds- Returns:
- Builder
-
dockerCertificates
public B dockerCertificates(DockerCertificatesStore dockerCertificatesStore)
Description copied from interface:DockerClientBuilder
Provide certificates to secure the connection to Docker.- Specified by:
dockerCertificates
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
dockerCertificatesStore
- DockerCertificatesStore object- Returns:
- Builder
-
connectionPoolSize
public B connectionPoolSize(int connectionPoolSize)
Description copied from interface:DockerClientBuilder
Set the size of the connection pool for connections to Docker. Note that due to a known issue, DefaultDockerClient maintains two separate connection pools, each of which is capped at this size. Therefore, the maximum number of concurrent connections to Docker may be up to 2 * connectionPoolSize.- Specified by:
connectionPoolSize
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
connectionPoolSize
- connection pool size- Returns:
- Builder
-
useProxy
public B useProxy(boolean useProxy)
Description copied from interface:DockerClientBuilder
Allows connecting to Docker Daemon using HTTP proxy.- Specified by:
useProxy
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
useProxy
- tells if Docker Client has to connect to docker daemon using HTTP Proxy- Returns:
- Builder
-
registryAuthSupplier
public B registryAuthSupplier(RegistryAuthSupplier registryAuthSupplier)
- Specified by:
registryAuthSupplier
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
-
header
public B header(String name, Object value)
Description copied from interface:DockerClientBuilder
Adds additional headers to be sent in all requests to the Docker Remote API.- Specified by:
header
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
name
- the header namevalue
- the header value- Returns:
- this
-
uri
public URI uri()
- Specified by:
uri
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Returns:
- the URI of the Docker engine
-
entityProcessing
public B entityProcessing(DockerClientBuilder.EntityProcessing entityProcessing)
Description copied from interface:DockerClientBuilder
Allows setting transfer encoding. CHUNKED does not send the content-length header while BUFFERED does.By default ApacheConnectorProvider uses CHUNKED mode. Some Docker API end-points seems to fail when no content-length is specified but a body is sent.
- Specified by:
entityProcessing
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
- Parameters:
entityProcessing
- is the requested entity processing to use when calling docker daemon (tcp protocol).- Returns:
- Builder
-
createClient
protected abstract javax.ws.rs.client.Client createClient()
-
createNoTimeoutClient
protected abstract javax.ws.rs.client.Client createNoTimeoutClient()
-
proxyFromEnv
protected ProxyConfiguration proxyFromEnv()
-
build
public DefaultDockerClient build()
- Specified by:
build
in interfaceDockerClientBuilder<B extends BaseDockerClientBuilder<B>>
-
getConnectionManager
protected org.apache.http.conn.HttpClientConnectionManager getConnectionManager(URI uri, org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> schemeRegistry, int connectionPoolSize)
-
getSchemeRegistry
protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> getSchemeRegistry(URI uri, DockerCertificatesStore certificateStore)
-
-