Class ProcessInstanceMigrationPreconditions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidrequireAuthorizedTenant(Map<String, Object> authorizations, String tenantId, long processInstanceKey) Checks whether given tenant is authorized for the process given instance.static voidrequireMappedCatchEventsToStayAttachedToSameElement(long processInstanceKey, DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition, String sourceElementId, String targetElementId, Map<String, String> sourceElementIdToTargetElementId) It should not be possible for a mapped element's catch events to be moved to another element.static voidrequireNoBoundaryEventInSource(DeployedProcess sourceProcessDefinition, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given source process definition contains a boundary event.static voidrequireNoBoundaryEventInTarget(DeployedProcess targetProcessDefinition, String targetElementId, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given target process definition contains a boundary event.static voidrequireNoCatchEventMappingToChangeEventType(long processInstanceKey, Map<String, String> mappingInstructions, DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition, String sourceElementId) It should not be possible to change the event type of a catch event during process instance migration.static voidrequireNoConcurrentCommand(EventScopeInstanceState eventScopeInstanceState, ElementInstance elementInstance, long processInstanceKey) Checks whether the given process instance has a concurrent command.static voidrequireNoDuplicateTargetsInCatchEventMappings(long processInstanceKey, DeployedProcess sourceProcessDefinition, String sourceElementId, Map<String, String> mappingInstructions) It should not be possible for a mapped element's catch events to be merged into a single catch event.static voidrequireNoEventSubprocessInSource(DeployedProcess sourceProcessDefinition, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given source process definition contains an event subprocess.static voidrequireNoEventSubprocessInTarget(DeployedProcess targetProcessDefinition, String targetElementId, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given target process definition contains an event subprocess.static voidrequireNonDuplicateSourceElementIds(List<ProcessInstanceMigrationRecordValue.ProcessInstanceMigrationMappingInstructionValue> mappingInstructions, long processInstanceKey) Checks whether the given mapping instructions contain duplicate source element ids.static voidrequireNonNullProcessInstance(ElementInstance record, long processInstanceKey) Checks whether the given record exists.static voidrequireNonNullTargetElementId(String targetElementId, long processInstanceKey, String sourceElementId) Checks whether the given target element id exists.static voidrequireNonNullTargetProcessDefinition(DeployedProcess targetProcessDefinition, long targetProcessDefinitionKey) Checks whether the given target process definition exists.static voidrequireNoPendingMsgSubMigrationDistribution(DistributionState distributionState, long distributionKey, String elementId, long processInstanceKey, String eventElementId) Throws an exception if the given message subscription distribution is pending.static voidrequireNoSubscriptionForMessage(boolean existSubscriptionForMessageName, ElementInstance elementInstance, org.agrona.DirectBuffer messageName, String targetCatchEventId) Throws an exception if the element instance is already subscribed to the same message.static voidrequireReferredElementsExist(DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition, List<ProcessInstanceMigrationRecordValue.ProcessInstanceMigrationMappingInstructionValue> mappingInstructions, long processInstanceKey) Checks whether the given mapping instructions refer to existing elements in the source and the target process definition.static voidrequireSameElementType(DeployedProcess targetProcessDefinition, String targetElementId, ElementInstance elementInstance, long processInstanceKey) Checks whether the given element instance has the same element type as the target element.static voidrequireSameMultiInstanceLoopCharacteristics(DeployedProcess sourceProcessDefinition, String sourceElementId, DeployedProcess targetProcessDefinition, String targetElementId, long processInstanceKey) static voidrequireSameUserTaskImplementation(DeployedProcess targetProcessDefinition, String targetElementId, ElementInstance elementInstance, long processInstanceKey) Since we introduce zeebe user tasks and job worker tasks has the same bpmn element type, we need to check whether the given element instance and target element has the same user task type.static voidrequireSupportedElementType(ProcessInstanceRecord elementInstanceRecord, long processInstanceKey, DeployedProcess sourceProcessDefinition) Checks whether the given element instance is of a supported type.static voidrequireUnchangedFlowScope(ElementInstanceState elementInstanceState, ProcessInstanceRecord elementInstanceRecord, DeployedProcess targetProcessDefinition, String targetElementId) Checks whether the given element instance has the same flow scope id as the target element.
-
Constructor Details
-
ProcessInstanceMigrationPreconditions
public ProcessInstanceMigrationPreconditions()
-
-
Method Details
-
requireNonNullProcessInstance
Checks whether the given record exists. Throws exception if given process instance record is null.- Parameters:
record- process instance record to do the null checkprocessInstanceKey- process instance key to be logged
-
requireAuthorizedTenant
public static void requireAuthorizedTenant(Map<String, Object> authorizations, String tenantId, long processInstanceKey) Checks whether given tenant is authorized for the process given instance.- Parameters:
authorizations- list of authorizations availabletenantId- tenant id to be checkedprocessInstanceKey- process instance key to be logged
-
requireNonNullTargetProcessDefinition
public static void requireNonNullTargetProcessDefinition(DeployedProcess targetProcessDefinition, long targetProcessDefinitionKey) Checks whether the given target process definition exists. Throws exception if given target process definition is null.- Parameters:
targetProcessDefinition- target process definition to do the null checktargetProcessDefinitionKey- target process definition key to be logged
-
requireNonDuplicateSourceElementIds
public static void requireNonDuplicateSourceElementIds(List<ProcessInstanceMigrationRecordValue.ProcessInstanceMigrationMappingInstructionValue> mappingInstructions, long processInstanceKey) Checks whether the given mapping instructions contain duplicate source element ids. Throws an exception if duplicate source element ids are found.- Parameters:
mappingInstructions- mapping instructions to do the checkprocessInstanceKey- process instance key to be logged
-
requireReferredElementsExist
public static void requireReferredElementsExist(DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition, List<ProcessInstanceMigrationRecordValue.ProcessInstanceMigrationMappingInstructionValue> mappingInstructions, long processInstanceKey) Checks whether the given mapping instructions refer to existing elements in the source and the target process definition. Throws an exception if any of the mapping instructions refers to a non-existing element.- Parameters:
sourceProcessDefinition- source process definitiontargetProcessDefinition- target process definitionmappingInstructions- mapping instructions to do the checkprocessInstanceKey- process instance key to be logged
-
requireNoEventSubprocessInSource
public static void requireNoEventSubprocessInSource(DeployedProcess sourceProcessDefinition, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given source process definition contains an event subprocess. Throws an exception if the source process definition contains an event subprocess that is not allowed.- Parameters:
sourceProcessDefinition- source process definition to do the checkelementInstanceRecord- element instance to be loggedallowedEventTypes- allowed event types for the boundary event
-
requireNoEventSubprocessInTarget
public static void requireNoEventSubprocessInTarget(DeployedProcess targetProcessDefinition, String targetElementId, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given target process definition contains an event subprocess. Throws an exception if the target process definition contains an event subprocess that is not allowed.- Parameters:
targetProcessDefinition- target process definition to do the checktargetElementId- target element id to retrieve the target elementelementInstanceRecord- element instance to be loggedallowedEventTypes- allowed event types for the boundary event
-
requireSupportedElementType
public static void requireSupportedElementType(ProcessInstanceRecord elementInstanceRecord, long processInstanceKey, DeployedProcess sourceProcessDefinition) Checks whether the given element instance is of a supported type. Throws an exception if the element instance is of an unsupported type.- Parameters:
elementInstanceRecord- element instance to do the checkprocessInstanceKey- process instance key to be logged
-
requireNonNullTargetElementId
public static void requireNonNullTargetElementId(String targetElementId, long processInstanceKey, String sourceElementId) Checks whether the given target element id exists. Throws an exception if the target element id is null.- Parameters:
targetElementId- target element id to do the null checkprocessInstanceKey- process instance key to be loggedsourceElementId- source element id to be logged
-
requireSameElementType
public static void requireSameElementType(DeployedProcess targetProcessDefinition, String targetElementId, ElementInstance elementInstance, long processInstanceKey) Checks whether the given element instance has the same element type as the target element. Throws an exception if the element instance has a different type.- Parameters:
targetProcessDefinition- target process definition to retrieve the target element typetargetElementId- target element idelementInstance- element instance to do the checkprocessInstanceKey- process instance key to be logged
-
requireSameUserTaskImplementation
public static void requireSameUserTaskImplementation(DeployedProcess targetProcessDefinition, String targetElementId, ElementInstance elementInstance, long processInstanceKey) Since we introduce zeebe user tasks and job worker tasks has the same bpmn element type, we need to check whether the given element instance and target element has the same user task type. Throws an exception if they have different types.- Parameters:
targetProcessDefinition- target process definition to retrieve the target element typetargetElementId- target element idelementInstance- element instance to do the checkprocessInstanceKey- process instance key to be logged
-
requireUnchangedFlowScope
public static void requireUnchangedFlowScope(ElementInstanceState elementInstanceState, ProcessInstanceRecord elementInstanceRecord, DeployedProcess targetProcessDefinition, String targetElementId) Checks whether the given element instance has the same flow scope id as the target element. Throws an exception if the element instance has a different flow scope.- Parameters:
elementInstanceState- element instance state to retrieve the source flow scope elementelementInstanceRecord- element instance to do the checktargetProcessDefinition- target process definition to retrieve the target elementtargetElementId- target element id to retrieve the target flow scope
-
requireNoBoundaryEventInSource
public static void requireNoBoundaryEventInSource(DeployedProcess sourceProcessDefinition, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given source process definition contains a boundary event. Throws an exception if the source process definition contains a boundary event that is not allowed.- Parameters:
sourceProcessDefinition- source process definition to do the checkelementInstanceRecord- element instance to be loggedallowedEventTypes- allowed event types for the boundary event
-
requireNoBoundaryEventInTarget
public static void requireNoBoundaryEventInTarget(DeployedProcess targetProcessDefinition, String targetElementId, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given target process definition contains a boundary event. Throws an exception if the target process definition contains a boundary event.- Parameters:
targetProcessDefinition- target process definition to do the checktargetElementId- target element id to retrieve the target elementelementInstanceRecord- element instance to be loggedallowedEventTypes- allowed event types for the boundary event
-
requireMappedCatchEventsToStayAttachedToSameElement
public static void requireMappedCatchEventsToStayAttachedToSameElement(long processInstanceKey, DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition, String sourceElementId, String targetElementId, Map<String, String> sourceElementIdToTargetElementId) It should not be possible for a mapped element's catch events to be moved to another element. This would mean an element instance is subscribed to a catch event that does not belong to this element. Triggering the catch event could lead to unexpected behavior.To avoid this, we check each catch event of the source element and ensure that they are mapped to a catch event on the target element. This check includes all catch events like boundary events, intermediate catch events, and start events (e.g. from event-subprocesses).
- Parameters:
processInstanceKey- process instance key to be loggedsourceProcessDefinition- source process definition to checktargetProcessDefinition- target process definition to checksourceElementId- source element id to checktargetElementId- target element id to checksourceElementIdToTargetElementId- mapping instructions (source element id to target
-
requireNoDuplicateTargetsInCatchEventMappings
public static void requireNoDuplicateTargetsInCatchEventMappings(long processInstanceKey, DeployedProcess sourceProcessDefinition, String sourceElementId, Map<String, String> mappingInstructions) It should not be possible for a mapped element's catch events to be merged into a single catch event. This would mean an element instance is subscribed multiple times to the same catch event.To avoid this, we check each catch event attached to the source element and ensure that they are the target of a mapping instruction only once.
- Parameters:
processInstanceKey- process instance key to be loggedsourceProcessDefinition- source process definition to checksourceElementId- source element id to checkmappingInstructions- mapping instructions (source element id to target element id)
-
requireNoCatchEventMappingToChangeEventType
public static void requireNoCatchEventMappingToChangeEventType(long processInstanceKey, Map<String, String> mappingInstructions, DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition, String sourceElementId) It should not be possible to change the event type of a catch event during process instance migration. This would mean that the catch event is subscribed to a different event type than before.- Parameters:
processInstanceKey- process instance key to be loggedmappingInstructions- mapping instructions (source catch event id to target catch event id)sourceProcessDefinition- source process definition to checktargetProcessDefinition- target process definition to checksourceElementId- source element id to check
-
requireNoConcurrentCommand
public static void requireNoConcurrentCommand(EventScopeInstanceState eventScopeInstanceState, ElementInstance elementInstance, long processInstanceKey) Checks whether the given process instance has a concurrent command. Throws an exception if the given process instance has a concurrent command.Some concurrent commands are a job complete, a timer trigger, or a message correlation. Since the concurrent command modifies the process instance, it is not safe to apply the migration in between.
- Parameters:
eventScopeInstanceState- event scope instance state to retrieve the event triggerelementInstance- element instance to do the check active sequence flowsprocessInstanceKey- process instance key to be logged
-
requireNoSubscriptionForMessage
public static void requireNoSubscriptionForMessage(boolean existSubscriptionForMessageName, ElementInstance elementInstance, org.agrona.DirectBuffer messageName, String targetCatchEventId) Throws an exception if the element instance is already subscribed to the same message.We cannot support re-subscribing to message catch events that we're already subscribed to. The user must provide a mapping instruction for such catch events to migrate them instead.
- Parameters:
existSubscriptionForMessageName- whether the element instance is already subscribed to the message, if true this method throws an exceptionelementInstance- the element instance to check for subscriptionsmessageName- the name of the message that the element should not be subscribed totargetCatchEventId- the id of the catch event that would subscribe to this message
-
requireNoPendingMsgSubMigrationDistribution
public static void requireNoPendingMsgSubMigrationDistribution(DistributionState distributionState, long distributionKey, String elementId, long processInstanceKey, String eventElementId) Throws an exception if the given message subscription distribution is pending.- Parameters:
distributionState- the distribution state to check for pending distributionsdistributionKey- the distribution key of the distribution that is being checkedelementId- the element id of the element that is being migrated (for logging)processInstanceKey- the process instance key of the process instance that is being migrated (for logging)eventElementId- the element id of the event that is being migrated (for logging)
-
requireSameMultiInstanceLoopCharacteristics
public static void requireSameMultiInstanceLoopCharacteristics(DeployedProcess sourceProcessDefinition, String sourceElementId, DeployedProcess targetProcessDefinition, String targetElementId, long processInstanceKey)
-