use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_processorCompletesSuccessfully_then_closeCalledImmediately.
@Test
public void when_processorCompletesSuccessfully_then_closeCalledImmediately() {
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", MockP::new);
Vertex v2 = dag.newVertex("v2", () -> new NoOutputSourceP());
dag.edge(between(v1, v2));
Job job = newJob(dag);
assertTrueEventually(this::assertPClosedWithoutError);
NoOutputSourceP.proceedLatch.countDown();
job.join();
assertJobSucceeded(job);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class Job_SeparateClusterTest method when_joinFromClientSentToNonMaster_then_futureShouldNotBeCompletedEarly.
@Test
public void when_joinFromClientSentToNonMaster_then_futureShouldNotBeCompletedEarly() throws InterruptedException {
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
int timeoutSecs = 1;
Address address = getAddress(instance2);
ClientConfig config = new ClientConfig().setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), Integer.toString(timeoutSecs)).setNetworkConfig(new ClientNetworkConfig().setSmartRouting(false).addAddress(address.getHost() + ":" + address.getPort()));
HazelcastInstance client = createHazelcastClient(config);
// join request is sent along with job submission
Job job = client.getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
// wait for join invocation to timeout
Thread.sleep(TimeUnit.SECONDS.toMillis(timeoutSecs));
// When
NoOutputSourceP.initCount.set(0);
instance1.getLifecycleService().terminate();
// wait for job to be restarted on remaining node
assertTrueEventually(() -> assertEquals(LOCAL_PARALLELISM, NoOutputSourceP.initCount.get()));
RuntimeException ex = new RuntimeException("Faulty job");
NoOutputSourceP.failure.set(ex);
// Then
expectedException.expectMessage(Matchers.containsString(ex.getMessage()));
job.join();
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class Job_SeparateClusterTest method when_suspendedJobScannedOnNewMaster_then_newJobWithEqualNameFails.
@Test
public void when_suspendedJobScannedOnNewMaster_then_newJobWithEqualNameFails() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
JobConfig config = new JobConfig().setName("job1");
// When
Job job1 = instance1.getJet().newJob(dag, config);
assertJobStatusEventually(job1, RUNNING);
job1.suspend();
assertJobStatusEventually(job1, SUSPENDED);
// gracefully shutdown the master
instance1.shutdown();
// Then
expectedException.expect(JobAlreadyExistsException.class);
instance2.getJet().newJob(dag, config);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class ClusterStateChangeTest method before.
@Before
public void before() {
TestProcessors.reset(TOTAL_PARALLELISM);
Config config = smallInstanceConfig();
config.getJetConfig().setCooperativeThreadCount(LOCAL_PARALLELISM);
members = createHazelcastInstances(config, NODE_COUNT);
assertTrueEventually(() -> {
for (HazelcastInstance instance : members) {
assertClusterSizeEventually(NODE_COUNT, instance);
}
});
for (HazelcastInstance member : members) {
if (!getNodeEngineImpl(member).getClusterService().isMaster()) {
hz = member;
break;
}
}
cluster = hz.getCluster();
dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(NoOutputSourceP::new, NODE_COUNT))));
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method stressTest_parallelNamedJobSubmission.
private void stressTest_parallelNamedJobSubmission(HazelcastInstance instance) throws Exception {
final int nThreads = 5;
ExecutorService executor = Executors.newFixedThreadPool(nThreads);
String randomPrefix = randomName();
try {
for (int round = 0; round < 10; round++) {
DAG dag = new DAG().vertex(new Vertex("test" + round, new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
System.out.println("Starting round " + round);
JobConfig config = new JobConfig().setName(randomPrefix + round);
List<Future<Job>> futures = new ArrayList<>();
for (int i = 0; i < nThreads; i++) {
futures.add(executor.submit(() -> instance.getJet().newJobIfAbsent(dag, config)));
}
for (int i = 1; i < nThreads; i++) {
assertEquals(futures.get(0).get().getId(), futures.get(i).get().getId());
}
}
} finally {
executor.shutdownNow();
assertTrue(executor.awaitTermination(1, MINUTES));
}
}
Aggregations