org.apache.cassandra.hints

## Class HintsService

- java.lang.Object
- - org.apache.cassandra.hints.HintsService

- All Implemented Interfaces:
    HintsServiceMBean

      public final class HintsService
      extends java.lang.Object
      implements HintsServiceMBean

  A singleton-ish wrapper over various hints components: - a catalog of all hints stores - a single-threaded write executor - a multi-threaded dispatch executor - the buffer pool for writing hints into The front-end for everything hints related.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static HintsService` | `instance`
    `HintedHandoffMetrics` | `metrics`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `deleteAllHints()` Deletes all hints for all destinations.
    `void` | `deleteAllHintsForEndpoint(java.net.InetAddress target)` Deletes all hints for the provided destination.
    `void` | `deleteAllHintsForEndpoint(java.lang.String address)` Deletes all hints for the provided destination.
    `void` | `excise(java.util.UUID hostId)` Cleans up hints-related state after a node with id = hostId left.
    `void` | `flushAndFsyncBlockingly(java.lang.Iterable<java.util.UUID> hostIds)` Flush the buffer pool for the selected target nodes, then fsync their writers.
    `boolean` | `isShutDown()` Returns true in case service is shut down.
    `void` | `pauseDispatch()` Pause dispatch of all hints.
    `void` | `registerMBean()`
    `void` | `resumeDispatch()` Resume dispatch of all hints.
    `void` | `shutdownBlocking()` Gracefully and blockingly shut down the service.
    `void` | `startDispatch()`
    `java.util.concurrent.Future` | `transferHints(java.util.function.Supplier<java.util.UUID> hostIdSupplier)` Transfer all local hints to the hostId supplied by hostIdSupplier Flushes the buffer to make sure all hints are on disk and closes the hint writers so we don't leave any hint files around.
    `void` | `write(java.lang.Iterable<java.util.UUID> hostIds, Hint hint)` Write a hint for a iterable of nodes.
    `void` | `write(java.util.UUID hostId, Hint hint)` Write a hint for a single node.

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

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

- - ### Field Detail

    - #### instance

          public static HintsService instance

    - #### metrics

          public final HintedHandoffMetrics metrics

  - ### Method Detail

    - #### registerMBean

          public void registerMBean()

    - #### write

          public void write(java.lang.Iterable<java.util.UUID> hostIds,
                            Hint hint)

      Write a hint for a iterable of nodes.
      Parameters:
        `hostIds` - host ids of the hint's target nodes
        `hint` - the hint to store

    - #### write

          public void write(java.util.UUID hostId,
                            Hint hint)

      Write a hint for a single node.
      Parameters:
        `hostId` - host id of the hint's target node
        `hint` - the hint to store

    - #### flushAndFsyncBlockingly

          public void flushAndFsyncBlockingly(java.lang.Iterable<java.util.UUID> hostIds)

      Flush the buffer pool for the selected target nodes, then fsync their writers.
      Parameters:
        `hostIds` - host ids of the nodes to flush and fsync hints for

    - #### startDispatch

          public void startDispatch()

    - #### pauseDispatch

          public void pauseDispatch()

      Description copied from interface: `HintsServiceMBean`
      Pause dispatch of all hints. Does not affect the creation of hints.
      Specified by:
        `pauseDispatch` in interface `HintsServiceMBean`

    - #### resumeDispatch

          public void resumeDispatch()

      Description copied from interface: `HintsServiceMBean`
      Resume dispatch of all hints. Does not affect the creation of hints.
      Specified by:
        `resumeDispatch` in interface `HintsServiceMBean`

    - #### shutdownBlocking

          public void shutdownBlocking()
                                throws java.util.concurrent.ExecutionException,
                                       java.lang.InterruptedException

      Gracefully and blockingly shut down the service. Will abort dispatch sessions that are currently in progress (which is okay, it's idempotent), and make sure the buffers are flushed, hints files written and fsynced.
      Throws:
        `java.util.concurrent.ExecutionException`
        `java.lang.InterruptedException`

    - #### deleteAllHints

          public void deleteAllHints()

      Deletes all hints for all destinations. Doesn't make snapshots - should be used with care.
      Specified by:
        `deleteAllHints` in interface `HintsServiceMBean`

    - #### deleteAllHintsForEndpoint

          public void deleteAllHintsForEndpoint(java.lang.String address)

      Deletes all hints for the provided destination. Doesn't make snapshots - should be used with care.
      Specified by:
        `deleteAllHintsForEndpoint` in interface `HintsServiceMBean`
      Parameters:
        `address` - inet address of the target node - encoded as a string for easier JMX consumption

    - #### deleteAllHintsForEndpoint

          public void deleteAllHintsForEndpoint(java.net.InetAddress target)

      Deletes all hints for the provided destination. Doesn't make snapshots - should be used with care.
      Parameters:
        `target` - inet address of the target node

    - #### excise

          public void excise(java.util.UUID hostId)

      Cleans up hints-related state after a node with id = hostId left. Dispatcher can not stop itself (isHostAlive() can not start returning false for the leaving host because this method is called by the same thread as gossip, which blocks gossip), so we can't simply wait for completion. We should also flush the buffer if there are any hints for the node there, and close the writer (if any), so that we don't leave any hint files lying around. Once that is done, we can simply delete all hint files and remove the host id from the catalog. The worst that can happen if we don't get everything right is a hints file (or two) remaining undeleted.
      Parameters:
        `hostId` - id of the node being excised

    - #### transferHints

          public java.util.concurrent.Future transferHints(java.util.function.Supplier<java.util.UUID> hostIdSupplier)

      Transfer all local hints to the hostId supplied by hostIdSupplier Flushes the buffer to make sure all hints are on disk and closes the hint writers so we don't leave any hint files around. After that, we serially dispatch all the hints in the HintsCatalog. If we fail delivering all hints, we will ask the hostIdSupplier for a new target host and retry delivering any remaining hints there, once, with a delay of 10 seconds before retrying.
      Parameters:
        `hostIdSupplier` - supplier of stream target host ids. This is generally the closest one according to the DynamicSnitch
      Returns:
        When this future is done, it either has streamed all hints to remote nodes or has failed with a proper log message

    - #### isShutDown

          public boolean isShutDown()

      Returns true in case service is shut down.

Copyright © 2018 The Apache Software Foundation