Class MountTableResolver

java.lang.Object
org.apache.hadoop.hdfs.server.federation.resolver.MountTableResolver
All Implemented Interfaces:
FileSubclusterResolver, StateStoreCache
Direct Known Subclasses:
MultipleDestinationMountTableResolver

public class MountTableResolver extends Object implements FileSubclusterResolver, StateStoreCache
Mount table to map between global paths and remote locations. This allows the Router to map the global HDFS view to the remote namespaces. This is similar to ViewFs. This is implemented as a tree.
  • Constructor Details

    • MountTableResolver

      @VisibleForTesting public MountTableResolver(org.apache.hadoop.conf.Configuration conf)
    • MountTableResolver

      public MountTableResolver(org.apache.hadoop.conf.Configuration conf, Router routerService)
    • MountTableResolver

      public MountTableResolver(org.apache.hadoop.conf.Configuration conf, StateStoreService store)
    • MountTableResolver

      public MountTableResolver(org.apache.hadoop.conf.Configuration conf, Router routerService, StateStoreService store)
  • Method Details

    • getRouter

      protected Router getRouter()
      Get a reference for the Router for this resolver.
      Returns:
      Router for this resolver.
    • getMountTableStore

      protected MountTableStore getMountTableStore() throws IOException
      Get the mount table store for this resolver.
      Returns:
      Mount table store.
      Throws:
      IOException - If it cannot connect to the State Store.
    • addEntry

      public void addEntry(MountTable entry)
      Add a mount entry to the table.
      Parameters:
      entry - The mount table record to add from the state store.
    • removeEntry

      public void removeEntry(String srcPath)
      Remove a mount table entry.
      Parameters:
      srcPath - Source path for the entry to remove.
    • refreshEntries

      @VisibleForTesting public void refreshEntries(Collection<MountTable> entries)
      Updates the mount path tree with a new set of mount table entries. It also updates the needed caches.
      Parameters:
      entries - Full set of mount table entries to update.
    • isTrashPath

      @VisibleForTesting public static boolean isTrashPath(String path) throws IOException
      Check if path is the trail associated with the Trash.
      Parameters:
      path - a path.
      Returns:
      true if the path matches the trash path pattern, false otherwise.
      Throws:
      IOException - if retrieving current user's trash directory fails.
    • getTrashRoot

      @VisibleForTesting public static String getTrashRoot() throws IOException
      Throws:
      IOException
    • subtractTrashCurrentPath

      @VisibleForTesting public static String subtractTrashCurrentPath(String path) throws IOException
      Subtract a TrashCurrent to get a new path.
      Parameters:
      path - a path.
      Returns:
      new path with subtracted trash current path.
      Throws:
      IOException - if retrieving current user's trash directory fails.
    • loadCache

      public boolean loadCache(boolean force)
      Replaces the current in-memory cached of the mount table with a new version fetched from the data store.
      Specified by:
      loadCache in interface StateStoreCache
      Parameters:
      force - If we force the load.
      Returns:
      If the cache was loaded successfully.
    • clear

      public void clear()
      Clears all data.
    • getDestinationForPath

      public PathLocation getDestinationForPath(String path) throws IOException
      Description copied from interface: FileSubclusterResolver
      Get the destinations for a global path. Results are from the mount table cache. If multiple destinations are available, the first result is the highest priority destination.
      Specified by:
      getDestinationForPath in interface FileSubclusterResolver
      Parameters:
      path - Global path.
      Returns:
      Location in a destination namespace or null if it does not exist.
      Throws:
      IOException - Throws exception if the data is not available.
    • lookupLocation

      public PathLocation lookupLocation(String str) throws IOException
      Build the path location to insert into the cache atomically. It must hold the read lock.
      Parameters:
      str - Path to check/insert.
      Returns:
      New remote location.
      Throws:
      IOException - If it cannot find the location.
    • getMountPoint

      public MountTable getMountPoint(String path) throws IOException
      Get the mount table entry for a path.
      Parameters:
      path - Path to look for.
      Returns:
      Mount table entry the path belongs.
      Throws:
      IOException - If the State Store could not be reached.
    • getMountPoints

      public List<String> getMountPoints(String str) throws IOException
      Description copied from interface: FileSubclusterResolver
      Get a list of mount points for a path. Results are from the mount table cache.
      Specified by:
      getMountPoints in interface FileSubclusterResolver
      Parameters:
      str - Path to get the mount points under.
      Returns:
      List of mount points present at this path. Return zero-length list if the path is a mount point but there are no mount points under the path. Return null if the path is not a mount point and there are no mount points under the path.
      Throws:
      IOException - Throws exception if the data is not available.
    • getMounts

      public List<MountTable> getMounts(String path) throws IOException
      Get all the mount records at or beneath a given path.
      Parameters:
      path - Path to get the mount points from.
      Returns:
      List of mount table records under the path or null if the path is not found.
      Throws:
      IOException - If it's not connected to the State Store.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDefaultNamespace

      public String getDefaultNamespace()
      Description copied from interface: FileSubclusterResolver
      Get the default namespace for the cluster.
      Specified by:
      getDefaultNamespace in interface FileSubclusterResolver
      Returns:
      Default namespace identifier.
    • getCacheSize

      protected long getCacheSize() throws IOException
      Get the size of the cache.
      Returns:
      Size of the cache.
      Throws:
      IOException - If the cache is not initialized.
    • getDefaultNameService

      @VisibleForTesting public String getDefaultNameService()
    • setDefaultNameService

      @VisibleForTesting public void setDefaultNameService(String defaultNameService)
    • isDefaultNSEnable

      @VisibleForTesting public boolean isDefaultNSEnable()
    • setDefaultNSEnable

      @VisibleForTesting public void setDefaultNSEnable(boolean defaultNSRWEnable)
    • setDisabled

      @VisibleForTesting public void setDisabled(boolean disable)
    • getLocCacheMiss

      public LongAdder getLocCacheMiss()
    • getLocCacheAccess

      public LongAdder getLocCacheAccess()