Class HeartbeatThread

  • All Implemented Interfaces:
    java.lang.Runnable

    @NotThreadSafe
    public final class HeartbeatThread
    extends java.lang.Object
    implements java.lang.Runnable
    Thread class to execute a heartbeat periodically. This thread is daemonic, so it will not prevent the JVM from exiting.
    • Constructor Detail

      • HeartbeatThread

        public HeartbeatThread​(java.lang.String executorName,
                               java.lang.String threadId,
                               HeartbeatExecutor executor,
                               java.util.function.Supplier<SleepIntervalSupplier> intervalSupplier,
                               AlluxioConfiguration conf,
                               UserState userState,
                               java.time.Clock clock)
        Creates a Runnable to execute heartbeats for the given HeartbeatExecutor. This class is responsible for closing the given HeartbeatExecutor when it finishes.
        Parameters:
        executorName - identifies the heartbeat thread's executor, should be those defined in HeartbeatContext
        threadId - the thread identifier, normally, it is empty, but if a heartbeat executor is started in multiple threads, this can be used to distinguish them, the heartbeat thread's name is a combination of executorName and threadId
        executor - identifies the heartbeat thread executor; an instance of a class that implements the HeartbeatExecutor interface
        intervalSupplier - Sleep time between different heartbeat supplier
        conf - Alluxio configuration
        userState - the user state for this heartbeat thread
        clock - the clock used to compute the current time
    • Method Detail

      • generateThreadName

        public static java.lang.String generateThreadName​(java.lang.String executorName,
                                                          java.lang.String threadId)
        Parameters:
        executorName - the executor name defined in HeartbeatContext
        threadId - the thread identifier
        Returns:
        the thread name combined of executorName and threadId, if threadId is empty or null, return executorName
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable