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()
Get the system free memory in MB.
|
protected static boolean |
isOnLinux()
Extracting out to mock it for tests.
|
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,
String numaId)
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 ResourceIsolationInterface
conf
- storm confsIOException
- on any error.public void reserveResourcesForWorker(String workerId, Integer totalMem, Integer cpuNum, String numaId) throws SecurityException
ResourceIsolationInterface
This function should be used prior to starting the worker to reserve resources for the worker.
reserveResourcesForWorker
in interface ResourceIsolationInterface
workerId
- 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 toSecurityException
public void releaseResourcesForWorker(String workerId)
ResourceIsolationInterface
This 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 ResourceIsolationInterface
workerId
- worker id to shutdown and clean up afterprotected static boolean isOnLinux()
Extracting out to mock it for tests.
public List<String> getLaunchCommand(String workerId, List<String> existingCommand)
ResourceIsolationInterface
After 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 ResourceIsolationInterface
existingCommand
- the current command to run that may need to be modified.public List<String> getLaunchCommandPrefix(String workerId)
ResourceIsolationInterface
After reserving resources for the worker (i.e. calling reserveResourcesForWorker). this function can be used to get the launch command prefix
getLaunchCommandPrefix
in interface ResourceIsolationInterface
workerId
- the of the workerpublic Set<Long> getRunningPids(String workerId) throws IOException
ResourceIsolationInterface
Get the list of PIDs currently in an isolated container.
getRunningPids
in interface ResourceIsolationInterface
workerId
- the id of the worker to get these forIOException
- on any errorpublic long getMemoryUsage(String workerId) throws IOException
ResourceIsolationInterface
Get the current memory usage of the a given worker.
getMemoryUsage
in interface ResourceIsolationInterface
workerId
- the id of the workerIOException
- on any error.public long getSystemFreeMemoryMb() throws IOException
ResourceIsolationInterface
Get the system free memory in MB.
getSystemFreeMemoryMb
in interface ResourceIsolationInterface
IOException
- on any error.Copyright © 2022 The Apache Software Foundation. All rights reserved.