use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class TopologyChangeTest method when_nonCoordinatorLeavesDuringExecution_then_jobRestarts.
@Test
public void when_nonCoordinatorLeavesDuringExecution_then_jobRestarts() throws Throwable {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
// When
Job job = instances[0].getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
instances[2].getLifecycleService().terminate();
NoOutputSourceP.proceedLatch.countDown();
job.join();
// upon non-coordinator member leave, remaining members restart and complete the job
final int count = nodeCount * 2 - 1;
assertEquals(count, MockPS.initCount.get());
assertTrueEventually(() -> {
assertEquals(count, MockPS.closeCount.get());
assertEquals(nodeCount, MockPS.receivedCloseErrors.size());
for (int i = 0; i < MockPS.receivedCloseErrors.size(); i++) {
Throwable error = MockPS.receivedCloseErrors.get(i);
assertTrue(error instanceof CancellationException);
}
});
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class TopologyChangeTest method when_coordinatorLeavesDuringExecution_then_nonCoordinatorJobSubmitterStillGetsJobResult.
@Test
public void when_coordinatorLeavesDuringExecution_then_nonCoordinatorJobSubmitterStillGetsJobResult() throws Throwable {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
// When
Job job = instances[1].getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
instances[0].getLifecycleService().terminate();
NoOutputSourceP.proceedLatch.countDown();
// Then
job.join();
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class TopologyChangeTest method when_coordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends.
private void when_coordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends(boolean snapshotted) throws Throwable {
// Given
HazelcastInstance client = createHazelcastClient();
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
JobConfig config = new JobConfig();
config.setAutoScaling(false);
config.setProcessingGuarantee(snapshotted ? EXACTLY_ONCE : NONE);
// When
Job job = client.getJet().newJob(dag, config);
NoOutputSourceP.executionStarted.await();
instances[0].getLifecycleService().terminate();
NoOutputSourceP.proceedLatch.countDown();
assertTrueEventually(() -> {
JobStatus status = null;
while (status == null) {
try {
status = job.getStatus();
} catch (TargetNotMemberException ignored) {
}
}
assertEquals(snapshotted ? SUSPENDED : FAILED, status);
}, 10);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class TopologyChangeTest method when_addAndRemoveNodeDuringExecution_then_completeSuccessfully.
@Test
public void when_addAndRemoveNodeDuringExecution_then_completeSuccessfully() throws Throwable {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
// When
Job job = instances[0].getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
HazelcastInstance instance = createHazelcastInstance(config);
instance.shutdown();
NoOutputSourceP.proceedLatch.countDown();
job.join();
// Then
assertEquals(nodeCount, MockPS.initCount.get());
assertTrueEventually(() -> {
assertEquals(nodeCount, MockPS.closeCount.get());
assertThat(MockPS.receivedCloseErrors, empty());
});
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class TopologyChangeTest method when_nonCoordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends.
private void when_nonCoordinatorLeaves_AutoScalingOff_then_jobFailsOrSuspends(boolean snapshotted) throws Throwable {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
JobConfig config = new JobConfig();
config.setAutoScaling(false);
config.setProcessingGuarantee(snapshotted ? EXACTLY_ONCE : NONE);
// When
Job job = instances[0].getJet().newJob(dag, config);
NoOutputSourceP.executionStarted.await();
instances[2].getLifecycleService().terminate();
NoOutputSourceP.proceedLatch.countDown();
assertJobStatusEventually(job, snapshotted ? SUSPENDED : FAILED, 10);
if (!snapshotted) {
try {
job.join();
fail("join didn't fail");
} catch (Exception e) {
assertContains(e.getMessage(), TopologyChangedException.class.getName());
assertContains(e.getMessage(), "[127.0.0.1]:5703=" + MemberLeftException.class.getName());
}
}
}
Aggregations