org.apache.hadoop.util
Class DiskChecker

java.lang.Object
  extended by org.apache.hadoop.util.DiskChecker

public class DiskChecker
extends Object

Class that provides utility functions for checking disk problem


Nested Class Summary
static class DiskChecker.DiskErrorException
           
static class DiskChecker.DiskOutOfSpaceException
           
 
Constructor Summary
DiskChecker()
           
 
Method Summary
static void checkDir(File dir)
          Create the directory if it doesn't exist and
static void checkDir(LocalFileSystem localFS, Path dir, FsPermission expected)
          Create the local directory if necessary, check permissions and also ensure it can be read from and written into.
static boolean mkdirsWithExistsAndPermissionCheck(LocalFileSystem localFS, Path dir, FsPermission expected)
          Create the directory or check permissions if it already exists.
static boolean mkdirsWithExistsCheck(File dir)
          The semantics of mkdirsWithExistsCheck method is different from the mkdirs method provided in the Sun's java.io.File class in the following way: While creating the non-existent parent directories, this method checks for the existence of those directories if the mkdir fails at any point (since that directory might have just been created by some other process).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskChecker

public DiskChecker()
Method Detail

mkdirsWithExistsCheck

public static boolean mkdirsWithExistsCheck(File dir)
The semantics of mkdirsWithExistsCheck method is different from the mkdirs method provided in the Sun's java.io.File class in the following way: While creating the non-existent parent directories, this method checks for the existence of those directories if the mkdir fails at any point (since that directory might have just been created by some other process). If both mkdir() and the exists() check fails for any seemingly non-existent directory, then we signal an error; Sun's mkdir would signal an error (return false) if a directory it is attempting to create already exists or the mkdir fails.

Parameters:
dir -
Returns:
true on success, false on failure

checkDir

public static void checkDir(File dir)
                     throws DiskChecker.DiskErrorException
Create the directory if it doesn't exist and

Parameters:
dir -
Throws:
DiskChecker.DiskErrorException

mkdirsWithExistsAndPermissionCheck

public static boolean mkdirsWithExistsAndPermissionCheck(LocalFileSystem localFS,
                                                         Path dir,
                                                         FsPermission expected)
                                                  throws IOException
Create the directory or check permissions if it already exists. The semantics of mkdirsWithExistsAndPermissionCheck method is different from the mkdirs method provided in the Sun's java.io.File class in the following way: While creating the non-existent parent directories, this method checks for the existence of those directories if the mkdir fails at any point (since that directory might have just been created by some other process). If both mkdir() and the exists() check fails for any seemingly non-existent directory, then we signal an error; Sun's mkdir would signal an error (return false) if a directory it is attempting to create already exists or the mkdir fails.

Parameters:
localFS - local filesystem
dir - directory to be created or checked
expected - expected permission
Returns:
true on success, false on failure
Throws:
IOException

checkDir

public static void checkDir(LocalFileSystem localFS,
                            Path dir,
                            FsPermission expected)
                     throws DiskChecker.DiskErrorException,
                            IOException
Create the local directory if necessary, check permissions and also ensure it can be read from and written into.

Parameters:
localFS - local filesystem
dir - directory
expected - permission
Throws:
DiskChecker.DiskErrorException
IOException


Copyright © 2009 The Apache Software Foundation