public abstract class Container extends Object implements Killable
Represents a container that a worker will run in.
Modifier and Type | Class and Description |
---|---|
static class |
Container.ContainerType |
Modifier and Type | Field and Description |
---|---|
protected LocalAssignment |
_assignment |
protected Map<String,Object> |
_conf |
protected AdvancedFSOps |
_ops |
protected int |
_port |
protected String |
_supervisorId |
protected boolean |
_symlinksDisabled |
protected Map<String,Object> |
_topoConf |
protected String |
_topologyId |
protected Container.ContainerType |
_type |
protected String |
_workerId |
Modifier | Constructor and Description |
---|---|
protected |
Container(Container.ContainerType type,
Map<String,Object> conf,
String supervisorId,
int port,
LocalAssignment assignment,
String workerId,
Map<String,Object> topoConf,
AdvancedFSOps ops)
Create a new Container.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areAllProcessesDead() |
void |
cleanUp()
Clean up the container.
|
void |
cleanUpForRestart()
Clean up the container partly preparing for restart.
|
protected void |
createArtifactsLink()
Create symlink from the containers directory/artifacts to the artifacts directory
|
protected void |
createBlobstoreLinks()
Create symlinks for each of the blobs from the container’s directory to corresponding links in the storm dist directory.
|
protected void |
deleteSavedWorkerUser() |
abstract boolean |
didMainProcessExit() |
void |
forceKill()
Kill the processes in this container violently.
|
protected void |
forceKill(long pid)
Kill a given process
|
protected Set<Long> |
getAllPids() |
protected String |
getRunWorkerAsUser()
Returns the user that the worker process is running as.
|
String |
getWorkerId() |
protected String |
getWorkerUser() |
protected boolean |
isProcessAlive(long pid,
String user)
Is a process alive and running?
|
void |
kill()
Kill the processes in this container nicely.
|
protected void |
kill(long pid)
Kill a given process
|
abstract void |
launch()
Launch the process for the first time PREREQUISITE: setup has run and passed
|
LSWorkerHeartbeat |
readHeartbeat()
Read the Heartbeat for the current container.
|
protected Map<String,Object> |
readTopoConf() |
abstract void |
relaunch()
Restart the processes in this container PREREQUISITE: cleanUpForRestart has run and passed
|
abstract boolean |
runProfiling(ProfileRequest request,
boolean stop)
Run a profiling request
|
protected void |
saveWorkerUser(String user) |
protected void |
setup()
Setup the container to run.
|
String |
toString() |
protected void |
writeLogMetadata(String user)
Write out the file used by the log viewer to allow/reject log access
|
protected String _workerId
protected final String _topologyId
protected final String _supervisorId
protected final int _port
protected final LocalAssignment _assignment
protected final AdvancedFSOps _ops
protected Container.ContainerType _type
protected final boolean _symlinksDisabled
protected Container(Container.ContainerType type, Map<String,Object> conf, String supervisorId, int port, LocalAssignment assignment, String workerId, Map<String,Object> topoConf, AdvancedFSOps ops) throws IOException
Create a new Container.
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.workerId
- the id of the worker to use. Must not be null if doing a partial recovery.topoConf
- the config of the topology (mostly for testing) if null and not a partial recovery the real conf is read.ops
- file system operations (mostly for testing) if null a new one is madeIOException
- on any error.protected Map<String,Object> readTopoConf() throws IOException
IOException
protected void kill(long pid) throws IOException
Kill a given process
pid
- the id of the process to killIOException
protected void forceKill(long pid) throws IOException
Kill a given process
pid
- the id of the process to killIOException
public void kill() throws IOException
Killable
Kill the processes in this container nicely. kill -15 equivalent
kill
in interface Killable
IOException
- on any errorpublic void forceKill() throws IOException
Killable
Kill the processes in this container violently. kill -9 equivalent
forceKill
in interface Killable
IOException
- on any errorpublic LSWorkerHeartbeat readHeartbeat() throws IOException
Read the Heartbeat for the current container.
IOException
- on any errorprotected boolean isProcessAlive(long pid, String user) throws IOException
Is a process alive and running?
pid
- the PID of the running processuser
- the user that is expected to own that processIOException
- on any errorpublic boolean areAllProcessesDead() throws IOException
areAllProcessesDead
in interface Killable
IOException
- on any errorpublic void cleanUp() throws IOException
Killable
Clean up the container. It is not coming back. by default do the same thing as when restarting.
cleanUp
in interface Killable
IOException
- on any errorprotected void setup() throws IOException
Setup the container to run. By default this creates the needed directories/links in the local file system PREREQUISITE: All needed blobs and topology, jars/configs have been downloaded and placed in the appropriate locations
IOException
- on any errorprotected void writeLogMetadata(String user) throws IOException
Write out the file used by the log viewer to allow/reject log access
user
- the user this is going to run asIOException
- on any errorprotected void createArtifactsLink() throws IOException
Create symlink from the containers directory/artifacts to the artifacts directory
IOException
- on any errorprotected void createBlobstoreLinks() throws IOException
Create symlinks for each of the blobs from the container’s directory to corresponding links in the storm dist directory.
IOException
- on any error.protected Set<Long> getAllPids() throws IOException
IOException
protected String getWorkerUser() throws IOException
IOException
- on any errorprotected String getRunWorkerAsUser()
Returns the user that the worker process is running as.
The default behavior is to launch the worker as the user supervisor is running as (e.g. ‘storm’)
protected void saveWorkerUser(String user) throws IOException
IOException
protected void deleteSavedWorkerUser() throws IOException
IOException
public void cleanUpForRestart() throws IOException
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
IOException
- on any errorpublic abstract void launch() throws IOException
Launch the process for the first time PREREQUISITE: setup has run and passed
IOException
- on any errorpublic abstract void relaunch() throws IOException
Restart the processes in this container PREREQUISITE: cleanUpForRestart has run and passed
IOException
- on any errorpublic abstract boolean didMainProcessExit()
public abstract boolean runProfiling(ProfileRequest request, boolean stop) throws IOException, InterruptedException
Run a profiling request
request
- the request to runstop
- is this a stop request?IOException
- on any errorInterruptedException
- if running the command is interrupted.public String getWorkerId()
Copyright © 2022 The Apache Software Foundation. All Rights Reserved.