public interface Topology extends TopologyElement
Modifier and Type | Method and Description |
---|---|
<T> TStream<T> |
collection(java.util.Collection<T> tuples)
Declare a stream of constants from a collection.
|
<T> TStream<T> |
events(Consumer<Consumer<T>> eventSetup)
Declare a stream populated by an event system.
|
<T> TStream<T> |
generate(Supplier<T> data)
Declare an endless source stream.
|
java.lang.String |
getName()
Name of this topology.
|
Supplier<RuntimeServices> |
getRuntimeServiceSupplier()
Return a function that at execution time
will return a
RuntimeServices instance
a stream function can use. |
Tester |
getTester()
Get the tester for this topology.
|
Graph |
graph()
Get the underlying graph.
|
<T> TStream<T> |
of(T... values)
Declare a stream of objects.
|
<T> TStream<T> |
poll(Supplier<T> data,
long period,
java.util.concurrent.TimeUnit unit)
Declare a new source stream that calls
data.get() periodically. |
<T> TStream<T> |
source(Supplier<java.lang.Iterable<T>> data)
Declare a new source stream that iterates over the return of
Iterable<T> get() from data . |
TStream<java.lang.String> |
strings(java.lang.String... strings)
Declare a stream of strings.
|
topology
java.lang.String getName()
TopologyProvider.newTopology(String)
<T> TStream<T> source(Supplier<java.lang.Iterable<T>> data)
Iterable<T> get()
from data
. Once all the tuples from
data.get()
have been submitted on the stream, no more tuples are
submitted. Iterable
never completes.
If data
implements AutoCloseable
, its close()
method will be called when the topology's execution is terminated.
data
- Function that produces that data for the stream.data.get()
.<T> TStream<T> generate(Supplier<T> data)
data.get()
will be called
repeatably. Each non-null returned value will be present on the stream.
If data
implements AutoCloseable
, its close()
method will be called when the topology's execution is terminated.
data
- Supplier of the tuples.data.get()
.<T> TStream<T> poll(Supplier<T> data, long period, java.util.concurrent.TimeUnit unit)
data.get()
periodically.
Each non-null value returned will appear on the returned stream. Thus
each call to {code data.get()} will result in zero tuples or one tuple on
the stream.
If data
implements AutoCloseable
, its close()
method will be called when the topology's execution is terminated.
data
- Function that produces that data for the stream.period
- Approximate period {code data.get()} will be called.unit
- Time unit of period
.data.get()
.<T> TStream<T> events(Consumer<Consumer<T>> eventSetup)
eventSetup.accept(eventSubmitter))
is called by the runtime with
eventSubmitter
being a Consumer<T>
. Calling
eventSubmitter.accept(t)
results in t
being present on
the returned stream if it is not null. If t
is null then no
action is taken. eventSubmitter
is called from the event
handler callback registered with the event system.
Downstream processing is isolated from the event source to ensure that event listener is not blocked by a long or slow processing flow.
If eventSetup
implements AutoCloseable
, its close()
method will be called when the topology's execution is terminated.
eventSetup
- handler to receive the eventSubmitter
eventSubmitter.accept(t)
.PlumbingStreams.pressureReliever(TStream, quarks.function.Function, int)
,
Quarks Source StreamsTStream<java.lang.String> strings(java.lang.String... strings)
strings
- Strings that will be present on the stream.strings
.<T> TStream<T> of(T... values)
values
- Values that will be present on the stream.values
.<T> TStream<T> collection(java.util.Collection<T> tuples)
tuples
.tuples
- Tuples that will be present on the stream.tuples
.Tester getTester()
Graph graph()
Supplier<RuntimeServices> getRuntimeServiceSupplier()
RuntimeServices
instance
a stream function can use.RuntimeServices
instanceCopyright IBM 2015,2016 - 2f6ad0e-20160307-0902