Package org.apache.storm.task
Class WorkerTopologyContext
java.lang.Object
org.apache.storm.task.GeneralTopologyContext
org.apache.storm.task.WorkerTopologyContext
- All Implemented Interfaces:
org.apache.storm.shade.net.minidev.json.JSONAware
- Direct Known Subclasses:
TopologyContext
,WorkerUserContext
-
Field Summary
Fields inherited from class org.apache.storm.task.GeneralTopologyContext
doSanityCheck, topoConf
-
Constructor Summary
ConstructorDescriptionWorkerTopologyContext
(StormTopology topology, Map<String, Object> topoConf, Map<Integer, String> taskToComponent, Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String stormId, String codeDir, String pidDir, Integer workerPort, List<Integer> workerTasks, Map<String, Object> defaultResources, Map<String, Object> userResources) WorkerTopologyContext
(StormTopology topology, Map<String, Object> topoConf, Map<Integer, String> taskToComponent, Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String stormId, String codeDir, String pidDir, Integer workerPort, List<Integer> workerTasks, Map<String, Object> defaultResources, Map<String, Object> userResources, AtomicReference<Map<Integer, NodeInfo>> taskToNodePort, String assignmentId, AtomicReference<Map<String, String>> nodeToHost) -
Method Summary
Modifier and TypeMethodDescriptionGets the location of the external resources for this worker on the local filesystem.Get a map from nodeId to hostname.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.getResource
(String name) Fetches the worker-level data for the given name.Get a map from task Id to NodePort.Gets all the task ids that are running in this worker process (including the task for this task).Methods inherited from class org.apache.storm.task.GeneralTopologyContext
doSanityCheck, getComponentCommon, getComponentId, getComponentIds, getComponentOutputFields, getComponentOutputFields, getComponentStreams, getComponentTasks, getConf, getRawTopology, getSources, getStormId, getTargets, getTaskToComponent, maxTopologyMessageTimeout, toJSONString
-
Field Details
-
SHARED_EXECUTOR
- See Also:
-
-
Constructor Details
-
WorkerTopologyContext
public WorkerTopologyContext(StormTopology topology, Map<String, Object> topoConf, Map<Integer, String> taskToComponent, Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String stormId, String codeDir, String pidDir, Integer workerPort, List<Integer> workerTasks, Map<String, Object> defaultResources, Map<String, Object> userResources, AtomicReference<Map<Integer, NodeInfo>> taskToNodePort, String assignmentId, AtomicReference<Map<String, String>> nodeToHost) -
WorkerTopologyContext
public WorkerTopologyContext(StormTopology topology, Map<String, Object> topoConf, Map<Integer, String> taskToComponent, Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String stormId, String codeDir, String pidDir, Integer workerPort, List<Integer> workerTasks, Map<String, Object> defaultResources, Map<String, Object> userResources)
-
-
Method Details
-
getThisWorkerTasks
Gets all the task ids that are running in this worker process (including the task for this task). -
getThisWorkerPort
-
getAssignmentId
-
getTaskToNodePort
Get a map from task Id to NodePort.- Returns:
- a map from task To NodePort
-
getNodeToHost
Get a map from nodeId to hostname.- Returns:
- a map from nodeId to hostname
-
getCodeDir
Gets the location of the external resources for this worker on the local filesystem. These external resources typically include bolts implemented in other languages, such as Ruby or Python. -
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. -
getResource
Fetches the worker-level data for the given name. The corresponding data needs to be first set in an implementation ofIWorkerHook.start(Map, WorkerUserContext)
viaWorkerUserContext.setResource(String, Object)
- Parameters:
name
- name of the worker-level data to be fetched- Returns:
- Associated worker-level data
-