Class CachedClusterId

java.lang.Object
org.apache.hadoop.hbase.master.CachedClusterId

@Private public class CachedClusterId extends Object
Caches the cluster ID of the cluster. For standby masters, this is used to serve the client RPCs that fetch the cluster ID. ClusterID is only created by an active master if one does not already exist. Standby masters just read the information from the file system. This class is thread-safe. TODO: Make it a singleton without affecting concurrent junit tests.
  • Field Details

  • Constructor Details

  • Method Details

    • setClusterId

      private void setClusterId(ClusterId id)
      Succeeds only once, when setting to a non-null value. Overwrites are not allowed.
    • getClusterId

      private String getClusterId()
      Returns a cached copy of the cluster ID. null if the cache is not populated.
    • attemptFetch

      private boolean attemptFetch()
      Attempts to fetch the cluster ID from the file system. If no attempt is already in progress, synchronously fetches the cluster ID and sets it. If an attempt is already in progress, returns right away and the caller is expected to wait for the fetch to finish.
      Returns:
      true if the attempt is done, false if another thread is already fetching it.
    • waitForFetchToFinish

      Throws:
      InterruptedException
    • getFromCacheOrFetch

      Fetches the ClusterId from FS if it is not cached locally. Atomically updates the cached copy and is thread-safe. Optimized to do a single fetch when there are multiple threads are trying get from a clean cache.
      Returns:
      ClusterId by reading from FileSystem or null in any error case or cluster ID does not exist on the file system or if the server initiated a tear down.
    • getCacheStats

      public int getCacheStats()