Package alluxio.heartbeat
Class ScheduledTimer
- java.lang.Object
-
- alluxio.heartbeat.ScheduledTimer
-
- All Implemented Interfaces:
HeartbeatTimer
@ThreadSafe public final class ScheduledTimer extends java.lang.Object implements HeartbeatTimer
This class can be used for controlling heartbeat execution of threads. In particular, theScheduledTimer
blocks on thetick()
method, waiting for someone to invoke theschedule()
method. The contract of this class is that theschedule()
method should only be called after thetick()
was called and that there is exactly oneschedule()
call pertick()
call. Theschedule()
method is not meant to be invoked directly. Instead, theHeartbeatScheduler
class should be used.
-
-
Constructor Summary
Constructors Constructor Description ScheduledTimer(java.lang.String threadName, long intervalMs)
Creates a new instance ofScheduledTimer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getThreadName()
protected void
schedule()
Schedules execution of the heartbeat.void
tick()
Waits until next heartbeat should be executed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface alluxio.heartbeat.HeartbeatTimer
setIntervalMs
-
-
-
-
Constructor Detail
-
ScheduledTimer
public ScheduledTimer(java.lang.String threadName, long intervalMs)
Creates a new instance ofScheduledTimer
.- Parameters:
threadName
- the thread nameintervalMs
- the heartbeat interval (unused)
-
-
Method Detail
-
getThreadName
public java.lang.String getThreadName()
- Returns:
- the thread name
-
schedule
protected void schedule()
Schedules execution of the heartbeat.
-
tick
public void tick() throws java.lang.InterruptedException
Description copied from interface:HeartbeatTimer
Waits until next heartbeat should be executed.- Specified by:
tick
in interfaceHeartbeatTimer
- Throws:
java.lang.InterruptedException
- if the thread is interrupted while waiting
-
-