Class ProcessManagerTools
java.lang.Object
de.aristaflow.adept2.core.processmanager.ProcessManagerTools
This class provides some useful methods for process manager logic, e. g. retrieving the latest
template of a process type and aggregating states of subprocess instances.
-
Method Summary
Modifier and TypeMethodDescriptionaggregateStatus(SessionToken session, Collection<UUID> parallels, InstanceManager im) Aggregates several instance execution statuses to one, that is the designated subprocess instances (running in parallel) are retrieved from the designated subprocess manager instance and their execution statuses are aggregated.static ProcessConstants.NodeStateaggregateSubprocessStatuses(SessionToken session, Collection<UUID> parallels, InstanceManager im) Aggregates several instance execution statuses to the corresponding node state of the parent node.static voidcheckScheduledStartIDs(TemplateStatus status, Supplier<Collection<TemplateStatus>> others, Function<UUID, String> names) Checks the IDs of the enabled scheduled starts of the designated template status as it is to be stored if its template is released, instantiable, top-level usable and not outdated with it: no other template in this state may have an enabled start of the same ID, so that the ID of an enabled start is live in one template at most.static voidcheckScheduledStarts(TemplateStatus status, String name, Collection<? extends Parameter> parameters) Checks the scheduled starts of the designated template status, which enter a storage of templates: each needs an ID, a period and a retry count which are not negative and input values which the designated input parameters of its template accept and which provide every mandatory one, asAdeptDataConversion.rejectParams(Map, Collection)andAdeptDataConversion.getMissingValues(Map, Collection)check them.static FiltercreateLiveStartFilter(FilterFactory filtFactory) Creates the filter on template statuses which matches the status of a template with a live scheduled start: an enabled one while the template is released, instantiable and not outdated on top-level scope and top-level usable, ascreateStartableStatusFilter(FilterFactory)requires.static FiltercreateStartableStatusFilter(FilterFactory filtFactory) Creates the filter on template statuses which matches the status of a template in the state in whichisStartable(TemplateReference)accepts a template: released, instantiable and not outdated on top-level scope and top-level usable.static TemplateReferencegetLatestTemplateVersion(SessionToken session, String processType, TemplateManager templMgr, FilterFactory filtFactory) Tries to retrieve the template of the designated process type having the highest version number in the template manager.static booleanisEnabledStartChange(TemplateStatus status, TemplateStatus stored) Gets whether the designated template status changes the enabled scheduled starts of the designated stored status: the enabled ones among its scheduled starts differ from the enabled stored ones by content, so that it enables a start or changes, disables or removes an enabled one.static booleanisScheduledStartChange(TemplateStatus status, TemplateStatus stored) Gets whether the designated template status changes the scheduled starts of the designated stored status: it carries scheduled starts which differ from the stored ones by content, a stored status without scheduled starts counting as one with none.static booleanisStartable(TemplateReference template) Gets whether the designated template is in the state in whichgetLatestTemplateVersion(SessionToken, String, TemplateManager, FilterFactory)recognises a template: released, instantiable and not outdated on top-level scope and top-level usable.static ProcessConstants.NodeStatemapToNodeState(ProcessConstants.InstanceExecutionStatus instanceExecutionStatus) Maps an instance execution status to a node state.static booleanstopsScheduledStart(TemplateStatus status, TemplateStatus stored) Gets whether the designated template status stops a scheduled start of the designated stored status: the stored status has an enabled start while its template is released, instantiable, top-level usable and not outdated, and the designated status disables or removes this start or takes the template out of this state.static booleantemplatesStored(CheckReport checkReport, ADEPT2Service processManager) Gets whether the designated check report indicates no problems and a successful storing (in the designated process manager).
-
Method Details
-
getLatestTemplateVersion
public static TemplateReference getLatestTemplateVersion(SessionToken session, String processType, TemplateManager templMgr, FilterFactory filtFactory) Tries to retrieve the template of the designated process type having the highest version number in the template manager. Only released, instantiable, non-outdated and top-level usable templates will be recognised. If no such template is found (the process type is unknown or the filter yields an empty result),nullwill be returned.Important! This method has some serious restrictions:
Due to the non-linear versioning of templates, the result of this method is ambiguous. It just retrieves the template with the highest version number which need not be the latest version at all. Additionally, the template manager need not know all templates of a process type and therefore only a subset of all templates of the process type may be considered.
Last but not least, the "interface" of a process type may change between two versions, that is, templates of the same process type may have different input and output parameters. Therefore the "latest" template may be incompatible with the calling context.- Parameters:
session- The session with which to retrieve the templates.processType- The name of the process type of which to get the "latest" template.templMgr- The template manager from which to retrieve the template.filtFactory- The filter factory for creating the filters that apply to the templates.- Returns:
- The "latest" template of the designated process type from the designated
template manager. This is the instantiable top-level template having the highest
version number. If no template is found for the designated process type,
nullwill be returned.
-
isStartable
Gets whether the designated template is in the state in whichgetLatestTemplateVersion(SessionToken, String, TemplateManager, FilterFactory)recognises a template: released, instantiable and not outdated on top-level scope and top-level usable. Instances of such a template can be started on top level.- Parameters:
template- The template to check. This must not benull.- Returns:
- Whether the designated template is released, instantiable and not outdated on top-level scope and top-level usable.
-
createStartableStatusFilter
Creates the filter on template statuses which matches the status of a template in the state in whichisStartable(TemplateReference)accepts a template: released, instantiable and not outdated on top-level scope and top-level usable.- Parameters:
filtFactory- The filter factory creating the filter. This must not benull.- Returns:
- The filter matching the statuses of the templates whose instances can be started on top
level. This will never be
null.
-
createLiveStartFilter
Creates the filter on template statuses which matches the status of a template with a live scheduled start: an enabled one while the template is released, instantiable and not outdated on top-level scope and top-level usable, ascreateStartableStatusFilter(FilterFactory)requires. A status without scheduled starts does not match.- Parameters:
filtFactory- The filter factory creating the filter. This must not benull.- Returns:
- The filter matching the statuses of the templates with a live scheduled start. This
will never be
null.
-
isScheduledStartChange
Gets whether the designated template status changes the scheduled starts of the designated stored status: it carries scheduled starts which differ from the stored ones by content, a stored status without scheduled starts counting as one with none. A status whose scheduled starts arenullkeeps the stored ones and changes nothing.- Parameters:
status- The template status to be stored. This must not benull.stored- The stored status of the same template ornullif the template is new.- Returns:
- Whether the designated status changes the scheduled starts of the stored one.
-
isEnabledStartChange
Gets whether the designated template status changes the enabled scheduled starts of the designated stored status: the enabled ones among its scheduled starts differ from the enabled stored ones by content, so that it enables a start or changes, disables or removes an enabled one. A stored status without scheduled starts counts as one with none. A status whose scheduled starts arenullkeeps the stored ones and changes nothing.- Parameters:
status- The template status to be stored. This must not benull.stored- The stored status of the same template ornullif the template is new.- Returns:
- Whether the designated status changes the enabled scheduled starts of the stored one.
-
checkScheduledStarts
public static void checkScheduledStarts(TemplateStatus status, String name, Collection<? extends Parameter> parameters) throws InvalidScheduledStartException Checks the scheduled starts of the designated template status, which enter a storage of templates: each needs an ID, a period and a retry count which are not negative and input values which the designated input parameters of its template accept and which provide every mandatory one, asAdeptDataConversion.rejectParams(Map, Collection)andAdeptDataConversion.getMissingValues(Map, Collection)check them.- Parameters:
status- The template status whose scheduled starts to check. This must not benull.name- The name of the template of the designated status.parameters- The input parameters of the template of the designated status. This must not benull.- Throws:
InvalidScheduledStartException- If a scheduled start of the designated status is invalid, anInvalidScheduledStartExceptionnaming the first one will be thrown.
-
checkScheduledStartIDs
public static void checkScheduledStartIDs(TemplateStatus status, Supplier<Collection<TemplateStatus>> others, Function<UUID, String> names) throws InvalidScheduledStartExceptionChecks the IDs of the enabled scheduled starts of the designated template status as it is to be stored if its template is released, instantiable, top-level usable and not outdated with it: no other template in this state may have an enabled start of the same ID, so that the ID of an enabled start is live in one template at most. Since releasing a template and enabling a start are both writes of a status, this covers every way a start goes live. The caller checks and stores each status under a lock shared by all of them, so that two statuses of different templates cannot both pass.- Parameters:
status- The template status as it is to be stored. This must not benull.others- Supplies the statuses of the templates to check against, of which a status of the template of the designated status is skipped. It is called only if that template is in the state named above and the designated status has an enabled start.names- Gives the name of a template by its ID, of the designated status or of a supplied one. It is called only for a refusal, which names both templates.- Throws:
InvalidScheduledStartException- If an enabled start of the designated status shares its ID with an enabled start of another template in the state named above, anInvalidScheduledStartExceptionnaming both templates will be thrown.
-
stopsScheduledStart
Gets whether the designated template status stops a scheduled start of the designated stored status: the stored status has an enabled start while its template is released, instantiable, top-level usable and not outdated, and the designated status disables or removes this start or takes the template out of this state. A status whose scheduled starts arenullkeeps the stored ones. Setting the statuses which stop a start before the others lets a start move from one template to another without two templates sharing its ID meanwhile.- Parameters:
status- The template status to be stored. This must not benull.stored- The stored status of the same template ornullif the template is new.- Returns:
- Whether the designated status stops a scheduled start of the designated stored one.
-
aggregateSubprocessStatuses
public static ProcessConstants.NodeState aggregateSubprocessStatuses(SessionToken session, Collection<UUID> parallels, InstanceManager im) Aggregates several instance execution statuses to the corresponding node state of the parent node.- Parameters:
session- The session token for accessing the instance manager for retrieving the instance execution statuses.parallels- The IDs of the instances of which to aggregate the instance execution statuses.im- The subprocess manager to retrieve the subprocess instances from.- Returns:
- The node state aggregated from the execution statuses of the designated instances running in parallel.
- See Also:
-
aggregateStatus
public static ProcessConstants.InstanceExecutionStatus aggregateStatus(SessionToken session, Collection<UUID> parallels, InstanceManager im) Aggregates several instance execution statuses to one, that is the designated subprocess instances (running in parallel) are retrieved from the designated subprocess manager instance and their execution statuses are aggregated. Instance execution statuses have the following priority:- IE_RUNNING
- IE_SOFTLY_SUSPENDED
- IE_SUSPENDED
- IE_SOFTLY_ABORTED
- IE_ABORTED
- IE_FINISHED
- Parameters:
session- The session token for accessing the instance manager for retrieving the instance execution statuses.parallels- The IDs of the instances of which to aggregate the instance execution statuses.im- The subprocess manager to retrieve the subprocess instances from.- Returns:
- The aggregated execution status for all of the designated instances running in parallel.
-
mapToNodeState
public static ProcessConstants.NodeState mapToNodeState(ProcessConstants.InstanceExecutionStatus instanceExecutionStatus) Maps an instance execution status to a node state. This is needed for setting the state of an LWP.- Parameters:
instanceExecutionStatus- The instance execution status which to map to a corresponding node state.- Returns:
- The node state corresponding to the designated instance execution status.
-
templatesStored
Gets whether the designated check report indicates no problems and a successful storing (in the designated process manager). This depends on the check result and, for a process manager of release15.0.0or later or of an unknown release, also on the last report entry. Some checks may lead to a warning but this alone does not indicate whether storing has or has not been successful.- Parameters:
checkReport- The check report of the template upload (attempt).processManager- The process manager to which the templates have been uploaded (or not).- Returns:
- Whether the templates have been successfully uploaded as indicated by the designated check report.
-