use of com.hazelcast.jet.core.TestProcessors.DummyStatefulP in project hazelcast by hazelcast.
the class OperationLossTest method when_snapshotOperationLost_then_retried.
@Test
public void when_snapshotOperationLost_then_retried() {
PacketFiltersUtil.dropOperationsFrom(instance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.SNAPSHOT_PHASE1_OPERATION));
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", () -> new DummyStatefulP()).localParallelism(1);
Vertex v2 = dag.newVertex("v2", mapP(identity())).localParallelism(1);
dag.edge(between(v1, v2).distributed());
Job job = instance().getJet().newJob(dag, new JobConfig().setProcessingGuarantee(EXACTLY_ONCE).setSnapshotIntervalMillis(100));
assertJobStatusEventually(job, RUNNING);
JobRepository jobRepository = new JobRepository(instance());
assertTrueEventually(() -> {
JobExecutionRecord record = jobRepository.getJobExecutionRecord(job.getId());
assertNotNull("null JobExecutionRecord", record);
assertEquals("ongoingSnapshotId", 0, record.ongoingSnapshotId());
}, 20);
sleepSeconds(1);
// now lift the filter and check that a snapshot is done
logger.info("Lifting the packet filter...");
PacketFiltersUtil.resetPacketFiltersFrom(instance());
waitForFirstSnapshot(jobRepository, job.getId(), 10, false);
cancelAndJoin(job);
}
use of com.hazelcast.jet.core.TestProcessors.DummyStatefulP in project hazelcast by hazelcast.
the class GracefulShutdown_LiteMasterTest method test.
@Test
public void test() {
DummyStatefulP.parallelism = 2;
DAG dag = new DAG();
dag.newVertex("v", (SupplierEx<Processor>) DummyStatefulP::new).localParallelism(DummyStatefulP.parallelism);
Job job = instance.getJet().newJob(dag, new JobConfig().setSnapshotIntervalMillis(DAYS.toMillis(1)).setProcessingGuarantee(EXACTLY_ONCE));
assertJobStatusEventually(job, RUNNING, 10);
DummyStatefulP.wasRestored = false;
liteMaster.shutdown();
assertJobStatusEventually(job, RUNNING, 10);
assertTrueEventually(() -> assertTrue("snapshot wasn't restored", DummyStatefulP.wasRestored), 10);
assertTrueAllTheTime(() -> assertEquals(RUNNING, job.getStatus()), 1);
}
Aggregations