Class PythonWsProcessService
java.lang.Object
de.iip_ecosphere.platform.services.environment.AbstractService
de.iip_ecosphere.platform.services.environment.AbstractRunnablesService
de.iip_ecosphere.platform.services.environment.AbstractPythonProcessService
de.iip_ecosphere.platform.services.environment.PythonAsyncProcessService
de.iip_ecosphere.platform.services.environment.PythonWsProcessService
- All Implemented Interfaces:
GenericMultiTypeService,ParameterConfigurerProvider,Service,ServiceBase
Generic WebSocket-based Python integration for asynchronous processing of multiple data types. Conventions:
- Python is determined by
PythonUtils.getPythonExecutable(). The default is "ServiceEnvironment.py" which must run for this integration with "--mode WS" and given port. - The Python program runs endless until stopped by this class.
- An asynchronous Python program receives the data via command line input streams based on the input serializer and the symbolic type name.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classWebsocket client implementation.Nested classes/interfaces inherited from class de.iip_ecosphere.platform.services.environment.AbstractPythonProcessService
AbstractPythonProcessService.InputHandler, AbstractPythonProcessService.SyncDataIngestor<D> -
Field Summary
FieldsFields inherited from class de.iip_ecosphere.platform.services.environment.AbstractPythonProcessService
TYPE_SEPARATOR_CHARFields inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase
APPLICATION_SEPARATOR, DEFAULT_APPLICATION_INSTANCE_ID -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of the service.PythonWsProcessService(String serviceId, InputStream ymlFile) Creates an instance from a service id and a YAML artifact. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateScanInputThread(Process proc) Creates the input scanning thread.protected voidcustomizePythonArgs(List<String> pythonArgs) Allows to customize the Python command line arguments taken from the yaml spec.longReturns the average response time for the execution in Python (without transport).protected static de.iip_ecosphere.platform.support.logging.LoggerReturns the logger.protected voidinitializeFrom(YamlService yaml) Does further initialization of this instance from the given YAML information.protected voidsendToService(String type, Object data) Sendstextas input to the service process.protected ServiceStatestop()Stops the service and the background process.Methods inherited from class de.iip_ecosphere.platform.services.environment.PythonAsyncProcessService
activate, migrate, passivate, process, processSync, reconfigure, setState, start, switchTo, updateMethods inherited from class de.iip_ecosphere.platform.services.environment.AbstractPythonProcessService
addParameterConfigurer, attachIngestor, compose, createAndCustomizeProcess, createScanInputThread, enableFileDeletion, getHome, getInTypeInfo, getLocationKey, getOutTypeInfo, getOutTypeName, getParameterConfigurer, getParameterNames, getPythonExecutable, getTypeSubstitutionsJson, handleErrorStream, handleResult, isFileDeletionEnabled, registerInOutRelation, registerInputTypeTranslator, registerOutputTypeTranslator, scanInputStream, startExecutableByName, toJson, unbufferMethods inherited from class de.iip_ecosphere.platform.services.environment.AbstractRunnablesService
registerMethods inherited from class de.iip_ecosphere.platform.services.environment.AbstractService
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, isDeployable, isTopLevel, notifyReconfigured, reconf, reconfigure, rollbackReconfigurationOnFailure, setLibJars, 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.GenericMultiTypeService
processQuiet, processSyncQuietMethods inherited from interface de.iip_ecosphere.platform.services.environment.Service
addTypeSubstitution, createType, createType, getDescription, getKind, getName, getNetMgtKeyAddress, getSubstitutedType, getTypeCreator, getTypeSubstitutions, getVersion, isDeployable, isTopLevelMethods inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase
getId, getState
-
Field Details
-
instancePort
private int instancePort -
averageResponseTime
private long averageResponseTime -
socket
-
networkPortKey
-
-
Constructor Details
-
PythonWsProcessService
Creates an 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
-
PythonWsProcessService
Creates an instance of the service.- Parameters:
yaml- the service description
-
-
Method Details
-
initializeFrom
Description copied from class:AbstractServiceDoes further initialization of this instance from the given YAML information.- Overrides:
initializeFromin classAbstractPythonProcessService- Parameters:
yaml- the service information as read from YAML
-
customizePythonArgs
Description copied from class:AbstractPythonProcessServiceAllows to customize the Python command line arguments taken from the yaml spec.- Overrides:
customizePythonArgsin classAbstractPythonProcessService- Parameters:
pythonArgs- the arguments to customize
-
createScanInputThread
Description copied from class:PythonAsyncProcessServiceCreates the input scanning thread.- Overrides:
createScanInputThreadin classPythonAsyncProcessService- Parameters:
proc- the process instance to observe
-
stop
Description copied from class:AbstractServiceStops the service and the background process.- Overrides:
stopin classPythonAsyncProcessService- Returns:
- the state to transition to, may be null for none
-
sendToService
Description copied from class:PythonAsyncProcessServiceSendstextas input to the service process.- Overrides:
sendToServicein classPythonAsyncProcessService- Parameters:
type- the type of the data to be sentdata- the data to be sent- Throws:
ExecutionException- if sending fails for some reason
-
getLogger
protected static de.iip_ecosphere.platform.support.logging.Logger getLogger()Returns the logger.- Returns:
- the logger
-
getAvgResponseTime
public long getAvgResponseTime()Description copied from class:AbstractPythonProcessServiceReturns the average response time for the execution in Python (without transport).- Overrides:
getAvgResponseTimein classAbstractPythonProcessService- Returns:
- the average response time (in nanoseconds)
-