public static StreamSource<BufferedImage> webcam(long pollIntervalMillis) { return SourceBuilder.timestampedStream("webcam", ctx -> new WebcamSource(pollIntervalMillis)) .fillBufferFn(WebcamSource::addToBufferFn) .destroyFn(WebcamSource::close) .build(); }
@Nonnull String name, @Nonnull DistributedFunction<? super Processor.Context, ? extends S> createFn ) { return new SourceBuilder<S>(name, createFn).new Stream<Void>();
private static StreamSource<String> twitterSource(Properties properties, List<String> terms) { return SourceBuilder.timestampedStream("twitter", ignored -> new TwitterSource(properties, terms)) .fillBufferFn(TwitterSource::addToBuffer) .destroyFn(TwitterSource::destroy) .build(); }
@Nonnull String name, @Nonnull DistributedFunction<? super Processor.Context, ? extends S> createFn ) { return new SourceBuilder<S>(name, createFn).new Batch<Void>();
public static StreamSource<Aircraft> flightDataSource(String url, long pollIntervalMillis, long allowedLateness) { return SourceBuilder.timestampedStream("Flight Data Source", ctx -> new FlightDataSource(ctx.logger(), url, pollIntervalMillis)) .fillBufferFn(FlightDataSource::fillBuffer) .allowedLateness(allowedLateness) .build(); } }
@Nonnull DistributedFunction<? super Processor.Context, ? extends S> createFn ) { return new SourceBuilder<S>(name, createFn).new TimestampedStream<Void>();
/** * This code is the main point of the sample: use the source builder to * create an HTTP source connector, then create a Jet pipeline that * performs windowed aggregation over its data. */ private static Pipeline buildPipeline() { StreamSource<TimestampedItem<Long>> usedMemorySource = SourceBuilder .timestampedStream("used-memory", x -> new PollHttp()) .fillBufferFn(PollHttp::fillBuffer) .destroyFn(PollHttp::close) .build(); Pipeline p = Pipeline.create(); p.drawFrom(usedMemorySource) .window(sliding(100, 20)) .aggregate(linearTrend(TimestampedItem::timestamp, TimestampedItem::item)) .map(tsItem -> entry(tsItem.timestamp(), tsItem.item())) .drainTo(Sinks.map(MAP_NAME)); return p; }