Class ProcessInstanceMigrationPreconditionChecker
java.lang.Object
io.camunda.zeebe.engine.processing.processinstance.ProcessInstanceMigrationPreconditionChecker
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
requireAuthorizedTenant
(Map<String, Object> authorizations, String tenantId, long processInstanceKey) Checks whether given tenant is authorized for the process given instance.static void
requireNoBoundaryEventInSource
(DeployedProcess sourceProcessDefinition, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given source process definition contains a boundary event.static void
requireNoBoundaryEventInTarget
(DeployedProcess targetProcessDefinition, String targetElementId, ProcessInstanceRecord elementInstanceRecord, EnumSet<BpmnEventType> allowedEventTypes) Checks whether the given target process definition contains a boundary event.static void
requireNoConcurrentCommand
(EventScopeInstanceState eventScopeInstanceState, ElementInstance elementInstance, long processInstanceKey) Checks whether the given process instance has a concurrent command.static void
requireNoEventSubprocess
(DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition) Checks whether the given source and target process definition contain event subprocesses.static void
requireNoMappedCatchEventsInSource
(Map<String, String> sourceElementIdToTargetElementId, String sourceCatchEventId, long processInstanceKey, String elementId) Throws an exception if a mapping is provided for a catch event that the active element is subscribed to.static void
requireNoMappedCatchEventsInTarget
(Map<String, String> sourceElementIdToTargetElementId, String targetCatchEventId, long processInstanceKey, String elementId, String targetElementId) Throws an exception if a mapping is provided to the target catch event.static void
requireNonDuplicateSourceElementIds
(List<ProcessInstanceMigrationRecordValue.ProcessInstanceMigrationMappingInstructionValue> mappingInstructions, long processInstanceKey) Checks whether the given mapping instructions contain duplicate source element ids.static void
requireNonNullProcessInstance
(ElementInstance record, long processInstanceKey) Checks whether the given record exists.static void
requireNonNullTargetElementId
(String targetElementId, long processInstanceKey, String sourceElementId) Checks whether the given target element id exists.static void
requireNonNullTargetProcessDefinition
(DeployedProcess targetProcessDefinition, long targetProcessDefinitionKey) Checks whether the given target process definition exists.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.static void
requireNullParent
(long parentProcessInstanceKey, long processInstanceKey) Checks whether the given process instance key is a parent key.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.static void
requireSameElementType
(DeployedProcess targetProcessDefinition, String targetElementId, ProcessInstanceRecord elementInstanceRecord, long processInstanceKey) Checks whether the given element instance has the same element type as the target element.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.static void
requireSupportedElementType
(ProcessInstanceRecord elementInstanceRecord, long processInstanceKey) Checks whether the given element instance is of a supported type.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.
-
Constructor Details
-
ProcessInstanceMigrationPreconditionChecker
public ProcessInstanceMigrationPreconditionChecker()
-
-
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
-
requireNullParent
public static void requireNullParent(long parentProcessInstanceKey, long processInstanceKey) Checks whether the given process instance key is a parent key. Throws exception if given parent process key is a parent.- Parameters:
parentProcessInstanceKey
- parent process instance key to do the checkprocessInstanceKey
- 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
-
requireNoEventSubprocess
public static void requireNoEventSubprocess(DeployedProcess sourceProcessDefinition, DeployedProcess targetProcessDefinition) Checks whether the given source and target process definition contain event subprocesses.- Parameters:
sourceProcessDefinition
- source process definitiontargetProcessDefinition
- target process definition
-
requireSupportedElementType
public static void requireSupportedElementType(ProcessInstanceRecord elementInstanceRecord, long processInstanceKey) 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, ProcessInstanceRecord elementInstanceRecord, 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 idelementInstanceRecord
- 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
-
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
-
requireNoMappedCatchEventsInSource
public static void requireNoMappedCatchEventsInSource(Map<String, String> sourceElementIdToTargetElementId, String sourceCatchEventId, long processInstanceKey, String elementId) Throws an exception if a mapping is provided for a catch event that the active element is subscribed to.- Parameters:
sourceElementIdToTargetElementId
- the mapping instructionssourceCatchEventId
- the id of the source catch event to check forprocessInstanceKey
- the key of the process instance (for logging)elementId
- the id of the active element (for logging)
-
requireNoMappedCatchEventsInTarget
public static void requireNoMappedCatchEventsInTarget(Map<String, String> sourceElementIdToTargetElementId, String targetCatchEventId, long processInstanceKey, String elementId, String targetElementId) Throws an exception if a mapping is provided to the target catch event.- Parameters:
sourceElementIdToTargetElementId
- the mapping instructionstargetCatchEventId
- the id of the target catch event to check forprocessInstanceKey
- the key of the process instance (for logging)elementId
- the id of the active element (for logging)targetElementId
- the id of the target element (for logging)
-