Class ServicesAas
java.lang.Object
de.iip_ecosphere.platform.services.ServicesAas
- All Implemented Interfaces:
de.iip_ecosphere.platform.support.iip_aas.AasContributor
public class ServicesAas
extends Object
implements de.iip_ecosphere.platform.support.iip_aas.AasContributor
Implements the AAS for the services. Container ids used as short AAS ids may be translated into ids that are
valid from the perspective of the AAS implementation. All nested elements also carry their original id in
NAME_PROP_ID.
The created submodels may be used standalone or deployed to a common server. In the second case, parts of the
submodels will be complemented incrementally, e.g., the relations by the services started or the resources
by the ECS runtime.
This class builds the submodel services (NAME_SUBMODEL):
- A submodel elements collection "services"
NAME_COLL_SERVICEScontaining all declared services with their input and output types using the service id as ID. - A submodel elements collection "artifacts"
NAME_COLL_ARTIFACTSwith all artifacts implementing the services using the artifact id as ID. - A submodel elements collection "relations"
NAME_COLL_RELATIONSwith all relations connecting the services with the channel name as ID. This part is aimed at a quick lookup whether a related service is already there.
NAME_SUBMODEL_RESOURCES), containing
submodel elements named according to the Unique JVM identifier of this process containing the provided operations.
This submodel is complemented by the ECSruntime with more resource specific information.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.support.iip_aas.AasContributor
de.iip_ecosphere.platform.support.iip_aas.AasContributor.Kind -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Set<de.iip_ecosphere.platform.services.environment.ServiceState> static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddArtifact(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smB, ArtifactDescriptor desc) Adds an artifact to the given submodel builder.private static voidaddRelationData(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, List<? extends TypedDataConnectorDescriptor> descriptors, boolean input, de.iip_ecosphere.platform.support.aas.Reference serviceRef) Adds data toNAME_COLL_RELATIONS.private static voidaddService(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smB, ServiceDescriptor desc) Adds an service to the given submodel builder.private static voidaddServiceOperations(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder descriptorBuilder, ServiceDescriptor desc) Adds the service operations todescriptorBuilder.private static voidaddTypedData(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, String name, List<? extends TypedDataDescriptor> descriptors) Adds a typed data submodel elements collection to the givenbuilder.private static voidclearRelations(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, String aasDeviceId, String deviceId) Clears a relations collection from elements with the given resource property and valueaasDeviceId.private voidcontributeArtifactTo(de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder) Further operation contributions for artifacts.private voidcontributeTaskTo(de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder) Further task operation contributions.de.iip_ecosphere.platform.support.aas.AascontributeTo(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder, de.iip_ecosphere.platform.support.aas.InvocablesCreator iCreator) voidcontributeTo(de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder) createAvailabilityPredicate(int timeout, int retryDelay, boolean input) Returns an availability predicate functor to determine whether typed data connector descriptors do exist in the AAS.private voidcreateIdOp(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder smB, String name, de.iip_ecosphere.platform.support.aas.InvocablesCreator iCreator, String... otherParams) Creates an operation with a String parameter "id" and optional string parameters and a result of type string.private voidcreateServiceManagerSubmodelElements(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, de.iip_ecosphere.platform.support.aas.InvocablesCreator iCreator) Creates the elements representing a service manager.static voiddeferForCleanup(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder smBuilder) Defers the creation ofsmBuilderif the device is still in cleanup.private static voiddefineServiceOperations(ServiceDescriptor desc, de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationMode mode) Updates the service operations, e.g., to add information an updated/newly created invokable.private static voiddeleteSubmodelElement(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, String name, String elt) Safely deletes a submodel element in a nested collection.de.iip_ecosphere.platform.support.iip_aas.AasContributor.KindgetKind()private static de.iip_ecosphere.platform.support.logging.LoggerReturns the logger instance.static StringReturns the qualified name for an operation/property implementation.private static intgetServiceStateCount(String state) Returns the number of service instances in the given state.booleanisValid()static voidIs called when an artifact is added.static voidIs called when an artifact is removed.static voidCalled when the service manager disappears.static voidIs called when a service (via app instances) is added.static voidnotifyServiceStateChanged(de.iip_ecosphere.platform.services.environment.ServiceState old, de.iip_ecosphere.platform.services.environment.ServiceState act, ServiceDescriptor desc) Is called when a service state changed.static voidnotifyServiceStateChanged(de.iip_ecosphere.platform.services.environment.ServiceState old, de.iip_ecosphere.platform.services.environment.ServiceState act, ServiceDescriptor desc, de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationMode mode) Is called when a service state changed.private static String[]readStringArray(Object[] args, int index) Reads all params as string array.private static voidregisterMetrics(ServiceDescriptor desc, de.iip_ecosphere.platform.support.aas.Submodel sub, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection elt) Registers metrics for a changed service.private static voidregisterMetrics(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder subB) Registers metrics for a service service.private static voidremoveArtifact(de.iip_ecosphere.platform.support.aas.Submodel sub, ArtifactDescriptor desc) Removes the artifactdescfrom the submodelsub.static voidremoveDevice(de.iip_ecosphere.platform.support.aas.Submodel sub, String deviceId) Removes a specific device fromsub.static voidremoveDevice(String deviceId) Removes a specific device.private static de.iip_ecosphere.platform.support.aas.SubmodelElementCollectionremoveRelations(ServiceDescriptor service, de.iip_ecosphere.platform.support.aas.Submodel sub, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll) Remove the relations forservice.private static voidremoveService(ServiceDescriptor service, de.iip_ecosphere.platform.support.aas.Submodel sub) Removesservice.static voidsetCleanup(de.iip_ecosphere.platform.support.aas.Submodel sm, String deviceId) Sets the cleanup flag totrue.private static voidsetupRelations(ServiceDescriptor desc, de.iip_ecosphere.platform.support.aas.Submodel sub, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection elt) Sets up the relations for a starting service.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.support.iip_aas.AasContributor
exists, getAasAuthentication, getSubmodelAuthentication
-
Field Details
-
NAME_SUBMODEL
- See Also:
-
NAME_SUBMODEL_RESOURCES
- See Also:
-
NAME_COLL_ARTIFACTS
- See Also:
-
NAME_COLL_SERVICES
- See Also:
-
NAME_COLL_RELATIONS
- See Also:
-
NAME_COLL_SERVICE_MANAGERS
- See Also:
-
NAME_SUBCOLL_PARAMETERS
- See Also:
-
NAME_SUBCOLL_INPUT_DATA_CONN
- See Also:
-
NAME_SUBCOLL_OUTPUT_DATA_CONN
- See Also:
-
NAME_PROP_ID
- See Also:
-
NAME_PROP_APPLICATION_ID
- See Also:
-
NAME_PROP_APPLICATION_INSTANCE_ID
- See Also:
-
NAME_PROP_SERVICEMGR_ID
- See Also:
-
NAME_PROP_NAME
- See Also:
-
NAME_PROP_STATE
- See Also:
-
NAME_PROP_KIND
- See Also:
-
NAME_PROP_VERSION
- See Also:
-
NAME_PROP_DESCRIPTION
- See Also:
-
NAME_PROP_TYPE
- See Also:
-
NAME_PROP_RESOURCE
- See Also:
-
NAME_PROP_FROM
- See Also:
-
NAME_PROP_FROM_RESOURCE
- See Also:
-
NAME_PROP_TO
- See Also:
-
NAME_PROP_TO_RESOURCE
- See Also:
-
NAME_PROP_ARTIFACT
- See Also:
-
NAME_PROP_TOPLEVEL
- See Also:
-
NAME_PROP_SERVICE_AAS
- See Also:
-
NAME_PROP_DEVICE_AAS
- See Also:
-
NAME_PROP_IN_CLEANUP
- See Also:
-
NAME_PROP_SUPPORTED_APPIDS
- See Also:
-
NAME_OP_SVC_GET_STATE
- See Also:
-
NAME_OP_SVC_SET_STATE
- See Also:
-
NAME_OP_SERVICE_START
- See Also:
-
NAME_OP_SERVICE_START_TASK
- See Also:
-
NAME_OP_SERVICE_START_WITH_OPTS
- See Also:
-
NAME_OP_SERVICE_START_WITH_OPTS_TASK
- See Also:
-
NAME_OP_SERVICE_ACTIVATE
- See Also:
-
NAME_OP_SERVICE_PASSIVATE
- See Also:
-
NAME_OP_SERVICE_MIGRATE
- See Also:
-
NAME_OP_SERVICE_UPDATE
- See Also:
-
NAME_OP_SERVICE_SWITCH
- See Also:
-
NAME_OP_SERVICE_RECONF
- See Also:
-
NAME_OP_SERVICE_STOP
- See Also:
-
NAME_OP_SERVICE_STOP_TASK
- See Also:
-
NAME_OP_SERVICE_GET_STATE
- See Also:
-
NAME_OP_SERVICE_SET_STATE
- See Also:
-
NAME_OP_ARTIFACT_ADD
- See Also:
-
NAME_OP_ARTIFACT_ADD_TASK
- See Also:
-
NAME_OP_ARTIFACT_REMOVE
- See Also:
-
NAME_OP_ARTIFACT_REMOVE_TASK
- See Also:
-
NAME_OP_SERVICE_INSTANCE_COUNT
- See Also:
-
NAME_OP_SERVICE_STATE_COUNT
- See Also:
-
NAME_OP_SERVICE_STREAM_LOG
- See Also:
-
ERROR_IF_NOT_FOUND
private static final Set<de.iip_ecosphere.platform.services.environment.ServiceState> ERROR_IF_NOT_FOUND
-
-
Constructor Details
-
ServicesAas
public ServicesAas()
-
-
Method Details
-
contributeTo
public de.iip_ecosphere.platform.support.aas.Aas contributeTo(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder, de.iip_ecosphere.platform.support.aas.InvocablesCreator iCreator) - Specified by:
contributeToin interfacede.iip_ecosphere.platform.support.iip_aas.AasContributor
-
createServiceManagerSubmodelElements
private void createServiceManagerSubmodelElements(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, de.iip_ecosphere.platform.support.aas.InvocablesCreator iCreator) Creates the elements representing a service manager.- Parameters:
builder- the target builderiCreator- the invocables creator for binding (remote) property and operation implementations.
-
createIdOp
private void createIdOp(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder smB, String name, de.iip_ecosphere.platform.support.aas.InvocablesCreator iCreator, String... otherParams) Creates an operation with a String parameter "id" and optional string parameters and a result of type string. The operation name is derived fromnameapplied togetQName(String).- Parameters:
smB- the submodel elements collection buildername- the operation nameiCreator- the invocables creatorotherParams- other String parameters
-
getQName
Returns the qualified name for an operation/property implementation.- Parameters:
elementName- the element name- Returns:
- the qualified name
-
readStringArray
Reads all params as string array.- Parameters:
args- the argumentsindex- the index of the argument to read fromargs- Returns:
- the string array
-
contributeTo
public void contributeTo(de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder) - Specified by:
contributeToin interfacede.iip_ecosphere.platform.support.iip_aas.AasContributor
-
getServiceStateCount
Returns the number of service instances in the given state. Preliminarily in here, may be moved into the service manager- Parameters:
state- the state- Returns:
- the number of service instances
-
contributeArtifactTo
private void contributeArtifactTo(de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder) Further operation contributions for artifacts.- Parameters:
sBuilder- the server protocol builder
-
contributeTaskTo
private void contributeTaskTo(de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder) Further task operation contributions.- Parameters:
sBuilder- the server protocol builder
-
getKind
public de.iip_ecosphere.platform.support.iip_aas.AasContributor.Kind getKind()- Specified by:
getKindin interfacede.iip_ecosphere.platform.support.iip_aas.AasContributor
-
addArtifact
private static void addArtifact(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smB, ArtifactDescriptor desc) Adds an artifact to the given submodel builder.- Parameters:
smB- represents the submodel in creationdesc- the descriptor to be added
-
addService
private static void addService(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smB, ServiceDescriptor desc) Adds an service to the given submodel builder.- Parameters:
smB- represents the submodel in creationdesc- the descriptor to be added
-
addServiceOperations
private static void addServiceOperations(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder descriptorBuilder, ServiceDescriptor desc) Adds the service operations todescriptorBuilder. Own method as depending on AAS setup may be called twice, once without invokable, once to update the operations then with invokable.- Parameters:
descriptorBuilder- the descriptor builder representingdescdesc- the actual service descriptor to represent- See Also:
-
defineServiceOperations
private static void defineServiceOperations(ServiceDescriptor desc, de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationMode mode) Updates the service operations, e.g., to add information an updated/newly created invokable.- Parameters:
desc- the descriptormode- the notification mode, may be null for default- See Also:
-
addTypedData
private static void addTypedData(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, String name, List<? extends TypedDataDescriptor> descriptors) Adds a typed data submodel elements collection to the givenbuilder.- Parameters:
builder- the builder to use as parentname- the name of the collectiondescriptors- the descriptors to add to the parent collection
-
addRelationData
private static void addRelationData(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder builder, List<? extends TypedDataConnectorDescriptor> descriptors, boolean input, de.iip_ecosphere.platform.support.aas.Reference serviceRef) Adds data toNAME_COLL_RELATIONS.- Parameters:
builder- the builder to use as parentdescriptors- the descriptors to add to the parent collectioninput- whether we are processing input or output descriptorsserviceRef- the reference to the using service
-
createAvailabilityPredicate
public static Predicate<TypedDataConnectorDescriptor> createAvailabilityPredicate(int timeout, int retryDelay, boolean input) Returns an availability predicate functor to determine whether typed data connector descriptors do exist in the AAS.- Parameters:
timeout- the timeout in ms within the request shall be repeated without directly failingretryDelay- time delay in ms after which a failed request shall be re-triedinput- whether input or output side of the relation shall be queried- Returns:
- the predictate for testing
-
notifyArtifactAdded
Is called when an artifact is added.- Parameters:
desc- the artifact descriptor
-
notifyServiceAdded
Is called when a service (via app instances) is added.- Parameters:
desc- the service descriptor
-
notifyArtifactRemoved
Is called when an artifact is removed.- Parameters:
desc- the artifact descriptor
-
removeArtifact
private static void removeArtifact(de.iip_ecosphere.platform.support.aas.Submodel sub, ArtifactDescriptor desc) Removes the artifactdescfrom the submodelsub. Removes also all services.- Parameters:
sub- the submodeldesc- the artifact descriptor to remove
-
notifyManagerRemoved
public static void notifyManagerRemoved()Called when the service manager disappears. -
removeRelations
private static de.iip_ecosphere.platform.support.aas.SubmodelElementCollection removeRelations(ServiceDescriptor service, de.iip_ecosphere.platform.support.aas.Submodel sub, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll) Remove the relations forservice.- Parameters:
service- the servicesub- the submodel forNAME_SUBMODEL.coll- therelationssubmodel elements collection, may be null thensubis queried for the collection- Returns:
collor the queried collection
-
removeService
private static void removeService(ServiceDescriptor service, de.iip_ecosphere.platform.support.aas.Submodel sub) Removesservice.- Parameters:
service- the servicesub- the submodel forNAME_SUBMODEL.
-
deleteSubmodelElement
private static void deleteSubmodelElement(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, String name, String elt) Safely deletes a submodel element in a nested collection.- Parameters:
coll- the parent collectionname- name the child collectionelt- element the element to delete
-
notifyServiceStateChanged
public static void notifyServiceStateChanged(de.iip_ecosphere.platform.services.environment.ServiceState old, de.iip_ecosphere.platform.services.environment.ServiceState act, ServiceDescriptor desc) Is called when a service state changed.- Parameters:
old- the previous state before the changeact- the actual state after the changedesc- the service descriptor (depending on implementation, may have the new state or not)
-
notifyServiceStateChanged
public static void notifyServiceStateChanged(de.iip_ecosphere.platform.services.environment.ServiceState old, de.iip_ecosphere.platform.services.environment.ServiceState act, ServiceDescriptor desc, de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationMode mode) Is called when a service state changed.- Parameters:
old- the previous state before the changeact- the actual state after the changedesc- the service descriptor (depending on implementation, may have the new state or not)mode- explicit notification mode to be used (if null, use the mode defined inActiveAasBase)
-
registerMetrics
private static void registerMetrics(ServiceDescriptor desc, de.iip_ecosphere.platform.support.aas.Submodel sub, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection elt) Registers metrics for a changed service.- Parameters:
desc- the service descriptorsub- the submodelelt- the element representing the service
-
registerMetrics
private static void registerMetrics(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder subB) Registers metrics for a service service.- Parameters:
subB- the submodel element collection builder representing the service
-
setupRelations
private static void setupRelations(ServiceDescriptor desc, de.iip_ecosphere.platform.support.aas.Submodel sub, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection elt) Sets up the relations for a starting service.- Parameters:
desc- the service descriptorsub- the submodelelt- the element representing the service
-
removeDevice
Removes a specific device.- Parameters:
deviceId- the device id- See Also:
-
removeDevice
public static void removeDevice(de.iip_ecosphere.platform.support.aas.Submodel sub, String deviceId) Removes a specific device fromsub.- Parameters:
sub- the submodel to delete fromdeviceId- the device id
-
clearRelations
private static void clearRelations(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection coll, String aasDeviceId, String deviceId) Clears a relations collection from elements with the given resource property and valueaasDeviceId.- Parameters:
coll- the collection to be clearedaasDeviceId- the AAS device iddeviceId- the readable device ID
-
setCleanup
Sets the cleanup flag totrue.- Parameters:
sm- the submodel to set the cleanup flag ondeviceId- the device ID of the device to set into cleanup
-
deferForCleanup
public static void deferForCleanup(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder smBuilder) Defers the creation ofsmBuilderif the device is still in cleanup.- Parameters:
smBuilder- the device submodel builder
-
getLogger
private static de.iip_ecosphere.platform.support.logging.Logger getLogger()Returns the logger instance.- Returns:
- the logger instance
-
isValid
public boolean isValid()- Specified by:
isValidin interfacede.iip_ecosphere.platform.support.iip_aas.AasContributor
-