use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class CancellationTest method when_jobCancelledOnSingleNode_then_terminatedEventually.
@Test
public void when_jobCancelledOnSingleNode_then_terminatedEventually() {
// Given
JetInstance instance = newInstance();
DAG dag = new DAG();
dag.newVertex("slow", StuckSource::new);
Job job = instance.newJob(dag);
assertExecutionStarted();
// When
job.cancel();
// Then
assertExecutionTerminated();
expectedException.expect(CancellationException.class);
job.join();
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class CancellationTest method when_jobCancelled_then_jobStatusIsSetDuringCancellation.
@Test
public void when_jobCancelled_then_jobStatusIsSetDuringCancellation() {
// Given
JetInstance instance1 = newInstance();
JetInstance instance2 = newInstance();
rejectOperationsBetween(instance1.getHazelcastInstance(), instance2.getHazelcastInstance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.COMPLETE_EXECUTION_OP));
DAG dag = new DAG();
dag.newVertex("slow", StuckSource::new);
Job job = instance1.newJob(dag);
assertExecutionStarted();
// When
job.cancel();
// Then
assertTrueEventually(() -> assertEquals(JobStatus.COMPLETING, job.getStatus()), 3);
resetPacketFiltersFrom(instance1.getHazelcastInstance());
assertTrueEventually(() -> assertEquals(JobStatus.COMPLETED, job.getStatus()), 3);
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class CancellationTest method when_jobCanceled_then_jobFutureCanceled.
@Test
public void when_jobCanceled_then_jobFutureCanceled() {
JetInstance jet = newInstance();
DAG dag = new DAG();
dag.newVertex("blocking", BlockingProcessor::new).localParallelism(1);
Job job = jet.newJob(dag);
assertTrueEventually(() -> assertTrue(BlockingProcessor.hasStarted), 3);
job.cancel();
assertBlockingProcessorEventuallyNotRunning();
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class CancellationTest method when_jobCancelledFromClient_then_terminatedEventually.
@Test
public void when_jobCancelledFromClient_then_terminatedEventually() {
// 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
assertExecutionTerminated();
expectedException.expect(CancellationException.class);
job.join();
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class SplitBrainTest method when_jobIsSubmittedToMinoritySide_then_jobIsCancelledDuringMerge.
@Test
public void when_jobIsSubmittedToMinoritySide_then_jobIsCancelledDuringMerge() {
int firstSubClusterSize = 3;
int secondSubClusterSize = 2;
int clusterSize = firstSubClusterSize + secondSubClusterSize;
StuckProcessor.executionStarted = new CountDownLatch(secondSubClusterSize * PARALLELISM);
Job[] jobRef = new Job[1];
BiConsumer<JetInstance[], JetInstance[]> onSplit = (firstSubCluster, secondSubCluster) -> {
MockPS processorSupplier = new MockPS(StuckProcessor::new, clusterSize);
DAG dag = new DAG().vertex(new Vertex("test", processorSupplier));
jobRef[0] = secondSubCluster[1].newJob(dag, new JobConfig().setSplitBrainProtection(true));
assertOpenEventually(StuckProcessor.executionStarted);
};
Consumer<JetInstance[]> afterMerge = instances -> {
assertEquals(secondSubClusterSize, MockPS.receivedCloseErrors.size());
MockPS.receivedCloseErrors.forEach(t -> assertTrue(t instanceof TopologyChangedException));
try {
jobRef[0].getFuture().get(30, TimeUnit.SECONDS);
fail();
} catch (CancellationException ignored) {
} catch (Exception e) {
throw new AssertionError(e);
}
};
testSplitBrain(firstSubClusterSize, secondSubClusterSize, null, onSplit, afterMerge);
}
Aggregations