@InterfaceAudience.Private public abstract class FSUtils extends CommonFSUtils
Modifier and Type | Class and Description |
---|---|
static class |
FSUtils.BlackListDirFilter
Directory filter that doesn't include any of the directories in the specified blacklist
|
static class |
FSUtils.DirFilter
A
PathFilter that only allows directories. |
static class |
FSUtils.FamilyDirFilter
Filter for all dirs that are legal column family names.
|
static class |
FSUtils.HFileFilter
Filter for HFiles that excludes reference files.
|
static class |
FSUtils.HFileLinkFilter
Filter for HFileLinks (StoreFiles and HFiles not included).
|
static class |
FSUtils.ReferenceFileFilter |
static class |
FSUtils.RegionDirFilter
Filter for all dirs that don't start with '.'
|
static class |
FSUtils.UserTableDirFilter
A
PathFilter that returns usertable directories. |
CommonFSUtils.StreamLacksCapabilityException
Modifier and Type | Field and Description |
---|---|
static boolean |
WINDOWS
Set to true on Windows platforms
|
FULL_RWX_PERMISSIONS, HBASE_WAL_DIR, UNSAFE_STREAM_CAPABILITY_ENFORCE
Modifier | Constructor and Description |
---|---|
protected |
FSUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addToHDFSBlocksDistribution(HDFSBlocksDistribution blocksDistribution,
org.apache.hadoop.fs.BlockLocation[] blockLocations)
Update blocksDistribution with blockLocations
|
static void |
checkAccess(org.apache.hadoop.security.UserGroupInformation ugi,
org.apache.hadoop.fs.FileStatus file,
org.apache.hadoop.fs.permission.FsAction action)
Throw an exception if an action is not permitted by a user on a file.
|
static boolean |
checkClusterIdExists(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
int wait)
Checks that a cluster ID file exists in the HBase root directory
|
static void |
checkDfsSafeMode(org.apache.hadoop.conf.Configuration conf)
Check whether dfs is in safemode.
|
static void |
checkFileSystemAvailable(org.apache.hadoop.fs.FileSystem fs)
Checks to see if the specified file system is available
|
static void |
checkShortCircuitReadBufferSize(org.apache.hadoop.conf.Configuration conf)
Check if short circuit read buffer size is set and if not, set it to hbase value.
|
static void |
checkVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
boolean message)
Verifies current version of file system
|
static void |
checkVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
boolean message,
int wait,
int retries)
Verifies current version of file system
|
static HDFSBlocksDistribution |
computeHDFSBlocksDistribution(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.FileStatus status,
long start,
long length)
Compute HDFS blocks distribution of a given file, or a portion of the file
|
static List<org.apache.hadoop.fs.Path> |
copyFilesParallel(org.apache.hadoop.fs.FileSystem srcFS,
org.apache.hadoop.fs.Path src,
org.apache.hadoop.fs.FileSystem dstFS,
org.apache.hadoop.fs.Path dst,
org.apache.hadoop.conf.Configuration conf,
int threads) |
static org.apache.hadoop.fs.FSDataOutputStream |
create(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.permission.FsPermission perm,
InetSocketAddress[] favoredNodes)
Create the specified file on the filesystem.
|
static boolean |
deleteRegionDir(org.apache.hadoop.conf.Configuration conf,
HRegionInfo hri)
Delete the region directory if exists.
|
static List<org.apache.hadoop.fs.FileStatus> |
filterFileStatuses(org.apache.hadoop.fs.FileStatus[] input,
FileStatusFilter filter)
Filters FileStatuses in an array and returns a list
|
static List<org.apache.hadoop.fs.FileStatus> |
filterFileStatuses(Iterator<org.apache.hadoop.fs.FileStatus> input,
FileStatusFilter filter)
Filters FileStatuses in an iterator and returns a list
|
static ClusterId |
getClusterId(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir)
Returns the value of the unique cluster ID stored for this HBase instance.
|
static org.apache.hadoop.hdfs.DFSHedgedReadMetrics |
getDFSHedgedReadMetrics(org.apache.hadoop.conf.Configuration c) |
static List<org.apache.hadoop.fs.Path> |
getFamilyDirs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path regionDir)
Given a particular region dir, return all the familydirs inside it
|
static FSUtils |
getInstance(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration conf) |
static List<org.apache.hadoop.fs.Path> |
getLocalTableDirs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir) |
static List<org.apache.hadoop.fs.Path> |
getReferenceFilePaths(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path familyDir) |
static Map<String,Map<String,Float>> |
getRegionDegreeLocalityMappingFromFS(org.apache.hadoop.conf.Configuration conf)
This function is to scan the root path of the file system to get the
degree of locality for each region on each of the servers having at least
one block of that region.
|
static Map<String,Map<String,Float>> |
getRegionDegreeLocalityMappingFromFS(org.apache.hadoop.conf.Configuration conf,
String desiredTable,
int threadPoolSize)
This function is to scan the root path of the file system to get the
degree of locality for each region on each of the servers having at least
one block of that region.
|
static org.apache.hadoop.fs.Path |
getRegionDirFromRootDir(org.apache.hadoop.fs.Path rootDir,
RegionInfo region) |
static org.apache.hadoop.fs.Path |
getRegionDirFromTableDir(org.apache.hadoop.fs.Path tableDir,
RegionInfo region) |
static List<org.apache.hadoop.fs.Path> |
getRegionDirs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir)
Given a particular table dir, return all the regiondirs inside it, excluding files such as
.tableinfo
|
static int |
getRegionReferenceFileCount(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path p) |
static List<org.apache.hadoop.fs.Path> |
getTableDirs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir) |
static Map<String,Integer> |
getTableFragmentation(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir)
Runs through the HBase rootdir and checks how many stores for each table
have more than one file in them.
|
static Map<String,Integer> |
getTableFragmentation(HMaster master)
Runs through the HBase rootdir and checks how many stores for each table
have more than one file in them.
|
static Map<String,org.apache.hadoop.fs.Path> |
getTableStoreFilePathMap(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir)
Runs through the HBase rootdir and creates a reverse lookup map for
table StoreFile names to the full Path.
|
static Map<String,org.apache.hadoop.fs.Path> |
getTableStoreFilePathMap(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir,
org.apache.hadoop.fs.PathFilter sfFilter,
ExecutorService executor,
HBaseFsck.ErrorReporter errors)
Runs through the HBase rootdir and creates a reverse lookup map for
table StoreFile names to the full Path.
|
static Map<String,org.apache.hadoop.fs.Path> |
getTableStoreFilePathMap(Map<String,org.apache.hadoop.fs.Path> map,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir,
TableName tableName)
Runs through the HBase rootdir/tablename and creates a reverse lookup map for
table StoreFile names to the full Path.
|
static Map<String,org.apache.hadoop.fs.Path> |
getTableStoreFilePathMap(Map<String,org.apache.hadoop.fs.Path> resultMap,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir,
TableName tableName,
org.apache.hadoop.fs.PathFilter sfFilter,
ExecutorService executor,
HBaseFsck.ErrorReporter errors)
Runs through the HBase rootdir/tablename and creates a reverse lookup map for
table StoreFile names to the full Path.
|
static int |
getTotalTableFragmentation(HMaster master)
Returns the total overall fragmentation percentage.
|
static String |
getVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir)
Verifies current version of file system
|
static boolean |
isDistributedFileSystem(org.apache.hadoop.fs.FileSystem fs) |
static boolean |
isMatchingTail(org.apache.hadoop.fs.Path pathToSearch,
org.apache.hadoop.fs.Path pathTail)
Compare path component of the Path URI; e.g.
|
static List<org.apache.hadoop.fs.FileStatus> |
listStatusWithStatusFilter(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path dir,
FileStatusFilter filter)
Calls fs.listStatus() and treats FileNotFoundException as non-fatal
This accommodates differences between hadoop versions, where hadoop 1
does not throw a FileNotFoundException, and return an empty FileStatus[]
while Hadoop 2 will throw FileNotFoundException.
|
static boolean |
metaRegionExists(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootDir)
Checks if meta region exists
|
abstract void |
recoverFileLease(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path p,
org.apache.hadoop.conf.Configuration conf,
CancelableProgressable reporter)
Recover file lease.
|
static void |
setClusterId(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
ClusterId clusterId,
int wait)
Writes a new unique identifier for this cluster to the "hbase.id" file
in the HBase root directory
|
static void |
setupShortCircuitRead(org.apache.hadoop.conf.Configuration conf)
Do our short circuit read setup.
|
static void |
setVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir)
Sets version of file system
|
static void |
setVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
int wait,
int retries)
Sets version of file system
|
static void |
setVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
String version,
int wait,
int retries)
Sets version of file system
|
static void |
waitOnSafeMode(org.apache.hadoop.conf.Configuration conf,
long wait)
If DFS, check safe mode and if so, wait until we clear it.
|
create, createForWal, createForWal, delete, deleteDirectory, getCurrentFileSystem, getDefaultBlockSize, getDefaultBufferSize, getDefaultReplication, getFilePermissions, getNamespaceDir, getPath, getRootDir, getRootDirFileSystem, getTableDir, getTableName, getWALFileSystem, getWALRegionDir, getWALRootDir, getWALTableDir, getWrongWALRegionDir, hasCapability, isExists, isHDFS, isMatchingTail, isRecoveredEdits, isStartingWithPath, listLocatedStatus, listStatus, listStatus, logFileSystemState, removeWALRootPath, renameAndSetModifyTime, setFsDefault, setRootDir, setStoragePolicy, setWALRootDir, validateRootPath
public static boolean isDistributedFileSystem(org.apache.hadoop.fs.FileSystem fs) throws IOException
fs
is instance of DistributedFileSystemIOException
public static boolean isMatchingTail(org.apache.hadoop.fs.Path pathToSearch, org.apache.hadoop.fs.Path pathTail)
pathToSearch
- Path we will be trying to match.pathTail
- pathTail
is tail on the path of pathToSearch
public static FSUtils getInstance(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf)
public static boolean deleteRegionDir(org.apache.hadoop.conf.Configuration conf, HRegionInfo hri) throws IOException
conf
- hri
- IOException
public static org.apache.hadoop.fs.FSDataOutputStream create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission perm, InetSocketAddress[] favoredNodes) throws IOException
HColumnDescriptor.DEFAULT_DFS_REPLICATION
conf
- configurationsfs
- FileSystem
on which to write the filepath
- Path
to the file to writeperm
- permissionsfavoredNodes
- IOException
- if the file cannot be createdpublic static void checkFileSystemAvailable(org.apache.hadoop.fs.FileSystem fs) throws IOException
fs
- filesystemIOException
- epublic static void checkDfsSafeMode(org.apache.hadoop.conf.Configuration conf) throws IOException
conf
- IOException
public static String getVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir) throws IOException, DeserializationException
fs
- filesystem objectrootdir
- root hbase directoryIOException
- eDeserializationException
public static void checkVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, boolean message) throws IOException, DeserializationException
fs
- file systemrootdir
- root directory of HBase installationmessage
- if true, issues a message on System.outIOException
- eDeserializationException
public static void checkVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, boolean message, int wait, int retries) throws IOException, DeserializationException
fs
- file systemrootdir
- root directory of HBase installationmessage
- if true, issues a message on System.outwait
- wait intervalretries
- number of times to retryIOException
- eDeserializationException
public static void setVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir) throws IOException
fs
- filesystem objectrootdir
- hbase rootIOException
- epublic static void setVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, int wait, int retries) throws IOException
fs
- filesystem objectrootdir
- hbase rootwait
- time to wait for retryretries
- number of times to retry before failingIOException
- epublic static void setVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, String version, int wait, int retries) throws IOException
fs
- filesystem objectrootdir
- hbase root directoryversion
- version to setwait
- time to wait for retryretries
- number of times to retry before throwing an IOExceptionIOException
- epublic static boolean checkClusterIdExists(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, int wait) throws IOException
fs
- the root directory FileSystemrootdir
- the HBase root directory in HDFSwait
- how long to wait between retriestrue
if the file exists, otherwise false
IOException
- if checking the FileSystem failspublic static ClusterId getClusterId(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir) throws IOException
fs
- the root directory FileSystemrootdir
- the path to the HBase root directoryIOException
- if reading the cluster ID file failspublic static void setClusterId(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, ClusterId clusterId, int wait) throws IOException
fs
- the root directory FileSystemrootdir
- the path to the HBase root directoryclusterId
- the unique identifier to storewait
- how long (in milliseconds) to wait between retriesIOException
- if writing to the FileSystem fails and no wait valuepublic static void waitOnSafeMode(org.apache.hadoop.conf.Configuration conf, long wait) throws IOException
conf
- configurationwait
- Sleep between retriesIOException
- epublic static boolean metaRegionExists(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir) throws IOException
fs
- file systemrootDir
- root directory of HBase installationIOException
public static HDFSBlocksDistribution computeHDFSBlocksDistribution(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.FileStatus status, long start, long length) throws IOException
fs
- file systemstatus
- file status of the filestart
- start position of the portionlength
- length of the portionIOException
public static void addToHDFSBlocksDistribution(HDFSBlocksDistribution blocksDistribution, org.apache.hadoop.fs.BlockLocation[] blockLocations) throws IOException
blocksDistribution
- the hdfs blocks distributionblockLocations
- an array containing block locationIOException
public static int getTotalTableFragmentation(HMaster master) throws IOException
master
- The master defining the HBase root and file system.IOException
- When scanning the directory fails.public static Map<String,Integer> getTableFragmentation(HMaster master) throws IOException
master
- The master defining the HBase root and file system.IOException
- When scanning the directory fails.public static Map<String,Integer> getTableFragmentation(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir) throws IOException
fs
- The file system to use.hbaseRootDir
- The root directory to scan.IOException
- When scanning the directory fails.public abstract void recoverFileLease(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p, org.apache.hadoop.conf.Configuration conf, CancelableProgressable reporter) throws IOException
fs
- FileSystem handlep
- Path of file to recover leaseconf
- Configuration handleIOException
public static List<org.apache.hadoop.fs.Path> getTableDirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir) throws IOException
IOException
public static List<org.apache.hadoop.fs.Path> getLocalTableDirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir) throws IOException
fs
- rootdir
- rootdir
. Ignore non table hbase folders such as
.logs, .oldlogs, .corrupt folders.IOException
public static List<org.apache.hadoop.fs.Path> getRegionDirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir) throws IOException
fs
- A file system for the PathtableDir
- Path to a specific table directory <hbase.rootdir>/<tabledir>IOException
public static org.apache.hadoop.fs.Path getRegionDirFromRootDir(org.apache.hadoop.fs.Path rootDir, RegionInfo region)
public static org.apache.hadoop.fs.Path getRegionDirFromTableDir(org.apache.hadoop.fs.Path tableDir, RegionInfo region)
public static List<org.apache.hadoop.fs.Path> getFamilyDirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path regionDir) throws IOException
fs
- A file system for the PathregionDir
- Path to a specific region directoryIOException
public static List<org.apache.hadoop.fs.Path> getReferenceFilePaths(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path familyDir) throws IOException
IOException
public static Map<String,org.apache.hadoop.fs.Path> getTableStoreFilePathMap(Map<String,org.apache.hadoop.fs.Path> map, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir, TableName tableName) throws IOException, InterruptedException
map
- map to add values. If null, this method will create and populate one to returnfs
- The file system to use.hbaseRootDir
- The root directory to scan.tableName
- name of the table to scan.IOException
- When scanning the directory fails.InterruptedException
public static Map<String,org.apache.hadoop.fs.Path> getTableStoreFilePathMap(Map<String,org.apache.hadoop.fs.Path> resultMap, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir, TableName tableName, org.apache.hadoop.fs.PathFilter sfFilter, ExecutorService executor, HBaseFsck.ErrorReporter errors) throws IOException, InterruptedException
resultMap
- map to add values. If null, this method will create and populate one to returnfs
- The file system to use.hbaseRootDir
- The root directory to scan.tableName
- name of the table to scan.sfFilter
- optional path filter to apply to store filesexecutor
- optional executor service to parallelize this operationerrors
- ErrorReporter instance or nullIOException
- When scanning the directory fails.InterruptedException
public static int getRegionReferenceFileCount(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p)
public static Map<String,org.apache.hadoop.fs.Path> getTableStoreFilePathMap(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir) throws IOException, InterruptedException
fs
- The file system to use.hbaseRootDir
- The root directory to scan.IOException
- When scanning the directory fails.InterruptedException
public static Map<String,org.apache.hadoop.fs.Path> getTableStoreFilePathMap(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir, org.apache.hadoop.fs.PathFilter sfFilter, ExecutorService executor, HBaseFsck.ErrorReporter errors) throws IOException, InterruptedException
fs
- The file system to use.hbaseRootDir
- The root directory to scan.sfFilter
- optional path filter to apply to store filesexecutor
- optional executor service to parallelize this operationerrors
- ErrorReporter instance or nullIOException
- When scanning the directory fails.InterruptedException
public static List<org.apache.hadoop.fs.FileStatus> filterFileStatuses(org.apache.hadoop.fs.FileStatus[] input, FileStatusFilter filter)
input
- An array of FileStatusesfilter
- A required filter to filter the arraypublic static List<org.apache.hadoop.fs.FileStatus> filterFileStatuses(Iterator<org.apache.hadoop.fs.FileStatus> input, FileStatusFilter filter)
input
- An iterator of FileStatusesfilter
- A required filter to filter the arraypublic static List<org.apache.hadoop.fs.FileStatus> listStatusWithStatusFilter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, FileStatusFilter filter) throws IOException
fs
- file systemdir
- directoryfilter
- file status filterIOException
public static void checkAccess(org.apache.hadoop.security.UserGroupInformation ugi, org.apache.hadoop.fs.FileStatus file, org.apache.hadoop.fs.permission.FsAction action) throws AccessDeniedException
ugi
- the userfile
- the fileaction
- the actionAccessDeniedException
public static Map<String,Map<String,Float>> getRegionDegreeLocalityMappingFromFS(org.apache.hadoop.conf.Configuration conf) throws IOException
RegionPlacementMaintainer
conf
- the configuration to useIOException
- in case of file system errors or interruptspublic static Map<String,Map<String,Float>> getRegionDegreeLocalityMappingFromFS(org.apache.hadoop.conf.Configuration conf, String desiredTable, int threadPoolSize) throws IOException
conf
- the configuration to usedesiredTable
- the table you wish to scan locality forthreadPoolSize
- the thread pool size to useIOException
- in case of file system errors or interruptspublic static void setupShortCircuitRead(org.apache.hadoop.conf.Configuration conf)
conf
- public static void checkShortCircuitReadBufferSize(org.apache.hadoop.conf.Configuration conf)
conf
- public static org.apache.hadoop.hdfs.DFSHedgedReadMetrics getDFSHedgedReadMetrics(org.apache.hadoop.conf.Configuration c) throws IOException
c
- IOException
public static List<org.apache.hadoop.fs.Path> copyFilesParallel(org.apache.hadoop.fs.FileSystem srcFS, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.FileSystem dstFS, org.apache.hadoop.fs.Path dst, org.apache.hadoop.conf.Configuration conf, int threads) throws IOException
IOException
Copyright © 2007–2019 Cloudera. All rights reserved.