public class CgroupManager extends Object implements ResourceIsolationInterface
Class that implements ResourceIsolationInterface that manages cgroups.
| Constructor and Description |
|---|
CgroupManager() |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getLaunchCommand(String workerId,
List<String> existingCommand)
After reserving resources for the worker (i.e.
|
List<String> |
getLaunchCommandPrefix(String workerId)
After reserving resources for the worker (i.e.
|
long |
getMemoryUsage(String workerId)
Get the current memory usage of the a given worker.
|
Set<Long> |
getRunningPids(String workerId)
Get the list of PIDs currently in an isolated container.
|
long |
getSystemFreeMemoryMb() |
void |
prepare(Map<String,Object> conf)
initialize data structures.
|
void |
releaseResourcesForWorker(String workerId)
This function will be called when the worker needs to shutdown.
|
void |
reserveResourcesForWorker(String workerId,
Integer totalMem,
Integer cpuNum)
This function should be used prior to starting the worker to reserve resources for the worker.
|
public void prepare(Map<String,Object> conf) throws IOException
initialize data structures.
prepare in interface ResourceIsolationInterfaceconf - storm confsIOException - on any error.public void reserveResourcesForWorker(String workerId, Integer totalMem, Integer cpuNum) throws SecurityException
ResourceIsolationInterfaceThis function should be used prior to starting the worker to reserve resources for the worker.
reserveResourcesForWorker in interface ResourceIsolationInterfaceworkerId - 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 enforcedSecurityExceptionpublic void releaseResourcesForWorker(String workerId)
ResourceIsolationInterfaceThis function will be called when the worker needs to shutdown. This function should include logic to clean up after a worker is shutdown.
releaseResourcesForWorker in interface ResourceIsolationInterfaceworkerId - worker id to shutdown and clean up afterpublic List<String> getLaunchCommand(String workerId, List<String> existingCommand)
ResourceIsolationInterfaceAfter reserving resources for the worker (i.e. calling reserveResourcesForWorker). This function can be used to get the modified command line to launch the worker with resource isolation
getLaunchCommand in interface ResourceIsolationInterfaceexistingCommand - the current command to run that may need to be modified.public List<String> getLaunchCommandPrefix(String workerId)
ResourceIsolationInterfaceAfter reserving resources for the worker (i.e. calling reserveResourcesForWorker). this function can be used to get the launch command prefix
getLaunchCommandPrefix in interface ResourceIsolationInterfaceworkerId - the of the workerpublic Set<Long> getRunningPids(String workerId) throws IOException
ResourceIsolationInterfaceGet the list of PIDs currently in an isolated container.
getRunningPids in interface ResourceIsolationInterfaceworkerId - the id of the worker to get these forIOException - on any errorpublic long getMemoryUsage(String workerId) throws IOException
ResourceIsolationInterfaceGet the current memory usage of the a given worker.
getMemoryUsage in interface ResourceIsolationInterfaceworkerId - the id of the workerIOException - on any error.public long getSystemFreeMemoryMb()
throws IOException
getSystemFreeMemoryMb in interface ResourceIsolationInterfaceIOException - on any error.Copyright © 2022 The Apache Software Foundation. All rights reserved.