|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object backtype.storm.task.GeneralTopologyContext 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.
Field Summary |
---|
Fields inherited from class backtype.storm.task.GeneralTopologyContext |
---|
_stormConf |
Constructor Summary | |
---|---|
TopologyContext(StormTopology topology,
java.util.Map stormConf,
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,
java.lang.Integer workerPort,
java.util.List<java.lang.Integer> workerTasks)
|
Method Summary | ||
---|---|---|
void |
addTaskHook(ITaskHook hook)
|
|
java.lang.String |
getCodeDir()
Gets the location of the external resources for this worker on the local filesystem. |
|
java.util.Collection<ITaskHook> |
getHooks()
|
|
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. |
|
java.lang.Object |
getTaskData()
|
|
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()). |
|
java.lang.Integer |
getThisWorkerPort()
|
|
java.util.List<java.lang.Integer> |
getThisWorkerTasks()
Gets all the task ids that are running in this worker process (including the task for this task). |
|
|
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)
|
Methods inherited from class backtype.storm.task.GeneralTopologyContext |
---|
getComponentCommon, getComponentId, getComponentIds, getComponentOutputFields, getComponentOutputFields, getComponentStreams, getComponentTasks, getRawTopology, getSources, getStormId, getTargets, getTaskToComponent, maxTopologyMessageTimeout, 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 stormConf, 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, java.lang.Integer workerPort, java.util.List<java.lang.Integer> workerTasks)
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 int getThisTaskId()
public java.lang.String getThisComponentId()
public java.util.List<java.lang.Integer> getThisWorkerTasks()
public Fields getThisOutputFields(java.lang.String streamId)
public java.util.Set<java.lang.String> getThisStreams()
public int getThisTaskIndex()
public java.util.Map<GlobalStreamId,Grouping> getThisSources()
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,Grouping>> getThisTargets()
public java.lang.String getCodeDir()
public java.lang.String getPIDDir()
public void setTaskData(java.lang.Object data)
public java.lang.Object getTaskData()
public java.lang.Integer getThisWorkerPort()
public void addTaskHook(ITaskHook hook)
public java.util.Collection<ITaskHook> getHooks()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |