public class DockerManager extends OciContainerManager
For security, we can launch worker processes inside the docker container. This class manages the interaction with docker containers including launching, stopping, profiling and etc.
OciContainerManager.CmdTypecgroupParent, cgroupRootPath, conf, memoryCgroupRootPath, memoryCoreAtRoot, nscdPath, readonlyBindmounts, readwriteBindmounts, seccompJsonFile, stormHome, TMP_DIR, validatedNumaMap, workerToCores, workerToCpu, workerToMemoryMb, workerToMemoryZone| Constructor and Description |
|---|
DockerManager() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areAllProcessesDead(String user,
String workerId)
Currently it only checks if the container is alive.
|
void |
cleanup(String user,
String workerId,
int port)
This function will be called when the worker needs to shutdown.
|
void |
forceKill(String user,
String workerId)
Kill the given worker forcefully.
|
long |
getMemoryUsage(String user,
String workerId,
int port)
Get the current memory usage of the a given worker.
|
boolean |
isResourceManaged()
Return true if resources are being managed.
|
void |
kill(String user,
String workerId)
Kill the given worker.
|
void |
launchWorkerProcess(String user,
String topologyId,
Map<String,Object> topoConf,
int port,
String workerId,
List<String> command,
Map<String,String> env,
String logPrefix,
ExitCodeCallback processExitCallback,
File targetDir)
After reserving resources for the worker (i.e.
|
void |
prepare(Map<String,Object> conf)
Called when starting up.
|
boolean |
runProfilingCommand(String user,
String workerId,
List<String> command,
Map<String,String> env,
String logPrefix,
File targetDir)
Run profiling command in the container.
|
commandFilePath, getImageName, getSystemFreeMemoryMb, reserveResourcesForWorker, writeToCommandFilepublic void prepare(Map<String,Object> conf) throws IOException
ResourceIsolationInterfaceCalled when starting up.
prepare in interface ResourceIsolationInterfaceprepare in class OciContainerManagerconf - the cluster configIOException - on any error.public void launchWorkerProcess(String user, String topologyId, Map<String,Object> topoConf, int port, String workerId, List<String> command, Map<String,String> env, String logPrefix, ExitCodeCallback processExitCallback, File targetDir) throws IOException
ResourceIsolationInterfaceAfter reserving resources for the worker (i.e. calling reserveResourcesForWorker), this function can be used to launch worker process.
user - the user who runs the command astopologyId - the Id of the topologytopoConf - the topology configurationport - the port where the worker is onworkerId - the Id of the workercommand - the command to runenv - the environment to run the commandlogPrefix - the prefix to include in the logsprocessExitCallback - a callback for when the process exitstargetDir - the working directory to run the command inIOException - on I/O exceptionpublic long getMemoryUsage(String user, String workerId, int port) throws IOException
ResourceIsolationInterfaceGet the current memory usage of the a given worker.
user - the user that the worker is running asworkerId - the id of the workerport - the port of the workerIOException - on I/O exceptionpublic void kill(String user, String workerId) throws IOException
ResourceIsolationInterfaceKill the given worker.
user - the user that the worker is running asworkerId - the id of the worker to killIOException - on I/O exceptionpublic void forceKill(String user, String workerId) throws IOException
ResourceIsolationInterfaceKill the given worker forcefully.
user - the user that the worker is running asworkerId - the id of the worker to killIOException - on I/O exceptionpublic boolean areAllProcessesDead(String user, String workerId) throws IOException
Currently it only checks if the container is alive. If the worker process inside the container dies, the container will exit. So we only need to check if the container is running to know if the worker process is still alive.
user - the user of the processesworkerId - the id of the worker to killIOException - on I/O exceptionpublic boolean runProfilingCommand(String user, String workerId, List<String> command, Map<String,String> env, String logPrefix, File targetDir) throws IOException, InterruptedException
Run profiling command in the container.
user - the user that the worker is running asworkerId - the id of the workercommand - the command to run. The profiler to be used is configured in worker-launcher.cfg.env - the environment to run the commandlogPrefix - the prefix to include in the logstargetDir - the working directory to run the command inIOException - on I/O exceptionInterruptedException - if interruptedpublic void cleanup(String user, String workerId, int port) throws IOException
ResourceIsolationInterfaceThis function will be called when the worker needs to shutdown. This function should include logic to clean up after a worker is shutdown.
cleanup in interface ResourceIsolationInterfacecleanup in class OciContainerManageruser - the user of the workerworkerId - worker id to shutdown and clean up afterport - the port of the workerIOExceptionpublic boolean isResourceManaged()
ResourceIsolationInterfaceReturn true if resources are being managed. The DefaultResourceIsolationManager will have it return false since it doesn’t really manage resources.
Copyright © 2021 The Apache Software Foundation. All rights reserved.