Search in sources :

Example 1 with DummyStatefulP

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);
}
Also used : DummyStatefulP(com.hazelcast.jet.core.TestProcessors.DummyStatefulP) Job(com.hazelcast.jet.Job) JobRepository(com.hazelcast.jet.impl.JobRepository) JobExecutionRecord(com.hazelcast.jet.impl.JobExecutionRecord) JobConfig(com.hazelcast.jet.config.JobConfig) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 2 with DummyStatefulP

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);
}
Also used : DummyStatefulP(com.hazelcast.jet.core.TestProcessors.DummyStatefulP) SupplierEx(com.hazelcast.function.SupplierEx) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Job (com.hazelcast.jet.Job)2 JobConfig (com.hazelcast.jet.config.JobConfig)2 DummyStatefulP (com.hazelcast.jet.core.TestProcessors.DummyStatefulP)2 Test (org.junit.Test)2 SupplierEx (com.hazelcast.function.SupplierEx)1 JobExecutionRecord (com.hazelcast.jet.impl.JobExecutionRecord)1 JobRepository (com.hazelcast.jet.impl.JobRepository)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1