private void rewriteDagWithSnapshotRestore(DAG dag, long snapshotId, String mapName) { IMap<Object, Object> snapshotMap = nodeEngine.getHazelcastInstance().getMap(mapName); snapshotId = SnapshotValidator.validateSnapshot(snapshotId, jobIdString(), snapshotMap); logger.info("State of " + jobIdString() + " will be restored from snapshot " + snapshotId + ", map=" + mapName); List<Vertex> originalVertices = new ArrayList<>(); dag.iterator().forEachRemaining(originalVertices::add); Map<String, Integer> vertexToOrdinal = new HashMap<>(); Vertex readSnapshotVertex = dag.newVertex(SNAPSHOT_VERTEX_PREFIX + "read", readMapP(mapName)); long finalSnapshotId = snapshotId; Vertex explodeVertex = dag.newVertex(SNAPSHOT_VERTEX_PREFIX + "explode", () -> new ExplodeSnapshotP(vertexToOrdinal, finalSnapshotId)); dag.edge(between(readSnapshotVertex, explodeVertex).isolated()); int index = 0; // add the edges for (Vertex userVertex : originalVertices) { vertexToOrdinal.put(userVertex.getName(), index); int destOrdinal = dag.getInboundEdges(userVertex.getName()).size(); dag.edge(new SnapshotRestoreEdge(explodeVertex, index, userVertex, destOrdinal)); index++; } }
@Override @SuppressWarnings("unchecked") public void addToDag(Planner p) { if (emitsWatermarks || eventTimePolicy == null) { // Reached when the source either emits both JetEvents and watermarks // or neither. In these cases we don't have to insert watermarks. p.addVertex(this, p.uniqueVertexName(name()), localParallelism(), metaSupplierFn.apply(eventTimePolicy != null ? eventTimePolicy : noEventTime()) ); } else { // ------------ // | sourceP | // ------------ // | // isolated // v // ------------- // | insertWmP | // ------------- String v1name = p.uniqueVertexName(name()); Vertex v1 = p.dag.newVertex(v1name, metaSupplierFn.apply(eventTimePolicy)) .localParallelism(localParallelism()); PlannerVertex pv2 = p.addVertex( this, v1name + "-add-timestamps", localParallelism(), insertWatermarksP(eventTimePolicy) ); p.dag.edge(between(v1, pv2.v).isolated()); } }
.distributed()) .edge(between(slidingStage2, formatOutput) .isolated()) .edge(between(formatOutput, sink));
.partitioned(Trade::getTicker, HASH_CODE) .distributed()) .edge(between(slidingWindow, formatOutput).isolated()) .edge(between(formatOutput, sink));