Package org.apache.cassandra.hints
Class HintsService
java.lang.Object
org.apache.cassandra.hints.HintsService
- All Implemented Interfaces:
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
- an optional scheduled task to clean up the applicable hints files
The front-end for everything hints related.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic HintsServicestatic final Stringfinal HintedHandoffMetrics -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes all hints for all destinations.voiddeleteAllHintsForEndpoint(String address) Deletes all hints for the provided destination.voidDeletes all hints for the provided destination.voidCleans up hints-related state after a node with id = hostId left.longfindOldestHintTimestamp(UUID hostId) Find the oldest hint written for a particular node by looking into descriptors and current open writer, if any.voidflushAndFsyncBlockingly(Iterable<UUID> hostIds) Flush the buffer pool for the selected target nodes, then fsync their writers.Returns all pending hints that this node has.Returns all pending hints that this node has.longgetTotalHintsSize(UUID hostId) Get the total size in bytes of all the hints files associating with the host on disk.booleanbooleanReturns true in case service is shut down.voidPause dispatch of all hints.voidvoidResume dispatch of all hints.voidGracefully and blockingly shut down the service.voidtransferHints(Supplier<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.voidwrite(Collection<UUID> hostIds, Hint hint) Write a hint for a iterable of nodes.voidWrite a hint for a single node.
-
Field Details
-
instance
-
MBEAN_NAME
- See Also:
-
metrics
-
-
Method Details
-
registerMBean
public void registerMBean() -
write
Write a hint for a iterable of nodes.- Parameters:
hostIds- host ids of the hint's target nodeshint- the hint to store
-
write
Write a hint for a single node.- Parameters:
hostId- host id of the hint's target nodehint- the hint to store
-
flushAndFsyncBlockingly
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:HintsServiceMBeanPause dispatch of all hints. Does not affect the creation of hints.- Specified by:
pauseDispatchin interfaceHintsServiceMBean
-
resumeDispatch
public void resumeDispatch()Description copied from interface:HintsServiceMBeanResume dispatch of all hints. Does not affect the creation of hints.- Specified by:
resumeDispatchin interfaceHintsServiceMBean
-
getTotalHintsSize
Get the total size in bytes of all the hints files associating with the host on disk.- Parameters:
hostId- belonging host- Returns:
- total file size, in bytes
-
shutdownBlocking
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. -
getPendingHintsInfo
Returns all pending hints that this node has.- Returns:
- a list of
PendingHintsInfo
-
getPendingHints
Returns all pending hints that this node has.- Specified by:
getPendingHintsin interfaceHintsServiceMBean- Returns:
- a list of maps with endpoints' ids, total number of hint files, their oldest and newest timestamps.
-
deleteAllHints
public void deleteAllHints()Deletes all hints for all destinations. Doesn't make snapshots - should be used with care.- Specified by:
deleteAllHintsin interfaceHintsServiceMBean
-
deleteAllHintsForEndpoint
Deletes all hints for the provided destination. Doesn't make snapshots - should be used with care.- Specified by:
deleteAllHintsForEndpointin interfaceHintsServiceMBean- Parameters:
address- inet address of the target node - encoded as a string for easier JMX consumption
-
deleteAllHintsForEndpoint
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
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
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
-
findOldestHintTimestamp
Find the oldest hint written for a particular node by looking into descriptors and current open writer, if any.- Parameters:
hostId- UUID of the node to check its hints.- Returns:
- the oldest hint of the given host id or Long.MAX_VALUE when not found
-
isShutDown
public boolean isShutDown()Returns true in case service is shut down. -
isDispatchPaused
public boolean isDispatchPaused()
-