Class BasicContainer
java.lang.Object
org.apache.storm.daemon.supervisor.Container
org.apache.storm.daemon.supervisor.BasicContainer
- All Implemented Interfaces:
- Killable
A container that runs processes on the local box.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.storm.daemon.supervisor.ContainerContainer.ContainerType
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanprotected final doubleprotected final longprotected final LocalStateprotected final longprotected final longprotected final longprotected longprotected longprotected final Stringprotected final StringFields inherited from class org.apache.storm.daemon.supervisor.Containerassignment, conf, containerMemoryTracker, ops, port, resourceIsolationManager, runAsUser, supervisorId, supervisorPort, symlinksDisabled, topoConf, topologyId, type, workerId
- 
Constructor SummaryConstructorsConstructorDescriptionBasicContainer(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) Create a new BasicContainer.
- 
Method SummaryModifier and TypeMethodDescriptionvoidClean up the container partly preparing for restart.protected voidCreate a new worker ID for this process and store in in this object and in the local state.booleanReturn true if the main process exited, else false.frameworkClasspath(SimpleVersion topoVersion) getDependencyLocationsFor(Map<String, Object> conf, String topologyId, AdvancedFSOps ops, String stormRoot) longGet the current memory reservation of this container.longGet the current memory usage of this container.static StringgetStormVersionFor(Map<String, Object> conf, String topologyId, AdvancedFSOps ops, String stormRoot) protected StringgetWildcardDir(File dir) Returns a path with a wildcard as the final element, so that the JVM will expand that to all JARs in the directory.protected StringgetWorkerClassPath(String stormJar, List<String> dependencyLocations, SimpleVersion topoVersion) Compute the classpath for the worker process.protected StringgetWorkerLogWriter(SimpleVersion topoVersion) protected StringgetWorkerMain(SimpleVersion topoVersion) booleanisMemoryLimitViolated(LocalAssignment withUpdatedLimits) Check if the container is over its memory limit AND needs to be killed.protected Stringprotected StringjavaLibraryPath(String stormRoot, Map<String, Object> conf) Compute the java.library.path that should be used for the worker.voidlaunch()Launch the process for the first time.voidrelaunch()Restart the processes in this container.booleanrunProfiling(ProfileRequest request, boolean stop) Run a profiling request.substituteChildopts(Object value) substituteChildopts(Object value, int memOnheap, int memOffHeap) Methods inherited from class org.apache.storm.daemon.supervisor.ContainerareAllProcessesDead, cleanUp, createArtifactsLink, createBlobstoreLinks, deleteSavedWorkerUser, forceKill, getTotalTopologyMemoryReserved, getTotalTopologyMemoryUsed, getTotalWorkersForThisTopology, getWorkerId, getWorkerUser, kill, readHeartbeat, readTopoConf, saveWorkerUser, setup, toString, updateMemoryAccounting, writeLogMetadata
- 
Field Details- 
localState
- 
profileCmd
- 
stormHome
- 
hardMemoryLimitMultiplierprotected final double hardMemoryLimitMultiplier
- 
hardMemoryLimitOverprotected final long hardMemoryLimitOver
- 
lowMemoryThresholdMbprotected final long lowMemoryThresholdMb
- 
mediumMemoryThresholdMbprotected final long mediumMemoryThresholdMb
- 
mediumMemoryGracePeriodMsprotected final long mediumMemoryGracePeriodMs
- 
exitedEarlyprotected volatile boolean exitedEarly
- 
memoryLimitMbprotected volatile long memoryLimitMb
- 
memoryLimitExceededStartprotected volatile long memoryLimitExceededStart
 
- 
- 
Constructor Details- 
BasicContainerpublic BasicContainer(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 IOExceptionCreate a new BasicContainer.- Parameters:
- type- the type of container being made.
- conf- the supervisor config
- supervisorId- the ID of the supervisor this is a part of.
- supervisorPort- the thrift server port of the supervisor this is a part of.
- port- the port the container is on. Should be <= 0 if only a partial recovery
- assignment- the assignment for this container. Should be null if only a partial recovery.
- resourceIsolationManager- used to isolate resources for a container can be null if no isolation is used.
- localState- the local state of the supervisor. May be null if partial recovery
- workerId- the id of the worker to use. Must not be null if doing a partial recovery.
- metricsRegistry- The metrics registry.
- containerMemoryTracker- The shared memory tracker for the supervisor's containers
- Throws:
- IOException
 
 
- 
- 
Method Details- 
getDependencyLocationsForpublic static List<String> getDependencyLocationsFor(Map<String, Object> conf, String topologyId, AdvancedFSOps ops, String stormRoot) throws IOException- Throws:
- IOException
 
- 
getStormVersionForpublic static String getStormVersionFor(Map<String, Object> conf, String topologyId, AdvancedFSOps ops, String stormRoot) throws IOException- Throws:
- IOException
 
- 
createNewWorkerIdprotected void createNewWorkerId()Create a new worker ID for this process and store in in this object and in the local state. Never call this if a worker is currently up and running. We will lose track of the process.
- 
cleanUpForRestartDescription copied from class:ContainerClean up the container partly preparing for restart. By default delete all of the temp directories we are going to get a new worker_id anyways. POST CONDITION: the workerId will be set to null- Overrides:
- cleanUpForRestartin class- Container
- Throws:
- IOException- on any error
 
- 
relaunchDescription copied from class:ContainerRestart the processes in this container. PREREQUISITE: cleanUpForRestart has run and passed- Specified by:
- relaunchin class- Container
- Throws:
- IOException- on any error
 
- 
didMainProcessExitpublic boolean didMainProcessExit()Description copied from class:ContainerReturn true if the main process exited, else false. This is just best effort return false if unknown.- Specified by:
- didMainProcessExitin class- Container
 
- 
runProfilingpublic boolean runProfiling(ProfileRequest request, boolean stop) throws IOException, InterruptedException Description copied from class:ContainerRun a profiling request.- Specified by:
- runProfilingin class- Container
- Parameters:
- request- the request to run
- stop- is this a stop request?
- Returns:
- true if it succeeded, else false
- Throws:
- IOException- on any error
- InterruptedException- if running the command is interrupted.
 
- 
javaLibraryPathCompute the java.library.path that should be used for the worker. This helps it to load JNI libraries that are packaged in the uber jar.- Parameters:
- stormRoot- the root directory of the worker process
- conf- the config for the supervisor.
- Returns:
- the java.library.path/LD_LIBRARY_PATH to use so native libraries load correctly.
 
- 
getWildcardDirReturns a path with a wildcard as the final element, so that the JVM will expand that to all JARs in the directory.- Parameters:
- dir- the directory to which a wildcard will be appended
- Returns:
- the path with wildcard ("*") suffix
 
- 
frameworkClasspath
- 
getWorkerMain
- 
getWorkerLogWriter
- 
getWorkerClassPathprotected String getWorkerClassPath(String stormJar, List<String> dependencyLocations, SimpleVersion topoVersion) Compute the classpath for the worker process.- Parameters:
- stormJar- the topology jar
- dependencyLocations- any dependencies from the topology
- topoVersion- the version of the storm framework to use
- Returns:
- the full classpath
 
- 
substituteChildopts
- 
substituteChildopts
- 
javaCmd
- 
isMemoryLimitViolatedDescription copied from class:ContainerCheck if the container is over its memory limit AND needs to be killed. This does not necessarily mean that it just went over the limit.- Overrides:
- isMemoryLimitViolatedin class- Container
- Throws:
- IOException- on any error
 
- 
getMemoryUsageMbpublic long getMemoryUsageMb()Description copied from class:ContainerGet the current memory usage of this container.- Overrides:
- getMemoryUsageMbin class- Container
 
- 
getMemoryReservationMbpublic long getMemoryReservationMb()Description copied from class:ContainerGet the current memory reservation of this container.- Overrides:
- getMemoryReservationMbin class- Container
 
- 
launchDescription copied from class:ContainerLaunch the process for the first time. PREREQUISITE: setup has run and passed- Specified by:
- launchin class- Container
- Throws:
- IOException- on any error
 
 
-