use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class SplitBrainTest method when_minorityMasterBecomesMajorityMaster_then_jobKeepsRunning.
@Test
public void when_minorityMasterBecomesMajorityMaster_then_jobKeepsRunning() {
int firstSubClusterSize = 2;
int secondSubClusterSize = 1;
int clusterSize = firstSubClusterSize + secondSubClusterSize;
NoOutputSourceP.executionStarted = new CountDownLatch(secondSubClusterSize * PARALLELISM);
Job[] jobRef = new Job[1];
Consumer<HazelcastInstance[]> beforeSplit = instances -> {
MockPS processorSupplier = new MockPS(NoOutputSourceP::new, clusterSize);
DAG dag = new DAG().vertex(new Vertex("test", processorSupplier));
jobRef[0] = instances[2].getJet().newJob(dag);
assertOpenEventually(NoOutputSourceP.executionStarted);
};
Consumer<HazelcastInstance[]> afterMerge = instances -> {
assertEquals(clusterSize, instances.length);
logger.info("Shutting down 1st instance");
instances[0].shutdown();
logger.info("1st instance down, starting another instance");
createHazelcastInstance(createConfig());
logger.info("Shutting down 2nd instance");
instances[1].shutdown();
assertTrue(((ClusterService) instances[2].getCluster()).isMaster());
assertJobStatusEventually(jobRef[0], RUNNING, 10);
assertTrueAllTheTime(() -> assertEquals(RUNNING, jobRef[0].getStatus()), 5);
};
testSplitBrain(firstSubClusterSize, secondSubClusterSize, beforeSplit, null, afterMerge);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class OperationLossTest method when_terminateExecutionOperationLost_then_jobTerminates.
@Test
public void when_terminateExecutionOperationLost_then_jobTerminates() {
PacketFiltersUtil.dropOperationsFrom(instance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.TERMINATE_EXECUTION_OP));
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", () -> new NoOutputSourceP()).localParallelism(1);
Vertex v2 = dag.newVertex("v2", mapP(identity())).localParallelism(1);
dag.edge(between(v1, v2).distributed());
Job job = instance().getJet().newJob(dag);
assertJobStatusEventually(job, RUNNING);
job.cancel();
// sleep so that the TerminateExecutionOperation is sent out, but lost
sleepSeconds(1);
// reset filters so that the situation can resolve
PacketFiltersUtil.resetPacketFiltersFrom(instance());
try {
// Then
job.join();
} catch (CancellationException ignored) {
}
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class OperationLossTest method when_connectionDroppedWithoutMemberLeaving_then_jobRestarts.
private void when_connectionDroppedWithoutMemberLeaving_then_jobRestarts(boolean useLightJob) {
DAG dag = new DAG();
Vertex source = dag.newVertex("source", () -> new NoOutputSourceP()).localParallelism(1);
Vertex sink = dag.newVertex("sink", DiagnosticProcessors.writeLoggerP());
dag.edge(between(source, sink).distributed());
Job job = useLightJob ? instance().getJet().newLightJob(dag) : instance().getJet().newJob(dag);
assertTrueEventually(() -> assertEquals(2, NoOutputSourceP.initCount.get()));
Connection connection = ImdgUtil.getMemberConnection(getNodeEngineImpl(instance()), getAddress(instances()[1]));
// When
connection.close(null, null);
System.out.println("connection closed");
sleepSeconds(1);
// Then
NoOutputSourceP.proceedLatch.countDown();
if (useLightJob) {
assertThatThrownBy(job::join).hasMessageContaining("The member was reconnected");
} else {
job.join();
assertEquals(4, NoOutputSourceP.initCount.get());
}
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class SuspendExecutionOnFailureTest method when_jobSuspendedByUser_then_suspensionCauseSaysSo.
@Test
public void when_jobSuspendedByUser_then_suspensionCauseSaysSo() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, MEMBER_COUNT)));
// When
Job job = hz().getJet().newJob(dag, jobConfig);
assertJobStatusEventually(job, RUNNING);
job.suspend();
assertJobStatusEventually(job, SUSPENDED);
assertThat(job.getSuspensionCause()).matches(JobSuspensionCause::requestedByUser);
assertThat(job.getSuspensionCause().description()).isEqualTo("Requested by user");
assertThatThrownBy(job.getSuspensionCause()::errorCause).isInstanceOf(IllegalStateException.class).hasMessage("Suspension not caused by an error");
cancelAndJoin(job);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class TopologyChangeDuringJobSubmissionTest method when_jobIsCompletedBeforeSubmissionCallReturns_then_jobRunsOnlyOnce.
@Test
public void when_jobIsCompletedBeforeSubmissionCallReturns_then_jobRunsOnlyOnce() throws Throwable {
// Given that the job is already completed
String jobName = "job1";
Future<Job> future = spawn(() -> {
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, 1)));
return instance2.getJet().newJob(dag, new JobConfig().setName(jobName));
});
NoOutputSourceP.executionStarted.await();
dropOperationsBetween(instance1, instance2, SpiDataSerializerHook.F_ID, singletonList(SpiDataSerializerHook.NORMAL_RESPONSE));
Job submittedJob = instance1.getJet().getJob(jobName);
assertNotNull(submittedJob);
NoOutputSourceP.proceedLatch.countDown();
submittedJob.join();
// When the coordinator leaves before the submission response is received
instance1.getLifecycleService().terminate();
Job job = future.get();
// Then the job does not run for the second time
job.join();
assertEquals(1, MockPS.initCount.get());
}
Aggregations