Class ProcCgroupV2Discoverer
java.lang.Object
org.apache.druid.java.util.metrics.cgroups.ProcCgroupDiscoverer
org.apache.druid.java.util.metrics.cgroups.ProcCgroupV2Discoverer
- All Implemented Interfaces:
CgroupDiscoverer
-
Field Summary
Fields inherited from class org.apache.druid.java.util.metrics.cgroups.ProcCgroupDiscoverer
procDir -
Constructor Summary
ConstructorsConstructorDescriptionProcCgroupV2Discoverer(Path procDir) Create a proc discovery mechanism based on a `/proc` directory. -
Method Summary
Modifier and TypeMethodDescriptionGets the path in the virtual FS for the given cgroup (cpu, mem, etc.).Gets CPU metrics (shares, quota, period, usage) appropriate for this cgroups version.Gets CPU set metrics (effective CPU list) appropriate for this cgroups version.Methods inherited from class org.apache.druid.java.util.metrics.cgroups.ProcCgroupDiscoverer
getMountEntry
-
Constructor Details
-
ProcCgroupV2Discoverer
Create a proc discovery mechanism based on a `/proc` directory.- Parameters:
procDir- The directory under proc. This is usually `/proc/self` or `/proc/#pid`
-
-
Method Details
-
discover
Description copied from class:ProcCgroupDiscovererGets the path in the virtual FS for the given cgroup (cpu, mem, etc.). The method first retrieves 2 paths: - The cgroup virtual FS mount point by calling /proc/mounts. This is usually like '/sys/fs/cgroup/cpu'. - The heirarchy path by calling /proc/[pid]/cgroup. In Docker this can look like '/docker/4b053f1267369a19dcdcb293e1b4d6b71fd0f26bf7711d589f19d48af92e6278' The method then tries to find the final virtual FS path by contenating the 2 paths first, and then falling back to the root virtual FS path. In this example, the method tries '/sys/fs/cgroup/cpu/docker/4b053f1267369a19dcdcb293e1b4d6b71fd0f26bf7711d589f19d48af92e6278' and then falls back to '/sys/fs/cgroup/cpu'. An exception is thrown if neither path exists.- Specified by:
discoverin interfaceCgroupDiscoverer- Overrides:
discoverin classProcCgroupDiscoverer- Parameters:
cgroup- The cgroup.- Returns:
- the virtual FS path.
-
getCpuMetrics
Description copied from interface:CgroupDiscovererGets CPU metrics (shares, quota, period, usage) appropriate for this cgroups version. Encapsulates the difference between v1 (cpu.shares, cpu.cfs_*) and v2 (cpu.weight, cpu.max).- Specified by:
getCpuMetricsin interfaceCgroupDiscoverer- Overrides:
getCpuMetricsin classProcCgroupDiscoverer- Returns:
- CPU metrics compatible with both cgroups v1 and v2
-
getCpuSetMetrics
Description copied from interface:CgroupDiscovererGets CPU set metrics (effective CPU list) appropriate for this cgroups version. Encapsulates the difference between v1 (cpuset.effective_cpus) and v2 (cpuset.cpus.effective).- Specified by:
getCpuSetMetricsin interfaceCgroupDiscoverer- Overrides:
getCpuSetMetricsin classProcCgroupDiscoverer- Returns:
- CPU set metrics compatible with both cgroups v1 and v2
-
getCgroupVersion
- Specified by:
getCgroupVersionin interfaceCgroupDiscoverer- Overrides:
getCgroupVersionin classProcCgroupDiscoverer
-