/** Watches the growth of the given poll function. See class documentation for more details. */ public static <InputT, OutputT> Growth<InputT, OutputT, OutputT> growthOf( Growth.PollFn<InputT, OutputT> pollFn) { return growthOf(pollFn, Requirements.empty()); }
/** * Wraps a {@link SerializableFunction} as a {@link Contextful} of {@link Fn} with empty {@link * Requirements}. */ public static <InputT, OutputT> Contextful<Fn<InputT, OutputT>> fn( final SerializableFunction<InputT, OutputT> fn) { return new Contextful<>((element, c) -> fn.apply(element), Requirements.empty()); }
@Override public PCollection<MatchResult.Metadata> expand(PCollection<String> input) { PCollection<MatchResult.Metadata> res; if (getConfiguration().getWatchInterval() == null) { res = input.apply( "Match filepatterns", ParDo.of(new MatchFn(getConfiguration().getEmptyMatchTreatment()))); } else { res = input .apply( "Continuously match filepatterns", Watch.growthOf( Contextful.of(new MatchPollFn(), Requirements.empty()), new ExtractFilenameFn()) .withPollInterval(getConfiguration().getWatchInterval()) .withTerminationPerInput(getConfiguration().getWatchTerminationCondition())) .apply(Values.create()); } return res.apply(Reshuffle.viaRandomKey()); }
standardSeconds(3) /* timeToDeclareOutputFinal */, standardSeconds(30) /* timeToFail */), Requirements.empty()), KV::getKey) .withTerminationPerInput(Growth.afterTotalOf(standardSeconds(5)))