public interface Processor
The special case of zero input streams applies to a source vertex, which gets its data from the environment. The special case of zero output streams applies to a sink vertex, which pushes its data to the environment.
The processor accepts input from instances of Inbox
and pushes its output
to an instance of Outbox
.
The processing methods should limit the amount of data they output per invocation
because the outbox will not be emptied until the processor yields control back to
its caller. Specifically, Outbox
has a method isHighWater()
that can be tested to see whether it's time to stop pushing more data into it. There is
also a finer-grained method isHighWater(ordinal)
, which
tells the state of an individual output bucket.
If this processor declares itself as "cooperative" (isCooperative()
returns
true
, the default), it should also limit the amount of time it spends per call because it
will participate in a cooperative multithreading scheme.
Modifier and Type | Interface and Description |
---|---|
static interface |
Processor.Context
Context passed to the processor in the
init() call. |
Modifier and Type | Method and Description |
---|---|
default boolean |
complete()
Called after all the inputs are exhausted.
|
default boolean |
completeEdge(int ordinal)
Called after the edge input with the supplied
ordinal is exhausted. |
default void |
init(Outbox outbox,
Processor.Context context)
Initializes this processor with the outbox that the processing methods
must use to deposit their output items.
|
default boolean |
isCooperative()
Tells whether this processor is able to participate in cooperative multithreading.
|
default void |
process(int ordinal,
Inbox inbox)
Processes some items in the supplied inbox.
|
default void init(@Nonnull Outbox outbox, @Nonnull Processor.Context context)
process(int, Inbox)
, completeEdge(int)
, complete()
).
The default implementation does nothing.
default void process(int ordinal, @Nonnull Inbox inbox)
The default implementation does nothing.
ordinal
- ordinal of the edge the item comes frominbox
- the inbox containing the pending itemsdefault boolean completeEdge(int ordinal)
ordinal
is exhausted. If
it returns false
, it will be invoked again until it returns true
,
and until it does, no other methods will be invoked on the processor.true
if the processor is now done completing this input,
false
otherwise.default boolean complete()
false
, it will be
invoked again until it returns true
. After this method is called, no other
processing methods will be called on this processor.true
if the completing step is now done, false
otherwise.default boolean isCooperative()
If this processor declares itself non-cooperative, it will be allocated a dedicated Java thread. Otherwise it will be allocated a tasklet which shares a thread with other tasklets.
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.