Package alluxio.heartbeat
Class HeartbeatThread
- java.lang.Object
-
- alluxio.heartbeat.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HeartbeatThread.Status
Enum representing the status of HeartbeatThread.
-
Constructor Summary
Constructors Constructor Description HeartbeatThread(java.lang.String executorName, HeartbeatExecutor executor, java.util.function.Supplier<SleepIntervalSupplier> intervalSupplier, AlluxioConfiguration conf, UserState userState)
Convenience method forHeartbeatThread(String, String, HeartbeatExecutor, Supplier, AlluxioConfiguration, UserState, Clock)
where threadId is null.HeartbeatThread(java.lang.String executorName, HeartbeatExecutor executor, java.util.function.Supplier<SleepIntervalSupplier> intervalSupplier, AlluxioConfiguration conf, UserState userState, java.time.Clock clock)
Convenience method forHeartbeatThread(String, String, HeartbeatExecutor, Supplier, AlluxioConfiguration, UserState, Clock)
where threadId is null.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 aRunnable
to execute heartbeats for the givenHeartbeatExecutor
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
generateThreadName(java.lang.String executorName, java.lang.String threadId)
HeartbeatThread.Status
getStatus()
void
run()
-
-
-
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 aRunnable
to execute heartbeats for the givenHeartbeatExecutor
. This class is responsible for closing the givenHeartbeatExecutor
when it finishes.- Parameters:
executorName
- identifies the heartbeat thread's executor, should be those defined inHeartbeatContext
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 threadIdexecutor
- identifies the heartbeat thread executor; an instance of a class that implements the HeartbeatExecutor interfaceintervalSupplier
- Sleep time between different heartbeat supplierconf
- Alluxio configurationuserState
- the user state for this heartbeat threadclock
- the clock used to compute the current time
-
HeartbeatThread
public HeartbeatThread(java.lang.String executorName, HeartbeatExecutor executor, java.util.function.Supplier<SleepIntervalSupplier> intervalSupplier, AlluxioConfiguration conf, UserState userState)
Convenience method forHeartbeatThread(String, String, HeartbeatExecutor, Supplier, AlluxioConfiguration, UserState, Clock)
where threadId is null.- Parameters:
executorName
- the executor name that is one of those defined inHeartbeatContext
executor
- the heartbeat executorintervalSupplier
- the interval between heartbeats supplierconf
- the Alluxio configurationuserState
- the user state for this heartbeat thread
-
HeartbeatThread
public HeartbeatThread(java.lang.String executorName, HeartbeatExecutor executor, java.util.function.Supplier<SleepIntervalSupplier> intervalSupplier, AlluxioConfiguration conf, UserState userState, java.time.Clock clock)
Convenience method forHeartbeatThread(String, String, HeartbeatExecutor, Supplier, AlluxioConfiguration, UserState, Clock)
where threadId is null.- Parameters:
executorName
- the executor name that is one of those defined inHeartbeatContext
executor
- the heartbeat executorintervalSupplier
- the interval between heartbeats supplierconf
- the Alluxio configurationuserState
- the user state for this heartbeat threadclock
- 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 inHeartbeatContext
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 interfacejava.lang.Runnable
-
getStatus
public HeartbeatThread.Status getStatus()
- Returns:
- the status of current heartbeat thread
-
-