Class PeriodicService
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.hdfs.server.federation.router.PeriodicService
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
- Direct Known Subclasses:
NamenodeHeartbeatService,RouterHeartbeatService,RouterQuotaUpdateService,RouterSafemodeService,StateStoreCacheUpdateService,StateStoreConnectionMonitorService
public abstract class PeriodicService
extends org.apache.hadoop.service.AbstractService
Service to periodically execute a runnable.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Constructor Summary
ConstructorsConstructorDescriptionPeriodicService(String name) Create a new periodic update service.PeriodicService(String name, long interval) Create a new periodic update service. -
Method Summary
Modifier and TypeMethodDescriptionprotected longGet how many times we failed to run the periodic service.protected longGet the interval for the periodic service.protected longGet the last time the periodic service was executed.protected longGet how many times we run the periodic service.protected abstract voidMethod that the service will run periodically.protected voidprotected voidprotected voidsetIntervalMs(long interval) Set the interval for the periodic service.protected voidStart the periodic execution.protected voidStop the periodic task.Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
PeriodicService
Create a new periodic update service.- Parameters:
name- Name of the service.
-
PeriodicService
Create a new periodic update service.- Parameters:
name- Name of the service.interval- Interval for the periodic service in milliseconds.
-
-
Method Details
-
setIntervalMs
protected void setIntervalMs(long interval) Set the interval for the periodic service.- Parameters:
interval- Interval in milliseconds.
-
getIntervalMs
protected long getIntervalMs()Get the interval for the periodic service.- Returns:
- Interval in milliseconds.
-
getErrorCount
protected long getErrorCount()Get how many times we failed to run the periodic service.- Returns:
- Times we failed to run the periodic service.
-
getRunCount
protected long getRunCount()Get how many times we run the periodic service.- Returns:
- Times we run the periodic service.
-
getLastUpdate
protected long getLastUpdate()Get the last time the periodic service was executed.- Returns:
- Last time the periodic service was executed.
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
stopPeriodic
protected void stopPeriodic()Stop the periodic task. -
startPeriodic
protected void startPeriodic()Start the periodic execution. -
periodicInvoke
protected abstract void periodicInvoke()Method that the service will run periodically.
-