Package org.apache.heron.api.topology
Interface TopologyContext
-
- All Superinterfaces:
GeneralTopologyContext
,IMetricsRegister
public interface TopologyContext extends GeneralTopologyContext, IMetricsRegister
A TopologyContext is given to bolts and spouts in their "prepare" and "open" methods, respectively. This object provides information about the component's place within the topology, such as task ids, inputs and outputs, etc.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addTaskHook(ITaskHook hook)
Add a Task Hook for this instanceCollection<ITaskHook>
getHooks()
Get the list of all task hooksObject
getTaskData(String name)
String
getThisComponentId()
Gets the component id for this task.Fields
getThisOutputFields(String streamId)
Gets the declared output fields for the specified stream id for the component this task is a part of.Map<org.apache.heron.api.generated.TopologyAPI.StreamId,org.apache.heron.api.generated.TopologyAPI.Grouping>
getThisSources()
Gets the declared inputs to this component.Set<String>
getThisStreams()
Gets the set of streams declared for the component of this task.Map<String,Map<String,org.apache.heron.api.generated.TopologyAPI.Grouping>>
getThisTargets()
Gets information about who is consuming the outputs of this component, and how.int
getThisTaskId()
Gets the task id of this task.int
getThisTaskIndex()
Gets the index of this task id in getComponentTasks(getThisComponentId()).<T> CombinedMetric<T>
registerMetric(String name, ICombiner<T> combiner, int timeBucketSizeInSecs)
<T,U,V>
ReducedMetric<T,U,V>registerMetric(String name, IReducer<T,U,V> reducer, int timeBucketSizeInSecs)
void
setTaskData(String name, Object data)
-
Methods inherited from interface org.apache.heron.api.topology.GeneralTopologyContext
getComponentId, getComponentIds, getComponentOutputFields, getComponentStreams, getComponentTasks, getRawTopology, getSources, getTargets, getTaskToComponent, getTopologyId, maxTopologyMessageTimeout
-
Methods inherited from interface org.apache.heron.api.metric.IMetricsRegister
registerMetric
-
-
-
-
Method Detail
-
getThisTaskId
int getThisTaskId()
Gets the task id of this task.- Returns:
- the task id
-
getThisComponentId
String getThisComponentId()
Gets the component id for this task. The component id maps to a component id specified for a Spout or Bolt in the topology definition.
-
getThisOutputFields
Fields getThisOutputFields(String streamId)
Gets the declared output fields for the specified stream id for the component this task is a part of.
-
getThisStreams
Set<String> getThisStreams()
Gets the set of streams declared for the component of this task.
-
getThisTaskIndex
int getThisTaskIndex()
Gets the index of this task id in getComponentTasks(getThisComponentId()). An example use case for this method is determining which task accesses which resource in a distributed resource to ensure an even distribution.
-
getThisSources
Map<org.apache.heron.api.generated.TopologyAPI.StreamId,org.apache.heron.api.generated.TopologyAPI.Grouping> getThisSources()
Gets the declared inputs to this component.- Returns:
- A map from subscribed component/stream to the grouping subscribed with.
-
getThisTargets
Map<String,Map<String,org.apache.heron.api.generated.TopologyAPI.Grouping>> getThisTargets()
Gets information about who is consuming the outputs of this component, and how.- Returns:
- Map from stream id to component id to the Grouping used.
-
addTaskHook
void addTaskHook(ITaskHook hook)
Add a Task Hook for this instance
-
getHooks
Collection<ITaskHook> getHooks()
Get the list of all task hooks
-
registerMetric
<T,U,V> ReducedMetric<T,U,V> registerMetric(String name, IReducer<T,U,V> reducer, int timeBucketSizeInSecs)
-
registerMetric
<T> CombinedMetric<T> registerMetric(String name, ICombiner<T> combiner, int timeBucketSizeInSecs)
-
-