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();
}
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));
}
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);
}
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);
}
}
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();
}
Aggregations