Class ProcessInstanceMigrationPreconditionChecker

java.lang.Object
io.camunda.zeebe.engine.processing.processinstance.ProcessInstanceMigrationPreconditionChecker

public final class ProcessInstanceMigrationPreconditionChecker extends Object
  • Constructor Details

    • ProcessInstanceMigrationPreconditionChecker

      public ProcessInstanceMigrationPreconditionChecker()
  • Method Details

    • requireNonNullProcessInstance

      public static void requireNonNullProcessInstance(ElementInstance record, long processInstanceKey)
      Checks whether the given record exists. Throws exception if given process instance record is null.
      Parameters:
      record - process instance record to do the null check
      processInstanceKey - 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 available
      tenantId - tenant id to be checked
      processInstanceKey - 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 check
      processInstanceKey - 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 check
      targetProcessDefinitionKey - 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 check
      processInstanceKey - 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 definition
      targetProcessDefinition - target process definition
      mappingInstructions - mapping instructions to do the check
      processInstanceKey - 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 definition
      targetProcessDefinition - 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 check
      processInstanceKey - 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 check
      processInstanceKey - process instance key to be logged
      sourceElementId - 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 type
      targetElementId - target element id
      elementInstanceRecord - element instance to do the check
      processInstanceKey - 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 type
      targetElementId - target element id
      elementInstance - element instance to do the check
      processInstanceKey - 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 element
      elementInstanceRecord - element instance to do the check
      targetProcessDefinition - target process definition to retrieve the target element
      targetElementId - 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 check
      elementInstanceRecord - element instance to be logged
      allowedEventTypes - 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 check
      targetElementId - target element id to retrieve the target element
      elementInstanceRecord - element instance to be logged
      allowedEventTypes - 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 trigger
      elementInstance - element instance to do the check active sequence flows
      processInstanceKey - 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 exception
      elementInstance - the element instance to check for subscriptions
      messageName - the name of the message that the element should not be subscribed to
      targetCatchEventId - 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 instructions
      sourceCatchEventId - the id of the source catch event to check for
      processInstanceKey - 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 instructions
      targetCatchEventId - the id of the target catch event to check for
      processInstanceKey - 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)