PeriodicService (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.router, class: PeriodicService

Package org.apache.hadoop.hdfs.server.federation.router

# 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

  Constructors
  Constructor
  Description
  `PeriodicService(String name)`
  Create a new periodic update service.
  `PeriodicService(String name, long interval)`
  Create a new periodic update service.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected long`
  `getErrorCount()`
  Get how many times we failed to run the periodic service.
  `protected long`
  `getIntervalMs()`
  Get the interval for the periodic service.
  `protected long`
  `getLastUpdate()`
  Get the last time the periodic service was executed.
  `protected long`
  `getRunCount()`
  Get how many times we run the periodic service.
  `protected abstract void`
  `periodicInvoke()`
  Method that the service will run periodically.
  `protected void`
  `serviceStart()`
  `protected void`
  `serviceStop()`
  `protected void`
  `setIntervalMs(long interval)`
  Set the interval for the periodic service.
  `protected void`
  `startPeriodic()`
  Start the periodic execution.
  `protected void`
  `stopPeriodic()`
  Stop 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### PeriodicService

    public PeriodicService(String name)
    Create a new periodic update service.
    Parameters:
      `name` - Name of the service.

  - ### PeriodicService

    public PeriodicService(String name, long interval)
    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

    protected void serviceStart() throws Exception
    Overrides:
      `serviceStart` in class `org.apache.hadoop.service.AbstractService`
    Throws:
      `Exception`

  - ### serviceStop

    protected void serviceStop() throws Exception
    Overrides:
      `serviceStop` in class `org.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.