Search in sources :

Example 96 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast by hazelcast.

the class JetClassLoaderTest method when_processorSupplierCalled_then_contextClassLoaderSet.

@Test
public void when_processorSupplierCalled_then_contextClassLoaderSet() {
    DAG dag = new DAG();
    dag.newVertex("v", new LeakClassLoaderPS()).localParallelism(1);
    Config config = smallInstanceWithResourceUploadConfig();
    HazelcastInstance instance = createHazelcastInstance(config);
    // When
    instance.getJet().newJob(dag).join();
    assertClassLoaders(LeakClassLoaderPS.classLoaders);
    assertThat(LeakClassLoaderPS.classLoaders).containsKeys("init", "get", "close");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) JobConfig(com.hazelcast.jet.config.JobConfig) DAG(com.hazelcast.jet.core.DAG) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 97 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast by hazelcast.

the class OrderedBatchParallelismTest method applyTransformAndGetDag.

private DAG applyTransformAndGetDag(FunctionEx<BatchStage<Long>, BatchStage<Long>> transform) {
    PipelineImpl p = (PipelineImpl) Pipeline.create().setPreserveOrder(true);
    BatchStage<Long> source = p.readFrom(TestSources.items(1L)).setLocalParallelism(UPSTREAM_PARALLELISM);
    BatchStage<Long> applied = source.apply(transform);
    applied.mapStateful(LongAccumulator::new, (s, x) -> x).writeTo(Sinks.noop());
    return p.toDag(PIPELINE_CTX);
}
Also used : PipelineImpl(com.hazelcast.jet.impl.pipeline.PipelineImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) AggregateOperations.counting(com.hazelcast.jet.aggregate.AggregateOperations.counting) Arrays(java.util.Arrays) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) Processors(com.hazelcast.jet.core.processor.Processors) HazelcastSerialParametersRunnerFactory(com.hazelcast.test.HazelcastSerialParametersRunnerFactory) DAG(com.hazelcast.jet.core.DAG) UseParametersRunnerFactory(org.junit.runners.Parameterized.UseParametersRunnerFactory) FunctionEx(com.hazelcast.function.FunctionEx) HazelcastParametrizedRunner(com.hazelcast.test.HazelcastParametrizedRunner) Parameter(org.junit.runners.Parameterized.Parameter) Collection(java.util.Collection) Test(org.junit.Test) Traversers(com.hazelcast.jet.Traversers) Category(org.junit.experimental.categories.Category) Vertex(com.hazelcast.jet.core.Vertex) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Functions.wholeItem(com.hazelcast.function.Functions.wholeItem) Context(com.hazelcast.jet.impl.pipeline.PipelineImpl.Context) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) PipelineImpl(com.hazelcast.jet.impl.pipeline.PipelineImpl)

Example 98 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast by hazelcast.

the class JobMetrics_NonSharedClusterTest method when_metricsCollectionOff_then_emptyMetrics.

@Test
public void when_metricsCollectionOff_then_emptyMetrics() {
    Config config = smallInstanceConfig();
    config.getMetricsConfig().setEnabled(false);
    HazelcastInstance inst = createHazelcastInstance(config);
    DAG dag = new DAG();
    dag.newVertex("v1", (SupplierEx<Processor>) NoOutputSourceP::new).localParallelism(1);
    Job job = inst.getJet().newJob(dag, JOB_CONFIG_WITH_METRICS);
    assertTrue(job.getMetrics().metrics().isEmpty());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) SupplierEx(com.hazelcast.function.SupplierEx) DAG(com.hazelcast.jet.core.DAG) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 99 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast by hazelcast.

the class JobMetrics_StressTest method stressTest.

private void stressTest(Function<Job, Runnable> restart) throws Throwable {
    DAG dag = buildDag();
    Job job = instance.getJet().newJob(dag, JOB_CONFIG_WITH_METRICS);
    try {
        assertTrueEventually(() -> assertEquals(JobStatus.RUNNING, job.getStatus()));
        ObtainMetricsThread obtainMetrics = new ObtainMetricsThread(job);
        Thread restartThread = new Thread(restart.apply(job));
        Thread obtainThread = new Thread(obtainMetrics);
        restartThread.start();
        obtainThread.start();
        restartThread.join();
        obtainMetrics.stop = true;
        obtainThread.join();
        if (restartThreadException != null) {
            throw restartThreadException;
        }
        if (obtainMetricsThreadException != null) {
            throw obtainMetricsThreadException;
        }
    } finally {
        ditchJob(job, instance);
    }
}
Also used : DAG(com.hazelcast.jet.core.DAG) Job(com.hazelcast.jet.Job)

Example 100 with DAG

use of com.hazelcast.jet.core.DAG in project hazelcast by hazelcast.

the class JobMetrics_StressTest method buildDag.

private DAG buildDag() {
    DAG dag = new DAG();
    dag.newVertex("p", (SupplierEx<Processor>) IncrementingProcessor::new);
    return dag;
}
Also used : AbstractProcessor(com.hazelcast.jet.core.AbstractProcessor) Processor(com.hazelcast.jet.core.Processor) DAG(com.hazelcast.jet.core.DAG)

Aggregations

DAG (com.hazelcast.jet.core.DAG)211 Test (org.junit.Test)159 Vertex (com.hazelcast.jet.core.Vertex)127 QuickTest (com.hazelcast.test.annotation.QuickTest)100 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)91 Job (com.hazelcast.jet.Job)64 Entry (java.util.Map.Entry)51 List (java.util.List)38 Assert.assertEquals (org.junit.Assert.assertEquals)37 Map (java.util.Map)36 JobConfig (com.hazelcast.jet.config.JobConfig)35 Assert.assertTrue (org.junit.Assert.assertTrue)31 Edge (com.hazelcast.jet.core.Edge)29 IntStream (java.util.stream.IntStream)29 Category (org.junit.experimental.categories.Category)28 Collectors.toList (java.util.stream.Collectors.toList)26 HazelcastInstance (com.hazelcast.core.HazelcastInstance)23 FunctionEx (com.hazelcast.function.FunctionEx)23 ArrayList (java.util.ArrayList)22 Nonnull (javax.annotation.Nonnull)21