/** * Convenience for {@link #writeLoggerP(DistributedFunction)} that uses * {@code toString()} as {@code toStringFn}. */ @Nonnull public static ProcessorMetaSupplier writeLoggerP() { return writeLoggerP(Object::toString); }
/** * Convenience for {@link #peekInputP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekInput(toStringFn, * shouldLogFn, metaSupplier)} with a pass-through filter and {@code * Object#toString} as the formatting function. This variant accepts a * {@code ProcessorSupplier} instead of a meta-supplier. */ @Nonnull public static ProcessorSupplier peekInputP(@Nonnull ProcessorSupplier wrapped) { return peekInputP(Object::toString, alwaysTrue(), wrapped); }
/** * Convenience for {@link #peekOutputP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekOutput(toStringFn, * shouldLogFn, metaSupplier} with a pass-through filter and {@code * Object#toString} as the formatting function. */ @Nonnull public static ProcessorMetaSupplier peekOutputP(@Nonnull ProcessorMetaSupplier wrapped) { return peekOutputP(Object::toString, alwaysTrue(), wrapped); }
/** * Convenience for {@link #peekSnapshotP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekSnapshot(toStringFn, * shouldLogFn, metaSupplier} with a pass-through filter and {@code * Object#toString} as the formatting function. */ @Nonnull public static ProcessorMetaSupplier peekSnapshotP(@Nonnull ProcessorMetaSupplier wrapped) { return peekSnapshotP(Object::toString, alwaysTrue(), wrapped); }
/** * Convenience for {@link #peekSnapshotP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekSnapshot(toStringFn, * shouldLogFn, metaSupplier} with a pass-through filter and {@code * Object#toString} as the formatting function. This variant accepts a * {@code ProcessorSupplier} instead of a meta-supplier. */ @Nonnull public static ProcessorSupplier peekSnapshotP(@Nonnull ProcessorSupplier wrapped) { return peekSnapshotP(Object::toString, alwaysTrue(), wrapped); } }
/** * Returns a sink that logs all the data items it receives, at the INFO * level to the log category {@link * com.hazelcast.jet.impl.connector.WriteLoggerP}. It also logs {@link * com.hazelcast.jet.core.Watermark watermark} items, but at FINE level. * <p> * The sink logs each item on whichever cluster member it happens to * receive it. Its primary purpose is for development, when running Jet on * a local machine. * <p> * The default local parallelism for this sink is 1. * * @param toStringFn a function that returns a string representation of a stream item * @param <T> stream item type */ @Nonnull public static <T> Sink<T> logger(@Nonnull DistributedFunction<? super T, String> toStringFn) { return fromProcessor("loggerSink", writeLoggerP(toStringFn)); }
/** * Convenience for {@link #peekOutputP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekOutput(toStringFn, * shouldLogFn, metaSupplier} with a pass-through filter and {@code * Object#toString} as the formatting function. This variant accepts a * {@code ProcessorSupplier} instead of a meta-supplier. */ @Nonnull public static ProcessorSupplier peekOutputP(@Nonnull ProcessorSupplier wrapped) { return peekOutputP(Object::toString, alwaysTrue(), wrapped); }
/** * Convenience for {@link #peekSnapshotP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekSnapshot(toStringFn, * shouldLogFn, metaSupplier} with a pass-through filter and {@code * Object#toString} as the formatting function. This variant accepts a * {@code DistributedSupplier} of processors instead of a meta-supplier. */ @Nonnull public static DistributedSupplier<Processor> peekSnapshotP(@Nonnull DistributedSupplier<Processor> wrapped) { return peekSnapshotP(Object::toString, alwaysTrue(), wrapped); }
/** * Convenience for {@link #peekInputP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekInput(toStringFn, * shouldLogFn, metaSupplier)} with a pass-through filter and {@code * Object#toString} as the formatting function. */ @Nonnull public static ProcessorMetaSupplier peekInputP(@Nonnull ProcessorMetaSupplier wrapped) { return peekInputP(Object::toString, alwaysTrue(), wrapped); }
public static void main(String[] args) { System.setProperty("hazelcast.logging.type", "log4j"); JetInstance instance = Jet.newJetInstance(); Jet.newJetInstance(); try { TickerInfo.populateMap(instance.getHazelcastInstance().getReplicatedMap("tickersInfo")); DAG dag = new DAG(); Vertex tradesSource = dag.newVertex("tradesSource", GenerateTradesP::new); Vertex enrichment = dag.newVertex("enrichment", mapUsingContextP(replicatedMapContext("tickersInfo"), (ReplicatedMap<String, TickerInfo> map, Trade item) -> tuple2(item, map.get(item.getTicker())))); Vertex sink = dag.newVertex("sink", DiagnosticProcessors.writeLoggerP()); tradesSource.localParallelism(1); dag .edge(between(tradesSource, enrichment)) .edge(between(enrichment, sink)); instance.newJob(dag).join(); } finally { Jet.shutdownAll(); } } }
/** * Convenience for {@link #peekOutputP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekOutput(toStringFn, * shouldLogFn, metaSupplier} with a pass-through filter and {@code * Object#toString} as the formatting function. This variant accepts a * {@code DistributedSupplier} of processors instead of a meta-supplier. */ @Nonnull public static DistributedSupplier<Processor> peekOutputP(@Nonnull DistributedSupplier<Processor> wrapped) { return peekOutputP(Object::toString, alwaysTrue(), wrapped); }
/** * Convenience for {@link #peekInputP(DistributedFunction, * DistributedPredicate, ProcessorMetaSupplier) peekInput(toStringFn, * shouldLogFn, metaSupplier)} with a pass-through filter and {@code * Object#toString} as the formatting function. This variant accepts a * {@code DistributedSupplier} of processors instead of a meta-supplier. */ @Nonnull public static DistributedSupplier<Processor> peekInputP(@Nonnull DistributedSupplier<Processor> wrapped) { return peekInputP(Object::toString, alwaysTrue(), wrapped); }
Processors.aggregateP(AggregateOperations.toMap(entryKey(), entryValue()))); Vertex hashJoin = dag.newVertex("hashJoin", () -> new HashJoinP<>(Trade::getTicker)); Vertex sink = dag.newVertex("sink", writeLoggerP(o -> Arrays.toString((Object[]) o)));
@Override public void addToDag(Planner p) { PlannerVertex peekedPv = p.xform2vertex.get(this.upstream().get(0)); // Peeking transform doesn't add a vertex, so point to the upstream // transform's vertex: p.xform2vertex.put(this, peekedPv); peekedPv.v.updateMetaSupplier(sup -> peekOutputP(toStringFn, shouldLogFn, sup)); } }