Search in sources :

Example 21 with JetInstance

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

the class TopologyChangeTest method when_nodeIsShuttingDownDuringInit_then_jobRestarts.

@Test
public void when_nodeIsShuttingDownDuringInit_then_jobRestarts() {
    // Given that newInstance will have a long shutdown process
    for (JetInstance instance : instances) {
        warmUpPartitions(instance.getHazelcastInstance());
    }
    dropOperationsBetween(instances[2].getHazelcastInstance(), instances[0].getHazelcastInstance(), PartitionDataSerializerHook.F_ID, singletonList(SHUTDOWN_REQUEST));
    rejectOperationsBetween(instances[0].getHazelcastInstance(), instances[2].getHazelcastInstance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(INIT_EXECUTION_OP));
    // When a job participant starts its shutdown after the job is submitted
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(TestProcessors.Identity::new, nodeCount - 1)));
    Job job = instances[0].newJob(dag);
    JetService jetService = getJetService(instances[0]);
    assertTrueEventually(() -> assertFalse(jetService.getJobCoordinationService().getMasterContexts().isEmpty()));
    spawn(instances[2]::shutdown);
    // Then, it restarts until the shutting down node is gone
    assertTrueEventually(() -> assertEquals(STARTING, job.getStatus()));
    assertTrueAllTheTime(() -> assertEquals(STARTING, job.getStatus()), 5);
    resetPacketFiltersFrom(instances[2].getHazelcastInstance());
    job.join();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JetService(com.hazelcast.jet.impl.JetService) JetInstance(com.hazelcast.jet.JetInstance) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 22 with JetInstance

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

the class AbstractDeploymentTest method testDeployment_whenJarAddedAsResource_thenClassesAvailableOnClassLoader.

@Test
public void testDeployment_whenJarAddedAsResource_thenClassesAvailableOnClassLoader() throws Throwable {
    createCluster();
    DAG dag = new DAG();
    dag.newVertex("load class", new LoadPersonIsolatedMetaSupplier());
    JetInstance jetInstance = getJetInstance();
    JobConfig jobConfig = new JobConfig();
    jobConfig.addJar(this.getClass().getResource("/deployment/sample-pojo-1.0-person.jar"));
    executeAndPeel(jetInstance.newJob(dag, jobConfig));
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) LoadPersonIsolatedMetaSupplier(com.hazelcast.jet.impl.deployment.LoadPersonIsolated.LoadPersonIsolatedMetaSupplier) DAG(com.hazelcast.jet.core.DAG) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 23 with JetInstance

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

the class CancellationTest method when_jobCancelledFromClient_then_jobStatusIsSetEventually.

@Test
public void when_jobCancelledFromClient_then_jobStatusIsSetEventually() {
    // Given
    newInstance();
    newInstance();
    JetInstance client = createJetClient();
    DAG dag = new DAG();
    dag.newVertex("slow", StuckSource::new);
    Job job = client.newJob(dag);
    assertExecutionStarted();
    // When
    job.cancel();
    // Then
    assertTrueEventually(() -> assertEquals(JobStatus.COMPLETED, job.getStatus()), 3);
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Example 24 with JetInstance

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

the class CancellationTest method when_jobFailsOnOnInitiatorNode_then_cancelledOnOtherNodes.

@Test
public void when_jobFailsOnOnInitiatorNode_then_cancelledOnOtherNodes() throws Throwable {
    // Given
    JetInstance instance = newInstance();
    newInstance();
    RuntimeException fault = new RuntimeException("fault");
    DAG dag = new DAG();
    SingleNodeFaultSupplier supplier = new SingleNodeFaultSupplier(getAddress(instance.getHazelcastInstance()), fault);
    dag.newVertex("faulty", supplier).localParallelism(4);
    Job job = instance.newJob(dag);
    assertExecutionStarted();
    // Then
    FaultyProcessor.failNow = true;
    assertExecutionTerminated();
    expectedException.expect(fault.getClass());
    expectedException.expectMessage(fault.getMessage());
    try {
        job.join();
    } catch (Exception e) {
        throw peel(e);
    }
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) Job(com.hazelcast.jet.Job) CancellationException(java.util.concurrent.CancellationException) UnknownHostException(java.net.UnknownHostException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 25 with JetInstance

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

the class CancellationTest method when_shutdown_then_jobFuturesCanceled.

@Test
public void when_shutdown_then_jobFuturesCanceled() throws Exception {
    JetInstance jet = newInstance();
    DAG dag = new DAG();
    dag.newVertex("blocking", BlockingProcessor::new).localParallelism(1);
    jet.newJob(dag);
    assertTrueEventually(() -> assertTrue(BlockingProcessor.hasStarted), 3);
    jet.shutdown();
    assertBlockingProcessorEventuallyNotRunning();
}
Also used : JetInstance(com.hazelcast.jet.JetInstance) 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