org.apache.solr.hadoop

## Class HeartBeater

- java.lang.Object
- - java.lang.Thread
  - - org.apache.solr.hadoop.HeartBeater

- All Implemented Interfaces:
    Runnable

      public class HeartBeater
      extends Thread

  This class runs a background thread that once every 60 seconds checks to see if a progress report is needed. If a report is needed it is issued. A simple counter `threadsNeedingHeartBeat` handles the number of threads requesting a heart beat. The expected usage pattern is

        try {
             heartBeater.needHeartBeat();
             do something that may take a while
          } finally {
             heartBeater.cancelHeartBeat();
          }

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HeartBeater(org.apache.hadoop.util.Progressable progress)` Create the heart beat object thread set it to daemon priority and start the thread.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancelHeartBeat()` inform the background thread that this heartbeat request is not needed.
    `void` | `close()` Releases any resources
    `org.apache.hadoop.util.Progressable` | `getProgress()`
    `void` | `needHeartBeat()` inform the background thread that heartbeats are to be issued.
    `void` | `run()`
    `void` | `setProgress(org.apache.hadoop.util.Progressable progress)`
    `void` | `setStatus(String status)`

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

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

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

- - ### Constructor Detail

    - #### HeartBeater

          public HeartBeater(org.apache.hadoop.util.Progressable progress)

      Create the heart beat object thread set it to daemon priority and start the thread. When the count in `threadsNeedingHeartBeat` is positive, the heart beat will be issued on the progress object every 60 seconds.

  - ### Method Detail

    - #### getProgress

          public org.apache.hadoop.util.Progressable getProgress()

    - #### setProgress

          public void setProgress(org.apache.hadoop.util.Progressable progress)

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`
      Overrides:
        `run` in class `Thread`

    - #### needHeartBeat

          public void needHeartBeat()

      inform the background thread that heartbeats are to be issued. Issue a heart beat also

    - #### cancelHeartBeat

          public void cancelHeartBeat()

      inform the background thread that this heartbeat request is not needed. This must be called at some point after each `needHeartBeat()` request.

    - #### setStatus

          public void setStatus(String status)

    - #### close

          public void close()

      Releases any resources

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.