use of org.camunda.bpm.engine.impl.batch.BatchEntity in project camunda-bpm-platform by camunda.
the class UpdateProcessInstancesSuspendStateBatchCmd method createBatch.
protected BatchEntity createBatch(CommandContext commandContext, Collection<String> processInstanceIds) {
ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration();
BatchJobHandler batchJobHandler = getBatchJobHandler(processEngineConfiguration);
BatchConfiguration configuration = getAbstractIdsBatchConfiguration(new ArrayList<String>(processInstanceIds));
BatchEntity batch = new BatchEntity();
batch.setType(batchJobHandler.getType());
batch.setTotalJobs(calculateSize(processEngineConfiguration, (UpdateProcessInstancesSuspendStateBatchConfiguration) configuration));
batch.setBatchJobsPerSeed(processEngineConfiguration.getBatchJobsPerSeed());
batch.setInvocationsPerBatchJob(processEngineConfiguration.getInvocationsPerBatchJob());
batch.setConfigurationBytes(batchJobHandler.writeConfiguration(configuration));
commandContext.getBatchManager().insert(batch);
return batch;
}
use of org.camunda.bpm.engine.impl.batch.BatchEntity in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstancesBatchCmd method execute.
@Override
public Batch execute(CommandContext commandContext) {
List<String> processInstanceIds = collectHistoricProcessInstanceIds();
ensureNotEmpty(BadUserRequestException.class, "historicProcessInstanceIds", processInstanceIds);
checkAuthorizations(commandContext);
writeUserOperationLog(commandContext, deleteReason, processInstanceIds.size(), true);
BatchEntity batch = createBatch(commandContext, processInstanceIds);
batch.createSeedJobDefinition();
batch.createMonitorJobDefinition();
batch.createBatchJobDefinition();
batch.fireHistoricStartEvent();
batch.createSeedJob();
return batch;
}
use of org.camunda.bpm.engine.impl.batch.BatchEntity in project camunda-bpm-platform by camunda.
the class DeleteHistoricDecisionInstancesBatchCmd method execute.
@Override
public Batch execute(CommandContext commandContext) {
List<String> decisionInstanceIds = collectHistoricDecisionInstanceIds();
ensureNotEmpty(BadUserRequestException.class, "historicDecisionInstanceIds", decisionInstanceIds);
checkAuthorizations(commandContext);
writeUserOperationLog(commandContext, decisionInstanceIds.size());
BatchEntity batch = createBatch(commandContext, decisionInstanceIds);
batch.createSeedJobDefinition();
batch.createMonitorJobDefinition();
batch.createBatchJobDefinition();
batch.fireHistoricStartEvent();
batch.createSeedJob();
return batch;
}
use of org.camunda.bpm.engine.impl.batch.BatchEntity in project camunda-bpm-platform by camunda.
the class HistoryCleanupHistoricBatchTest method testCleanupHistoricIncident.
@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
String jobId = historyService.cleanUpHistoryAsync(true).getId();
managementService.executeJob(jobId);
assertEquals(0, historyService.createHistoricBatchQuery().count());
assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
assertEquals(0, historyService.createHistoricIncidentQuery().count());
verifyByteArraysWereRemoved(byteArrayIds.toArray(new String[] {}));
}
use of org.camunda.bpm.engine.impl.batch.BatchEntity in project camunda-bpm-platform by camunda.
the class AbstractSetBatchStateCmd method execute.
public Void execute(CommandContext commandContext) {
ensureNotNull(BadUserRequestException.class, "Batch id must not be null", "batch id", batchId);
BatchManager batchManager = commandContext.getBatchManager();
BatchEntity batch = batchManager.findBatchById(batchId);
ensureNotNull(BadUserRequestException.class, "Batch for id '" + batchId + "' cannot be found", "batch", batch);
checkAccess(commandContext, batch);
setJobDefinitionState(commandContext, batch.getSeedJobDefinitionId());
setJobDefinitionState(commandContext, batch.getMonitorJobDefinitionId());
setJobDefinitionState(commandContext, batch.getBatchJobDefinitionId());
batchManager.updateBatchSuspensionStateById(batchId, getNewSuspensionState());
logUserOperation(commandContext);
return null;
}
Aggregations