use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class JobMetrics_MiscTest method when_jobMetricsDisabled_then_emptyMetrics.
@Test
public void when_jobMetricsDisabled_then_emptyMetrics() throws Throwable {
DAG dag = new DAG();
dag.newVertex("v1", MockP::new);
dag.newVertex("v2", (SupplierEx<Processor>) NoOutputSourceP::new);
// init
JobConfig config = new JobConfig().setMetricsEnabled(// enable metric collection
true).setStoreMetricsAfterJobCompletion(// disable metric saving on completion
false);
Job job = hz().getJet().newJob(dag, config);
// when
NoOutputSourceP.executionStarted.await();
assertJobStatusEventually(job, JobStatus.RUNNING);
// then
assertTrueEventually(() -> assertJobHasMetrics(job, false));
// when
NoOutputSourceP.proceedLatch.countDown();
job.join();
// then
assertJobStatusEventually(job, JobStatus.COMPLETED);
assertEmptyJobMetrics(job, false);
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class JobMetrics_MiscTest method when_jobRestarted_then_metricsRepopulate.
@Test
public void when_jobRestarted_then_metricsRepopulate() throws Throwable {
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", TestProcessors.MockP::new);
Vertex v2 = dag.newVertex("v2", (SupplierEx<Processor>) TestProcessors.NoOutputSourceP::new);
dag.edge(between(v1, v2));
Job job = hz().getJet().newJob(dag, JOB_CONFIG_WITH_METRICS);
TestProcessors.NoOutputSourceP.executionStarted.await();
assertJobStatusEventually(job, JobStatus.RUNNING);
job.restart();
assertJobStatusEventually(job, JobStatus.RUNNING);
assertTrueEventually(() -> assertJobHasMetrics(job, false));
TestProcessors.NoOutputSourceP.proceedLatch.countDown();
job.join();
assertJobStatusEventually(job, JobStatus.COMPLETED);
assertJobHasMetrics(job, true);
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class JobMetrics_MiscTest method when_jobRunning_then_nonEmptyMetrics.
@Test
public void when_jobRunning_then_nonEmptyMetrics() throws Throwable {
DAG dag = new DAG();
dag.newVertex("v1", MockP::new);
dag.newVertex("v2", (SupplierEx<Processor>) NoOutputSourceP::new);
Job job = hz().getJet().newJob(dag, JOB_CONFIG_WITH_METRICS);
// when
NoOutputSourceP.executionStarted.await();
assertJobStatusEventually(job, JobStatus.RUNNING);
// then
assertTrueEventually(() -> assertJobHasMetrics(job, false));
// when
NoOutputSourceP.proceedLatch.countDown();
job.join();
// then
assertJobStatusEventually(job, JobStatus.COMPLETED);
assertJobHasMetrics(job, true);
assertTrue(hz().getMap(JobRepository.JOB_METRICS_MAP_NAME).containsKey(job.getId()));
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class TestSupportTest method test_processorSupplierHasJetInstance.
@Test
public void test_processorSupplierHasJetInstance() {
HazelcastInstance hazelcastInstance = mockHazelcastInstance();
boolean[] called = { false };
verifyProcessor(new ProcessorSupplier() {
@Override
public void init(@Nonnull Context context) {
assertSame(context.hazelcastInstance(), hazelcastInstance);
called[0] = true;
}
@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
assertEquals(1, count);
return singletonList(new MockP());
}
}).hazelcastInstance(hazelcastInstance).expectOutput(emptyList());
assertTrue(called[0]);
}
use of com.hazelcast.jet.core.Processor in project hazelcast by hazelcast.
the class AsyncTransformUsingServicePTest method test_wmNotCountedToParallelOps.
@Test
public void test_wmNotCountedToParallelOps() throws Exception {
Processor processor = getSupplier(2, (ctx, item) -> new CompletableFuture<>()).get(1).iterator().next();
processor.init(new TestOutbox(128), new TestProcessorContext());
TestInbox inbox = new TestInbox();
inbox.add("foo");
processor.process(0, inbox);
assertTrue("inbox not empty", inbox.isEmpty());
assertTrue("wm rejected", processor.tryProcessWatermark(wm(0)));
inbox.add("bar");
processor.process(0, inbox);
assertTrue("2nd item rejected even though max parallel ops is 1", inbox.isEmpty());
}
Aggregations