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.org.json.simple.JSONAware
  Direct Known Subclasses:
    TopologyContext

      public class WorkerTopologyContext
      extends GeneralTopologyContext

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SHARED_EXECUTOR`

    - ### Fields inherited from class org.apache.storm.task.GeneralTopologyContext

      `doSanityCheck, topoConf`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `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)`
    `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)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getCodeDir()` Gets the location of the external resources for this worker on the local filesystem.
    `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.
    `Object` | `getResource(String name)`
    `ExecutorService` | `getSharedExecutor()`
    `AtomicReference<Map<Integer,NodeInfo>>` | `getTaskToNodePort()` Get a map from task Id to NodePort.
    `String` | `getThisWorkerHost()`
    `Integer` | `getThisWorkerPort()`
    `List<Integer>` | `getThisWorkerTasks()` 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SHARED_EXECUTOR

          public static final String SHARED_EXECUTOR

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### 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)

    - #### 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 Detail

    - #### getThisWorkerTasks

          public List<Integer> getThisWorkerTasks()

      Gets all the task ids that are running in this worker process (including the task for this task).

    - #### getThisWorkerPort

          public Integer getThisWorkerPort()

    - #### getThisWorkerHost

          public String getThisWorkerHost()

    - #### getTaskToNodePort

          public AtomicReference<Map<Integer,NodeInfo>> getTaskToNodePort()

      Get a map from task Id to NodePort.

      Returns:
        a map from task To NodePort

    - #### getCodeDir

          public String 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

          public 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.

    - #### getResource

          public Object getResource(String name)

    - #### getSharedExecutor

          public ExecutorService getSharedExecutor()

Copyright © 2019 The Apache Software Foundation. All rights reserved.