Class InstanceStateNotificationWrapper
- java.lang.Object
-
- de.aristaflow.ilm.core.executionmanager.InstanceStateNotificationWrapper
-
- All Implemented Interfaces:
InstanceStateNotification
public class InstanceStateNotificationWrapper extends Object implements InstanceStateNotification
This class wraps anInstanceStateCallback
and forwards calls toInstanceStateNotification
appropriately.
-
-
Field Summary
Fields Modifier and Type Field Description protected UUID
callbackAfterResume
The ID of the notification callback used after the current resume.protected boolean
ignoreResumed
Whether this wrapper has been created when resuming.protected InstanceStateCallback
isc
The object to which to forward calls to.protected LocalInstanceStateNotifier
lisn
The instance state listener to unregister from incleanup(UUID)
.protected ConcurrentMap<UUID,InstanceStateNotificationWrapper>
listeners
The map to unregister from incleanup(UUID)
.protected Logger
logger
The logger used for transforming data containers to ILM.protected URI[]
regUris
The URIs with which thisInstanceStateNotification
has been registered.protected SessionToken
session
The session token for unregistering incleanup(UUID)
.
-
Constructor Summary
Constructors Constructor Description InstanceStateNotificationWrapper(InstanceStateCallback isc, boolean ignoreResumed, SessionToken session, ConcurrentMap<UUID,InstanceStateNotificationWrapper> listeners, LocalInstanceStateNotifier lisn, Logger logger)
Creates a new wrapper for the designatedInstanceStateCallback
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
autoStartPending(EBPInstanceReference act, long termTime, QualifiedAgent agent, URI[] rtMgr, boolean rtmResolved)
Notifies that the designated activity may be autostarted.protected void
cleanup(UUID instId)
Removes this wrapper from the map of listeners and from the global instance state listener for a specific instance.UUID
getId()
Gets the ID of the wrappedInstanceStateCallback
-instance.URI[]
getUris()
Gets the URIs with which thisInstanceStateNotification
has been registered ornull
.void
init(URI[] uris)
Sets the URIs with which thisInstanceStateNotification
has been registered.void
instanceFailed(UUID instId, DataContainer dc, String errorMessage, String state, long errorCode)
Notifies that the designated top-level instance has failed and provides the necessary failure information.void
instanceFinished(UUID instId, DataContainer dc)
Notifies that the designated top-level instance has finished normally and provides the output parameters of the instance.void
instanceResumed(UUID instId, URI[] newListener)
Notifies that the designated top-level instance has been resumed.void
instanceSuspended(UUID instId)
Notifies that the designated top-level instance has been suspended.URI[]
setCallbackAfterResume(UUID id)
Sets the ID of the callback used after resuming.protected DataContainer
toIlmDc(UUID instId, DataContainer dc)
Gets the ILM data container for the designated data container ornull
if the designated data container isnull
.
-
-
-
Field Detail
-
isc
protected final InstanceStateCallback isc
The object to which to forward calls to.
-
ignoreResumed
protected boolean ignoreResumed
Whether this wrapper has been created when resuming. This skips the first resume notification.
-
callbackAfterResume
protected UUID callbackAfterResume
The ID of the notification callback used after the current resume.
-
session
protected final SessionToken session
The session token for unregistering incleanup(UUID)
.
-
listeners
protected final ConcurrentMap<UUID,InstanceStateNotificationWrapper> listeners
The map to unregister from incleanup(UUID)
.
-
lisn
protected final LocalInstanceStateNotifier lisn
The instance state listener to unregister from incleanup(UUID)
.
-
logger
protected final Logger logger
The logger used for transforming data containers to ILM.
-
regUris
protected URI[] regUris
The URIs with which thisInstanceStateNotification
has been registered.
-
-
Constructor Detail
-
InstanceStateNotificationWrapper
public InstanceStateNotificationWrapper(InstanceStateCallback isc, boolean ignoreResumed, SessionToken session, ConcurrentMap<UUID,InstanceStateNotificationWrapper> listeners, LocalInstanceStateNotifier lisn, Logger logger)
Creates a new wrapper for the designatedInstanceStateCallback
.- Parameters:
isc
- TheInstanceStateCallback
to wrap.ignoreResumed
- Whether this wrapper has been created when resuming. This skips the first resume notification.session
- The session token for unregistering incleanup(UUID)
. This must not benull
listeners
- The map to unregister from incleanup(UUID)
. This must not benull
lisn
- The instance state listener to unregister from incleanup(UUID)
. This must not benull
logger
- The logger used for transforming data containers to ILM.
-
-
Method Detail
-
init
public void init(URI[] uris)
Sets the URIs with which thisInstanceStateNotification
has been registered.- Parameters:
uris
- The URIs with which thisInstanceStateNotification
has been registered This must not benull
nor empty.
-
getUris
public URI[] getUris()
Gets the URIs with which thisInstanceStateNotification
has been registered ornull
.- Returns:
- The URIs with which this
InstanceStateNotification
has been registered.
-
getId
public UUID getId()
Gets the ID of the wrappedInstanceStateCallback
-instance.- Returns:
- The ID of the wrapped
InstanceStateCallback
-instance.
-
setCallbackAfterResume
public URI[] setCallbackAfterResume(UUID id)
Sets the ID of the callback used after resuming. This is required to determine whether it is the same or a different notification. This is also part of the notification interface.- Parameters:
id
- The ID of the notification callback used after the current resume.- Returns:
- The URIs with which this
InstanceStateNotification
has been registered in case it is the wrapper for the designated callback ID ornull
.
-
instanceFinished
public void instanceFinished(UUID instId, DataContainer dc)
Description copied from interface:InstanceStateNotification
Notifies that the designated top-level instance has finished normally and provides the output parameters of the instance. In case the instance does not have parameters, null is provided as data container. If the instance has input and/or output parameters, an instance data container will be provided.- Specified by:
instanceFinished
in interfaceInstanceStateNotification
- Parameters:
instId
- The ID of the top-level instance that has finished normally.dc
- The corresponding data container that contains the values of the output parameters of the top-level instance or null in case the instance does not have a data container.
If the instance has been a top-level instance and it has been provided anInstanceDataContainer
in its execution context whenstarted
, this data container will also be anInstanceDataContainer
.
The caller is responsible for closing. That means, implementors may need toDataContainer.clone()
if required longer than or outside of this method.
-
instanceSuspended
public void instanceSuspended(UUID instId)
Description copied from interface:InstanceStateNotification
Notifies that the designated top-level instance has been suspended. No data container is provided since unlike applications no data needs to be stored intermediately outside of the system in case of a top-level instance.- Specified by:
instanceSuspended
in interfaceInstanceStateNotification
- Parameters:
instId
- The ID of the top-level instance that has been suspended.
-
instanceResumed
public void instanceResumed(UUID instId, URI[] newListener)
Description copied from interface:InstanceStateNotification
Notifies that the designated top-level instance has been resumed. No data container is provided since unlike applications no data needs to be stored intermediately outside of the system in case of a top-level instance.- Specified by:
instanceResumed
in interfaceInstanceStateNotification
- Parameters:
instId
- The ID of the top-level instance that has been resumed.newListener
- The URIs of the listener that has been registered when resuming ornull
in case no listener has been registered when resuming (that is, the old listener remains). If a new listener has been registered, this listener will not be notified any more.
-
instanceFailed
public void instanceFailed(UUID instId, DataContainer dc, String errorMessage, String state, long errorCode)
Description copied from interface:InstanceStateNotification
Notifies that the designated top-level instance has failed and provides the necessary failure information.- Specified by:
instanceFailed
in interfaceInstanceStateNotification
- Parameters:
instId
- The ID of the top-level instance that failed or was aborted.dc
- The corresponding data container that contains the values of the output parameters of the top-level instance which have been produced until the failure occurred or null in case the instance does not have a data container. Please note that many output parameters may be Null due to the failure.
If the instance has been a top-level instance and it has been provided anInstanceDataContainer
in its execution context whenstarted
, this data container will also be anInstanceDataContainer
.
The caller is responsible for closing. That means, implementors may need toDataContainer.clone()
if required longer than or outside of this method.errorMessage
- The error message to be interpreted by a user or by a failure handling routine.state
- Arbitrary state information specific to the instance, comparable to the vendor code inSQLException
errorCode
- The error code specifying the type of error.
-
autoStartPending
public void autoStartPending(EBPInstanceReference act, long termTime, QualifiedAgent agent, URI[] rtMgr, boolean rtmResolved)
Description copied from interface:InstanceStateNotification
Notifies that the designated activity may be autostarted. The previous node has been terminated at the previous time (System.currentTimeMillis()
). The auto start should take place on the designated runtime manager.- Specified by:
autoStartPending
in interfaceInstanceStateNotification
- Parameters:
act
- The activity which may be autostarted.termTime
- The termination time of the preceeding node of the designated activity (asSystem.currentTimeMillis()
). This allows to decide whether autostarting is still feasible, e. g. autostart should not take place if too much time has elapsed since the termination of the previous node.agent
- The agent for whom to autostart including the corresponding user session ID if available.
Note that QualifiedAgent.equals(Object) does not consider the user session ID.rtMgr
- The URI of the runtime manager in which the activity should be autostarted. If this isnull
, no specific runtime manager has been set. Otherwise the URIs do not refer to a runtime manager or the corresponding runtime manager prefers to be notified instead of a pushed autostart. Refer tortmResolved
to distinguish both cases.rtmResolved
- Whether the runtime manager has been successfully resolved, that is, the URIs specify a runtime manager but this wants a notification instead of a pushed autostart.
-
toIlmDc
protected DataContainer toIlmDc(UUID instId, DataContainer dc)
Gets the ILM data container for the designated data container ornull
if the designated data container isnull
.
If there are problems determining the input and output parameters of the instance since the corresponding process manager cannot be retrieved, this will be logged andnull
will be returned.- Parameters:
instId
- The ID of the instance to which the data container belongs to.dc
- The data container which to transform to ILM ornull
.- Returns:
- The ILM data container for the designated data container or
null
if the designated data container isnull
.
-
cleanup
protected void cleanup(UUID instId)
Removes this wrapper from the map of listeners and from the global instance state listener for a specific instance.- Parameters:
instId
- The ID of the instance for which this wrapper has been listening to.
-
-