|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object backtype.storm.task.TopologyContext
public class TopologyContext
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.
The TopologyContext is also used to declare ISubscribedState objects to synchronize state with StateSpouts this object is subscribed to.
Constructor Summary | |
---|---|
TopologyContext(StormTopology topology,
java.util.Map<java.lang.Integer,java.lang.String> taskToComponent,
java.lang.String stormId,
java.lang.String codeDir,
java.lang.String pidDir,
java.lang.Integer taskId)
|
Method Summary | ||
---|---|---|
java.lang.String |
getCodeDir()
Gets the location of the external resources for this worker on the local filesystem. |
|
ComponentCommon |
getComponentCommon(java.lang.String componentId)
|
|
java.lang.String |
getComponentId(int taskId)
Gets the component id for the specified task id. |
|
java.util.Set<java.lang.String> |
getComponentIds()
Gets a list of all component ids in this topology |
|
Fields |
getComponentOutputFields(GlobalStreamId id)
Gets the declared output fields for the specified global stream id. |
|
Fields |
getComponentOutputFields(java.lang.String componentId,
java.lang.String streamId)
Gets the declared output fields for the specified component/stream. |
|
java.util.Set<java.lang.String> |
getComponentStreams(java.lang.String componentId)
Gets the set of streams declared for the specified component. |
|
java.util.List<java.lang.Integer> |
getComponentTasks(java.lang.String componentId)
Gets the task ids allocated for the given component id. |
|
java.lang.String |
getPIDDir()
If this task spawns any subprocesses, those subprocesses must immediately write their PID to this directory on the local filesystem to ensure that Storm properly destroys that process when the worker is shutdown. |
|
StormTopology |
getRawTopology()
Gets the Thrift object representing the topology. |
|
java.util.Map<GlobalStreamId,Grouping> |
getSources(java.lang.String componentId)
Gets the declared inputs to the specified component. |
|
java.lang.String |
getStormId()
Gets the unique id assigned to this topology. |
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,Grouping>> |
getTargets(java.lang.String componentId)
Gets information about who is consuming the outputs of the specified component, and how. |
|
java.lang.Object |
getTaskData()
|
|
java.util.Map<java.lang.Integer,java.lang.String> |
getTaskToComponent()
Gets a map from task id to component id. |
|
java.lang.String |
getThisComponentId()
Gets the component id for this task. |
|
Fields |
getThisOutputFields(java.lang.String streamId)
Gets the declared output fields for the specified stream id for the component this task is a part of. |
|
java.util.Map<GlobalStreamId,Grouping> |
getThisSources()
Gets the declared inputs to this component. |
|
java.util.Set<java.lang.String> |
getThisStreams()
Gets the set of streams declared for the component of this task. |
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,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()). |
|
int |
maxTopologyMessageTimeout(java.util.Map<java.lang.String,java.lang.Object> topologyConfig)
|
|
|
setAllSubscribedState(T obj)
All state from all subscribed state spouts streams will be synced with the provided object. |
|
|
setSubscribedState(java.lang.String componentId,
java.lang.String streamId,
T obj)
Synchronizes the specified stream from the specified state spout component id with the provided ISubscribedState object. |
|
|
setSubscribedState(java.lang.String componentId,
T obj)
Synchronizes the default stream from the specified state spout component id with the provided ISubscribedState object. |
|
void |
setTaskData(java.lang.Object data)
|
|
java.lang.String |
toJSONString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TopologyContext(StormTopology topology, java.util.Map<java.lang.Integer,java.lang.String> taskToComponent, java.lang.String stormId, java.lang.String codeDir, java.lang.String pidDir, java.lang.Integer taskId)
Method Detail |
---|
public <T extends ISubscribedState> T setAllSubscribedState(T obj)
It is recommended that your ISubscribedState object is kept as an instance variable of this object. The recommended usage of this method is as follows:
_myState = context.setAllSubscribedState(new MyState());
obj
- Provided ISubscribedState implementation
public <T extends ISubscribedState> T setSubscribedState(java.lang.String componentId, T obj)
The recommended usage of this method is as follows:
_myState = context.setSubscribedState(componentId, new MyState());
componentId
- the id of the StateSpout component to subscribe toobj
- Provided ISubscribedState implementation
public <T extends ISubscribedState> T setSubscribedState(java.lang.String componentId, java.lang.String streamId, T obj)
The recommended usage of this method is as follows:
_myState = context.setSubscribedState(componentId, streamId, new MyState());
componentId
- the id of the StateSpout component to subscribe tostreamId
- the stream to subscribe toobj
- Provided ISubscribedState implementation
public java.lang.String getStormId()
public int getThisTaskId()
public StormTopology getRawTopology()
public java.lang.String getComponentId(int taskId)
taskId
- the task id
public java.lang.String getThisComponentId()
public Fields getThisOutputFields(java.lang.String streamId)
public java.util.Set<java.lang.String> getThisStreams()
public java.util.Set<java.lang.String> getComponentStreams(java.lang.String componentId)
public java.util.List<java.lang.Integer> getComponentTasks(java.lang.String componentId)
public int getThisTaskIndex()
public Fields getComponentOutputFields(java.lang.String componentId, java.lang.String streamId)
public Fields getComponentOutputFields(GlobalStreamId id)
public java.util.Map<GlobalStreamId,Grouping> getThisSources()
public java.util.Map<GlobalStreamId,Grouping> getSources(java.lang.String componentId)
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,Grouping>> getThisTargets()
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,Grouping>> getTargets(java.lang.String componentId)
public java.lang.String toJSONString()
public java.lang.String getCodeDir()
public java.lang.String getPIDDir()
public java.util.Map<java.lang.Integer,java.lang.String> getTaskToComponent()
public java.util.Set<java.lang.String> getComponentIds()
public ComponentCommon getComponentCommon(java.lang.String componentId)
public void setTaskData(java.lang.Object data)
public java.lang.Object getTaskData()
public int maxTopologyMessageTimeout(java.util.Map<java.lang.String,java.lang.Object> topologyConfig)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |