Search in sources :

Example 6 with EdgeConfig

use of com.hazelcast.jet.config.EdgeConfig in project hazelcast by hazelcast.

the class DotTest method when_dagToDotString.

@Test
public void when_dagToDotString() {
    DAG dag = new DAG();
    Vertex a = dag.newVertex("a", noopP()).localParallelism(1);
    Vertex b = dag.newVertex("b", noopP());
    Vertex c = dag.newVertex("c", noopP()).localParallelism(1);
    Vertex d = dag.newVertex("d", noopP()).localParallelism(1);
    dag.edge(from(a, 0).to(c, 0).partitioned(wholeItem()).setConfig(new EdgeConfig().setQueueSize(128)));
    dag.edge(from(a, 1).to(b, 0).broadcast().distributed());
    String actual = dag.toDotString();
    System.out.println(actual);
    // contains multiple subgraphs, order isn't stable, we'll assert individual lines and the length
    assertTrue(actual.startsWith("digraph DAG {"));
    assertTrue(actual.contains("\"a\" [localParallelism=1];"));
    assertTrue(actual.contains("\"b\" [localParallelism=default];"));
    assertTrue(actual.contains("\"c\" [localParallelism=1];"));
    assertTrue(actual.contains("\"d\" [localParallelism=1];"));
    assertTrue(actual.contains("\"a\" -> \"c\" [label=\"partitioned\", taillabel=0, queueSize=128];"));
    assertTrue(actual.contains("\"a\" -> \"b\" [label=\"distributed-broadcast\", taillabel=1, queueSize=1024]"));
    assertTrue(actual.endsWith("\n}"));
}
Also used : EdgeConfig(com.hazelcast.jet.config.EdgeConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with EdgeConfig

use of com.hazelcast.jet.config.EdgeConfig in project hazelcast by hazelcast.

the class DotTest method when_dagToDotStringNonDefaults.

@Test
public void when_dagToDotStringNonDefaults() {
    DAG dag = new DAG();
    Vertex a = dag.newVertex("a", noopP()).localParallelism(1);
    Vertex b = dag.newVertex("b", noopP());
    Vertex c = dag.newVertex("c", noopP()).localParallelism(1);
    Vertex d = dag.newVertex("d", noopP()).localParallelism(1);
    dag.edge(from(a, 0).to(c, 0).partitioned(wholeItem()).setConfig(new EdgeConfig().setQueueSize(128)));
    dag.edge(from(a, 1).to(b, 0).broadcast().distributed());
    String actual = dag.toDotString(16, 16384);
    System.out.println(actual);
    // contains multiple subgraphs, order isn't stable, we'll assert individual lines and the length
    assertTrue(actual.startsWith("digraph DAG {"));
    assertTrue(actual.contains("\"a\" [localParallelism=1];"));
    assertTrue(actual.contains("\"b\" [localParallelism=16];"));
    assertTrue(actual.contains("\"c\" [localParallelism=1];"));
    assertTrue(actual.contains("\"d\" [localParallelism=1];"));
    assertTrue(actual.contains("\"a\" -> \"c\" [label=\"partitioned\", taillabel=0, queueSize=128];"));
    assertTrue(actual.contains("\"a\" -> \"b\" [label=\"distributed-broadcast\", taillabel=1, queueSize=16384]"));
    assertTrue(actual.endsWith("\n}"));
}
Also used : EdgeConfig(com.hazelcast.jet.config.EdgeConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with EdgeConfig

use of com.hazelcast.jet.config.EdgeConfig in project hazelcast by hazelcast.

the class ExecutionPlanBuilder method createExecutionPlans.

@SuppressWarnings("checkstyle:ParameterNumber")
public static Map<MemberInfo, ExecutionPlan> createExecutionPlans(NodeEngineImpl nodeEngine, List<MemberInfo> memberInfos, DAG dag, long jobId, long executionId, JobConfig jobConfig, long lastSnapshotId, boolean isLightJob, Subject subject) {
    final int defaultParallelism = nodeEngine.getConfig().getJetConfig().getCooperativeThreadCount();
    final Map<MemberInfo, int[]> partitionsByMember = getPartitionAssignment(nodeEngine, memberInfos);
    final Map<Address, int[]> partitionsByAddress = partitionsByMember.entrySet().stream().collect(toMap(en -> en.getKey().getAddress(), Entry::getValue));
    final List<Address> addresses = toList(partitionsByMember.keySet(), MemberInfo::getAddress);
    final int clusterSize = partitionsByMember.size();
    final boolean isJobDistributed = clusterSize > 1;
    final EdgeConfig defaultEdgeConfig = nodeEngine.getConfig().getJetConfig().getDefaultEdgeConfig();
    final Map<MemberInfo, ExecutionPlan> plans = new HashMap<>();
    int memberIndex = 0;
    for (MemberInfo member : partitionsByMember.keySet()) {
        plans.put(member, new ExecutionPlan(partitionsByAddress, jobConfig, lastSnapshotId, memberIndex++, clusterSize, isLightJob, subject));
    }
    final Map<String, Integer> vertexIdMap = assignVertexIds(dag);
    for (Entry<String, Integer> entry : vertexIdMap.entrySet()) {
        final Vertex vertex = dag.getVertex(entry.getKey());
        assert vertex != null;
        final ProcessorMetaSupplier metaSupplier = vertex.getMetaSupplier();
        final int vertexId = entry.getValue();
        // The local parallelism determination here is effective only
        // in jobs submitted as DAG. Otherwise, in jobs submitted as
        // pipeline, we are already doing this determination while
        // converting it to DAG and there is no vertex left with LP=-1.
        final int localParallelism = vertex.determineLocalParallelism(defaultParallelism);
        final int totalParallelism = localParallelism * clusterSize;
        final List<EdgeDef> inbound = toEdgeDefs(dag.getInboundEdges(vertex.getName()), defaultEdgeConfig, e -> vertexIdMap.get(e.getSourceName()), isJobDistributed);
        final List<EdgeDef> outbound = toEdgeDefs(dag.getOutboundEdges(vertex.getName()), defaultEdgeConfig, e -> vertexIdMap.get(e.getDestName()), isJobDistributed);
        String prefix = prefix(jobConfig.getName(), jobId, vertex.getName(), "#PMS");
        ILogger logger = prefixedLogger(nodeEngine.getLogger(metaSupplier.getClass()), prefix);
        JetServiceBackend jetBackend = nodeEngine.getService(JetServiceBackend.SERVICE_NAME);
        JobClassLoaderService jobClassLoaderService = jetBackend.getJobClassLoaderService();
        ClassLoader processorClassLoader = jobClassLoaderService.getClassLoader(jobId);
        try {
            doWithClassLoader(processorClassLoader, () -> metaSupplier.init(new MetaSupplierCtx(nodeEngine, jobId, executionId, jobConfig, logger, vertex.getName(), localParallelism, totalParallelism, clusterSize, isLightJob, partitionsByAddress, subject, processorClassLoader)));
        } catch (Exception e) {
            throw sneakyThrow(e);
        }
        Function<? super Address, ? extends ProcessorSupplier> procSupplierFn = doWithClassLoader(processorClassLoader, () -> metaSupplier.get(addresses));
        for (Entry<MemberInfo, ExecutionPlan> e : plans.entrySet()) {
            final ProcessorSupplier processorSupplier = doWithClassLoader(processorClassLoader, () -> procSupplierFn.apply(e.getKey().getAddress()));
            if (!isLightJob) {
                // We avoid the check for light jobs - the user will get the error anyway, but maybe with less information.
                // And we can recommend the user to use normal job to have more checks.
                checkSerializable(processorSupplier, "ProcessorSupplier in vertex '" + vertex.getName() + '\'');
            }
            final VertexDef vertexDef = new VertexDef(vertexId, vertex.getName(), processorSupplier, localParallelism);
            vertexDef.addInboundEdges(inbound);
            vertexDef.addOutboundEdges(outbound);
            e.getValue().addVertex(vertexDef);
        }
    }
    return plans;
}
Also used : IntStream(java.util.stream.IntStream) Address(com.hazelcast.cluster.Address) EdgeConfig(com.hazelcast.jet.config.EdgeConfig) Util.checkSerializable(com.hazelcast.jet.impl.util.Util.checkSerializable) Util.doWithClassLoader(com.hazelcast.jet.impl.util.Util.doWithClassLoader) HashMap(java.util.HashMap) ExceptionUtil.sneakyThrow(com.hazelcast.jet.impl.util.ExceptionUtil.sneakyThrow) Function(java.util.function.Function) ArrayList(java.util.ArrayList) PrefixedLogger.prefixedLogger(com.hazelcast.jet.impl.util.PrefixedLogger.prefixedLogger) LinkedHashMap(java.util.LinkedHashMap) Collectors.toMap(java.util.stream.Collectors.toMap) ILogger(com.hazelcast.logging.ILogger) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Map(java.util.Map) DAG(com.hazelcast.jet.core.DAG) Edge(com.hazelcast.jet.core.Edge) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) Tuple2(com.hazelcast.jet.datamodel.Tuple2) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) PrefixedLogger.prefix(com.hazelcast.jet.impl.util.PrefixedLogger.prefix) NodeEngine(com.hazelcast.spi.impl.NodeEngine) Util.toList(com.hazelcast.jet.impl.util.Util.toList) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) IPartitionService(com.hazelcast.internal.partition.IPartitionService) JobConfig(com.hazelcast.jet.config.JobConfig) MetaSupplierCtx(com.hazelcast.jet.impl.execution.init.Contexts.MetaSupplierCtx) Collectors(java.util.stream.Collectors) Subject(javax.security.auth.Subject) Vertex(com.hazelcast.jet.core.Vertex) List(java.util.List) Tuple2.tuple2(com.hazelcast.jet.datamodel.Tuple2.tuple2) FunctionEx.identity(com.hazelcast.function.FunctionEx.identity) Entry(java.util.Map.Entry) JobClassLoaderService(com.hazelcast.jet.impl.JobClassLoaderService) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) Vertex(com.hazelcast.jet.core.Vertex) Address(com.hazelcast.cluster.Address) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Util.doWithClassLoader(com.hazelcast.jet.impl.util.Util.doWithClassLoader) ILogger(com.hazelcast.logging.ILogger) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) EdgeConfig(com.hazelcast.jet.config.EdgeConfig) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) JobClassLoaderService(com.hazelcast.jet.impl.JobClassLoaderService) MetaSupplierCtx(com.hazelcast.jet.impl.execution.init.Contexts.MetaSupplierCtx)

Example 9 with EdgeConfig

use of com.hazelcast.jet.config.EdgeConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testJetConfig.

@Test
public void testJetConfig() {
    JetConfig jetConfig = config.getJetConfig();
    assertTrue(jetConfig.isEnabled());
    assertTrue(jetConfig.isResourceUploadEnabled());
    assertEquals(4, jetConfig.getCooperativeThreadCount());
    assertEquals(2, jetConfig.getBackupCount());
    assertEquals(200, jetConfig.getFlowControlPeriodMs());
    assertEquals(20000, jetConfig.getScaleUpDelayMillis());
    assertEquals(1000000, jetConfig.getMaxProcessorAccumulatedRecords());
    assertFalse(jetConfig.isLosslessRestartEnabled());
    EdgeConfig edgeConfig = jetConfig.getDefaultEdgeConfig();
    assertEquals(2048, edgeConfig.getQueueSize());
    assertEquals(15000, edgeConfig.getPacketSizeLimit());
    assertEquals(4, edgeConfig.getReceiveWindowMultiplier());
}
Also used : EdgeConfig(com.hazelcast.jet.config.EdgeConfig) JetConfig(com.hazelcast.jet.config.JetConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 10 with EdgeConfig

use of com.hazelcast.jet.config.EdgeConfig in project hazelcast by hazelcast.

the class JobSubmissionSlownessRegressionTest method twoVertex.

private static DAG twoVertex() {
    DAG dag = new DAG();
    Vertex v1 = dag.newVertex("v", noopP());
    Vertex v2 = dag.newVertex("v2", noopP());
    dag.edge(Edge.between(v1, v2).setConfig(new EdgeConfig().setQueueSize(1)));
    return dag;
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) EdgeConfig(com.hazelcast.jet.config.EdgeConfig) DAG(com.hazelcast.jet.core.DAG)

Aggregations

EdgeConfig (com.hazelcast.jet.config.EdgeConfig)12 DAG (com.hazelcast.jet.core.DAG)6 Vertex (com.hazelcast.jet.core.Vertex)6 Test (org.junit.Test)6 JobConfig (com.hazelcast.jet.config.JobConfig)5 JetConfig (com.hazelcast.jet.config.JetConfig)4 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Function (java.util.function.Function)4 Config (com.hazelcast.config.Config)3 IList (com.hazelcast.collection.IList)2 BiFunctionEx (com.hazelcast.function.BiFunctionEx)2 FunctionEx (com.hazelcast.function.FunctionEx)2 PredicateEx.alwaysTrue (com.hazelcast.function.PredicateEx.alwaysTrue)2 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)2 Job (com.hazelcast.jet.Job)2 SimpleTestInClusterSupport (com.hazelcast.jet.SimpleTestInClusterSupport)2 Traverser (com.hazelcast.jet.Traverser)2 Traversers.traverseItems (com.hazelcast.jet.Traversers.traverseItems)2