public class ContainerManagerImpl extends Object implements ContainerManager
| Modifier and Type | Field and Description |
|---|---|
private List<ContainerStateObserver> |
containerObservers
Observers that should be notified if a container terminates.
|
private static String |
DEPLOY_ENV |
private static String |
DEPLOY_ENV_DEVELOP |
static String |
DEPLOY_ENV_KEY |
private static String |
DEPLOY_ENV_TESTING |
private static Boolean |
DOCKER_AUTOPULL |
static String |
DOCKER_AUTOPULL_ENV_KEY |
private static long |
DOCKER_IMAGE_PULL_MAX_WAITING_TIME |
private static long |
DOCKER_POLL_INTERVAL |
private com.spotify.docker.client.DockerClient |
dockerClient
Docker client instance
|
private String |
experimentId |
private String |
gelfAddress |
private com.spotify.docker.client.messages.RegistryAuth |
gitlabAuth
Authentication configuration for accessing private repositories.
|
static String |
HOBBIT_DOCKER_NETWORK
Default network for new containers
|
private static org.slf4j.Logger |
LOGGER |
private static String |
LOGGING_DRIVER_GELF |
static String |
LOGGING_GELF_ADDRESS_KEY |
private static String |
LOGGING_SEPARATOR
Logging separator for type/experiment id.
|
static String |
LOGGING_TAG
Logging pattern.
|
static Set<String> |
NEW_TASKS_STATES
Task states which are considered as not running yet.
|
private com.spotify.docker.client.messages.RegistryAuth |
nullAuth
Empty authentication configuration.
|
private static Pattern |
PORT_PATTERN |
static String |
REGISTRY_URL_KEY |
static Set<String> |
UNFINISHED_TASK_STATES
Task states which are considered as not finished yet.
|
static String |
USER_EMAIL_KEY |
static String |
USER_NAME_KEY |
static String |
USER_PASSWORD_KEY |
LABEL_PARENT, LABEL_TYPE| Constructor and Description |
|---|
ContainerManagerImpl()
Constructor that creates new docker client instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContainerObserver(ContainerStateObserver containerObserver)
Adds the given observer to the list of internal observers.
|
static boolean |
containsVersionTag(String imageName) |
private String |
createContainer(String imageName,
String containerType,
String parentId,
String[] env,
String[] command)
Creates new container using given image and assigns given type and parent
|
String |
getContainerId(String name)
Retrieves the container Id for the container with the given name or null if
no such container could be found.
|
com.spotify.docker.client.messages.swarm.Task |
getContainerInfo(String taskId)
Returns container info
|
String |
getContainerName(String containerId)
Returns the name of the container with the given Id or
null if such a
container can not be found |
List<com.spotify.docker.client.messages.swarm.Task> |
getContainers(com.spotify.docker.client.messages.swarm.Task.Criteria criteria)
Get a list of tasks which fulfill the given filter criteria.
|
private String |
getInstanceName(String imageName)
Generates new unique instance name based on image name
|
com.spotify.docker.client.messages.ContainerStats |
getStats(String containerId)
Returns statistics of the container with the given Id or
null if the
container can not be found or an error occurs. |
void |
pullImage(String imageName)
Pulls the image with the given name.
|
void |
removeContainer(String taskId)
Removes the container with the given container Id.
|
void |
removeParentAndChildren(String parentId)
Removes the parent container and all its children given the parent id
|
String |
startContainer(String imageName)
Deprecated.
|
String |
startContainer(String imageName,
String[] command)
Deprecated.
|
String |
startContainer(String imageName,
String type,
String parent)
Start container with given image, type and parent
|
String |
startContainer(String imageName,
String containerType,
String parentId,
String[] command)
Starts the container with the given image name.
|
String |
startContainer(String imageName,
String containerType,
String parentId,
String[] env,
String[] command)
Starts the container with the given image name.
|
String |
startContainer(String imageName,
String containerType,
String parentId,
String[] env,
String[] command,
String experimentId)
Starts the container with the given image name.
|
void |
stopContainer(String containerId)
Deprecated.
|
void |
stopParentAndChildren(String parentId)
Deprecated.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetContainersprivate static final org.slf4j.Logger LOGGER
public static final String DEPLOY_ENV_KEY
public static final String DOCKER_AUTOPULL_ENV_KEY
public static final String LOGGING_GELF_ADDRESS_KEY
public static final String USER_NAME_KEY
public static final String USER_EMAIL_KEY
public static final String USER_PASSWORD_KEY
public static final String REGISTRY_URL_KEY
private static final String DEPLOY_ENV
private static final String DEPLOY_ENV_TESTING
private static final String DEPLOY_ENV_DEVELOP
private static final String LOGGING_DRIVER_GELF
private static final Pattern PORT_PATTERN
private static final Boolean DOCKER_AUTOPULL
private static final long DOCKER_POLL_INTERVAL
private static final long DOCKER_IMAGE_PULL_MAX_WAITING_TIME
public static final String HOBBIT_DOCKER_NETWORK
public static final String LOGGING_TAG
public static final Set<String> NEW_TASKS_STATES
public static final Set<String> UNFINISHED_TASK_STATES
private static final String LOGGING_SEPARATOR
private com.spotify.docker.client.DockerClient dockerClient
private final com.spotify.docker.client.messages.RegistryAuth gitlabAuth
private final com.spotify.docker.client.messages.RegistryAuth nullAuth
private List<ContainerStateObserver> containerObservers
private String gelfAddress
private String experimentId
private String getInstanceName(String imageName)
imageName - base image namepublic void pullImage(String imageName)
pullImage in interface ContainerManagerimageName - the name of the image that should be pulledprivate String createContainer(String imageName, String containerType, String parentId, String[] env, String[] command)
imageName - image to use as base for containercontainerType - container typeparentId - parent idenv - (optional) environment variablescommand - (optional) command to be executed with imagenull if an error occurs@Deprecated public String startContainer(String imageName)
ContainerManagerstartContainer in interface ContainerManagerimageName - Name of the image to start@Deprecated public String startContainer(String imageName, String[] command)
ContainerManagerstartContainer in interface ContainerManagerimageName - name of the image to startcommand - command to be executedpublic String startContainer(String imageName, String type, String parent)
ContainerManagerstartContainer in interface ContainerManagerimageName - name of the image to starttype - container typeparent - parent idpublic String startContainer(String imageName, String containerType, String parentId, String[] command)
ContainerManagerstartContainer in interface ContainerManagerimageName - name of the image to be startedcontainerType - type to be assigned to containerparentId - id of the parent containercommand - commands that should be executedpublic String startContainer(String imageName, String containerType, String parentId, String[] env, String[] command)
ContainerManagerstartContainer in interface ContainerManagerimageName - name of the image to be startedcontainerType - type to be assigned to containerparentId - id of the parent containerenv - environment variables of the schema "key=value"command - commands that should be executedpublic String startContainer(String imageName, String containerType, String parentId, String[] env, String[] command, String experimentId)
ContainerManagerstartContainer in interface ContainerManagerimageName - name of the image to be startedcontainerType - type to be assigned to containerparentId - id of the parent containerenv - environment variables of the schema "key=value"command - commands that should be executedexperimentId - experimentId to add to GELF tagpublic void removeContainer(String taskId)
ContainerManagerremoveContainer in interface ContainerManagertaskId - id of the container that should be removed@Deprecated public void stopContainer(String containerId)
ContainerManagerstopContainer in interface ContainerManagercontainerId - id of the container that should be stopped@Deprecated public void stopParentAndChildren(String parentId)
ContainerManagerstopParentAndChildren in interface ContainerManagerparentId - id of the parent containerpublic void removeParentAndChildren(String parentId)
ContainerManagerremoveParentAndChildren in interface ContainerManagerparentId - id of the parent containerpublic com.spotify.docker.client.messages.swarm.Task getContainerInfo(String taskId) throws InterruptedException, com.spotify.docker.client.exceptions.DockerException
ContainerManagergetContainerInfo in interface ContainerManagerInterruptedExceptioncom.spotify.docker.client.exceptions.DockerExceptionpublic List<com.spotify.docker.client.messages.swarm.Task> getContainers(com.spotify.docker.client.messages.swarm.Task.Criteria criteria)
ContainerManagergetContainers in interface ContainerManagerpublic String getContainerId(String name)
ContainerManagergetContainerId in interface ContainerManagerpublic String getContainerName(String containerId)
ContainerManagernull if such a
container can not be foundgetContainerName in interface ContainerManagercontainerId - the Id of the container for which the name should be retrievednull if such a
container can not be foundpublic void addContainerObserver(ContainerStateObserver containerObserver)
ContainerManageraddContainerObserver in interface ContainerManagercontainerObserver - the observer that should be added to the internal listpublic static boolean containsVersionTag(String imageName)
public com.spotify.docker.client.messages.ContainerStats getStats(String containerId)
ContainerManagernull if the
container can not be found or an error occurs.getStats in interface ContainerManagercontainerId - the Id of the container for which statistics should be requestednull if the
container can not be found or an error occurs.Copyright © 2017–2018. All rights reserved.