use of com.hazelcast.jet.impl.JobExecutionRecord in project hazelcast by hazelcast.
the class JetTestSupport method waitForFirstSnapshot.
public void waitForFirstSnapshot(JobRepository jr, long jobId, int timeoutSeconds, boolean allowEmptySnapshot) {
long[] snapshotId = { -1 };
assertTrueEventually(() -> {
JobExecutionRecord record = jr.getJobExecutionRecord(jobId);
assertNotNull("null JobExecutionRecord", record);
assertTrue("No snapshot produced", record.dataMapIndex() >= 0 && record.snapshotId() >= 0);
assertTrue("stats are 0", allowEmptySnapshot || record.snapshotStats().numBytes() > 0);
snapshotId[0] = record.snapshotId();
}, timeoutSeconds);
SUPPORT_LOGGER.info("First snapshot found (id=" + snapshotId[0] + ")");
}
use of com.hazelcast.jet.impl.JobExecutionRecord in project hazelcast by hazelcast.
the class JobRestartWithSnapshotTest method when_snapshotStartedBeforeExecution_then_firstSnapshotIsSuccessful.
@Test
public void when_snapshotStartedBeforeExecution_then_firstSnapshotIsSuccessful() {
// instance1 is always coordinator
// delay ExecuteOperation so that snapshot is started before execution is started on the worker member
delayOperationsFrom(instance1, JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.START_EXECUTION_OP));
DAG dag = new DAG();
dag.newVertex("p", FirstSnapshotProcessor::new).localParallelism(1);
JobConfig config = new JobConfig();
config.setProcessingGuarantee(EXACTLY_ONCE);
config.setSnapshotIntervalMillis(0);
Job job = instance1.getJet().newJob(dag, config);
JobRepository repository = new JobRepository(instance1);
// the first snapshot should succeed
assertTrueEventually(() -> {
JobExecutionRecord record = repository.getJobExecutionRecord(job.getId());
assertNotNull("null JobRecord", record);
assertEquals(0, record.snapshotId());
}, 30);
}
use of com.hazelcast.jet.impl.JobExecutionRecord in project hazelcast by hazelcast.
the class PostponedSnapshotTestBase method startJob.
// used by subclass in jet-enterprise
@SuppressWarnings("WeakerAccess")
protected Job startJob(long snapshotInterval) {
DAG dag = new DAG();
Vertex highPrioritySource = dag.newVertex("highPrioritySource", () -> new SourceP(0)).localParallelism(1);
Vertex lowPrioritySource = dag.newVertex("lowPrioritySource", () -> new SourceP(1)).localParallelism(1);
Vertex sink = dag.newVertex("sink", writeLoggerP());
dag.edge(between(highPrioritySource, sink).priority(-1)).edge(from(lowPrioritySource).to(sink, 1));
JobConfig config = new JobConfig();
config.setProcessingGuarantee(ProcessingGuarantee.EXACTLY_ONCE);
config.setSnapshotIntervalMillis(snapshotInterval);
Job job = instance.getJet().newJob(dag, config);
JobRepository jr = new JobRepository(instance);
// check, that snapshot starts, but stays in ONGOING state
if (snapshotInterval < 1000) {
assertTrueEventually(() -> {
JobExecutionRecord record = jr.getJobExecutionRecord(job.getId());
assertNotNull("record is null", record);
assertTrue(record.ongoingSnapshotId() >= 0);
}, 5);
assertTrueAllTheTime(() -> {
JobExecutionRecord record = jr.getJobExecutionRecord(job.getId());
assertTrue(record.ongoingSnapshotId() >= 0);
assertTrue("snapshotId=" + record.snapshotId(), record.snapshotId() < 0);
}, 2);
} else {
assertJobStatusEventually(job, RUNNING);
}
return job;
}
Aggregations