Class Transport.TransportInstance
java.lang.Object
de.iip_ecosphere.platform.transport.Transport.TransportInstance
- Enclosing class:
Transport
An instance of the transport.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TransportConnectorprivate longprivate Queue<de.iip_ecosphere.platform.support.function.IOConsumer<TransportConnector>> private booleanprivate Supplier<TransportSetup> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a transport instance without transport setup information (for deferred setup).TransportInstance(Supplier<TransportSetup> supplier) Creates a transport information instance and sets the transport information. -
Method Summary
Modifier and TypeMethodDescriptionTries creating a connector.Returns the transport connector.voidReleases an existing connector and stays offline.voidreleaseConnector(boolean stayOff) Releases an existing connector.voidsend(de.iip_ecosphere.platform.support.function.IOConsumer<TransportConnector> sender, String kind) Sends a message of a certainkindand cares for queuing.voidSends an alert message.voidsendContainerStatus(ActionType action, String containerId, String... aliasIds) Sends a container status message.voidsendProcessStatus(String componentId, int step, int max, String description) Sends information about a processing status.voidsendProcessStatus(String componentId, int step, int max, String description, String subDescription) Sends information about a processing status.voidsendProcessStatus(String componentId, ActionTypes type, Object result) Sends information about finalizing a task-based process.voidsendResourceStatus(ActionType action, String... aliasIds) Sends a resource status message for this resource.voidsendResourceStatus(ActionType action, String deviceId, String... aliasIds) Sends a resource status message.voidsendServiceArtifactStatus(ActionType action, String artifactId, String... aliasIds) Sends a service artifact status message.voidsendServiceStatus(ActionType action, String serviceId, String... aliasIds) Sends a service status message.voidsendServiceStatusWithDescription(ActionType action, String serviceId, String description, String... aliasIds) Sends a service status message.voidsendStatus(StatusMessage msg) Sends a status message.voidsendTraceRecord(TraceRecord record) Sends a trace record.voidsetTraceFilter(Predicate<TraceRecord> filter) Defines a trace filter.setTransportSetup(Supplier<TransportSetup> supplier) Sets up the transport information.
-
Field Details
-
connector
-
stayOffline
private boolean stayOffline -
queue
-
transportSupplier
-
lastQueuedMsg
private long lastQueuedMsg
-
-
Constructor Details
-
TransportInstance
public TransportInstance()Creates a transport instance without transport setup information (for deferred setup). CallsetTransportSetup(Supplier)afterwards. -
TransportInstance
Creates a transport information instance and sets the transport information.- Parameters:
supplier- the transport supplier- See Also:
-
-
Method Details
-
setTransportSetup
Sets up the transport information.- Parameters:
supplier- the transport supplier- Returns:
- the supplier before this operation
-
sendServiceStatus
Sends a service status message. UsesId.getDeviceId(). CallscreateConnector()to obtain a connector instance on demand.- Parameters:
action- the action on the serviceserviceId- the service IdaliasIds- optional alias ids for the service
-
sendServiceStatusWithDescription
public void sendServiceStatusWithDescription(ActionType action, String serviceId, String description, String... aliasIds) Sends a service status message. UsesId.getDeviceId(). CallscreateConnector()to obtain a connector instance on demand.- Parameters:
action- the action on the serviceserviceId- the service Iddescription- with description, usually the new service statealiasIds- optional alias ids for the service
-
sendServiceArtifactStatus
Sends a service artifact status message. UsesId.getDeviceId(). CallscreateConnector()to obtain a connector instance on demand.- Parameters:
action- the action on the artifactartifactId- the artifact IdaliasIds- optional alias ids for the artifact
-
sendContainerStatus
Sends a container status message. UsesId.getDeviceId(). CallscreateConnector()to obtain a connector instance on demand.- Parameters:
action- the action on the containercontainerId- the container IdaliasIds- optional alias ids for the container
-
sendResourceStatus
Sends a resource status message for this resource. CallscreateConnector()to obtain a connector instance on demand.- Parameters:
action- the action on the containeraliasIds- optional alias ids for the resource
-
sendResourceStatus
Sends a resource status message. CallscreateConnector()to obtain a connector instance on demand.- Parameters:
action- the action on the containerdeviceId- the device id, may be null thenId.getDeviceId()is usedaliasIds- optional alias ids for the resource
-
send
public void send(de.iip_ecosphere.platform.support.function.IOConsumer<TransportConnector> sender, String kind) Sends a message of a certainkindand cares for queuing.- Parameters:
sender- the sender including the messagekind- the kind of the message for logging
-
setTraceFilter
Defines a trace filter.- Parameters:
filter- the filter, null for no filter
-
sendTraceRecord
Sends a trace record. CallscreateConnector()to obtain a connector instance on demand. Caches messages if no connector is available.- Parameters:
record- the record to be sent
-
sendProcessStatus
Sends information about a processing status.- Parameters:
componentId- the component idstep- the step [0; max]max- the maximum stepdescription- the description of the task
-
sendProcessStatus
public void sendProcessStatus(String componentId, int step, int max, String description, String subDescription) Sends information about a processing status. Attaches the actual task data if available.- Parameters:
componentId- the component idstep- the step [0; max]max- the maximum stepdescription- the description of the tasksubDescription- the description of an optional sub-task within the actual task, may be null or empty
-
sendProcessStatus
Sends information about finalizing a task-based process. Attaches the actual task data if available.- Parameters:
componentId- the component idtype- shall beActionTypes.RESULTorActionTypes.ERRORresult- a serializable result, may be null
-
sendStatus
Sends a status message. CallscreateConnector()to obtain a connector instance on demand. Caches messages if no connector is available.- Parameters:
msg- the message to be sent
-
sendAlert
Sends an alert message. CallscreateConnector()to obtain a connector instance on demand. Caches messages if no connector is available.- Parameters:
alert- the alert to be sent
-
createConnector
Tries creating a connector. If successful,connectorwill be initialized for caching. The instance is cached. The transport information must be set up beforesetTransportSetup(Supplier). After successfully creating a connector, queued messages are sent and removed from the queue. However, there is no guarantee that a connector can be created.- Returns:
- the (cached) connector, a non-functional dummy instance if no connector can be created
- See Also:
-
releaseConnector
public void releaseConnector()Releases an existing connector and stays offline. -
releaseConnector
public void releaseConnector(boolean stayOff) Releases an existing connector.- Parameters:
stayOff- whether a call tocreateConnector()shall create a new connector or prevent sending further messages.
-
getConnector
Returns the transport connector.- Returns:
- the transport connector, may be null
- See Also:
-