org.apache.storm.daemon.supervisor

## Class RunAsUserContainer

- java.lang.Object
- - org.apache.storm.daemon.supervisor.Container
  - - org.apache.storm.daemon.supervisor.BasicContainer
    - - org.apache.storm.daemon.supervisor.RunAsUserContainer

- All Implemented Interfaces:
    Killable

      public class RunAsUserContainer
      extends BasicContainer

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.storm.daemon.supervisor.Container

      `Container.ContainerType`

  - ### Field Summary

    - ### Fields inherited from class org.apache.storm.daemon.supervisor.BasicContainer

      `_exitedEarly, _localState, _profileCmd, _stormHome, hardMemoryLimitMultiplier, hardMemoryLimitOver, lowMemoryThresholdMB, mediumMemoryGracePeriodMs, mediumMemoryThresholdMb, memoryLimitExceededStart, memoryLimitMB`

    - ### Fields inherited from class org.apache.storm.daemon.supervisor.Container

      `_assignment, _conf, _ops, _port, _resourceIsolationManager, _supervisorId, _supervisorPort, _symlinksDisabled, _topoConf, _topologyId, _type, _workerId, containerMemoryTracker`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RunAsUserContainer(Container.ContainerType type, Map<String,Object> conf, String supervisorId, int supervisorPort, int port, LocalAssignment assignment, ResourceIsolationInterface resourceIsolationManager, LocalState localState, String workerId, StormMetricsRegistry metricsRegistry, ContainerMemoryTracker containerMemoryTracker)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `forceKill(long pid)` Kill a given process.
    `protected String` | `getRunWorkerAsUser()` If ‘supervisor.run.worker.as.user’ is set, worker will be launched as the user that launched the topology.
    `protected void` | `kill(long pid)` Kill a given process.
    `protected void` | `launchWorkerProcess(List<String> command, Map<String,String> env, String logPrefix, ExitCodeCallback processExitCallback, File targetDir)` Launch the worker process (non-blocking).
    `protected boolean` | `runProfilingCommand(List<String> command, Map<String,String> env, String logPrefix, File targetDir)` Run the given command for profiling.

    - ### Methods inherited from class org.apache.storm.daemon.supervisor.BasicContainer

      `cleanUpForRestart, createNewWorkerId, didMainProcessExit, frameworkClasspath, getDependencyLocationsFor, getMemoryReservationMb, getMemoryUsageMb, getStormVersionFor, getWildcardDir, getWorkerClassPath, getWorkerLogWriter, getWorkerMain, isMemoryLimitViolated, javaCmd, javaLibraryPath, launch, relaunch, runProfiling, substituteChildopts, substituteChildopts`

    - ### Methods inherited from class org.apache.storm.daemon.supervisor.Container

      `areAllProcessesDead, cleanUp, createArtifactsLink, createBlobstoreLinks, deleteSavedWorkerUser, forceKill, getAllPids, getTotalTopologyMemoryReserved, getTotalTopologyMemoryUsed, getTotalWorkersForThisTopology, getWorkerId, getWorkerUser, isProcessAlive, kill, readHeartbeat, readTopoConf, saveWorkerUser, setup, toString, updateMemoryAccounting, writeLogMetadata`

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

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

- - ### Constructor Detail

    - #### RunAsUserContainer

          public RunAsUserContainer(Container.ContainerType type,
                                    Map<String,Object> conf,
                                    String supervisorId,
                                    int supervisorPort,
                                    int port,
                                    LocalAssignment assignment,
                                    ResourceIsolationInterface resourceIsolationManager,
                                    LocalState localState,
                                    String workerId,
                                    StormMetricsRegistry metricsRegistry,
                                    ContainerMemoryTracker containerMemoryTracker)
                             throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### kill

          protected void kill(long pid)
                       throws IOException

      Description copied from class: `Container`

      Kill a given process.

      Overrides:
        `kill` in class `Container`
      Parameters:
        `pid` - the id of the process to kill
      Throws:
        `IOException`

    - #### forceKill

          protected void forceKill(long pid)
                            throws IOException

      Description copied from class: `Container`

      Kill a given process.

      Overrides:
        `forceKill` in class `Container`
      Parameters:
        `pid` - the id of the process to kill
      Throws:
        `IOException`

    - #### runProfilingCommand

          protected boolean runProfilingCommand(List<String> command,
                                                Map<String,String> env,
                                                String logPrefix,
                                                File targetDir)
                                         throws IOException,
                                                InterruptedException

      Description copied from class: `BasicContainer`

      Run the given command for profiling.

      Overrides:
        `runProfilingCommand` in class `BasicContainer`
      Parameters:
        `command` - the command to run
        `env` - the environment to run the command
        `logPrefix` - the prefix to include in the logs
        `targetDir` - the working directory to run the command in
      Returns:
        true if it ran successfully, else false
      Throws:
        `IOException` - on any error
        `InterruptedException` - if interrupted wile waiting for the process to exit.

    - #### launchWorkerProcess

          protected void launchWorkerProcess(List<String> command,
                                             Map<String,String> env,
                                             String logPrefix,
                                             ExitCodeCallback processExitCallback,
                                             File targetDir)
                                      throws IOException

      Description copied from class: `BasicContainer`

      Launch the worker process (non-blocking).

      Overrides:
        `launchWorkerProcess` in class `BasicContainer`
      Parameters:
        `command` - the command to run
        `env` - the environment to run the command
        `logPrefix` - the prefix to include in the logs
        `processExitCallback` - a callback for when the process exits
        `targetDir` - the working directory to run the command in
      Throws:
        `IOException` - on any error

    - #### getRunWorkerAsUser

          protected String getRunWorkerAsUser()

      If ‘supervisor.run.worker.as.user’ is set, worker will be launched as the user that launched the topology.

      Overrides:
        `getRunWorkerAsUser` in class `Container`
      Returns:
        the user that the worker process is running as.

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