@SpringAware public class CustomSourceP extends AbstractProcessor
@SpringAware
annotation enables this auto-wiring functionality.AbstractProcessor.FlatMapper<T,R>
Processor.Context
Constructor and Description |
---|
CustomSourceP() |
Modifier and Type | Method and Description |
---|---|
boolean |
complete()
Called after all the inbound edges' streams are exhausted.
|
static BatchSource<User> |
customSource() |
protected void |
init(Processor.Context context)
Method that can be overridden to perform any necessary initialization
for the processor.
|
boolean |
isCooperative()
Tells whether this processor is able to participate in cooperative
multithreading.
|
emitFromTraverser, emitFromTraverser, emitFromTraverser, emitFromTraverserToSnapshot, flatMapper, flatMapper, flatMapper, getLogger, getOutbox, init, process, restoreFromSnapshot, restoreFromSnapshot, tryEmit, tryEmit, tryEmit, tryEmitToSnapshot, tryProcess, tryProcess0, tryProcess1, tryProcess2, tryProcess3, tryProcess4, tryProcessWatermark
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, completeEdge, finishSnapshotRestore, saveToSnapshot, tryProcess
public boolean isCooperative()
Processor
A cooperative processor should also not attempt any blocking operations,
such as I/O operations, waiting for locks/semaphores or sleep
operations. Violations of this rule will manifest as less than 100% CPU
usage under maximum load (note that this is possible for other reasons too,
for example if the network is the bottleneck or if parking time is too high).
The processor must also return as soon as the outbox rejects an item
(that is when the offer()
method returns
false
).
If this processor declares itself cooperative, it will share a thread with other cooperative processors. Otherwise it will run in a dedicated Java thread.
Jet prefers cooperative processors because they result in a greater overall throughput. A processor should be non-cooperative only if it involves blocking operations, which would cause all other processors on the same shared thread to starve.
Processor instances of a single vertex are allowed to return different values, but a single processor instance must always return the same value.
The default implementation returns true
.
protected void init(@Nonnull Processor.Context context)
AbstractProcessor
process()
and
Processor.complete()
), but after the outbox and logger
have been initialized.
Subclasses are not required to call this superclass method, it does nothing.
init
in class AbstractProcessor
context
- the context
associated with this processorpublic boolean complete()
Processor
false
, it will be invoked again until it returns true
.
For example, a streaming source processor will return false
forever. Unlike other methods which guarantee that no other method is
called until they return true
, Processor.saveToSnapshot()
can be
called even though this method returned false
. If you returned
because Outbox.offer()
returned false
, make sure to
first offer the pending item to the outbox in Processor.saveToSnapshot()
before continuing to offer to
snapshot.
After this method is called, no other processing methods are called on
this processor, except for Processor.saveToSnapshot()
.
Non-cooperative processors are required to return from this method from time to time to give the system a chance to check for snapshot requests and job cancellation. The time the processor spends in this method affects the latency of snapshots and job cancellations.
true
if the completing step is now done, false
otherwise.public static BatchSource<User> customSource()
Copyright © 2020 Hazelcast, Inc.. All rights reserved.