Class SpringCloudServiceDescriptor
- java.lang.Object
-
- de.iip_ecosphere.platform.services.AbstractServiceDescriptor<SpringCloudArtifactDescriptor>
-
- de.iip_ecosphere.platform.services.spring.SpringCloudServiceDescriptor
-
- All Implemented Interfaces:
de.iip_ecosphere.platform.services.ServiceDescriptor
public class SpringCloudServiceDescriptor extends de.iip_ecosphere.platform.services.AbstractServiceDescriptor<SpringCloudArtifactDescriptor>
Specific descriptor implementation for spring cloud streams. [public for testing] Relies on parameter functions fromStarter.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private de.iip_ecosphere.platform.support.net.ManagedServerAddressadminAddrprivate java.lang.StringdeploymentIdprivate SpringCloudServiceDescriptorensembleLeaderprivate java.util.List<java.lang.String>portKeysprivate java.lang.Processprocessprivate java.io.FileprocessDirprivate Serverserverprivate Serviceserviceprivate java.lang.StringserviceProtocol
-
Constructor Summary
Constructors Modifier Constructor Description SpringCloudServiceDescriptor(Service service, TypeResolver resolver)Creates an instance.protectedSpringCloudServiceDescriptor(java.lang.String id, java.lang.String applicationId, java.lang.String name, java.lang.String description, de.iip_ecosphere.platform.support.iip_aas.Version version)Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidattachStub()Attaches a service stub to directly interact with the service ifadminAddrhas been set bycreateDeploymentRequest(SpringCloudServiceSetup, List)before.(package private) java.util.List<java.lang.String>collectCmdArguments(SpringCloudServiceSetup config, int port, java.lang.String protocol)Collects basic command line arguments.(package private) org.springframework.cloud.deployer.spi.core.AppDeploymentRequestcreateDeploymentRequest(SpringCloudServiceSetup config, java.util.List<java.lang.String> cmdArgs)Creates the deployment request for the Spring deployer.(package private) static SpringCloudServiceDescriptorcreateFor(Server server)Creates a temporary descriptor for the given server spec instance.(package private) voiddetachStub()Detaches an attached service stub.(package private) java.lang.StringgetAasNetmanagerKey()Returns theNetworkManagerkey for the AAS command connection to an external process.protected java.lang.Class<SpringCloudArtifactDescriptor>getArtifactDescriptorClass()(package private) java.lang.StringgetDeploymentId()Returns the Spring cloud deployer deployment id.SpringCloudServiceDescriptorgetEnsembleLeader()java.lang.StringgetGroup()Returns the deployment group.de.iip_ecosphere.platform.support.aas.InvocablesCreatorgetInvocablesCreator()(package private) ServergetServer()If the service represents a server, return the server specification.private java.lang.StringgetStreamingNetmanagerKey()Returns theNetworkManagerkey for the streaming connection to an external process.ServicegetSvc()Returns the YAML descriptor.private java.lang.StringgetTransportHost(SpringCloudServiceSetup setup)Returns the actual transport host.private intgetTransportPort(SpringCloudServiceSetup setup)Returns the actual transport port.(package private) SpringCloudServiceDescriptorinstantiate(java.lang.String sId)Instantiates this service as a template to represent an instance service with idserviceId.private de.iip_ecosphere.platform.support.net.ManagedServerAddressregisterPort(de.iip_ecosphere.platform.support.net.NetworkManager mgr, java.lang.String key)Obtains a network port and registers it if necessary for release insetState(ServiceState).private voidrelease()(package private) voidsetDeploymentId(java.lang.String id)Sets the Spring cloud deployer deployment id.(package private) voidsetEnsembleLeader(SpringCloudServiceDescriptor ensembleLeader)Defines the ensemble leader.voidsetState(de.iip_ecosphere.platform.services.environment.ServiceState state)(package private) intstartProcess(SpringCloudServiceSetup config, ProcessSpec pSpec)Starts the non-Java execution process if needed.static java.lang.StringtoFunctionDefinition(java.util.Set<de.iip_ecosphere.platform.services.AbstractServiceManager.TypedDataConnection> conn)Turns typed data connections into a Spring cloud function definition argument.(package private) voidwaitForAdminServer(int waitingTime)Waits that the server onadminAddrbecomes available.-
Methods inherited from class de.iip_ecosphere.platform.services.AbstractServiceDescriptor
addInputDataConnector, addOutputDataConnector, addParameter, connectorIds, ensemble, ensembleConnectorNames, getAdditionalArguments, getApplicationId, getArtifact, getDataConnectors, getDescription, getId, getInputDataConnectors, getKind, getName, getOutputDataConnectors, getParameters, getState, getStub, getVersion, instantiateFrom, internalConnectorNames, isDeployable, isTopLevel, setAdditionalArguments, setArtifact, setClassification, setStub
-
-
-
-
Field Detail
-
service
private Service service
-
ensembleLeader
private SpringCloudServiceDescriptor ensembleLeader
-
deploymentId
private java.lang.String deploymentId
-
portKeys
private java.util.List<java.lang.String> portKeys
-
process
private java.lang.Process process
-
processDir
private java.io.File processDir
-
serviceProtocol
private java.lang.String serviceProtocol
-
adminAddr
private de.iip_ecosphere.platform.support.net.ManagedServerAddress adminAddr
-
server
private Server server
-
-
Constructor Detail
-
SpringCloudServiceDescriptor
public SpringCloudServiceDescriptor(Service service, TypeResolver resolver)
Creates an instance.- Parameters:
service- the service deployment specification objectresolver- the (artifact) type resolver- See Also:
AbstractServiceDescriptor.setClassification(de.iip_ecosphere.platform.services.environment.ServiceKind, boolean, boolean)
-
SpringCloudServiceDescriptor
protected SpringCloudServiceDescriptor(java.lang.String id, java.lang.String applicationId, java.lang.String name, java.lang.String description, de.iip_ecosphere.platform.support.iip_aas.Version version)Creates an instance. CallAbstractServiceDescriptor.setClassification(ServiceKind, boolean, boolean)afterwards.- Parameters:
id- the service idapplicationId- the application id, may be empty for default application/legacyname- the name of this servicedescription- the description of the serviceversion- the version
-
-
Method Detail
-
createFor
static SpringCloudServiceDescriptor createFor(Server server)
Creates a temporary descriptor for the given server spec instance.- Parameters:
server- the server spec instance- Returns:
- the descriptor
-
getServer
Server getServer()
If the service represents a server, return the server specification.- Returns:
- the server specification, may be null
-
instantiate
SpringCloudServiceDescriptor instantiate(java.lang.String sId)
Instantiates this service as a template to represent an instance service with idserviceId. Typically, the application instance id changes compared to existing service descriptors.- Parameters:
sId- the service id- Returns:
- the instantiated service
-
getArtifactDescriptorClass
protected java.lang.Class<SpringCloudArtifactDescriptor> getArtifactDescriptorClass()
- Specified by:
getArtifactDescriptorClassin classde.iip_ecosphere.platform.services.AbstractServiceDescriptor<SpringCloudArtifactDescriptor>
-
setState
public void setState(de.iip_ecosphere.platform.services.environment.ServiceState state) throws java.util.concurrent.ExecutionException- Specified by:
setStatein interfacede.iip_ecosphere.platform.services.ServiceDescriptor- Overrides:
setStatein classde.iip_ecosphere.platform.services.AbstractServiceDescriptor<SpringCloudArtifactDescriptor>- Throws:
java.util.concurrent.ExecutionException
-
release
private void release()
-
registerPort
private de.iip_ecosphere.platform.support.net.ManagedServerAddress registerPort(de.iip_ecosphere.platform.support.net.NetworkManager mgr, java.lang.String key)Obtains a network port and registers it if necessary for release insetState(ServiceState).- Parameters:
mgr- the network manager instancekey- the key to obtain the network address- Returns:
- the obtained address
-
setEnsembleLeader
void setEnsembleLeader(SpringCloudServiceDescriptor ensembleLeader)
Defines the ensemble leader.- Parameters:
ensembleLeader- optional ensemble leader some information shall be taken from/synchronized with
-
getGroup
public java.lang.String getGroup()
Returns the deployment group.- Returns:
- the deployment group
-
getEnsembleLeader
public SpringCloudServiceDescriptor getEnsembleLeader()
- Specified by:
getEnsembleLeaderin interfacede.iip_ecosphere.platform.services.ServiceDescriptor- Overrides:
getEnsembleLeaderin classde.iip_ecosphere.platform.services.AbstractServiceDescriptor<SpringCloudArtifactDescriptor>
-
createDeploymentRequest
org.springframework.cloud.deployer.spi.core.AppDeploymentRequest createDeploymentRequest(SpringCloudServiceSetup config, java.util.List<java.lang.String> cmdArgs) throws java.util.concurrent.ExecutionException
Creates the deployment request for the Spring deployer.- Parameters:
config- the service manager configuration instancecmdArgs- further command line arguments to be considered, may be null or empty for none- Returns:
- the deployment request, may be null if this service is an ensemble follower and should not be started individually
- Throws:
java.util.concurrent.ExecutionException- when preparing the service fails for some reason
-
collectCmdArguments
java.util.List<java.lang.String> collectCmdArguments(SpringCloudServiceSetup config, int port, java.lang.String protocol)
Collects basic command line arguments.- Parameters:
config- the configurationport- the network port to substitute in the service command line argumentsprotocol- the protocol, may be empty for none- Returns:
- the command line arguments
-
getTransportHost
private java.lang.String getTransportHost(SpringCloudServiceSetup setup)
Returns the actual transport host. [legacy fallback, due to testing]- Parameters:
setup- the instance to take the information from- Returns:
- the host
-
getTransportPort
private int getTransportPort(SpringCloudServiceSetup setup)
Returns the actual transport port. [legacy fallback, due to testing]- Parameters:
setup- the instance to take the information from- Returns:
- the port
-
attachStub
void attachStub()
Attaches a service stub to directly interact with the service ifadminAddrhas been set bycreateDeploymentRequest(SpringCloudServiceSetup, List)before.
-
waitForAdminServer
void waitForAdminServer(int waitingTime)
Waits that the server onadminAddrbecomes available.- Parameters:
waitingTime- maximum waiting time in ms
-
detachStub
void detachStub()
Detaches an attached service stub.
-
getInvocablesCreator
public de.iip_ecosphere.platform.support.aas.InvocablesCreator getInvocablesCreator()
-
startProcess
int startProcess(SpringCloudServiceSetup config, ProcessSpec pSpec) throws java.util.concurrent.ExecutionException
Starts the non-Java execution process if needed.- Parameters:
config- the service manager configuration instancepSpec- the specification of the service to start- Returns:
- the process port, valid if positive
- Throws:
java.util.concurrent.ExecutionException- when preparing the service fails for some reason
-
getStreamingNetmanagerKey
private java.lang.String getStreamingNetmanagerKey()
Returns theNetworkManagerkey for the streaming connection to an external process.- Returns:
- the key
-
getAasNetmanagerKey
java.lang.String getAasNetmanagerKey()
Returns theNetworkManagerkey for the AAS command connection to an external process.- Returns:
- the key
-
setDeploymentId
void setDeploymentId(java.lang.String id)
Sets the Spring cloud deployer deployment id.- Parameters:
id- the deployment id
-
getDeploymentId
java.lang.String getDeploymentId()
Returns the Spring cloud deployer deployment id.- Returns:
- the deployment id, may be null for not deployed
-
getSvc
public Service getSvc()
Returns the YAML descriptor. [for testing]- Returns:
- the YAML descriptor
-
toFunctionDefinition
public static java.lang.String toFunctionDefinition(java.util.Set<de.iip_ecosphere.platform.services.AbstractServiceManager.TypedDataConnection> conn)
Turns typed data connections into a Spring cloud function definition argument.- Parameters:
conn- the connections- Returns:
- the composed function definition argument
-
-