Search in sources :

Example 6 with JobExecutionRecord

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] + ")");
}
Also used : JobExecutionRecord(com.hazelcast.jet.impl.JobExecutionRecord)

Example 7 with JobExecutionRecord

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

Example 8 with JobExecutionRecord

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;
}
Also used : Job(com.hazelcast.jet.Job) JobRepository(com.hazelcast.jet.impl.JobRepository) JobExecutionRecord(com.hazelcast.jet.impl.JobExecutionRecord) JobConfig(com.hazelcast.jet.config.JobConfig)

Aggregations

JobExecutionRecord (com.hazelcast.jet.impl.JobExecutionRecord)8 Job (com.hazelcast.jet.Job)6 JobConfig (com.hazelcast.jet.config.JobConfig)6 JobRepository (com.hazelcast.jet.impl.JobRepository)6 Test (org.junit.Test)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 NightlyTest (com.hazelcast.test.annotation.NightlyTest)2 SlowTest (com.hazelcast.test.annotation.SlowTest)2 DummyStatefulP (com.hazelcast.jet.core.TestProcessors.DummyStatefulP)1 MockP (com.hazelcast.jet.core.TestProcessors.MockP)1 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)1 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)1 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)1 MasterContext (com.hazelcast.jet.impl.MasterContext)1 Pipeline (com.hazelcast.jet.pipeline.Pipeline)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1