Class MountTableResolver
java.lang.Object
org.apache.hadoop.hdfs.server.federation.resolver.MountTableResolver
- All Implemented Interfaces:
FileSubclusterResolver,StateStoreCache
- Direct Known Subclasses:
MultipleDestinationMountTableResolver
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 Summary
ConstructorsConstructorDescriptionMountTableResolver(org.apache.hadoop.conf.Configuration conf) MountTableResolver(org.apache.hadoop.conf.Configuration conf, Router routerService) MountTableResolver(org.apache.hadoop.conf.Configuration conf, Router routerService, StateStoreService store) MountTableResolver(org.apache.hadoop.conf.Configuration conf, StateStoreService store) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntry(MountTable entry) Add a mount entry to the table.voidclear()Clears all data.protected longGet the size of the cache.Get the default namespace for the cluster.getDestinationForPath(String path) Get the destinations for a global path.getMountPoint(String path) Get the mount table entry for a path.getMountPoints(String str) Get a list of mount points for a path.Get all the mount records at or beneath a given path.protected MountTableStoreGet the mount table store for this resolver.protected RouterGet a reference for the Router for this resolver.static Stringbooleanstatic booleanisTrashPath(String path) Check if path is the trail associated with the Trash.booleanloadCache(boolean force) Replaces the current in-memory cached of the mount table with a new version fetched from the data store.lookupLocation(String str) Build the path location to insert into the cache atomically.voidrefreshEntries(Collection<MountTable> entries) Updates the mount path tree with a new set of mount table entries.voidremoveEntry(String srcPath) Remove a mount table entry.voidsetDefaultNameService(String defaultNameService) voidsetDefaultNSEnable(boolean defaultNSRWEnable) voidsetDisabled(boolean disable) static StringSubtract a TrashCurrent to get a new path.toString()
-
Constructor Details
-
MountTableResolver
@VisibleForTesting public MountTableResolver(org.apache.hadoop.conf.Configuration conf) -
MountTableResolver
-
MountTableResolver
-
MountTableResolver
public MountTableResolver(org.apache.hadoop.conf.Configuration conf, Router routerService, StateStoreService store)
-
-
Method Details
-
getRouter
Get a reference for the Router for this resolver.- Returns:
- Router for this resolver.
-
getMountTableStore
Get the mount table store for this resolver.- Returns:
- Mount table store.
- Throws:
IOException- If it cannot connect to the State Store.
-
addEntry
Add a mount entry to the table.- Parameters:
entry- The mount table record to add from the state store.
-
removeEntry
Remove a mount table entry.- Parameters:
srcPath- Source path for the entry to remove.
-
refreshEntries
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
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
- Throws:
IOException
-
subtractTrashCurrentPath
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:
loadCachein interfaceStateStoreCache- Parameters:
force- If we force the load.- Returns:
- If the cache was loaded successfully.
-
clear
public void clear()Clears all data. -
getDestinationForPath
Description copied from interface:FileSubclusterResolverGet 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:
getDestinationForPathin interfaceFileSubclusterResolver- 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
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
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
Description copied from interface:FileSubclusterResolverGet a list of mount points for a path. Results are from the mount table cache.- Specified by:
getMountPointsin interfaceFileSubclusterResolver- 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
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
-
getDefaultNamespace
Description copied from interface:FileSubclusterResolverGet the default namespace for the cluster.- Specified by:
getDefaultNamespacein interfaceFileSubclusterResolver- Returns:
- Default namespace identifier.
-
getCacheSize
Get the size of the cache.- Returns:
- Size of the cache.
- Throws:
IOException- If the cache is not initialized.
-
getDefaultNameService
-
setDefaultNameService
-
isDefaultNSEnable
@VisibleForTesting public boolean isDefaultNSEnable() -
setDefaultNSEnable
@VisibleForTesting public void setDefaultNSEnable(boolean defaultNSRWEnable) -
setDisabled
@VisibleForTesting public void setDisabled(boolean disable) -
getLocCacheMiss
-
getLocCacheAccess
-