manika137 commented on code in PR #8056:
URL: https://github.com/apache/hadoop/pull/8056#discussion_r2537331384
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/WriteThreadPoolSizeManager.java:
##########
@@ -394,4 +481,99 @@ public void close() throws IOException {
}
}
}
+
+ /**
+ * Represents current statistics of the write thread pool and system.
+ */
+ public static class WriteThreadPoolStats {
+ private final int currentPoolSize; // matches CURRENT_POOL_SIZE metric
+ private final int maxPoolSize; // matches MAX_POOL_SIZE metric
+ private final int activeThreads; // matches ACTIVE_THREADS metric
+ private final double jvmCpuUtilization; // matches JVM_CPU_UTILIZATION
metric
+ private final double cpuUtilization; // matches CPU_UTILIZATION metric
+ private final long availableHeapGB; // matches MEMORY_UTILIZATION metric
+
+ /**
+ * Constructs a {@link WriteThreadPoolStats} instance with the given
thread pool
+ * and system utilization metrics.
+ *
+ * @param currentPoolSize the current number of threads in the pool.
+ * @param maxPoolSize the maximum allowed thread pool size.
+ * @param activeThreads the number of currently active threads.
+ * @param jvmCpuUtilization the JVM CPU utilization percentage.
+ * @param cpuUtilization the overall system CPU utilization
percentage.
+ * @param availableHeapGB the available heap memory in gigabytes.
+ */
+ public WriteThreadPoolStats(int currentPoolSize, int maxPoolSize,
+ int activeThreads, double jvmCpuUtilization, double cpuUtilization,
long availableHeapGB) {
+ this.currentPoolSize = currentPoolSize;
+ this.maxPoolSize = maxPoolSize;
+ this.activeThreads = activeThreads;
+ this.jvmCpuUtilization = jvmCpuUtilization;
+ this.cpuUtilization = cpuUtilization;
+ this.availableHeapGB = availableHeapGB;
+ }
+
+ /** @return the current number of threads in the pool. */
+ public int getCurrentPoolSize() {
+ return currentPoolSize;
+ }
+
+ /** @return the maximum allowed size of the thread pool. */
+ public int getMaxPoolSize() {
+ return maxPoolSize;
+ }
+
+ /** @return the number of threads currently executing tasks. */
+ public int getActiveThreads() {
+ return activeThreads;
+ }
+
+ /** @return the JVM process CPU utilization percentage. */
+ public double getJvmCpuUtilization() {
+ return jvmCpuUtilization;
+ }
+
+ /** @return the overall system CPU utilization percentage. */
+ public double getCpuUtilization() {
+ return cpuUtilization;
+ }
+
+ /** @return the available heap memory in gigabytes. */
+ public long getMemoryUtilization() {
+ return availableHeapGB;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "currentPoolSize=%d, maxPoolSize=%d, activeThreads=%d,
jvmCpuUtilization=%.2f%%, cpuUtilization=%.2f%%, availableHeap=%dGB",
+ currentPoolSize, maxPoolSize, activeThreads, jvmCpuUtilization,
cpuUtilization * HUNDRED, availableHeapGB);
Review Comment:
we dont need to multiply jvmCpuUtilization also by 100?
Also, should we be multiplying with HUNDRED_D instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]