X
- Tester typepublic abstract class GraphTopology<X extends Tester> extends AbstractTopology<X>
Graph
.Modifier | Constructor and Description |
---|---|
protected |
GraphTopology(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
<T> TStream<T> |
events(Consumer<Consumer<T>> eventSetup)
Declare a stream populated by an event system.
|
<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 . |
protected <N extends Source<T>,T> |
sourceStream(N sourceOp) |
collection, generate, getName, getTester, newTester, of, strings, topology
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRuntimeServiceSupplier, graph
public <T> TStream<T> source(Supplier<java.lang.Iterable<T>> data)
Topology
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.
T
- Tuple typedata
- Function that produces that data for the stream.data.get()
.public <T> TStream<T> poll(Supplier<T> data, long period, java.util.concurrent.TimeUnit unit)
Topology
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.
The poll rate may be changed when the topology is running via a runtime
PeriodMXBean
.
In order to use this mechanism the caller must provide a
alias for the stream when building the topology.
The PeriodMXBean
is registered with the ControlService
with type TStream.TYPE
and the stream's alias.
e.g.,
Topology t = ...
TStream<Integer> stream = t.poll(...).alias("myStreamControlAlias");
// change the poll frequency at runtime
static <T> void setPollFrequency(TStream<T> pollStream, long period, TimeUnit unit) {
ControlService cs = t.getRuntimeServiceSupplier().getService(ControlService.class);
String alias = pollStream.getAlias();
PeriodMXBean control = cs.getControl(TStream.TYPE, alias, PeriodMXBean.class);
control.setPoll(period, unit);
}
T
- Tuple typedata
- Function that produces that data for the stream.period
- Approximate period {code data.get()} will be called.unit
- Time unit of period
.data.get()
.public <T> TStream<T> events(Consumer<Consumer<T>> eventSetup)
Topology
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.
T
- Tuple typeeventSetup
- handler to receive the eventSubmitter
eventSubmitter.accept(t)
.PlumbingStreams.pressureReliever(TStream, org.apache.edgent.function.Function, int)
,
Edgent Source StreamsCopyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641