public class RunService extends Object
| Constructor and Description |
|---|
RunService(DockerAccess docker,
QueryService queryService,
ContainerTracker tracker,
LogOutputSpecFactory logConfig,
org.eclipse.jkube.kit.common.KitLogger log) |
| Modifier and Type | Method and Description |
|---|---|
void |
addShutdownHookForStoppingContainers(boolean keepContainer,
boolean removeVolumes,
boolean removeCustomNetworks)
Add a shutdown hook in order to stop all registered containers
|
String |
createAndStartContainer(org.eclipse.jkube.kit.config.image.ImageConfiguration imageConfig,
PortMapping portMapping,
GavLabel gavLabel,
Properties properties,
File baseDir,
String defaultContainerNamePattern,
Date buildTimestamp)
Create and start a container with the given image configuration.
|
void |
createCustomNetworkIfNotExistant(String customNetwork) |
PortMapping |
createPortMapping(org.eclipse.jkube.kit.config.image.RunImageConfiguration runConfig,
Properties properties)
Create port mapping for a specific configuration as it can be used when creating containers
|
List<String> |
createVolumesAsPerVolumeBinds(DockerServiceHub hub,
List<String> binds,
List<VolumeConfiguration> volumes)
Creates a Volume if a volume is referred to during startup in bind mount mapping and
a VolumeConfiguration exists
|
String |
execInContainer(String containerId,
String command,
org.eclipse.jkube.kit.config.image.ImageConfiguration imageConfiguration)
Create and start a Exec container with the given image configuration.
|
List<org.eclipse.jkube.kit.config.image.ImageConfiguration> |
getImagesConfigsInOrder(QueryService queryService,
List<org.eclipse.jkube.kit.config.image.ImageConfiguration> images)
Get the proper order for images to start
|
String |
lookupContainer(String lookup)
Lookup a container that has been started
|
void |
removeCustomNetworks(Collection<Network> networks) |
void |
stopContainer(String containerId,
org.eclipse.jkube.kit.config.image.ImageConfiguration imageConfig,
boolean keepContainer,
boolean removeVolumes)
Stop a container immediately by id.
|
void |
stopPreviouslyStartedContainer(String containerId,
boolean keepContainer,
boolean removeVolumes)
Lookup up whether a certain has been already started and registered.
|
void |
stopStartedContainers(boolean keepContainer,
boolean removeVolumes,
boolean removeCustomNetworks,
GavLabel gavLabel)
Stop all registered container
|
public RunService(DockerAccess docker, QueryService queryService, ContainerTracker tracker, LogOutputSpecFactory logConfig, org.eclipse.jkube.kit.common.KitLogger log)
public String execInContainer(String containerId, String command, org.eclipse.jkube.kit.config.image.ImageConfiguration imageConfiguration) throws DockerAccessException, ExecException
containerId - container id to run exec command againstcommand - command to executeimageConfiguration - configuration of the container's imageDockerAccessException - if access to the docker backend failsExecException - if any problem faced during execpublic String createAndStartContainer(org.eclipse.jkube.kit.config.image.ImageConfiguration imageConfig, PortMapping portMapping, GavLabel gavLabel, Properties properties, File baseDir, String defaultContainerNamePattern, Date buildTimestamp) throws DockerAccessException
imageConfig - image configuration holding the run information and the image nameportMapping - container port mappinggavLabel - label to tag the started container withbaseDir - base directoryproperties - properties to fill in with dynamically assigned portsdefaultContainerNamePattern - pattern to use for naming containers. Can be null in which case a default pattern is usedbuildTimestamp - date which should be used as the timestamp when calculating container namesDockerAccessException - if access to the docker backend failspublic void stopContainer(String containerId, org.eclipse.jkube.kit.config.image.ImageConfiguration imageConfig, boolean keepContainer, boolean removeVolumes) throws DockerAccessException, ExecException
containerId - the container to stopimageConfig - image configuration for this containerkeepContainer - whether to keep container or to remove them after stoppingremoveVolumes - whether to remove volumes after stoppingDockerAccessException - docker access exceptionExecException - exec exceptionpublic void stopPreviouslyStartedContainer(String containerId, boolean keepContainer, boolean removeVolumes) throws DockerAccessException, ExecException
containerId - the container to stopkeepContainer - whether to keep container or to remove them after stoppingsremoveVolumes - whether to remove volumes after stoppingDockerAccessException - docker access exceptionExecException - exec exceptionpublic void stopStartedContainers(boolean keepContainer,
boolean removeVolumes,
boolean removeCustomNetworks,
GavLabel gavLabel)
throws DockerAccessException,
ExecException
keepContainer - whether to keep container or to remove them after stoppingremoveVolumes - whether to remove volumes after stoppingremoveCustomNetworks - whether to remove custom networksgavLabel - group artifact version labelDockerAccessException - if during stopping of a container sth failsExecException - if any problem during execpublic String lookupContainer(String lookup)
lookup - a container by id or aliasnull otherwise.public List<org.eclipse.jkube.kit.config.image.ImageConfiguration> getImagesConfigsInOrder(QueryService queryService, List<org.eclipse.jkube.kit.config.image.ImageConfiguration> images)
queryService - query serviceimages - list of images for which the order should be createdpublic PortMapping createPortMapping(org.eclipse.jkube.kit.config.image.RunImageConfiguration runConfig, Properties properties)
runConfig - the cun configurationproperties - properties to lookup variablespublic void addShutdownHookForStoppingContainers(boolean keepContainer,
boolean removeVolumes,
boolean removeCustomNetworks)
keepContainer - whether to keep container or notremoveVolumes - whether to remove volumes or notremoveCustomNetworks - whether to remove custom networks or notpublic void createCustomNetworkIfNotExistant(String customNetwork) throws DockerAccessException
DockerAccessExceptionpublic void removeCustomNetworks(Collection<Network> networks) throws DockerAccessException
DockerAccessExceptionpublic List<String> createVolumesAsPerVolumeBinds(DockerServiceHub hub, List<String> binds, List<VolumeConfiguration> volumes) throws DockerAccessException
hub - Service hubbinds - volume binds present in ImageConfigurationvolumes - VolumeConfigs presentDockerAccessException - docker access exceptionCopyright © 2023. All rights reserved.