public class OutputCollector extends Object implements IOutputCollector
This output collector exposes the API for emitting tuples from an IRichBolt. This is the core API for emitting tuples. For a simpler API, and a more restricted form of stream processing, see IBasicBolt and BasicOutputCollector.
Constructor and Description |
---|
OutputCollector(IOutputCollector delegate) |
Modifier and Type | Method and Description |
---|---|
void |
ack(Tuple input) |
List<Integer> |
emit(Collection<Tuple> anchors,
List<Object> tuple)
Emits a new tuple to the default stream anchored on a group of input tuples.
|
List<Integer> |
emit(List<Object> tuple)
Emits a new unanchored tuple to the default stream.
|
List<Integer> |
emit(String streamId,
Collection<Tuple> anchors,
List<Object> tuple)
Returns the task ids that received the tuples.
|
List<Integer> |
emit(String streamId,
List<Object> tuple)
Emits a new unanchored tuple to the specified stream.
|
List<Integer> |
emit(String streamId,
Tuple anchor,
List<Object> tuple)
Emits a new tuple to a specific stream with a single anchor.
|
List<Integer> |
emit(Tuple anchor,
List<Object> tuple)
Emits a new tuple to the default stream anchored on a single tuple.
|
void |
emitDirect(int taskId,
Collection<Tuple> anchors,
List<Object> tuple)
Emits a tuple directly to the specified task id on the default stream.
|
void |
emitDirect(int taskId,
List<Object> tuple)
Emits a tuple directly to the specified task id on the default stream.
|
void |
emitDirect(int taskId,
String streamId,
Collection<Tuple> anchors,
List<Object> tuple) |
void |
emitDirect(int taskId,
String streamId,
List<Object> tuple)
Emits a tuple directly to the specified task id on the specified stream.
|
void |
emitDirect(int taskId,
String streamId,
Tuple anchor,
List<Object> tuple)
Emits a tuple directly to the specified task id on the specified stream.
|
void |
emitDirect(int taskId,
Tuple anchor,
List<Object> tuple)
Emits a tuple directly to the specified task id on the default stream.
|
void |
fail(Tuple input) |
void |
flush() |
void |
reportError(Throwable error) |
void |
resetTimeout(Tuple input)
Resets the message timeout for any tuple trees to which the given tuple belongs.
|
public OutputCollector(IOutputCollector delegate)
public List<Integer> emit(String streamId, Tuple anchor, List<Object> tuple)
Emits a new tuple to a specific stream with a single anchor. The emitted values must be immutable.
streamId
- the stream to emit toanchor
- the tuple to anchor totuple
- the new output tuple from this boltpublic List<Integer> emit(String streamId, List<Object> tuple)
Emits a new unanchored tuple to the specified stream. Because it’s unanchored, if a failure happens downstream, this new tuple won’t affect whether any spout tuples are considered failed or not. The emitted values must be immutable.
streamId
- the stream to emit totuple
- the new output tuple from this boltpublic List<Integer> emit(Collection<Tuple> anchors, List<Object> tuple)
Emits a new tuple to the default stream anchored on a group of input tuples. The emitted values must be immutable.
anchors
- the tuples to anchor totuple
- the new output tuple from this boltpublic List<Integer> emit(Tuple anchor, List<Object> tuple)
Emits a new tuple to the default stream anchored on a single tuple. The emitted values must be immutable.
anchor
- the tuple to anchor totuple
- the new output tuple from this boltpublic List<Integer> emit(List<Object> tuple)
Emits a new unanchored tuple to the default stream. Beacuse it’s unanchored, if a failure happens downstream, this new tuple won’t affect whether any spout tuples are considered failed or not. The emitted values must be immutable.
tuple
- the new output tuple from this boltpublic void emitDirect(int taskId, String streamId, Tuple anchor, List<Object> tuple)
Emits a tuple directly to the specified task id on the specified stream. If the target bolt does not subscribe to this bolt using a direct grouping, the tuple will not be sent. If the specified output stream is not declared as direct, or the target bolt subscribes with a non-direct grouping, an error will occur at runtime. The emitted values must be immutable.
taskId
- the taskId to send the new tuple tostreamId
- the stream to send the tuple on. It must be declared as a direct stream in the topology definition.anchor
- the tuple to anchor totuple
- the new output tuple from this boltpublic void emitDirect(int taskId, String streamId, List<Object> tuple)
Emits a tuple directly to the specified task id on the specified stream. If the target bolt does not subscribe to this bolt using a direct grouping, the tuple will not be sent. If the specified output stream is not declared as direct, or the target bolt subscribes with a non-direct grouping, an error will occur at runtime. Note that this method does not use anchors, so downstream failures won’t affect the failure status of any spout tuples. The emitted values must be immutable.
taskId
- the taskId to send the new tuple tostreamId
- the stream to send the tuple on. It must be declared as a direct stream in the topology definition.tuple
- the new output tuple from this boltpublic void emitDirect(int taskId, Collection<Tuple> anchors, List<Object> tuple)
Emits a tuple directly to the specified task id on the default stream. If the target bolt does not subscribe to this bolt using a direct grouping, the tuple will not be sent. If the specified output stream is not declared as direct, or the target bolt subscribes with a non-direct grouping, an error will occur at runtime. The emitted values must be immutable.
The default stream must be declared as direct in the topology definition. See OutputDeclarer#declare for how this is done when defining topologies in Java.
taskId
- the taskId to send the new tuple toanchors
- the tuples to anchor totuple
- the new output tuple from this boltpublic void emitDirect(int taskId, Tuple anchor, List<Object> tuple)
Emits a tuple directly to the specified task id on the default stream. If the target bolt does not subscribe to this bolt using a direct grouping, the tuple will not be sent. If the specified output stream is not declared as direct, or the target bolt subscribes with a non-direct grouping, an error will occur at runtime. The emitted values must be immutable.
The default stream must be declared as direct in the topology definition. See OutputDeclarer#declare for how this is done when defining topologies in Java.
taskId
- the taskId to send the new tuple toanchor
- the tuple to anchor totuple
- the new output tuple from this boltpublic void emitDirect(int taskId, List<Object> tuple)
Emits a tuple directly to the specified task id on the default stream. If the target bolt does not subscribe to this bolt using a direct grouping, the tuple will not be sent. If the specified output stream is not declared as direct, or the target bolt subscribes with a non-direct grouping, an error will occur at runtime. The emitted values must be immutable.
The default stream must be declared as direct in the topology definition. See OutputDeclarer#declare for how this is done when defining topologies in Java.<
Note that this method does not use anchors, so downstream failures won’t affect the failure status of any spout tuples.
taskId
- the taskId to send the new tuple totuple
- the new output tuple from this boltpublic List<Integer> emit(String streamId, Collection<Tuple> anchors, List<Object> tuple)
IOutputCollector
Returns the task ids that received the tuples.
emit
in interface IOutputCollector
public void emitDirect(int taskId, String streamId, Collection<Tuple> anchors, List<Object> tuple)
emitDirect
in interface IOutputCollector
public void ack(Tuple input)
ack
in interface IOutputCollector
public void fail(Tuple input)
fail
in interface IOutputCollector
public void resetTimeout(Tuple input)
Resets the message timeout for any tuple trees to which the given tuple belongs. The timeout is reset to Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS. Note that this is an expensive operation, and should be used sparingly.
resetTimeout
in interface IOutputCollector
input
- the tuple to reset timeout forpublic void reportError(Throwable error)
reportError
in interface IErrorReporter
public void flush()
flush
in interface IOutputCollector
Copyright © 2019 The Apache Software Foundation. All rights reserved.