Search in sources :

Example 6 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class DecoratorTest method mapDecorator.

@Test
public void mapDecorator() throws Exception {
    JetInstance instance = Mockito.mock(JetInstance.class);
    assertDecorator(IMap.class, IMapJet.class, m -> new IMapDecorator<>(m, instance));
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) Test(org.junit.Test)

Example 7 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class JetSplitBrainTestSupport method applyOnBrains.

private void applyOnBrains(JetInstance[] instances, int firstSubClusterSize, BiConsumer<HazelcastInstance, HazelcastInstance> action) {
    for (int i = 0; i < firstSubClusterSize; i++) {
        JetInstance isolatedInstance = instances[i];
        // do not take into account instances which have been shutdown
        if (!isInstanceActive(isolatedInstance)) {
            continue;
        }
        for (int j = firstSubClusterSize; j < instances.length; j++) {
            JetInstance currentInstance = instances[j];
            if (!isInstanceActive(currentInstance)) {
                continue;
            }
            action.accept(isolatedInstance.getHazelcastInstance(), currentInstance.getHazelcastInstance());
        }
    }
}
Also used : JetInstance(com.hazelcast.jet.JetInstance)

Example 8 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class JetSplitBrainTestSupport method assertSplitBrainCreated.

private void assertSplitBrainCreated(JetInstance[] instances, int firstSubClusterSize, int secondSubClusterSize) {
    for (int isolatedIndex = 0; isolatedIndex < firstSubClusterSize; isolatedIndex++) {
        JetInstance isolatedInstance = instances[isolatedIndex];
        assertClusterSizeEventually(firstSubClusterSize, isolatedInstance.getHazelcastInstance());
    }
    for (int i = firstSubClusterSize; i < instances.length; i++) {
        JetInstance currentInstance = instances[i];
        assertClusterSizeEventually(secondSubClusterSize, currentInstance.getHazelcastInstance());
    }
}
Also used : JetInstance(com.hazelcast.jet.JetInstance)

Example 9 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class JobTest method when_jobIsCompleted_then_trackedJobCanQueryJobResultFromClient.

@Test
public void when_jobIsCompleted_then_trackedJobCanQueryJobResultFromClient() throws InterruptedException {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, NODE_COUNT)));
    // When
    instance1.newJob(dag);
    StuckProcessor.executionStarted.await();
    JetInstance client = createJetClient();
    Collection<Job> trackedJobs = client.getJobs();
    assertEquals(1, trackedJobs.size());
    Job trackedJob = trackedJobs.iterator().next();
    StuckProcessor.proceedLatch.countDown();
    // Then
    trackedJob.join();
    assertEquals(COMPLETED, trackedJob.getStatus());
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JetInstance(com.hazelcast.jet.JetInstance) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 10 with JetInstance

use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.

the class ManualRestartTest method when_jobIsNotBeingExecuted_then_itCannotBeRestarted.

@Test
public void when_jobIsNotBeingExecuted_then_itCannotBeRestarted() {
    // Given that the job execution has not started
    rejectOperationsBetween(instances[0].getHazelcastInstance(), instances[1].getHazelcastInstance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.INIT_EXECUTION_OP));
    JetInstance client = createJetClient();
    Job job = client.newJob(dag);
    assertTrueEventually(() -> assertTrue(job.getStatus() == JobStatus.STARTING));
    // Then, the job cannot restart
    assertFalse(job.restart());
    resetPacketFiltersFrom(instances[0].getHazelcastInstance());
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Aggregations

JetInstance (com.hazelcast.jet.JetInstance)84 Test (org.junit.Test)45 Job (com.hazelcast.jet.Job)32 JetConfig (com.hazelcast.jet.config.JetConfig)22 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)14 Pipeline (com.hazelcast.jet.pipeline.Pipeline)14 JobConfig (com.hazelcast.jet.config.JobConfig)13 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)12 DAG (com.hazelcast.jet.core.DAG)10 ExpectedException (org.junit.rules.ExpectedException)10 Jet (com.hazelcast.jet.Jet)9 Assert.assertEquals (org.junit.Assert.assertEquals)9 JetService (com.hazelcast.jet.impl.JetService)8 Map (java.util.Map)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 JobRepository (com.hazelcast.jet.impl.JobRepository)7 Sources (com.hazelcast.jet.pipeline.Sources)7 CancellationException (java.util.concurrent.CancellationException)7 Assert.assertNotNull (org.junit.Assert.assertNotNull)7 Before (org.junit.Before)7