Class MemoryLogger
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.flink.runtime.taskmanager.MemoryLogger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description MemoryLogger(org.slf4j.Logger logger, long interval, CompletableFuture<Void> monitored)
Creates a new memory logger that logs in the given interval and lives until the given termination future completes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
getDirectMemoryStatsAsString(BufferPoolMXBean bufferPoolMxBean)
Returns a String with the direct memory footprint.static String
getGarbageCollectorStatsAsString(List<GarbageCollectorMXBean> gcMXBeans)
Gets the garbage collection statistics from the JVM.static String
getMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans)
Gets the memory pool statistics from the JVM.static String
getMemoryUsageStatsAsString(MemoryMXBean memoryMXBean)
Gets the memory footprint of the JVM in a string representation.void
run()
void
shutdown()
static void
startIfConfigured(org.slf4j.Logger logger, org.apache.flink.configuration.Configuration configuration, CompletableFuture<Void> taskManagerTerminationFuture)
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
MemoryLogger
public MemoryLogger(org.slf4j.Logger logger, long interval, CompletableFuture<Void> monitored)
Creates a new memory logger that logs in the given interval and lives until the given termination future completes.- Parameters:
logger
- The logger to use for outputting the memory statistics.interval
- The interval in which the thread logs.monitored
- termination future for the system to whose life the thread is bound. The thread terminates once the system terminates.
-
-
Method Detail
-
startIfConfigured
public static void startIfConfigured(org.slf4j.Logger logger, org.apache.flink.configuration.Configuration configuration, CompletableFuture<Void> taskManagerTerminationFuture)
-
shutdown
public void shutdown()
-
getMemoryUsageStatsAsString
public static String getMemoryUsageStatsAsString(MemoryMXBean memoryMXBean)
Gets the memory footprint of the JVM in a string representation.- Returns:
- A string describing how much heap memory and direct memory are allocated and used.
-
getDirectMemoryStatsAsString
public static String getDirectMemoryStatsAsString(BufferPoolMXBean bufferPoolMxBean)
Returns a String with the direct memory footprint.These stats are not part of the other memory beans.
- Parameters:
bufferPoolMxBean
- The direct buffer pool bean ornull
if none available.- Returns:
- A string with the count, total capacity, and used direct memory.
-
getMemoryPoolStatsAsString
public static String getMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans)
Gets the memory pool statistics from the JVM.- Parameters:
poolBeans
- The collection of memory pool beans.- Returns:
- A string denoting the names and sizes of the memory pools.
-
getGarbageCollectorStatsAsString
public static String getGarbageCollectorStatsAsString(List<GarbageCollectorMXBean> gcMXBeans)
Gets the garbage collection statistics from the JVM.- Parameters:
gcMXBeans
- The collection of garbage collector beans.- Returns:
- A string denoting the number of times and total elapsed time in garbage collection.
-
-