org.apache.hadoop.hbase
Class HBaseFileSystem

java.lang.Object
  extended by org.apache.hadoop.hbase.HBaseFileSystem
Direct Known Subclasses:
HLogFileSystem, HRegionFileSystem

public abstract class HBaseFileSystem
extends Object

An abstraction of the underlying filesystem. This is used by other entities such as HLogFileSystem, to make calls to the underlying filesystem.


Field Summary
protected static int hdfsClientRetriesNumber
          In order to handle NN connectivity hiccups, one need to retry non-idempotent operation at the client level.
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
HBaseFileSystem()
           
 
Method Summary
static boolean createNewFileOnFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file)
          Creates the file.
static org.apache.hadoop.fs.FSDataOutputStream createPathOnFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, boolean overwrite)
          Creates a path on the file system.
static org.apache.hadoop.fs.FSDataOutputStream createPathWithPermsOnFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission perm, boolean overwrite)
          Creates the specified file with the given permission.
static boolean deleteDirFromFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir)
          Deletes a directory.
static boolean deleteFileFromFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file)
          Deletes a file.
static boolean makeDirOnFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir)
          Creates a directory for a filesystem and configuration object.
static boolean renameAndSetModifyTime(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dest)
          rename the src path to dest path and set the dest path's modify time to current timestamp
static boolean renameDirForFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst)
          Renames a directory.
protected static void setRetryCounts(org.apache.hadoop.conf.Configuration conf)
           
protected static void sleepBeforeRetry(String msg, int sleepMultiplier)
          sleeping logic for static methods; handles the interrupt exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

hdfsClientRetriesNumber

protected static int hdfsClientRetriesNumber
In order to handle NN connectivity hiccups, one need to retry non-idempotent operation at the client level.

Constructor Detail

HBaseFileSystem

public HBaseFileSystem()
Method Detail

deleteFileFromFileSystem

public static boolean deleteFileFromFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                               org.apache.hadoop.fs.Path file)
                                        throws IOException
Deletes a file. Assumes the user has already checked for this file's existence.

Parameters:
fs -
file -
Returns:
true if the file is deleted.
Throws:
IOException

deleteDirFromFileSystem

public static boolean deleteDirFromFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                              org.apache.hadoop.fs.Path dir)
                                       throws IOException
Deletes a directory. Assumes the user has already checked for this directory's existence.

Parameters:
fs -
dir -
Returns:
true if the directory is deleted.
Throws:
IOException

setRetryCounts

protected static void setRetryCounts(org.apache.hadoop.conf.Configuration conf)

makeDirOnFileSystem

public static boolean makeDirOnFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                          org.apache.hadoop.fs.Path dir)
                                   throws IOException
Creates a directory for a filesystem and configuration object. Assumes the user has already checked for this directory existence.

Parameters:
fs -
dir -
Returns:
the result of fs.mkdirs(). In case underlying fs throws an IOException, it checks whether the directory exists or not, and returns true if it exists.
Throws:
IOException

renameDirForFileSystem

public static boolean renameDirForFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                             org.apache.hadoop.fs.Path src,
                                             org.apache.hadoop.fs.Path dst)
                                      throws IOException
Renames a directory. Assumes the user has already checked for this directory existence.

Parameters:
fs -
src -
dst -
Returns:
true if the directory is renamed.
Throws:
IOException

createPathOnFileSystem

public static org.apache.hadoop.fs.FSDataOutputStream createPathOnFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                                                             org.apache.hadoop.fs.Path dir,
                                                                             boolean overwrite)
                                                                      throws IOException
Creates a path on the file system. Checks whether the path exists already or not, and use it for retrying in case underlying fs throws an exception. If the dir already exists and overwrite flag is false, the underlying FileSystem throws an IOE. It is not retried and the IOE is re-thrown to the caller.

Parameters:
fs -
dir -
overwrite -
Returns:
Throws:
IOException

createPathWithPermsOnFileSystem

public static org.apache.hadoop.fs.FSDataOutputStream createPathWithPermsOnFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                                                                      org.apache.hadoop.fs.Path path,
                                                                                      org.apache.hadoop.fs.permission.FsPermission perm,
                                                                                      boolean overwrite)
                                                                               throws IOException
Creates the specified file with the given permission. If the dir already exists and the overwrite flag is false, underlying FileSystem throws an IOE. It is not retried and the IOE is re-thrown to the caller.

Parameters:
fs -
path -
perm -
overwrite -
Returns:
Throws:
IOException

createNewFileOnFileSystem

public static boolean createNewFileOnFileSystem(org.apache.hadoop.fs.FileSystem fs,
                                                org.apache.hadoop.fs.Path file)
                                         throws IOException
Creates the file. Assumes the user has already checked for this file existence.

Parameters:
fs -
dir -
Returns:
result true if the file is created with this call, false otherwise.
Throws:
IOException

sleepBeforeRetry

protected static void sleepBeforeRetry(String msg,
                                       int sleepMultiplier)
sleeping logic for static methods; handles the interrupt exception. Keeping a static version for this to avoid re-looking for the integer values.


renameAndSetModifyTime

public static boolean renameAndSetModifyTime(org.apache.hadoop.fs.FileSystem fs,
                                             org.apache.hadoop.fs.Path src,
                                             org.apache.hadoop.fs.Path dest)
                                      throws IOException
rename the src path to dest path and set the dest path's modify time to current timestamp

Throws:
IOException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.