Search in sources :

Example 21 with BatchEntity

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;
}
Also used : UpdateProcessInstancesSuspendStateBatchConfiguration(org.camunda.bpm.engine.impl.batch.update.UpdateProcessInstancesSuspendStateBatchConfiguration) BatchJobHandler(org.camunda.bpm.engine.impl.batch.BatchJobHandler) UpdateProcessInstancesSuspendStateBatchConfiguration(org.camunda.bpm.engine.impl.batch.update.UpdateProcessInstancesSuspendStateBatchConfiguration) BatchConfiguration(org.camunda.bpm.engine.impl.batch.BatchConfiguration) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 22 with BatchEntity

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;
}
Also used : BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity)

Example 23 with BatchEntity

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;
}
Also used : BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity)

Example 24 with BatchEntity

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[] {}));
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date) Test(org.junit.Test)

Example 25 with BatchEntity

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;
}
Also used : BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) BatchManager(org.camunda.bpm.engine.impl.persistence.entity.BatchManager)

Aggregations

BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)32 Test (org.junit.Test)18 HashMap (java.util.HashMap)11 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)11 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)10 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)10 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)6 DeleteProcessInstancesDto (org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto)6 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)5 ProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 BatchConfiguration (org.camunda.bpm.engine.impl.batch.BatchConfiguration)2 BatchJobHandler (org.camunda.bpm.engine.impl.batch.BatchJobHandler)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Date (java.util.Date)1 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)1 ModificationBatchConfiguration (org.camunda.bpm.engine.impl.ModificationBatchConfiguration)1 SetRetriesBatchConfiguration (org.camunda.bpm.engine.impl.batch.SetRetriesBatchConfiguration)1 UpdateProcessInstancesSuspendStateBatchConfiguration (org.camunda.bpm.engine.impl.batch.update.UpdateProcessInstancesSuspendStateBatchConfiguration)1 BatchManager (org.camunda.bpm.engine.impl.persistence.entity.BatchManager)1