use of com.twitter.heron.api.topology.IStatefulComponent in project incubator-heron by apache.
the class SpoutInstance method init.
@SuppressWarnings("unchecked")
@Override
public void init(State<Serializable, Serializable> state) {
TopologyContextImpl topologyContext = helper.getTopologyContext();
// Initialize the GlobalMetrics
GlobalMetrics.init(topologyContext, systemConfig.getHeronMetricsExportInterval());
spoutMetrics.registerMetrics(topologyContext);
// Initialize the instanceState if the spout is stateful
if (spout instanceof IStatefulComponent) {
this.instanceState = state;
((IStatefulComponent<Serializable, Serializable>) spout).initState(instanceState);
}
spout.open(topologyContext.getTopologyConfig(), topologyContext, new SpoutOutputCollector(collector));
// Invoke user-defined prepare task hook
topologyContext.invokeHookPrepare();
// Init the CustomStreamGrouping
helper.prepareForCustomStreamGrouping();
}
use of com.twitter.heron.api.topology.IStatefulComponent in project incubator-heron by apache.
the class BoltInstance method init.
@SuppressWarnings("unchecked")
@Override
public void init(State<Serializable, Serializable> state) {
TopologyContextImpl topologyContext = helper.getTopologyContext();
// Initialize the GlobalMetrics
GlobalMetrics.init(topologyContext, systemConfig.getHeronMetricsExportInterval());
boltMetrics.registerMetrics(topologyContext);
// Initialize the instanceState if the bolt is stateful
if (bolt instanceof IStatefulComponent) {
this.instanceState = state;
((IStatefulComponent<Serializable, Serializable>) bolt).initState(instanceState);
}
// Delegate
bolt.prepare(topologyContext.getTopologyConfig(), topologyContext, new OutputCollector(collector));
// Invoke user-defined prepare task hook
topologyContext.invokeHookPrepare();
// Init the CustomStreamGrouping
helper.prepareForCustomStreamGrouping();
}
Aggregations