Class TraceToAasService
java.lang.Object
de.iip_ecosphere.platform.services.environment.AbstractService
de.iip_ecosphere.platform.services.environment.services.TraceToAasService
- All Implemented Interfaces:
ParameterConfigurerProvider,Service,ServiceBase
Implements a generic service that maps
TraceRecord to an (application) AAS.
This service is in development/preliminary. The service does not take any data or produce data,
it is just meant to create up the trace record AAS entries. It can be used as a sink.
Currently, the service builds up the AAS of an application. However, this functionality
shall be moved that the platform is providing the AAS and the service just hooks the traces submodel into.
Can optionally send AAS data to a transport channel (see createTransport(BasicSerializerProvider),
getAasTransportChannel(), getTransportParameter()).- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA configured transport to AAS converter forTraceRecord.private static classRepresents construction information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate de.iip_ecosphere.platform.support.iip_aas.ApplicationSetupprivate YamlArtifactprivate TransportConverter<de.iip_ecosphere.platform.transport.status.TraceRecord> private de.iip_ecosphere.platform.transport.connectors.TransportConnectorprivate de.iip_ecosphere.platform.transport.connectors.TransportParameterprivate Map<String, ParameterConfigurer<?>> static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate DataRecorderprivate de.iip_ecosphere.platform.support.Serverstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase
APPLICATION_SEPARATOR, DEFAULT_APPLICATION_INSTANCE_ID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateIntermediary constructor based onTraceToAasService.YamlConstructionInfo.TraceToAasService(YamlArtifact artifact, String serviceId) Creates a service instance.TraceToAasService(de.iip_ecosphere.platform.support.iip_aas.ApplicationSetup app, YamlService yaml) Creates a service instance.TraceToAasService(String serviceId, InputStream ymlFile) Creates a service instance from a service id and a YAML artifact. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> voidaddParameterConfigurer(ParameterConfigurer<T> configurer) Adds a parameter configurer.protected voidaugmentCommandsSubmodel(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder) Allows adding application-specific elements to the command submodel, e.g., operations.private voidaugmentServicesSubmodel(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder) Adds elements to the services submodel if available.booleancleanup()Pursues a cleanup of the (internally known) AAS.protected StringcomposeIdentifier(String specificId) Composes an identifier based ongetAasUrn()and the given specific identifier.protected TransportConverter.ConverterInstances<de.iip_ecosphere.platform.transport.status.TraceRecord> Creates the actual converter instance.protected DataRecorderCreates an optional data recorder instance.protected final DataRecorderCreates a default data recorder instance (writes to target in JSON format).protected de.iip_ecosphere.platform.transport.connectors.TransportConnectorCreates a transport connector by combiningcreateTransport(BasicSerializerProvider)andgetConfiguredSerializationProvider().protected de.iip_ecosphere.platform.transport.connectors.TransportConnectorcreateTransport(de.iip_ecosphere.platform.transport.serialization.BasicSerializerProvider serializationProvider) Creates an optional transport connector to pump received data out.getAasId()Returns the AAS idShort of the AAS represented by this service/application.protected StringReturns the AAS transport channel.Returns the AAS URN of the AAS represented by this service/application.de.iip_ecosphere.platform.support.iip_aas.ApplicationSetupReturns the application setup.protected de.iip_ecosphere.platform.transport.serialization.BasicSerializerProviderReturns a pre-configured serialization provider for the output connector.de.iip_ecosphere.platform.support.ServerReturns the local gateway server.getParameterConfigurer(String paramName) Returns the parameter configurer for a given parameter.protected de.iip_ecosphere.platform.transport.connectors.TransportConnectorReturns the optional transport connector to pump received data out.de.iip_ecosphere.platform.transport.connectors.TransportParameterReturns the optional transport parameters.protected booleanReturns whether the AAS is enabled and shall be set up (the default) or whether it is intentionally deactivated and shall not be started/modified.booleanReturns whether the AAS was started/startup is done.booleanReturns whether traced data is directly stored in the AAS or not.protected StringmapPayloadType(Class<?> cls) Allows for application specific payload type names.voidMigrates a service.protected voidrecordData(String channel, Object data) Allows to record arbitrary data.protected voidRegisters own parameter configurers.protected de.iip_ecosphere.platform.support.aas.AasRetrieves the App AAS.protected voidsendTransportAsync(String channel, Object data) Sends data asynchronously via the optional transport connector.voidsetCleanupTimeout(long cleanupTimeout) Changes the cleanup timeout, i.e., the time between two cleanups.voidsetTimeout(long timeout) Changes the timeout until trace events are deleted.voidsetTransportParameter(de.iip_ecosphere.platform.transport.connectors.TransportParameter transportParameter) Defines the transport parameter forcreateTransport(BasicSerializerProvider).protected ServiceStatestart()Starts the service and the background process.protected ServiceStatestop()Stops the service and the background process.voidSwitches to an interface-compatible service.voidUpdates the service by the service in the givenlocation.Methods inherited from class de.iip_ecosphere.platform.services.environment.AbstractService
activate, addConfigurer, addConfigurer, addConfigurer, addTypeSubstitution, createGenericInstance, createGenericInstance, createGenericInstanceByPlugin, createGenericMultiInstance, createGenericMultiInstance, createGenericMultiInstanceByPlugin, createInstance, createInstance, createInstance, createInstanceByPlugin, getArg, getDescription, getId, getKind, getName, getNetMgtKeyAddress, getResourceAsStream, getState, getStringArg, getSubstitutedType, getTypeCreator, getTypeSubstitutions, getVersion, initializeFrom, isDeployable, isTopLevel, notifyReconfigured, passivate, reconf, reconfigure, reconfigure, rollbackReconfigurationOnFailure, setLibJars, setState, transferDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.services.environment.Service
createType, createType, getParameterNames
-
Field Details
-
VERSION
- See Also:
-
TRANSPORT_CHANNEL_PREFIX
- See Also:
-
SUBMODEL_TRACES
- See Also:
-
SUBMODEL_COMMANDS
- See Also:
-
SUBMODEL_SERVICES
- See Also:
-
PROPERTY_SOURCE
- See Also:
-
PROPERTY_ACTION
- See Also:
-
PROPERTY_TIMESTAMP
- See Also:
-
PROPERTY_PAYLOAD_TYPE
- See Also:
-
PROPERTY_PAYLOAD
- See Also:
-
paramConfigurers
-
appSetup
private de.iip_ecosphere.platform.support.iip_aas.ApplicationSetup appSetup -
artifact
-
converter
-
outTransport
private de.iip_ecosphere.platform.transport.connectors.TransportConnector outTransport -
outTransportParameter
private de.iip_ecosphere.platform.transport.connectors.TransportParameter outTransportParameter -
recorder
-
server
private de.iip_ecosphere.platform.support.Server server
-
-
Constructor Details
-
TraceToAasService
public TraceToAasService(de.iip_ecosphere.platform.support.iip_aas.ApplicationSetup app, YamlService yaml) Creates a service instance.- Parameters:
app- static information about the applicationyaml- the service description
-
TraceToAasService
Creates a service instance from a service id and a YAML artifact.- Parameters:
serviceId- the service idymlFile- the YML file containing the YAML artifact with the service descriptor
-
TraceToAasService
Intermediary constructor based onTraceToAasService.YamlConstructionInfo.- Parameters:
info- the information instance
-
TraceToAasService
Creates a service instance.- Parameters:
artifact- static information about the artifact this service is member ofserviceId- the id of the service
-
-
Method Details
-
getGatewayServer
public de.iip_ecosphere.platform.support.Server getGatewayServer()Returns the local gateway server.- Returns:
- the server instance, may be null for none
-
registerParameterConfigurers
protected void registerParameterConfigurers()Registers own parameter configurers. Called by constructor. UseaddParameterConfigurer(ParameterConfigurer)to declare a parameter. -
createDataRecorder
Creates an optional data recorder instance.- Returns:
- the data recorder instance, may be null for none
- See Also:
-
createDataRecorderOrig
Creates a default data recorder instance (writes to target in JSON format). Cannot be overriden to be accessible to subclasses althoughcreateDataRecorder()is overridden.- Returns:
- the data recorder instance, may be null for none
- See Also:
-
createConverter
protected TransportConverter.ConverterInstances<de.iip_ecosphere.platform.transport.status.TraceRecord> createConverter()Creates the actual converter instance.- Returns:
- the converter, the default one goes for web sockets (due to AAS performance problems)
-
setTimeout
public void setTimeout(long timeout) Changes the timeout until trace events are deleted.- Parameters:
timeout- the timeout in ms
-
setCleanupTimeout
public void setCleanupTimeout(long cleanupTimeout) Changes the cleanup timeout, i.e., the time between two cleanups.- Parameters:
cleanupTimeout- the timeout in ms
-
cleanup
public boolean cleanup()Pursues a cleanup of the (internally known) AAS.- Returns:
- whether a cleanup process was executed (not whether elements were deleted)
-
getApplicationSetup
public de.iip_ecosphere.platform.support.iip_aas.ApplicationSetup getApplicationSetup()Returns the application setup.- Returns:
- the application setup
-
addParameterConfigurer
Adds a parameter configurer.- Type Parameters:
T- the type of the parameter- Parameters:
configurer- the configurer instance, ignored if null
-
getAasId
Returns the AAS idShort of the AAS represented by this service/application.- Returns:
- the idShort
-
getAasUrn
Returns the AAS URN of the AAS represented by this service/application.- Returns:
- the URN
-
isAasEnabled
protected boolean isAasEnabled()Returns whether the AAS is enabled and shall be set up (the default) or whether it is intentionally deactivated and shall not be started/modified.- Returns:
truefor enabled (default),falsefor disabled
-
mapPayloadType
Allows for application specific payload type names.- Parameters:
cls- the type- Returns:
- the mapped name
-
composeIdentifier
Composes an identifier based ongetAasUrn()and the given specific identifier.- Parameters:
specificId- the specific identifier- Returns:
- the composed identifier
- See Also:
-
start
Description copied from class:AbstractServiceStarts the service and the background process.- Overrides:
startin classAbstractService- Returns:
- the state to transition to, may be null for none
- Throws:
ExecutionException- if starting the process fails
-
recordData
Allows to record arbitrary data.- Parameters:
channel- the channel, may be empty or nulldata- the data to be recorded
-
stop
Description copied from class:AbstractServiceStops the service and the background process.- Overrides:
stopin classAbstractService- Returns:
- the state to transition to, may be null for none
-
isAasStarted
public boolean isAasStarted()Returns whether the AAS was started/startup is done.- Returns:
truefor started,falseelse
-
getAasTransportChannel
Returns the AAS transport channel.- Returns:
- the AAS transport channel (per default, a combination of
TRANSPORT_CHANNEL_PREFIXand theServiceBase.getApplicationId(String)
-
getConfiguredSerializationProvider
protected de.iip_ecosphere.platform.transport.serialization.BasicSerializerProvider getConfiguredSerializationProvider()Returns a pre-configured serialization provider for the output connector. Please consider registering data type implementations rather than data type interfaces.- Returns:
- the provider
-
setTransportParameter
public void setTransportParameter(de.iip_ecosphere.platform.transport.connectors.TransportParameter transportParameter) Defines the transport parameter forcreateTransport(BasicSerializerProvider).- Parameters:
transportParameter- the transport parameter
-
createTransport
protected de.iip_ecosphere.platform.transport.connectors.TransportConnector createTransport()Creates a transport connector by combiningcreateTransport(BasicSerializerProvider)andgetConfiguredSerializationProvider().- Returns:
- the connector
-
createTransport
protected de.iip_ecosphere.platform.transport.connectors.TransportConnector createTransport(de.iip_ecosphere.platform.transport.serialization.BasicSerializerProvider serializationProvider) Creates an optional transport connector to pump received data out. [factory]- Parameters:
serializationProvider- pre-configured serialization provider- Returns:
- the transport connector, may be null for none
-
getTransport
protected de.iip_ecosphere.platform.transport.connectors.TransportConnector getTransport()Returns the optional transport connector to pump received data out.- Returns:
- the transport connector, may be null for none
-
getTransportParameter
public de.iip_ecosphere.platform.transport.connectors.TransportParameter getTransportParameter()Returns the optional transport parameters.- Returns:
- the transport parameter, may be null for none
-
sendTransportAsync
Sends data asynchronously via the optional transport connector. Does nothing if there is no transport connector,createTransport(BasicSerializerProvider).- Parameters:
channel- the channel to send todata- the data object to send
-
augmentServicesSubmodel
private void augmentServicesSubmodel(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder) Adds elements to the services submodel if available.- Parameters:
smBuilder- the submodel builder
-
augmentCommandsSubmodel
protected void augmentCommandsSubmodel(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder) Allows adding application-specific elements to the command submodel, e.g., operations. May not be called ifAAS enabled suppliersignals that there shall not be an AAS.- Parameters:
smBuilder- the builder, do not callBuilder.build()in here!
-
migrate
Description copied from interface:ServiceMigrates a service. However, it may be required to migrate/move the containing artifact. [adaptation]- Parameters:
resourceId- the target resource id, e.g., a device- Throws:
ExecutionException- if migration fails
-
update
Description copied from interface:ServiceUpdates 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:
location- 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
-
switchTo
Description copied from interface:ServiceSwitches to an interface-compatible service. This method cares for stopping the old service, performing a handover if adequate, starting thetargetservice. [adaptation]- Parameters:
targetId- the id of the target service- Throws:
ExecutionException- if switching the service cannot be performed for some reason
-
getParameterConfigurer
Description copied from interface:ParameterConfigurerProviderReturns the parameter configurer for a given parameter. We need this generic approach to ease code generation and initial setting of parameter values.- Parameters:
paramName- the name of the parameter- Returns:
- the associated parameter configurer or null if there is none
-
retrieveAas
Retrieves the App AAS.- Returns:
- the AAS
- Throws:
IOException- if the App AAS cannot be retrieved, in particular ifAAS enabled suppliersignals that there shall not be an AAS.
-
isTraceInAas
public boolean isTraceInAas()Returns whether traced data is directly stored in the AAS or not.- Returns:
truefor traced data in AAS,falseelse
-