Search in sources :

Example 51 with Vertex

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

the class MasterJobContext method completeVertices.

private void completeVertices(@Nullable Throwable failure) {
    if (vertices != null) {
        JobClassLoaderService classLoaderService = mc.getJetServiceBackend().getJobClassLoaderService();
        JetDelegatingClassLoader jobCl = classLoaderService.getClassLoader(mc.jobId());
        doWithClassLoader(jobCl, () -> {
            for (Vertex v : vertices) {
                try {
                    ClassLoader processorCl = classLoaderService.getProcessorClassLoader(mc.jobId(), v.getName());
                    doWithClassLoader(processorCl, () -> v.getMetaSupplier().close(failure));
                } catch (Throwable e) {
                    logger.severe(mc.jobIdString() + " encountered an exception in ProcessorMetaSupplier.close(), ignoring it", e);
                }
            }
        });
    }
}
Also used : JetDelegatingClassLoader(com.hazelcast.jet.impl.deployment.JetDelegatingClassLoader) Vertex(com.hazelcast.jet.core.Vertex) JetDelegatingClassLoader(com.hazelcast.jet.impl.deployment.JetDelegatingClassLoader) Util.doWithClassLoader(com.hazelcast.jet.impl.util.Util.doWithClassLoader) CustomClassLoadedObject.deserializeWithCustomClassLoader(com.hazelcast.jet.impl.execution.init.CustomClassLoadedObject.deserializeWithCustomClassLoader)

Example 52 with Vertex

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

the class MasterJobContext method formatExecutionSummary.

private String formatExecutionSummary(String conclusion, long completionTime) {
    StringBuilder sb = new StringBuilder();
    sb.append("Execution of ").append(mc.jobIdString()).append(' ').append(conclusion);
    sb.append("\n\t").append("Start time: ").append(Util.toLocalDateTime(executionStartTime));
    sb.append("\n\t").append("Duration: ").append(formatJobDuration(completionTime - executionStartTime));
    if (jobMetrics.stream().noneMatch(rjm -> rjm.getBlob() != null)) {
        sb.append("\n\tTo see additional job metrics enable JobConfig.storeMetricsAfterJobCompletion");
    } else {
        JobMetrics jobMetrics = JobMetricsUtil.toJobMetrics(this.jobMetrics);
        Map<String, Long> receivedCounts = mergeByVertex(jobMetrics.get(MetricNames.RECEIVED_COUNT));
        Map<String, Long> emittedCounts = mergeByVertex(jobMetrics.get(MetricNames.EMITTED_COUNT));
        Map<String, Long> distributedBytesIn = mergeByVertex(jobMetrics.get(MetricNames.DISTRIBUTED_BYTES_IN));
        Map<String, Long> distributedBytesOut = mergeByVertex(jobMetrics.get(MetricNames.DISTRIBUTED_BYTES_OUT));
        sb.append("\n\tVertices:");
        for (Vertex vertex : vertices) {
            sb.append("\n\t\t").append(vertex.getName());
            sb.append(getValueForVertex("\n\t\t\t" + MetricNames.RECEIVED_COUNT, vertex, receivedCounts));
            sb.append(getValueForVertex("\n\t\t\t" + MetricNames.EMITTED_COUNT, vertex, emittedCounts));
            sb.append(getValueForVertex("\n\t\t\t" + MetricNames.DISTRIBUTED_BYTES_IN, vertex, distributedBytesIn));
            sb.append(getValueForVertex("\n\t\t\t" + MetricNames.DISTRIBUTED_BYTES_OUT, vertex, distributedBytesOut));
        }
    }
    return sb.toString();
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) Util.idToString(com.hazelcast.jet.Util.idToString) JobMetrics(com.hazelcast.jet.core.metrics.JobMetrics) RawJobMetrics(com.hazelcast.jet.impl.metrics.RawJobMetrics)

Example 53 with Vertex

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

the class Util method copyMapUsingJob.

// used in jet-enterprise
@SuppressWarnings("WeakerAccess")
public static CompletableFuture<Void> copyMapUsingJob(HazelcastInstance instance, int queueSize, String sourceMap, String targetMap) {
    DAG dag = new DAG();
    Vertex source = dag.newVertex("readMap(" + sourceMap + ')', readMapP(sourceMap));
    Vertex sink = dag.newVertex("writeMap(" + targetMap + ')', writeMapP(targetMap));
    dag.edge(between(source, sink).setConfig(new EdgeConfig().setQueueSize(queueSize)));
    JobConfig jobConfig = new JobConfig().setName("copy-" + sourceMap + "-to-" + targetMap);
    return instance.getJet().newJob(dag, jobConfig).getFuture();
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) EdgeConfig(com.hazelcast.jet.config.EdgeConfig) DAG(com.hazelcast.jet.core.DAG) JobConfig(com.hazelcast.jet.config.JobConfig)

Example 54 with Vertex

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

the class AggregateTransform method addToDagTwoStage.

// WHEN PRESERVE ORDER IS NOT ACTIVE
// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// local          local
// unicast        unicast
// v              v
// -------------------
// |    accumulateP    |
// -------------------
// |
// distributed
// all-to-one
// v
// ----------------
// |    combineP    | local parallelism = 1
// ----------------
// WHEN PRESERVE ORDER IS ACTIVE
// ---------       ---------
// | source0 | ... | sourceN |
// ---------       ---------
// |              |
// isolated       isolated
// v              v
// -------------------
// |    accumulateP    |
// -------------------
// |
// distributed
// all-to-one
// v
// ----------------
// |    combineP    | local parallelism = 1
// ----------------
private void addToDagTwoStage(Planner p, Context context) {
    String vertexName = name();
    determineLocalParallelism(LOCAL_PARALLELISM_USE_DEFAULT, context, p.isPreserveOrder());
    Vertex v1 = p.dag.newVertex(vertexName + FIRST_STAGE_VERTEX_NAME_SUFFIX, accumulateP(aggrOp)).localParallelism(determinedLocalParallelism());
    if (p.isPreserveOrder()) {
        p.addEdges(this, v1, Edge::isolated);
    } else {
        p.addEdges(this, v1);
    }
    determinedLocalParallelism(1);
    PlannerVertex pv2 = p.addVertex(this, vertexName, determinedLocalParallelism(), ProcessorMetaSupplier.forceTotalParallelismOne(ProcessorSupplier.of(combineP(aggrOp)), vertexName));
    p.dag.edge(between(v1, pv2.v).distributed().allToOne(vertexName));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) Edge(com.hazelcast.jet.core.Edge)

Example 55 with Vertex

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

the class GroupTransform method addToDagTwoStage.

// ---------        ---------
// | source0 |  ... | sourceN |
// ---------        ---------
// |                |
// local            local
// partitioned      partitioned
// v                v
// --------------------
// |  accumulateByKeyP  |
// --------------------
// |
// distributed
// partitioned
// v
// ---------------
// | combineByKeyP |
// ---------------
private void addToDagTwoStage(Planner p) {
    List<FunctionEx<?, ? extends K>> groupKeyFns = this.groupKeyFns;
    Vertex v1 = p.dag.newVertex(name() + FIRST_STAGE_VERTEX_NAME_SUFFIX, accumulateByKeyP(groupKeyFns, aggrOp)).localParallelism(determinedLocalParallelism());
    PlannerVertex pv2 = p.addVertex(this, name(), determinedLocalParallelism(), combineByKeyP(aggrOp, mapToOutputFn));
    p.addEdges(this, v1, (e, ord) -> e.partitioned(groupKeyFns.get(ord), HASH_CODE));
    p.dag.edge(between(v1, pv2.v).distributed().partitioned(entryKey()));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) FunctionEx(com.hazelcast.function.FunctionEx) BiFunctionEx(com.hazelcast.function.BiFunctionEx)

Aggregations

Vertex (com.hazelcast.jet.core.Vertex)189 DAG (com.hazelcast.jet.core.DAG)130 Test (org.junit.Test)95 QuickTest (com.hazelcast.test.annotation.QuickTest)57 Job (com.hazelcast.jet.Job)53 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)48 Entry (java.util.Map.Entry)41 List (java.util.List)28 Edge.between (com.hazelcast.jet.core.Edge.between)26 Map (java.util.Map)26 Assert.assertEquals (org.junit.Assert.assertEquals)23 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)21 IntStream (java.util.stream.IntStream)21 Assert.assertTrue (org.junit.Assert.assertTrue)19 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)18 Category (org.junit.experimental.categories.Category)18 Collectors.toList (java.util.stream.Collectors.toList)17 Nonnull (javax.annotation.Nonnull)17 FunctionEx (com.hazelcast.function.FunctionEx)15 Edge (com.hazelcast.jet.core.Edge)15