backtype.storm.task
Class OutputCollector

java.lang.Object
  extended by backtype.storm.task.OutputCollector
All Implemented Interfaces:
IOutputCollector

public class OutputCollector
extends java.lang.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 Summary
OutputCollector(IOutputCollector delegate)
           
 
Method Summary
 void ack(Tuple input)
           
 java.util.List<java.lang.Integer> emit(java.util.Collection<Tuple> anchors, java.util.List<java.lang.Object> tuple)
          Emits a new tuple to the default stream anchored on a group of input tuples.
 java.util.List<java.lang.Integer> emit(java.util.List<java.lang.Object> tuple)
          Emits a new unanchored tuple to the default stream.
 java.util.List<java.lang.Integer> emit(java.lang.String streamId, java.util.Collection<Tuple> anchors, java.util.List<java.lang.Object> tuple)
          Returns the task ids that received the tuples.
 java.util.List<java.lang.Integer> emit(java.lang.String streamId, java.util.List<java.lang.Object> tuple)
          Emits a new unanchored tuple to the specified stream.
 java.util.List<java.lang.Integer> emit(java.lang.String streamId, Tuple anchor, java.util.List<java.lang.Object> tuple)
          Emits a new tuple to a specific stream with a single anchor.
 java.util.List<java.lang.Integer> emit(Tuple anchor, java.util.List<java.lang.Object> tuple)
          Emits a new tuple to the default stream anchored on a single tuple.
 void emitDirect(int taskId, java.util.Collection<Tuple> anchors, java.util.List<java.lang.Object> tuple)
          Emits a tuple directly to the specified task id on the default stream.
 void emitDirect(int taskId, java.util.List<java.lang.Object> tuple)
          Emits a tuple directly to the specified task id on the default stream.
 void emitDirect(int taskId, java.lang.String streamId, java.util.Collection<Tuple> anchors, java.util.List<java.lang.Object> tuple)
           
 void emitDirect(int taskId, java.lang.String streamId, java.util.List<java.lang.Object> tuple)
          Emits a tuple directly to the specified task id on the specified stream.
 void emitDirect(int taskId, java.lang.String streamId, Tuple anchor, java.util.List<java.lang.Object> tuple)
          Emits a tuple directly to the specified task id on the specified stream.
 void emitDirect(int taskId, Tuple anchor, java.util.List<java.lang.Object> tuple)
          Emits a tuple directly to the specified task id on the default stream.
 void fail(Tuple input)
           
 void reportError(java.lang.Throwable error)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputCollector

public OutputCollector(IOutputCollector delegate)
Method Detail

emit

public java.util.List<java.lang.Integer> emit(java.lang.String streamId,
                                              Tuple anchor,
                                              java.util.List<java.lang.Object> tuple)
Emits a new tuple to a specific stream with a single anchor. The emitted values must be immutable.

Parameters:
streamId - the stream to emit to
anchor - the tuple to anchor to
tuple - the new output tuple from this bolt
Returns:
the list of task ids that this new tuple was sent to

emit

public java.util.List<java.lang.Integer> emit(java.lang.String streamId,
                                              java.util.List<java.lang.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.

Parameters:
streamId - the stream to emit to
tuple - the new output tuple from this bolt
Returns:
the list of task ids that this new tuple was sent to

emit

public java.util.List<java.lang.Integer> emit(java.util.Collection<Tuple> anchors,
                                              java.util.List<java.lang.Object> tuple)
Emits a new tuple to the default stream anchored on a group of input tuples. The emitted values must be immutable.

Parameters:
anchors - the tuples to anchor to
tuple - the new output tuple from this bolt
Returns:
the list of task ids that this new tuple was sent to

emit

public java.util.List<java.lang.Integer> emit(Tuple anchor,
                                              java.util.List<java.lang.Object> tuple)
Emits a new tuple to the default stream anchored on a single tuple. The emitted values must be immutable.

Parameters:
anchor - the tuple to anchor to
tuple - the new output tuple from this bolt
Returns:
the list of task ids that this new tuple was sent to

emit

public java.util.List<java.lang.Integer> emit(java.util.List<java.lang.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.

Parameters:
tuple - the new output tuple from this bolt
Returns:
the list of task ids that this new tuple was sent to

emitDirect

public void emitDirect(int taskId,
                       java.lang.String streamId,
                       Tuple anchor,
                       java.util.List<java.lang.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.

Parameters:
taskId - the taskId to send the new tuple to
streamId - the stream to send the tuple on. It must be declared as a direct stream in the topology definition.
anchor - the tuple to anchor to
tuple - the new output tuple from this bolt

emitDirect

public void emitDirect(int taskId,
                       java.lang.String streamId,
                       java.util.List<java.lang.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.

Parameters:
taskId - the taskId to send the new tuple to
streamId - 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 bolt

emitDirect

public void emitDirect(int taskId,
                       java.util.Collection<Tuple> anchors,
                       java.util.List<java.lang.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.

Parameters:
taskId - the taskId to send the new tuple to
anchosr - the tuples to anchor to
tuple - the new output tuple from this bolt

emitDirect

public void emitDirect(int taskId,
                       Tuple anchor,
                       java.util.List<java.lang.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.

Parameters:
taskId - the taskId to send the new tuple to
anchor - the tuple to anchor to
tuple - the new output tuple from this bolt

emitDirect

public void emitDirect(int taskId,
                       java.util.List<java.lang.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.

Parameters:
taskId - the taskId to send the new tuple to
tuple - the new output tuple from this bolt

emit

public java.util.List<java.lang.Integer> emit(java.lang.String streamId,
                                              java.util.Collection<Tuple> anchors,
                                              java.util.List<java.lang.Object> tuple)
Description copied from interface: IOutputCollector
Returns the task ids that received the tuples.

Specified by:
emit in interface IOutputCollector

emitDirect

public void emitDirect(int taskId,
                       java.lang.String streamId,
                       java.util.Collection<Tuple> anchors,
                       java.util.List<java.lang.Object> tuple)
Specified by:
emitDirect in interface IOutputCollector

ack

public void ack(Tuple input)
Specified by:
ack in interface IOutputCollector

fail

public void fail(Tuple input)
Specified by:
fail in interface IOutputCollector

reportError

public void reportError(java.lang.Throwable error)
Specified by:
reportError in interface IOutputCollector