Search in sources :

Example 6 with JetEvent

use of com.hazelcast.jet.impl.pipeline.JetEvent in project hazelcast-jet by hazelcast.

the class WindowAggregateTransform method addSlidingWindowTwoStage.

// --------        ---------
// | source0 | ... | sourceN |
// --------        ---------
// |               |
// local           local
// unicast         unicast
// v               v
// --------------------
// | accumulateByFrameP | keyFn = constantKey()
// --------------------
// |
// distributed
// all-to-one
// v
// -------------------------
// | combineToSlidingWindowP | local parallelism = 1
// -------------------------
private void addSlidingWindowTwoStage(Planner p, SlidingWindowDef wDef) {
    String namePrefix = p.uniqueVertexName(name(), "-step");
    SlidingWindowPolicy winPolicy = wDef.toSlidingWindowPolicy();
    Vertex v1 = p.dag.newVertex(namePrefix + '1', accumulateByFrameP(nCopies(aggrOp.arity(), constantKey()), nCopies(aggrOp.arity(), (DistributedToLongFunction<JetEvent>) JetEvent::timestamp), TimestampKind.EVENT, winPolicy, aggrOp));
    v1.localParallelism(localParallelism());
    PlannerVertex pv2 = p.addVertex(this, namePrefix + '2', 1, combineToSlidingWindowP(winPolicy, aggrOp, mapToOutputFn.toKeyedWindowResultFn()));
    p.addEdges(this, v1);
    p.dag.edge(between(v1, pv2.v).distributed().allToOne());
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) PlannerVertex(com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex) SlidingWindowPolicy(com.hazelcast.jet.core.SlidingWindowPolicy) JetEvent(com.hazelcast.jet.impl.pipeline.JetEvent)

Example 7 with JetEvent

use of com.hazelcast.jet.impl.pipeline.JetEvent in project hazelcast-jet by hazelcast.

the class Util method logLateEvent.

public static void logLateEvent(ILogger logger, long currentWm, @Nonnull Object item) {
    if (!logger.isInfoEnabled()) {
        return;
    }
    if (item instanceof JetEvent) {
        JetEvent event = (JetEvent) item;
        logger.info(String.format("Event dropped, late by %dms. currentWatermark=%s, eventTime=%s, event=%s", currentWm - event.timestamp(), toLocalTime(currentWm), toLocalTime(event.timestamp()), event.payload()));
    } else {
        logger.info(String.format("Late event dropped. currentWatermark=%s, event=%s", new Watermark(currentWm), item));
    }
}
Also used : JetEvent(com.hazelcast.jet.impl.pipeline.JetEvent) Watermark(com.hazelcast.jet.core.Watermark)

Aggregations

JetEvent (com.hazelcast.jet.impl.pipeline.JetEvent)7 PlannerVertex (com.hazelcast.jet.impl.pipeline.Planner.PlannerVertex)6 SlidingWindowPolicy (com.hazelcast.jet.core.SlidingWindowPolicy)2 Vertex (com.hazelcast.jet.core.Vertex)2 Watermark (com.hazelcast.jet.core.Watermark)1