Package org.apache.heron.api.bolt
Class WindowedBoltExecutor
- java.lang.Object
-
- org.apache.heron.api.bolt.WindowedBoltExecutor
-
- All Implemented Interfaces:
Serializable,IBolt,IRichBolt,IComponent,IStatefulComponent<Serializable,Serializable>
- Direct Known Subclasses:
StatefulWindowedBoltExecutor
public class WindowedBoltExecutor extends Object implements IRichBolt, IStatefulComponent<Serializable,Serializable>
AnIWindowedBoltwrapper that does the windowing of tuples.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringLATE_TUPLE_FIELDprotected WaterMarkEventGenerator<Tuple>waterMarkEventGenerator
-
Constructor Summary
Constructors Constructor Description WindowedBoltExecutor(IWindowedBolt bolt)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidboltExecute(List<Tuple> tuples, List<Tuple> newTuples, List<Tuple> expiredTuples, Long timestamp)voidcleanup()Called when an IBolt is going to be shutdown.voiddeclareOutputFields(OutputFieldsDeclarer declarer)Declare the output schema for all the streams of this topology.protected voiddoPrepare(Map<String,Object> topoConf, TopologyContext context, OutputCollector collector, Collection<Event<Tuple>> queue)voidexecute(Tuple input)Process a single tuple of input.Map<String,Object>getComponentConfiguration()Declare configuration specific to this component.protected Map<String,Serializable>getState()protected intgetTopologyTimeoutMillis(Map<String,Object> topoConf)voidinitState(State<Serializable,Serializable> state)Initializes the state of the function or operator to that of a previous checkpoint.protected WindowLifecycleListener<Tuple>newWindowLifecycleListener()voidprepare(Map<String,Object> topoConf, TopologyContext context, OutputCollector collector)Called when a task for this component is initialized within a worker on the cluster.voidpreSave(String checkpointId)This is a hook for the component to perform some actions just before the framework saves its state.protected voidstart()Start the trigger policy and waterMarkEventGenerator if setprotected voidvalidate(Map<String,Object> topoConf, BaseWindowedBolt.Count windowLengthCount, Long windowLengthDuration, BaseWindowedBolt.Count slidingIntervalCount, Long slidingIntervalDuration)
-
-
-
Field Detail
-
LATE_TUPLE_FIELD
public static final String LATE_TUPLE_FIELD
- See Also:
- Constant Field Values
-
waterMarkEventGenerator
protected transient WaterMarkEventGenerator<Tuple> waterMarkEventGenerator
-
-
Constructor Detail
-
WindowedBoltExecutor
public WindowedBoltExecutor(IWindowedBolt bolt)
-
-
Method Detail
-
validate
protected void validate(Map<String,Object> topoConf, BaseWindowedBolt.Count windowLengthCount, Long windowLengthDuration, BaseWindowedBolt.Count slidingIntervalCount, Long slidingIntervalDuration)
-
getState
protected Map<String,Serializable> getState()
-
start
protected void start()
Start the trigger policy and waterMarkEventGenerator if set
-
prepare
public void prepare(Map<String,Object> topoConf, TopologyContext context, OutputCollector collector)
Description copied from interface:IBoltCalled when a task for this component is initialized within a worker on the cluster. It provides the bolt with the environment in which the bolt executes.This includes the:
- Specified by:
preparein interfaceIBolt- Parameters:
topoConf- The Heron configuration for this bolt. This is the configuration provided to the topology merged in with cluster configuration on this machine.context- This object can be used to get information about this task's place within the topology, including the task id and component id of this task, input and output information, etc.collector- The collector is used to emit tuples from this bolt. Tuples can be emitted at any time, including the prepare and cleanup methods. The collector is thread-safe and should be saved as an instance variable of this bolt object.
-
doPrepare
protected void doPrepare(Map<String,Object> topoConf, TopologyContext context, OutputCollector collector, Collection<Event<Tuple>> queue)
-
execute
public void execute(Tuple input)
Description copied from interface:IBoltProcess a single tuple of input. The Tuple object contains metadata on it about which component/stream/task it came from. The values of the Tuple can be accessed using Tuple#getValue. The IBolt does not have to process the Tuple immediately. It is perfectly fine to hang onto a tuple and process it later (for instance, to do an aggregation or join).Tuples should be emitted using the OutputCollector provided through the prepare method. It is required that all input tuples are acked or failed at some point using the OutputCollector. Otherwise, Heron will be unable to determine when tuples coming off the spouts have been completed.
For the common case of acking an input tuple at the end of the execute method, see IBasicBolt which automates this.
-
cleanup
public void cleanup()
Description copied from interface:IBoltCalled when an IBolt is going to be shutdown. There is no guarentee that cleanup will be called, because the supervisor kill -9's worker processes on the cluster.The one context where cleanup is guaranteed to be called is when a topology is killed when running Heron in simulator.
-
declareOutputFields
public void declareOutputFields(OutputFieldsDeclarer declarer)
Description copied from interface:IComponentDeclare the output schema for all the streams of this topology.- Specified by:
declareOutputFieldsin interfaceIComponent- Parameters:
declarer- this is used to declare output stream ids, output fields, and whether or not each output stream is a direct stream
-
getComponentConfiguration
public Map<String,Object> getComponentConfiguration()
Description copied from interface:IComponentDeclare configuration specific to this component. Only a subset of the "topology.*" configs can be overridden. The component configuration can be further overridden when constructing the topology usingTopologyBuilder- Specified by:
getComponentConfigurationin interfaceIComponent
-
newWindowLifecycleListener
protected WindowLifecycleListener<Tuple> newWindowLifecycleListener()
-
boltExecute
protected void boltExecute(List<Tuple> tuples, List<Tuple> newTuples, List<Tuple> expiredTuples, Long timestamp)
-
initState
public void initState(State<Serializable,Serializable> state)
Description copied from interface:IStatefulComponentInitializes the state of the function or operator to that of a previous checkpoint. This method is invoked when a component is executed as part of a recovery run. In case there was prior state associated with the component, the state will be empty. Stateful Spouts/Bolts are expected to hold on to the state variable to save their internal stateNote that initialState() is called before open() or prepare().
- Specified by:
initStatein interfaceIStatefulComponent<Serializable,Serializable>- Parameters:
state- the previously saved state of the component.
-
preSave
public void preSave(String checkpointId)
Description copied from interface:IStatefulComponentThis is a hook for the component to perform some actions just before the framework saves its state.- Specified by:
preSavein interfaceIStatefulComponent<Serializable,Serializable>- Parameters:
checkpointId- the ID of the checkpoint
-
-