Class TestSources
@EvolvingApi public final class TestSources extends Object
- Since:
- 3.2
-
Method Summary
Modifier and Type Method Description static <T> BatchSource<T>
items(Iterable<? extends T> items)
Returns a batch source which iterates through the supplied iterable and then terminates.static <T> BatchSource<T>
items(T... items)
Returns a batch source which iterates through the supplied items and then terminates.static StreamSource<SimpleEvent>
itemStream(int itemsPerSecond)
Returns a streaming source which generates events of typeSimpleEvent
at the specified rate infinitely.static <T> StreamSource<T>
itemStream(int itemsPerSecond, GeneratorFunction<? extends T> generatorFn)
Returns a streaming source which generates events created by thegeneratorFn
at the specified rate infinitely.
-
Method Details
-
items
Returns a batch source which iterates through the supplied iterable and then terminates.- Since:
- 3.2
-
items
Returns a batch source which iterates through the supplied items and then terminates.- Since:
- 3.2
-
itemStream
Returns a streaming source which generates events of typeSimpleEvent
at the specified rate infinitely.The source supports native timestamps. The timestamp is the current system time at the moment they are generated. The source is not distributed and all the items are generated on the same node. This source is not fault-tolerant. The sequence will be reset once a job is restarted.
Note: There is no absolute guarantee that the actual rate of emitted items will match the supplied value. It is done on a best-effort basis.
- Parameters:
itemsPerSecond
- how many items should be emitted each second- Since:
- 3.2
-
itemStream
@EvolvingApi @Nonnull public static <T> StreamSource<T> itemStream(int itemsPerSecond, @Nonnull GeneratorFunction<? extends T> generatorFn)Returns a streaming source which generates events created by thegeneratorFn
at the specified rate infinitely.The source supports native timestamps. The timestamp is the current system time at the moment they are generated. The source is not distributed and all the items are generated on the same node. This source is not fault-tolerant. The sequence will be reset once a job is restarted.
Note: There is no absolute guarantee that the actual rate of emitted items will match the supplied value. It is done on a best-effort basis.
- Parameters:
itemsPerSecond
- how many items should be emitted each secondgeneratorFn
- a function which takes the timestamp and the sequence of the generated item and maps it to the desired type- Since:
- 3.2
-