public class BasicContainer extends Container
A container that runs processes on the local box.
Container.ContainerType
Modifier and Type | Field and Description |
---|---|
protected boolean |
_exitedEarly |
protected LocalState |
_localState |
protected String |
_profileCmd |
protected String |
_stormHome |
_assignment, _conf, _ops, _port, _supervisorId, _symlinksDisabled, _topoConf, _topologyId, _type, _workerId
Constructor and Description |
---|
BasicContainer(Container.ContainerType type,
Map<String,Object> conf,
String supervisorId,
int port,
LocalAssignment assignment,
LocalState localState,
String workerId)
Create a new BasicContainer
|
Modifier and Type | Method and Description |
---|---|
void |
cleanUpForRestart()
Clean up the container partly preparing for restart.
|
protected void |
createNewWorkerId()
Create a new worker ID for this process and store in in this object and in the local state.
|
boolean |
didMainProcessExit() |
protected List<String> |
frameworkClasspath() |
static List<String> |
getDependencyLocationsFor(Map<String,Object> conf,
String topologyId,
AdvancedFSOps ops,
String stormRoot) |
protected String |
getWildcardDir(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 String |
getWorkerClassPath(String stormJar,
List<String> dependencyLocations)
Compute the classpath for the worker process
|
protected String |
javaCmd(String cmd) |
protected String |
javaLibraryPath(String stormRoot,
Map<String,Object> conf)
Compute the java.library.path that should be used for the worker.
|
void |
launch()
Launch the process for the first time PREREQUISITE: setup has run and passed
|
protected void |
launchWorkerProcess(List<String> command,
Map<String,String> env,
String logPrefix,
ExitCodeCallback processExitCallback,
File targetDir)
Launch the worker process (non-blocking)
|
void |
relaunch()
Restart the processes in this container PREREQUISITE: cleanUpForRestart has run and passed
|
boolean |
runProfiling(ProfileRequest request,
boolean stop)
Run a profiling request
|
protected boolean |
runProfilingCommand(List<String> command,
Map<String,String> env,
String logPrefix,
File targetDir)
Run the given command for profiling
|
protected List<String> |
substituteChildopts(Object value) |
protected List<String> |
substituteChildopts(Object value,
int memOnheap) |
areAllProcessesDead, cleanUp, createArtifactsLink, createBlobstoreLinks, deleteSavedWorkerUser, forceKill, forceKill, getAllPids, getRunWorkerAsUser, getWorkerId, getWorkerUser, isProcessAlive, kill, kill, readHeartbeat, readTopoConf, saveWorkerUser, setup, toString, writeLogMetadata
protected final LocalState _localState
protected final String _profileCmd
protected final String _stormHome
protected volatile boolean _exitedEarly
public BasicContainer(Container.ContainerType type, Map<String,Object> conf, String supervisorId, int port, LocalAssignment assignment, LocalState localState, String workerId) throws IOException
Create a new BasicContainer
type
- the type of container being made.conf
- the supervisor configsupervisorId
- the ID of the supervisor this is a part of.port
- the port the container is on. Should be <= 0 if only a partial recoveryassignment
- the assignment for this container. Should be null if only a partial recovery.localState
- the local state of the supervisor. May be null if partial recoveryworkerId
- the id of the worker to use. Must not be null if doing a partial recovery.IOException
protected 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.
public void cleanUpForRestart() throws IOException
Container
Clean 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
cleanUpForRestart
in class Container
IOException
- on any errorpublic void relaunch() throws IOException
Container
Restart the processes in this container PREREQUISITE: cleanUpForRestart has run and passed
relaunch
in class Container
IOException
- on any errorpublic boolean didMainProcessExit()
didMainProcessExit
in class Container
protected boolean runProfilingCommand(List<String> command, Map<String,String> env, String logPrefix, File targetDir) throws IOException, InterruptedException
Run the given command for profiling
command
- the command to runenv
- the environment to run the commandlogPrefix
- the prefix to include in the logstargetDir
- the working directory to run the command inIOException
- on any errorInterruptedException
- if interrupted wile waiting for the process to exit.public boolean runProfiling(ProfileRequest request, boolean stop) throws IOException, InterruptedException
Container
Run a profiling request
runProfiling
in class Container
request
- the request to runstop
- is this a stop request?IOException
- on any errorInterruptedException
- if running the command is interrupted.protected String javaLibraryPath(String stormRoot, Map<String,Object> conf)
Compute 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.
stormRoot
- the root directory of the worker processconf
- the config for the supervisor.protected String getWildcardDir(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.
dir
- the directory to which a wildcard will be appendedprotected String getWorkerClassPath(String stormJar, List<String> dependencyLocations)
Compute the classpath for the worker process
stormJar
- the topology jardependencyLocations
- any dependencies from the topologyprotected void launchWorkerProcess(List<String> command, Map<String,String> env, String logPrefix, ExitCodeCallback processExitCallback, File targetDir) throws IOException
Launch the worker process (non-blocking)
command
- the command to runenv
- the environment to run the commandprocessExitcallback
- a callback for when the process exitslogPrefix
- the prefix to include in the logstargetDir
- the working directory to run the command inIOException
- on any errorpublic static List<String> getDependencyLocationsFor(Map<String,Object> conf, String topologyId, AdvancedFSOps ops, String stormRoot) throws IOException
IOException
public void launch() throws IOException
Container
Launch the process for the first time PREREQUISITE: setup has run and passed
launch
in class Container
IOException
- on any errorCopyright © 2019 The Apache Software Foundation. All Rights Reserved.