smiklosovic commented on code in PR #3420:
URL: https://github.com/apache/cassandra/pull/3420#discussion_r1679473257
##########
src/java/org/apache/cassandra/tools/nodetool/GcStats.java:
##########
@@ -31,7 +39,69 @@ public void execute(NodeProbe probe)
double[] stats = probe.getAndResetGCStats();
double mean = stats[2] / stats[5];
double stdev = Math.sqrt((stats[3] / stats[5]) - (mean * mean));
+ long[] thread = probe.numberOfGCThreads();
+
+ //value of jnaLockable
+ boolean jnaLockable = NativeLibrary.jnaMemoryLockable();
+
+ OperatingSystemMXBean osBean = (OperatingSystemMXBean)
ManagementFactory.getOperatingSystemMXBean();
+
+ long freeMemoryBytes = osBean.getFreeMemorySize();
+ long swapMemoryBytes = osBean.getFreeSwapSpaceSize();
+ long totalMemoryBytes = osBean.getTotalMemorySize();
+ long totalswapMemoryBytes = osBean.getTotalSwapSpaceSize();
+
+ String PM_freeMemoryBytes =
FBUtilities.prettyPrintMemory(freeMemoryBytes, " ");
+ String PM_totalMemoryBytes =
FBUtilities.prettyPrintMemory(totalMemoryBytes, " ");
+ String PM_totalswapMemoryBytes =
FBUtilities.prettyPrintMemory(totalswapMemoryBytes, " ");
+
+ String PM_OSInUseMemoryBytes =
FBUtilities.prettyPrintMemory(totalswapMemoryBytes - freeMemoryBytes, " ");
+ String PM_SWAPInUseMemoryBytes =
FBUtilities.prettyPrintMemory(totalswapMemoryBytes - swapMemoryBytes, " ");
+
+ probe.output().out.println("GC Threads: " + thread[1]);
+ probe.output().out.println("Duration: " + thread[0] + " ms");
+ probe.output().out.println("MemLock: " + jnaLockable + "\n");
+
+ long osInUse = totalMemoryBytes - freeMemoryBytes;
+ double ospercent = ((double)osInUse/totalMemoryBytes) * 100;
+ probe.output().out.println("OS Free Memory Bytes: " +
PM_freeMemoryBytes);
+ probe.output().out.println("OS Total Memory Bytes: " +
PM_totalMemoryBytes);
+ probe.output().out.println("OS In Use: " + PM_OSInUseMemoryBytes + "
/ " + PM_totalMemoryBytes + " (" + String.format("%.1f", ospercent) + "%)\n");
+
+ long swapInUse = (totalswapMemoryBytes - swapMemoryBytes);
+ double swapPercent = ((double)swapInUse/totalswapMemoryBytes) * 100;
+
+ probe.output().out.println("Swap in Use: " + PM_SWAPInUseMemoryBytes +
" / " + PM_totalswapMemoryBytes + " (" + String.format("%.1f", swapPercent) +
"%)\n");
probe.output().out.printf("%20s%20s%20s%20s%20s%20s%25s%n", "Interval
(ms)", "Max GC Elapsed (ms)", "Total GC Elapsed (ms)", "Stdev GC Elapsed (ms)",
"GC Reclaimed (MB)", "Collections", "Direct Memory Bytes");
probe.output().out.printf("%20.0f%20.0f%20.0f%20.0f%20.0f%20.0f%25d%n",
stats[0], stats[1], stats[2], stdev, stats[4], stats[5], (long)stats[6]);
+ probe.output().out.printf("\n");
+
+ MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
Review Comment:
This should be most probably wrapped in try-catch until
https://issues.apache.org/jira/browse/CASSANDRA-19730 is resolved. Similar for
`getHeapMemoryUsage`.
This is actually wrong, because `ManagementFactory.getMemoryMXBean();` will
be called in the context of JVM the nodetool command will be called. It will
not call the memory beans from Cassandra process which is remote to this
execution environment.
You should probably obtain a proxy from probe. Look like `Info` nodetool
command gets this stuff from `MemoryUsage heapUsage =
probe.getHeapMemoryUsage();` for example.
--
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]