Interface ServiceOperations
- All Known Subinterfaces:
ServiceManager,ServicesClient
- All Known Implementing Classes:
AbstractServiceManager,ServicesAasClient
public interface ServiceOperations
Basic service operations that shall also be available via an AAS.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringService start option, command line options, usually -D<key>=<value>, given as JSON list (string).static final StringService start option, ensemble mapping (member-leader mapping), given as JSON map (string).static final StringService start option, mapping of service ids to memory limits in MBytes given as JSON map.static final StringService start option, mapping of service ids to maps of name-value for re-configuring the service parameters directly after start.static final StringService start option, mapping of service ids to server IP addresses JSON map (string). -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateService(String serviceId) Activates the service.addArtifact(URI location) Adds an artifact (and transitively the contained services) to the management domain of this instance, e.g., by downloading it from an artifact/service store.intgetServiceInstanceCount(String serviceId) Returns the number of service instances of the same service in the same application.de.iip_ecosphere.platform.services.environment.ServiceStategetServiceState(String serviceId) Returns the state of the service.voidmigrateService(String serviceId, String resourceId) Migrates a service.voidpassivateService(String serviceId) Passivates the service.voidreconfigureService(String serviceId, Map<String, String> values) Reconfigures the underlying service.voidremoveArtifact(String artifactId) Removes the artifact (and transitively its services) from the management domain of this instance.voidsetServiceState(String serviceId, de.iip_ecosphere.platform.services.environment.ServiceState state) Sets the state of the service.voidstartService(String... serviceId) Starts one or multiple service.voidstartService(Map<String, String> options, String... serviceId) Starts one or multiple service.voidstopService(String... serviceId) Stops one or multiple services.default StringstreamLog(String serviceId, ServiceOperations.StreamLogMode mode) Tries to attach the logs ofserviceIdto a sender determined byTransportConverterFactory.voidswitchToService(String serviceId, String targetId) Switches to an interface-compatible service.Turns a string value to aServiceOperations.StreamLogMode.voidupdateService(String serviceId, URI location) Updates the service by the service in the givenlocation.
-
Field Details
-
EXC_ALREADY_KNOWN
- See Also:
-
OPTION_ENSEMBLE
Service start option, ensemble mapping (member-leader mapping), given as JSON map (string).- See Also:
-
OPTION_ARGS
Service start option, command line options, usually -D<key>=<value>, given as JSON list (string).- See Also:
-
OPTION_SERVERS
Service start option, mapping of service ids to server IP addresses JSON map (string).- See Also:
-
OPTION_PARAMS
Service start option, mapping of service ids to maps of name-value for re-configuring the service parameters directly after start.- See Also:
-
OPTION_MEMLIMITS
Service start option, mapping of service ids to memory limits in MBytes given as JSON map.- See Also:
-
-
Method Details
-
addArtifact
Adds an artifact (and transitively the contained services) to the management domain of this instance, e.g., by downloading it from an artifact/service store. This defines theidof the service within the management domain of this instance. After a successful execution, the artifactidis returned, artifact and service(s) shall be available and the service(s) shall be in stateServiceState.AVAILABLE.- Parameters:
location- the location from where to download the service, e.g., an URL- Returns:
- the id of the artifact
- Throws:
ExecutionException- in case that adding the service fails for some reason
-
startService
Starts one or multiple service. The service implementation must be already within the management domain of this instance byaddArtifact(URI). The service(s) shall after some time be in stateServiceState.STARTING,ServiceState.RUNNINGorServiceState.FAILED.- Parameters:
serviceId- the id(s) of the service(s)- Throws:
ExecutionException- in case that starting the service fails for some reason
-
startService
Starts one or multiple service. The service implementation must be already within the management domain of this instance byaddArtifact(URI). The service(s) shall after some time be in stateServiceState.STARTING,ServiceState.RUNNINGorServiceState.FAILED.- Parameters:
options- optional map of optional options to be passed to the service manager, may modify the service descriptors, e.g., to change services to be started together on demand, may be empty for none; options are a name-value mapping with values that come either as primitive values or as JSON structures. For pre-defined names, seeOPTION_ARGS,OPTION_ENSEMBLE,OPTION_PARAMS,OPTION_SERVERS, orOPTION_MEMLIMITS. The service manager is responsible for correct JSON de-serialization.serviceId- the id(s) of the service(s)- Throws:
ExecutionException- in case that starting the service fails for some reason- See Also:
-
stopService
Stops one or multiple services. The service shall afterwards be in stateServiceState.STOPPED.- Parameters:
serviceId- the id(s) of the service(s) to stop- Throws:
ExecutionException- if stopping the service fails
-
migrateService
Migrates a service. However, it may be required to migrate/move the containing artifact. [adaptation]- Parameters:
serviceId- the id of the serviceresourceId- the target resource id, e.g., a device- Throws:
ExecutionException- if migration fails
-
removeArtifact
Removes the artifact (and transitively its services) from the management domain of this instance. This operation shall only remove the implementation of non-operational services and, thus, perform a state transition toServiceState.UNDEPLOYINGand ultimately the service(s) shall be removed and their descriptors (including the artifact descriptor) shall not be available anymore.- Parameters:
artifactId- the id of the artifact to remove, or as fallback the canonical URI of the artifact- Throws:
ExecutionException- if removing the service fails, e.g., because it is still running
-
updateService
Updates the service by the service in the givenlocation. This operation is responsible for stopping the running service (if needed), replacing it, starting the new service.- Parameters:
serviceId- the id of the service to be updatedlocation- the location of the new service, e.g., an URL- Throws:
ExecutionException- if the given service cannot be updated for some reason, e.g., because the replacement service is not an evolved version of the running service
-
switchToService
Switches to an interface-compatible service. This method cares for stopping the old service, performing a handover if adequate, starting thetargetservice. [adaptation]- Parameters:
serviceId- the id of the running servicetargetId- the id of the target service- Throws:
ExecutionException- if switching the service cannot be performed for some reason
-
activateService
Activates the service. [adaptation]- Parameters:
serviceId- the id of the running service- Throws:
ExecutionException- in case that activating fails, e.g., because the service is already active
-
passivateService
Passivates the service. [adaptation]- Parameters:
serviceId- the id of the running service- Throws:
ExecutionException- in case that passivating fails, e.g., because the service is already passive
-
reconfigureService
Reconfigures the underlying service. [adaptation]- Parameters:
serviceId- the serviceId of the running servicevalues- the (service-specific) name-value mapping that shall lead to a reconfiguration of the service; values come either as primitive values or as JSON structures complying with the parameter descriptor. The service is responsible for correct JSON de-serialization according to the respectivedescriptor- Throws:
ExecutionException- if reconfiguration fails
-
setServiceState
void setServiceState(String serviceId, de.iip_ecosphere.platform.services.environment.ServiceState state) throws ExecutionException Sets the state of the service. [adaptation]- Parameters:
serviceId- the id of the running servicestate- the new state of the service- Throws:
ExecutionException- if changing to the target state is not possible
-
getServiceState
Returns the state of the service.- Parameters:
serviceId- the id of the running service- Returns:
- the state of the service
-
getServiceInstanceCount
Returns the number of service instances of the same service in the same application.- Parameters:
serviceId- the service id, application instance id is ignored if not given- Returns:
- 0 if there is no other service instance, 1 if no applicationId is given in
serviceIdbut there is a service with the same id, the number of instances otherwise
-
toMode
Turns a string value to aServiceOperations.StreamLogMode.- Parameters:
value- the string value- Returns:
- the mode, fallback is
ServiceOperations.StreamLogMode.NONE.
-
streamLog
default String streamLog(String serviceId, ServiceOperations.StreamLogMode mode) throws ExecutionException Tries to attach the logs ofserviceIdto a sender determined byTransportConverterFactory.- Parameters:
serviceId- the service idmode- the mode- Returns:
- the URIs where to find the (streamed) log as JSON list or empty
- Throws:
ExecutionException- if attaching fails
-