protected static boolean isAsyncContinuation(JobEntity job) { return job != null && AsyncContinuationJobHandler.TYPE.equals(job.getJobHandlerType()); }
protected static boolean isAsyncContinuation(JobEntity job) { return job != null && AsyncContinuationJobHandler.TYPE.equals(job.getJobHandlerType()); }
protected ScopeImpl determineTimerTriggerTargetScope(JobEntity jobEntity, ScopeImpl targetScope) { if (TimerStartEventSubprocessJobHandler.TYPE.equals(jobEntity.getJobHandlerType())) { // for event subprocess start jobs, the job handler configuration references the subprocess while // the job references the start event return targetScope.getFlowScope(); } else { return targetScope; } }
protected ScopeImpl determineTimerTriggerTargetScope(JobEntity jobEntity, ScopeImpl targetScope) { if (TimerStartEventSubprocessJobHandler.TYPE.equals(jobEntity.getJobHandlerType())) { // for event subprocess start jobs, the job handler configuration references the subprocess while // the job references the start event return targetScope.getFlowScope(); } else { return targetScope; } }
/** * Workaround for CAM-5609: In general, only async continuations should be represented as TransitionInstances, but * due to this bug, completed multi-instances are represented like that as well. We tolerate the second case. */ protected boolean isAsyncTransitionInstance(TransitionInstance transitionInstance) { String executionId = transitionInstance.getExecutionId(); ExecutionEntity execution = Context.getCommandContext().getExecutionManager().findExecutionById(executionId); for (JobEntity job : execution.getJobs()) { if (AsyncContinuationJobHandler.TYPE.equals(job.getJobHandlerType())) { return true; } } return false; }
/** * Workaround for CAM-5609: In general, only async continuations should be represented as TransitionInstances, but * due to this bug, completed multi-instances are represented like that as well. We tolerate the second case. */ protected boolean isAsyncTransitionInstance(TransitionInstance transitionInstance) { String executionId = transitionInstance.getExecutionId(); ExecutionEntity execution = Context.getCommandContext().getExecutionManager().findExecutionById(executionId); for (JobEntity job : execution.getJobs()) { if (AsyncContinuationJobHandler.TYPE.equals(job.getJobHandlerType())) { return true; } } return false; }
protected ActivityImpl getCurrentActivity(CommandContext commandContext, JobEntity job) { String type = job.getJobHandlerType(); ActivityImpl activity = null; if (SUPPORTED_TYPES.contains(type)) { DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache(); ProcessDefinitionEntity processDefinitionEntity = deploymentCache.findDeployedProcessDefinitionById(job.getProcessDefinitionId()); activity = processDefinitionEntity.findActivity(job.getActivityId()); } else { // noop, because activity type is not supported } return activity; }
protected ActivityImpl getCurrentActivity(CommandContext commandContext, JobEntity job) { String type = job.getJobHandlerType(); ActivityImpl activity = null; if (SUPPORTED_TYPES.contains(type)) { DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache(); ProcessDefinitionEntity processDefinitionEntity = deploymentCache.findDeployedProcessDefinitionById(job.getProcessDefinitionId()); activity = processDefinitionEntity.findActivity(job.getActivityId()); } else { // noop, because activity type is not supported } return activity; }
@Override public void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, List<JobEntity> elements) { for (JobEntity job : elements) { if (!isAsyncContinuation(job)) { continue; } ScopeImpl targetScope = transitionInstance.getTargetScope(); if (targetScope != null) { JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.getTargetScope().getId(), job.getJobHandlerType()); MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.getTargetScope()); transitionInstance.setDependentJobInstance(migratingJobInstance); parseContext.submit(migratingJobInstance); } parseContext.consume(job); } }
@Override public void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, List<JobEntity> elements) { for (JobEntity job : elements) { if (!isAsyncContinuation(job)) { continue; } ScopeImpl targetScope = transitionInstance.getTargetScope(); if (targetScope != null) { JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.getTargetScope().getId(), job.getJobHandlerType()); MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.getTargetScope()); transitionInstance.setDependentJobInstance(migratingJobInstance); parseContext.submit(migratingJobInstance); } parseContext.consume(job); } }
protected ScopeImpl determineTimerTriggerTargetScope(JobEntity jobEntity, ScopeImpl targetScope) { if (TimerStartEventSubprocessJobHandler.TYPE.equals(jobEntity.getJobHandlerType())) { // for event subprocess start jobs, the job handler configuration references the subprocess while // the job references the start event return targetScope.getFlowScope(); } else { return targetScope; } }
JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(targetActivity.getActivityId(), job.getJobHandlerType());
@Test public void testDeleteHistoricIncidentByJobDefinitionId() { // given BatchEntity batch = (BatchEntity) createFailingMigrationBatch(); migrationHelper.executeSeedJob(batch); List<Job> list = managementService.createJobQuery().list(); for (Job job : list) { if (((JobEntity) job).getJobHandlerType().equals("instance-migration")) { managementService.setJobRetries(job.getId(), 1); } } migrationHelper.executeJobs(batch); // assume if (eventTypes != null) { HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult(); assertNotNull(historicIncident); } // when managementService.deleteBatch(batch.getId(), true); // then List<HistoricIncident> incidents = historyService.createHistoricIncidentQuery().list(); assertEquals(0, incidents.size()); }
JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(targetActivity.getActivityId(), job.getJobHandlerType());
if (((JobEntity) job).getJobHandlerType().equals("instance-migration")) { managementService.setJobRetries(job.getId(), 1);
@Test public void testCleanupHistoricIncident() { initBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS); ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), -11)); BatchEntity batch = (BatchEntity) createFailingMigrationBatch(); migrationHelper.executeSeedJob(batch); List<Job> list = managementService.createJobQuery().list(); for (Job job : list) { if (((JobEntity) job).getJobHandlerType().equals("instance-migration")) { managementService.setJobRetries(job.getId(), 1); } } migrationHelper.executeJobs(batch); List<String> byteArrayIds = findExceptionByteArrayIds(); ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), -10)); managementService.deleteBatch(batch.getId(), false); ClockUtil.setCurrentTime(new Date()); // given HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult(); String batchId = historicBatch.getId(); // when runHistoryCleanup(); assertEquals(0, historyService.createHistoricBatchQuery().count()); assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count()); assertEquals(0, historyService.createHistoricIncidentQuery().count()); verifyByteArraysWereRemoved(byteArrayIds.toArray(new String[] {})); }
/** * Workaround for CAM-5609: In general, only async continuations should be represented as TransitionInstances, but * due to this bug, completed multi-instances are represented like that as well. We tolerate the second case. */ protected boolean isAsyncTransitionInstance(TransitionInstance transitionInstance) { String executionId = transitionInstance.getExecutionId(); ExecutionEntity execution = Context.getCommandContext().getExecutionManager().findExecutionById(executionId); for (JobEntity job : execution.getJobs()) { if (AsyncContinuationJobHandler.TYPE.equals(job.getJobHandlerType())) { return true; } } return false; }
public void assertJobMigrated(Job jobBefore, String activityIdAfter, Date dueDateAfter) { Job jobAfter = snapshotAfterMigration.getJobById(jobBefore.getId()); assertNotNull("Expected that a job with id '" + jobBefore.getId() + "' exists after migration", jobAfter); JobDefinition jobDefinitionAfter = snapshotAfterMigration.getJobDefinitionForActivityIdAndType(activityIdAfter, ((JobEntity) jobBefore).getJobHandlerType()); assertNotNull("Expected that a job definition for activity '" + activityIdAfter + "' exists after migration", jobDefinitionAfter); assertEquals(jobBefore.getId(), jobAfter.getId()); assertEquals("Expected that job is assigned to job definition '" + jobDefinitionAfter.getId() + "' after migration", jobDefinitionAfter.getId(), jobAfter.getJobDefinitionId()); assertEquals("Expected that job is assigned to deployment '" + snapshotAfterMigration.getDeploymentId() + "' after migration", snapshotAfterMigration.getDeploymentId(), jobAfter.getDeploymentId()); assertEquals(dueDateAfter, jobAfter.getDuedate()); assertEquals(((JobEntity) jobBefore).getType(), ((JobEntity) jobAfter).getType()); assertEquals(jobBefore.getPriority(), jobAfter.getPriority()); assertEquals(jobDefinitionAfter.getProcessDefinitionId(), jobAfter.getProcessDefinitionId()); assertEquals(jobDefinitionAfter.getProcessDefinitionKey(), jobAfter.getProcessDefinitionKey()); }
evt.setJobDefinitionType(jobEntity.getJobHandlerType());
evt.setJobDefinitionType(jobEntity.getJobHandlerType());