public class CgroupManager extends DefaultResourceIsolationManager
Class that implements ResourceIsolationInterface that manages cgroups.
conf, runAsUser| Constructor and Description |
|---|
CgroupManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup(String user,
String workerId,
int port)
This function will be called when the worker needs to shutdown.
|
protected Set<Long> |
getAllPids(String workerId)
Get all of the pids that are a part of this container.
|
List<String> |
getLaunchCommand(String workerId,
List<String> existingCommand)
To compose launch command based on workerId and existing command.
|
long |
getMemoryUsage(String user,
String workerId,
int port)
Get the current memory usage of the a given worker.
|
long |
getSystemFreeMemoryMb()
Get the amount of free memory in MB.
|
protected static boolean |
isOnLinux()
Extracting out to mock it for tests.
|
boolean |
isResourceManaged()
This class doesn’t really manage resources.
|
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)
initialize data structures.
|
void |
reserveResourcesForWorker(String workerId,
Integer totalMem,
Integer cpuNum,
String numaId)
This function should be used prior to starting the worker to reserve resources for the worker.
|
areAllProcessesDead, forceKill, kill, runProfilingCommandpublic void prepare(Map<String,Object> conf) throws IOException
initialize data structures.
prepare in interface ResourceIsolationInterfaceprepare in class DefaultResourceIsolationManagerconf - storm confsIOException - on any error.public void reserveResourcesForWorker(String workerId, Integer totalMem, Integer cpuNum, String numaId) throws SecurityException
ResourceIsolationInterfaceThis function should be used prior to starting the worker to reserve resources for the worker.
reserveResourcesForWorker in interface ResourceIsolationInterfacereserveResourcesForWorker in class DefaultResourceIsolationManagerworkerId - worker id of the worker to starttotalMem - the amount of memory for the worker or null if not enforcedcpuNum - the amount of cpu for the worker or null if not enforcednumaId - NUMA zone if applicable the worker should be bound toSecurityExceptionpublic 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 DefaultResourceIsolationManageruser - the user of the workerworkerId - worker id to shutdown and clean up afterport - the port of the workerIOExceptionprotected static boolean isOnLinux()
Extracting out to mock it for tests.
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.
launchWorkerProcess in interface ResourceIsolationInterfacelaunchWorkerProcess in class DefaultResourceIsolationManageruser - 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 List<String> getLaunchCommand(String workerId, List<String> existingCommand)
To compose launch command based on workerId and existing command.
workerId - the worker idexistingCommand - the current command to run that may need to be modifiedprotected Set<Long> getAllPids(String workerId) throws IOException
Get all of the pids that are a part of this container.
getAllPids in class DefaultResourceIsolationManagerworkerId - the worker idIOExceptionpublic long getMemoryUsage(String user, String workerId, int port) throws IOException
ResourceIsolationInterfaceGet the current memory usage of the a given worker.
getMemoryUsage in interface ResourceIsolationInterfacegetMemoryUsage in class DefaultResourceIsolationManageruser - the user that the worker is running asworkerId - the id of the workerport - the port of the workerIOException - on I/O exceptionpublic long getSystemFreeMemoryMb()
throws IOException
ResourceIsolationInterfaceGet the amount of free memory in MB. This might not be the entire box, it might be within a parent resource group.
getSystemFreeMemoryMb in interface ResourceIsolationInterfacegetSystemFreeMemoryMb in class DefaultResourceIsolationManagerIOException - on I/O exceptionpublic boolean isResourceManaged()
DefaultResourceIsolationManagerThis class doesn’t really manage resources.
isResourceManaged in interface ResourceIsolationInterfaceisResourceManaged in class DefaultResourceIsolationManagerCopyright © 2021 The Apache Software Foundation. All rights reserved.