use of io.camunda.zeebe.engine.processing.job.JobBatchCollector.TooLargeJob in project zeebe by camunda.
the class JobBatchCollectorTest method shouldActivateUpToMaxJobs.
@Test
void shouldActivateUpToMaxJobs() {
// given
final TypedRecord<JobBatchRecord> record = createRecord();
final long scopeKey = state.getKeyGenerator().nextKey();
final List<Job> jobs = Arrays.asList(createJob(scopeKey), createJob(scopeKey));
record.getValue().setMaxJobsToActivate(1);
// when
final Either<TooLargeJob, Integer> result = collector.collectJobs(record);
// then
final JobBatchRecord batchRecord = record.getValue();
EitherAssert.assertThat(result).as("should collect only the first job").right().isEqualTo(1);
JobBatchRecordValueAssert.assertThat(batchRecord).hasJobKeys(jobs.get(0).key).isNotTruncated();
}
use of io.camunda.zeebe.engine.processing.job.JobBatchCollector.TooLargeJob in project zeebe by camunda.
the class JobBatchCollectorTest method shouldTruncateBatchIfNoMoreCanBeWritten.
@Test
void shouldTruncateBatchIfNoMoreCanBeWritten() {
// given
final long variableScopeKey = state.getKeyGenerator().nextKey();
final TypedRecord<JobBatchRecord> record = createRecord();
final List<Job> jobs = Arrays.asList(createJob(variableScopeKey), createJob(variableScopeKey));
final var toggle = new AtomicBoolean(true);
// when - set up the evaluator to only accept the first job
lengthEvaluator.canWriteEventOfLength = (length) -> toggle.getAndSet(false);
final Either<TooLargeJob, Integer> result = collector.collectJobs(record);
// then
final JobBatchRecord batchRecord = record.getValue();
EitherAssert.assertThat(result).as("should have activated only one job successfully").right().isEqualTo(1);
JobBatchRecordValueAssert.assertThat(batchRecord).hasOnlyJobKeys(jobs.get(0).key).isTruncated();
}
use of io.camunda.zeebe.engine.processing.job.JobBatchCollector.TooLargeJob in project zeebe by zeebe-io.
the class JobBatchActivateProcessor method activateJobs.
private void activateJobs(final TypedRecord<JobBatchRecord> record) {
final JobBatchRecord value = record.getValue();
final long jobBatchKey = keyGenerator.nextKey();
final Either<TooLargeJob, Integer> result = jobBatchCollector.collectJobs(record);
final var activatedJobCount = result.getOrElse(0);
result.ifLeft(largeJob -> raiseIncidentJobTooLargeForMessageSize(largeJob.key(), largeJob.record()));
activateJobBatch(record, value, jobBatchKey, activatedJobCount);
}
use of io.camunda.zeebe.engine.processing.job.JobBatchCollector.TooLargeJob in project zeebe by zeebe-io.
the class JobBatchCollectorTest method shouldActivateUpToMaxJobs.
@Test
void shouldActivateUpToMaxJobs() {
// given
final TypedRecord<JobBatchRecord> record = createRecord();
final long scopeKey = state.getKeyGenerator().nextKey();
final List<Job> jobs = Arrays.asList(createJob(scopeKey), createJob(scopeKey));
record.getValue().setMaxJobsToActivate(1);
// when
final Either<TooLargeJob, Integer> result = collector.collectJobs(record);
// then
final JobBatchRecord batchRecord = record.getValue();
EitherAssert.assertThat(result).as("should collect only the first job").right().isEqualTo(1);
JobBatchRecordValueAssert.assertThat(batchRecord).hasJobKeys(jobs.get(0).key).isNotTruncated();
}
use of io.camunda.zeebe.engine.processing.job.JobBatchCollector.TooLargeJob in project zeebe by zeebe-io.
the class JobBatchCollectorTest method shouldTruncateBatchIfNoMoreCanBeWritten.
@Test
void shouldTruncateBatchIfNoMoreCanBeWritten() {
// given
final long variableScopeKey = state.getKeyGenerator().nextKey();
final TypedRecord<JobBatchRecord> record = createRecord();
final List<Job> jobs = Arrays.asList(createJob(variableScopeKey), createJob(variableScopeKey));
final var toggle = new AtomicBoolean(true);
// when - set up the evaluator to only accept the first job
lengthEvaluator.canWriteEventOfLength = (length) -> toggle.getAndSet(false);
final Either<TooLargeJob, Integer> result = collector.collectJobs(record);
// then
final JobBatchRecord batchRecord = record.getValue();
EitherAssert.assertThat(result).as("should have activated only one job successfully").right().isEqualTo(1);
JobBatchRecordValueAssert.assertThat(batchRecord).hasOnlyJobKeys(jobs.get(0).key).isTruncated();
}
Aggregations