Package alluxio.heartbeat
Class SleepingTimer
- java.lang.Object
-
- alluxio.heartbeat.SleepingTimer
-
- All Implemented Interfaces:
HeartbeatTimer
@NotThreadSafe public final class SleepingTimer extends java.lang.Object implements HeartbeatTimer
This class can be used for executing heartbeats periodically.
-
-
Constructor Summary
Constructors Constructor Description SleepingTimer(java.lang.String threadName, long intervalMs)
Creates a new instance ofSleepingTimer
.SleepingTimer(java.lang.String threadName, long intervalMs, org.slf4j.Logger logger, java.time.Clock clock, Sleeper sleeper)
Creates a new instance ofSleepingTimer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setIntervalMs(long intervalMs)
Sets the heartbeat interval.void
tick()
Enforces the thread waits for the given interval between consecutive ticks.
-
-
-
Constructor Detail
-
SleepingTimer
public SleepingTimer(java.lang.String threadName, long intervalMs)
Creates a new instance ofSleepingTimer
.- Parameters:
threadName
- the thread nameintervalMs
- the heartbeat interval
-
SleepingTimer
public SleepingTimer(java.lang.String threadName, long intervalMs, org.slf4j.Logger logger, java.time.Clock clock, Sleeper sleeper)
Creates a new instance ofSleepingTimer
.- Parameters:
threadName
- the thread nameintervalMs
- the heartbeat intervallogger
- the logger to log toclock
- for telling the current timesleeper
- the utility to use for sleeping
-
-
Method Detail
-
setIntervalMs
public void setIntervalMs(long intervalMs)
Description copied from interface:HeartbeatTimer
Sets the heartbeat interval.- Specified by:
setIntervalMs
in interfaceHeartbeatTimer
- Parameters:
intervalMs
- the heartbeat interval in ms
-
tick
public void tick() throws java.lang.InterruptedException
Enforces the thread waits for the given interval between consecutive ticks.- Specified by:
tick
in interfaceHeartbeatTimer
- Throws:
java.lang.InterruptedException
- if the thread is interrupted while waiting
-
-