public void submit(MigratingJobInstance job) { migratingJobs.put(job.getJobEntity().getId(), job); }
public void submit(MigratingJobInstance job) { migratingJobs.put(job.getJobEntity().getId(), job); }
protected void initializeRetries(JobEntity job, int retries) { LOG.debugInitiallyAppyingRetryCycleForJob(job.getId(), retries); job.setRetries(retries); }
protected void initializeRetries(JobEntity job, int retries) { LOG.debugInitiallyAppyingRetryCycleForJob(job.getId(), retries); job.setRetries(retries); }
protected JobEntity createNonExclusiveJob(String id, String processInstanceId) { JobEntity job = mock(JobEntity.class); when(job.getId()).thenReturn(id); when(job.getProcessInstanceId()).thenReturn(processInstanceId); return job; }
public void checkReadJob(JobEntity job) { if (job != null && !getTenantManager().isAuthenticatedTenant(job.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("read the job '"+ job.getId() + "'"); } }
@Override public void checkUpdateJob(JobEntity job) { if (job != null && !getTenantManager().isAuthenticatedTenant(job.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("update the job '"+ job.getId() + "'"); } }
public void checkReadJob(JobEntity job) { if (job != null && !getTenantManager().isAuthenticatedTenant(job.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("read the job '"+ job.getId() + "'"); } }
@Override public void checkUpdateJob(JobEntity job) { if (job != null && !getTenantManager().isAuthenticatedTenant(job.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("update the job '"+ job.getId() + "'"); } }
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<JobEntity> jobsToDelete = getJobManager() .findJobsByConfiguration(TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); for (JobEntity job :jobsToDelete) { new DeleteJobsCmd(job.getId()).execute(Context.getCommandContext()); } }
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<JobEntity> jobsToDelete = getJobManager() .findJobsByConfiguration(TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); for (JobEntity job :jobsToDelete) { new DeleteJobsCmd(job.getId()).execute(Context.getCommandContext()); } }
protected void executeCustomStrategy(CommandContext commandContext, JobEntity job, ActivityImpl activity) throws Exception { FailedJobRetryConfiguration retryConfiguration = getFailedJobRetryConfiguration(job, activity); if (retryConfiguration == null) { executeStandardStrategy(commandContext); } else { if (isFirstJobExecution(job)) { // then change default retries to the ones configured initializeRetries(job, retryConfiguration.getRetries()); } else { LOG.debugDecrementingRetriesForJob(job.getId()); } List<String> intervals = retryConfiguration.getRetryIntervals(); int intervalsCount = intervals.size(); int indexOfInterval = Math.max(0, Math.min(intervalsCount - 1, intervalsCount - (job.getRetries() - 1))); DurationHelper durationHelper = getDurationHelper(intervals.get(indexOfInterval)); job.setLockExpirationTime(durationHelper.getDateAfter()); logException(job); decrementRetries(job); notifyAcquisition(commandContext); } }
@Deployment(resources="org/camunda/bpm/engine/test/jobexecutor/processWithTimerStart.bpmn20.xml") public void testTimerStartEvent() { Set<String> registeredDeployments = processEngineConfiguration.getRegisteredDeployments(); Job existingJob = managementService.createJobQuery().singleResult(); ClockUtil.setCurrentTime(new Date(System.currentTimeMillis()+1000)); List<JobEntity> acquirableJobs = findAcquirableJobs(); assertEquals(1, acquirableJobs.size()); assertEquals(existingJob.getId(), acquirableJobs.get(0).getId()); registeredDeployments.clear(); acquirableJobs = findAcquirableJobs(); assertEquals(0, acquirableJobs.size()); }
protected void createOpLogEntry(CommandContext commandContext, long previousPriority, JobEntity job) { PropertyChange propertyChange = new PropertyChange(JOB_PRIORITY_PROPERTY, previousPriority, job.getPriority()); commandContext .getOperationLogManager() .logJobOperation( UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, job.getId(), job.getJobDefinitionId(), job.getProcessInstanceId(), job.getProcessDefinitionId(), job.getProcessDefinitionKey(), propertyChange); } }
@Deployment(resources="org/camunda/bpm/engine/test/jobexecutor/processWithTimerCatch.bpmn20.xml") public void testIntermediateTimerEvent() { runtimeService.startProcessInstanceByKey("testProcess"); Set<String> registeredDeployments = processEngineConfiguration.getRegisteredDeployments(); Job existingJob = managementService.createJobQuery().singleResult(); ClockUtil.setCurrentTime(new Date(System.currentTimeMillis() + 61 * 1000)); List<JobEntity> acquirableJobs = findAcquirableJobs(); assertEquals(1, acquirableJobs.size()); assertEquals(existingJob.getId(), acquirableJobs.get(0).getId()); registeredDeployments.clear(); acquirableJobs = findAcquirableJobs(); assertEquals(0, acquirableJobs.size()); }
protected void createOpLogEntry(CommandContext commandContext, long previousPriority, JobEntity job) { PropertyChange propertyChange = new PropertyChange(JOB_PRIORITY_PROPERTY, previousPriority, job.getPriority()); commandContext .getOperationLogManager() .logJobOperation( UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, job.getId(), job.getJobDefinitionId(), job.getProcessInstanceId(), job.getProcessDefinitionId(), job.getProcessDefinitionKey(), propertyChange); } }
protected HistoryCleanupHandler initCleanupHandler(HistoryCleanupJobHandlerConfiguration configuration, CommandContext commandContext) { HistoryCleanupHandler cleanupHandler = null; if (isHistoryCleanupStrategyRemovalTimeBased(commandContext)) { cleanupHandler = new HistoryCleanupRemovalTime(); } else { cleanupHandler = new HistoryCleanupBatch(); } CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration() .getCommandExecutorTxRequiresNew(); String jobId = commandContext.getCurrentJob().getId(); return cleanupHandler .setConfiguration(configuration) .setCommandExecutor(commandExecutor) .setJobId(jobId); }
protected HistoryCleanupHandler initCleanupHandler(HistoryCleanupJobHandlerConfiguration configuration, CommandContext commandContext) { HistoryCleanupHandler cleanupHandler = null; if (isHistoryCleanupStrategyRemovalTimeBased(commandContext)) { cleanupHandler = new HistoryCleanupRemovalTime(); } else { cleanupHandler = new HistoryCleanupBatch(); } CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration() .getCommandExecutorTxRequiresNew(); String jobId = commandContext.getCurrentJob().getId(); return cleanupHandler .setConfiguration(configuration) .setCommandExecutor(commandExecutor) .setJobId(jobId); }
protected void setJobRetriesByJobId(String jobId, int retries, CommandContext commandContext) { JobEntity job = commandContext .getJobManager() .findJobById(jobId); if (job != null) { for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { checker.checkUpdateRetriesJob(job); } if (job.isInInconsistentLockState()) { job.resetLock(); } int oldRetries = job.getRetries(); job.setRetries(retries); PropertyChange propertyChange = new PropertyChange(RETRIES, oldRetries, job.getRetries()); commandContext.getOperationLogManager().logJobOperation(getLogEntryOperation(), job.getId(), job.getJobDefinitionId(), job.getProcessInstanceId(), job.getProcessDefinitionId(), job.getProcessDefinitionKey(), propertyChange); } else { throw new ProcessEngineException("No job found with id '" + jobId + "'."); } }
@Test public void testDeleteBatchJobManually() { // given Batch batch = helper.createMigrationBatchWithSize(1); helper.executeSeedJob(batch); JobEntity migrationJob = (JobEntity) helper.getExecutionJobs(batch).get(0); String byteArrayId = migrationJob.getJobHandlerConfigurationRaw(); ByteArrayEntity byteArrayEntity = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired() .execute(new GetByteArrayCommand(byteArrayId)); assertNotNull(byteArrayEntity); // when managementService.deleteJob(migrationJob.getId()); // then byteArrayEntity = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired() .execute(new GetByteArrayCommand(byteArrayId)); assertNull(byteArrayEntity); }