Class AbstractContainerManager<C extends ContainerDescriptor>
java.lang.Object
de.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<C>
- Type Parameters:
C- the actual type of container descriptor
- All Implemented Interfaces:
ContainerManager,ContainerOperations
public abstract class AbstractContainerManager<C extends ContainerDescriptor>
extends Object
implements ContainerManager
A basic re-usable implementation of the container manager. Implementations shall override at least
undeployContainer(String), migrateContainer(String, String)
and call the implementation of this class to perform the changes.- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsFields inherited from interface de.iip_ecosphere.platform.ecsRuntime.ContainerOperations
EXC_ALREADY_KNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaddContainer(String id, C descriptor) Adds a container.protected voidChecks the givenidfor basic validity.getContainer(String id) Returns a container descriptor.protected CgetContainer(String id, String idText, String activityText) Returns a service descriptor.Returns the available (installed) containers independent of their state.Returns the container id for a given container location as used inContainerOperations.addContainer(URI).getIds()Returns the ids of all available containers.Returns the state of the container.voidmigrateContainer(String id, String resourceId) Migrates the container.protected FileresolveUri(URI uri, File downloadDir) Resolves an URI takingEcsSetup.getArtifactInfixes()into account.protected voidsetState(BasicContainerDescriptor container, ContainerState state) Changes the container state and notifiesEcsAas.protected voidthrowExecutionException(String action, String message) Throws an execution exception for the given message.protected voidthrowExecutionException(String action, Throwable th) Throws an execution exception for the given throwable.voidRemoves the container from the management domain of this instance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.ecsRuntime.ContainerManager
getRuntimeName, getVersionMethods inherited from interface de.iip_ecosphere.platform.ecsRuntime.ContainerOperations
addContainer, getContainerSystemName, getContainerSystemVersion, startContainer, stopContainer, updateContainer
-
Field Details
-
containers
-
-
Constructor Details
-
AbstractContainerManager
public AbstractContainerManager()
-
-
Method Details
-
getIds
Description copied from interface:ContainerManagerReturns the ids of all available containers.- Specified by:
getIdsin interfaceContainerManager- Returns:
- the ids
-
getContainers
Description copied from interface:ContainerManagerReturns the available (installed) containers independent of their state.- Specified by:
getContainersin interfaceContainerManager- Returns:
- the container descriptors
-
getContainer
Description copied from interface:ContainerManagerReturns a container descriptor.- Specified by:
getContainerin interfaceContainerManager- Parameters:
id- the id of the container (may be null or invalid)- Returns:
- the related container descriptor or null if the container is not known at all
-
getId
Description copied from interface:ContainerOperationsReturns the container id for a given container location as used inContainerOperations.addContainer(URI).- Specified by:
getIdin interfaceContainerOperations- Parameters:
location- the location- Returns:
- the id of the container, may be empty or nullnull if there is none
-
getState
Description copied from interface:ContainerOperationsReturns the state of the container.- Specified by:
getStatein interfaceContainerOperations- Parameters:
id- the id/URI of the container- Returns:
- the state of the container
-
addContainer
Adds a container.- Parameters:
id- the container iddescriptor- the container descriptor- Returns:
id- Throws:
ExecutionException- in case that the id is invalid or already known
-
undeployContainer
Description copied from interface:ContainerOperationsRemoves the container from the management domain of this instance. This operation shall only remove the implementation of a non-operational container and, thus, perform a state transition toContainerState.UNDEPLOYINGand ultimately the container shall be removed and its descriptor shall not be available anymore.- Specified by:
undeployContainerin interfaceContainerOperations- Parameters:
id- the id of the container to remove, or as fallback the canonical URI of the container descriptor used for adding- Throws:
ExecutionException- if undeploying the container fails, e.g., because it is still running
-
setState
protected void setState(BasicContainerDescriptor container, ContainerState state) throws ExecutionException Changes the container state and notifiesEcsAas.- Parameters:
container- the containerstate- the new state- Throws:
ExecutionException- if changing the state fails- See Also:
-
getContainer
Returns a service descriptor.- Parameters:
id- the service id, or the URI used to add the container as fallbackidText- the id text to be passed tocheckId(String, String)activityText- a description of the activity the service is requested for to construct an exception if the service does not exist- Returns:
- the service (not null)
- Throws:
ExecutionException- if id is invalid or the service is unknown
-
checkId
Checks the givenidfor basic validity.- Parameters:
id- the id to checktext- the text to include into the exception- Throws:
ExecutionException- ifidis not considered valid
-
migrateContainer
Description copied from interface:ContainerOperationsMigrates the container.- Specified by:
migrateContainerin interfaceContainerOperations- Parameters:
id- the id of the containerresourceId- the target resource id, e.g., a device- Throws:
ExecutionException- if migration fails
-
throwExecutionException
Throws an execution exception for the given throwable.- Parameters:
action- the actual action to log (may be null or empty)th- the throwable- Throws:
ExecutionException- the constructed exception
-
throwExecutionException
Throws an execution exception for the given message.- Parameters:
action- the actual action to log (may be null or empty)message- the message for the exception- Throws:
ExecutionException- the constructed exception
-
resolveUri
Resolves an URI takingEcsSetup.getArtifactInfixes()into account.- Parameters:
uri- the default/base URI to be resolveddownloadDir- the directory to store resolved files, may be null for temporary files- Returns:
- the resolve file
- Throws:
IOException- if theuriultimately cannot be resolved
-