Search in sources :

Example 1 with ByteArrayManager

use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager in project camunda-bpm-platform by camunda.

the class DeleteProcessInstancesJobHandler method createJobEntities.

protected void createJobEntities(BatchEntity batch, DeleteProcessInstanceBatchConfiguration configuration, String deploymentId, List<String> processInstancesToHandle, int invocationsPerBatchJob) {
    CommandContext commandContext = Context.getCommandContext();
    ByteArrayManager byteArrayManager = commandContext.getByteArrayManager();
    JobManager jobManager = commandContext.getJobManager();
    int createdJobs = 0;
    while (!processInstancesToHandle.isEmpty()) {
        int lastIdIndex = Math.min(invocationsPerBatchJob, processInstancesToHandle.size());
        // view of process instances for this job
        List<String> idsForJob = processInstancesToHandle.subList(0, lastIdIndex);
        DeleteProcessInstanceBatchConfiguration jobConfiguration = createJobConfiguration(configuration, idsForJob);
        ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);
        JobEntity job = createBatchJob(batch, configurationEntity);
        job.setDeploymentId(deploymentId);
        jobManager.insertAndHintJobExecutor(job);
        createdJobs++;
        idsForJob.clear();
    }
    // update created jobs for batch
    batch.setJobsCreated(batch.getJobsCreated() + createdJobs);
    // update batch configuration
    batch.setConfigurationBytes(writeConfiguration(configuration));
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) ByteArrayManager(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager)

Example 2 with ByteArrayManager

use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager in project camunda-bpm-platform by camunda.

the class AbstractBatchJobHandler method createJobs.

@Override
public boolean createJobs(BatchEntity batch) {
    CommandContext commandContext = Context.getCommandContext();
    ByteArrayManager byteArrayManager = commandContext.getByteArrayManager();
    JobManager jobManager = commandContext.getJobManager();
    T configuration = readConfiguration(batch.getConfigurationBytes());
    int batchJobsPerSeed = batch.getBatchJobsPerSeed();
    int invocationsPerBatchJob = batch.getInvocationsPerBatchJob();
    List<String> ids = configuration.getIds();
    int numberOfItemsToProcess = Math.min(invocationsPerBatchJob * batchJobsPerSeed, ids.size());
    // view of process instances to process
    List<String> processIds = ids.subList(0, numberOfItemsToProcess);
    int createdJobs = 0;
    while (!processIds.isEmpty()) {
        int lastIdIndex = Math.min(invocationsPerBatchJob, processIds.size());
        // view of process instances for this job
        List<String> idsForJob = processIds.subList(0, lastIdIndex);
        T jobConfiguration = createJobConfiguration(configuration, idsForJob);
        ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);
        JobEntity job = createBatchJob(batch, configurationEntity);
        postProcessJob(configuration, job);
        jobManager.insertAndHintJobExecutor(job);
        idsForJob.clear();
        createdJobs++;
    }
    // update created jobs for batch
    batch.setJobsCreated(batch.getJobsCreated() + createdJobs);
    // update batch configuration
    batch.setConfigurationBytes(writeConfiguration(configuration));
    return ids.isEmpty();
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) ByteArrayManager(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager)

Aggregations

CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)2 ByteArrayEntity (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)2 ByteArrayManager (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)2