use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class SplitBrainTest method when_splitBrainProtectionIsDisabled_then_jobCompletesOnBothSides.
@Test
public void when_splitBrainProtectionIsDisabled_then_jobCompletesOnBothSides() {
int firstSubClusterSize = 2;
int secondSubClusterSize = 2;
int clusterSize = firstSubClusterSize + secondSubClusterSize;
StuckProcessor.executionStarted = new CountDownLatch(clusterSize * PARALLELISM);
Job[] jobRef = new Job[1];
Consumer<JetInstance[]> beforeSplit = instances -> {
MockPS processorSupplier = new MockPS(StuckProcessor::new, clusterSize);
DAG dag = new DAG().vertex(new Vertex("test", processorSupplier));
jobRef[0] = instances[0].newJob(dag);
assertOpenEventually(StuckProcessor.executionStarted);
};
BiConsumer<JetInstance[], JetInstance[]> onSplit = (firstSubCluster, secondSubCluster) -> {
StuckProcessor.proceedLatch.countDown();
long jobId = jobRef[0].getId();
assertTrueEventually(() -> {
JetService service1 = getJetService(firstSubCluster[0]);
JetService service2 = getJetService(secondSubCluster[0]);
assertEquals(COMPLETED, service1.getJobCoordinationService().getJobStatus(jobId));
assertEquals(COMPLETED, service2.getJobCoordinationService().getJobStatus(jobId));
});
};
Consumer<JetInstance[]> afterMerge = instances -> {
assertTrueEventually(() -> {
assertEquals(clusterSize * 2, MockPS.initCount.get());
assertEquals(clusterSize * 2, MockPS.closeCount.get());
});
assertEquals(clusterSize, MockPS.receivedCloseErrors.size());
MockPS.receivedCloseErrors.forEach(t -> assertTrue(t instanceof TopologyChangedException));
};
testSplitBrain(firstSubClusterSize, secondSubClusterSize, beforeSplit, onSplit, afterMerge);
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class TopologyChangeDuringJobSubmissionTest method when_coordinatorLeavesDuringSubmission_then_submissionCallReturnsSuccessfully.
@Test
public void when_coordinatorLeavesDuringSubmission_then_submissionCallReturnsSuccessfully() throws Throwable {
// Given that the job has submitted
dropOperationsBetween(instance1.getHazelcastInstance(), instance2.getHazelcastInstance(), SpiDataSerializerHook.F_ID, singletonList(SpiDataSerializerHook.NORMAL_RESPONSE));
Future<Job> future = spawn(() -> {
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, 1)));
return instance2.newJob(dag);
});
StuckProcessor.executionStarted.await();
// When the coordinator leaves before the submission response is received
instance1.getHazelcastInstance().getLifecycleService().terminate();
Job job = future.get();
// Then the job completes successfully
StuckProcessor.proceedLatch.countDown();
job.join();
assertEquals(2, MockPS.initCount.get());
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class TopologyChangeTest method when_addNodeDuringExecution_then_completeSuccessfully.
@Test
public void when_addNodeDuringExecution_then_completeSuccessfully() throws Throwable {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, nodeCount)));
// When
Job job = instances[0].newJob(dag);
StuckProcessor.executionStarted.await();
createJetMember();
StuckProcessor.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.StuckProcessor in project hazelcast-jet by hazelcast.
the class TopologyChangeTest method when_nonCoordinatorLeavesDuringExecutionAndNoRestartConfigured_then_jobFails.
@Test
public void when_nonCoordinatorLeavesDuringExecutionAndNoRestartConfigured_then_jobFails() throws Throwable {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, nodeCount)));
JobConfig config = new JobConfig().setAutoRestartOnMemberFailure(false);
// When
Job job = instances[0].newJob(dag, config);
StuckProcessor.executionStarted.await();
instances[2].getHazelcastInstance().getLifecycleService().terminate();
StuckProcessor.proceedLatch.countDown();
Throwable ex = job.getFuture().handle((r, e) -> e).get();
assertInstanceOf(TopologyChangedException.class, ex);
}
use of com.hazelcast.jet.core.TestProcessors.StuckProcessor in project hazelcast-jet by hazelcast.
the class TopologyChangeTest method when_coordinatorLeavesDuringExecutionAndNoRestartConfigured_then_jobFails.
@Test
public void when_coordinatorLeavesDuringExecutionAndNoRestartConfigured_then_jobFails() throws Throwable {
// Given
JetInstance client = createJetClient();
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, nodeCount)));
JobConfig config = new JobConfig().setAutoRestartOnMemberFailure(false);
// When
Job job = client.newJob(dag, config);
StuckProcessor.executionStarted.await();
instances[0].getHazelcastInstance().getLifecycleService().terminate();
StuckProcessor.proceedLatch.countDown();
Throwable ex = job.getFuture().handle((r, e) -> e).get();
assertInstanceOf(TopologyChangedException.class, ex);
}
Aggregations