Class StreamletSource
- java.lang.Object
-
- org.apache.heron.api.topology.BaseComponent
-
- org.apache.heron.api.spout.BaseRichSpout
-
- org.apache.heron.streamlet.impl.sources.StreamletSource
-
- All Implemented Interfaces:
Serializable
,IRichSpout
,ISpout
,IComponent
,IStatefulComponent<Serializable,Serializable>
- Direct Known Subclasses:
ComplexSource
,SupplierSource
public abstract class StreamletSource extends BaseRichSpout implements IStatefulComponent<Serializable,Serializable>
StreamletSource is the base class for all streamlet sources. The only common stuff amongst all of them is the output streams- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SpoutOutputCollector
collector
-
Constructor Summary
Constructors Constructor Description StreamletSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer)
The sources implementing streamlet functionality have some properties.void
initState(State<Serializable,Serializable> state)
Initializes the state of the function or operator to that of a previous checkpoint.void
open(Map<String,Object> map, TopologyContext topologyContext, SpoutOutputCollector outputCollector)
Called when a task for this component is initialized within a worker on the cluster.void
preSave(String checkpointId)
This is a hook for the component to perform some actions just before the framework saves its state.-
Methods inherited from class org.apache.heron.api.spout.BaseRichSpout
ack, activate, close, deactivate, fail
-
Methods inherited from class org.apache.heron.api.topology.BaseComponent
getComponentConfiguration
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.heron.api.topology.IComponent
getComponentConfiguration
-
-
-
-
Field Detail
-
collector
protected SpoutOutputCollector collector
-
-
Method Detail
-
initState
public void initState(State<Serializable,Serializable> state)
Description copied from interface:IStatefulComponent
Initializes 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:
initState
in interfaceIStatefulComponent<Serializable,Serializable>
- Parameters:
state
- the previously saved state of the component.
-
preSave
public void preSave(String checkpointId)
Description copied from interface:IStatefulComponent
This is a hook for the component to perform some actions just before the framework saves its state.- Specified by:
preSave
in interfaceIStatefulComponent<Serializable,Serializable>
- Parameters:
checkpointId
- the ID of the checkpoint
-
open
public void open(Map<String,Object> map, TopologyContext topologyContext, SpoutOutputCollector outputCollector)
Description copied from interface:ISpout
Called when a task for this component is initialized within a worker on the cluster. It provides the spout with the environment in which the spout executes.This includes the:
- Specified by:
open
in interfaceISpout
- Parameters:
map
- The Heron configuration for this spout. This is the configuration provided to the topology merged in with cluster configuration on this machine.topologyContext
- 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.outputCollector
- The collector is used to emit tuples from this spout. Tuples can be emitted at any time, including the open and close methods. The collector is thread-safe and should be saved as an instance variable of this spout object.
-
declareOutputFields
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer)
The sources implementing streamlet functionality have some properties. 1. They all output only one stream 2. All streamlet operators should be able to consume their output This imply that the output stream should be named same for all of them.- Specified by:
declareOutputFields
in interfaceIComponent
- Parameters:
outputFieldsDeclarer
- this is used to declare output stream ids, output fields, and whether or not each output stream is a direct stream
-
-