Save This Page
Home » hadoop-0.14.4 » org.apache » hadoop » fs » [javadoc | source]
org.apache.hadoop.fs
abstract public class: FileSystem [javadoc | source]
java.lang.Object
   org.apache.hadoop.conf.Configured
      org.apache.hadoop.fs.FileSystem

All Implemented Interfaces:
    Configurable

Direct Known Subclasses:
    S3FileSystem, PhasedFileSystem, HftpFileSystem, InMemoryFileSystem, RawInMemoryFileSystem, ChecksumFileSystem, LocalFileSystem, FilterFileSystem, RawLocalFileSystem, ChecksumDistributedFileSystem

An abstract base class for a fairly generic filesystem. It may be implemented as a distributed filesystem, or as a "local" one that reflects the locally-connected disk. The local version exists for small Hadopp instances and for testing.

All user code that may potentially use the Hadoop Distributed File System should be written to use a FileSystem object. The Hadoop DFS is a multi-machine system that appears as a single disk. It's useful because of its fault tolerance and potentially very large capacity.

The local implementation is LocalFileSystem and distributed implementation is DistributedFileSystem .
Field Summary
public static final  Log LOG     
Constructor:
 protected FileSystem() 
Method from org.apache.hadoop.fs.FileSystem Summary:
checkPath,   close,   closeAll,   completeLocalOutput,   copyFromLocalFile,   copyFromLocalFile,   copyToLocalFile,   copyToLocalFile,   create,   create,   create,   create,   create,   create,   create,   create,   createNewFile,   delete,   exists,   get,   get,   getBlockSize,   getContentLength,   getDefaultBlockSize,   getDefaultReplication,   getFileCacheHints,   getFileStatus,   getLength,   getLocal,   getName,   getNamed,   getReplication,   getUri,   getUsed,   getWorkingDirectory,   globPaths,   globPaths,   initialize,   isDirectory,   isFile,   listPaths,   listPaths,   listPaths,   listPaths,   lock,   makeQualified,   mkdirs,   moveFromLocalFile,   moveToLocalFile,   open,   open,   parseArgs,   release,   rename,   setReplication,   setWorkingDirectory,   startLocalOutput
Methods from org.apache.hadoop.conf.Configured:
getConf,   setConf
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.hadoop.fs.FileSystem Detail:
 protected  void checkPath(Path path) 
    Check that a Path belongs to this FileSystem.
 public  void close() throws IOException 
    No more filesystem operations are needed. Will release any held locks.
 public static synchronized  void closeAll() throws IOException 
    Close all cached filesystems. Be sure those filesystems are not used anymore.
 public  void completeLocalOutput(Path fsOutputFile,
    Path tmpLocalFile) throws IOException 
    Called when we're all done writing to the target. A local FS will do nothing, because we've written to exactly the right place. A remote FS will copy the contents of tmpLocalFile to the correct target at fsOutputFile.
 public  void copyFromLocalFile(Path src,
    Path dst) throws IOException 
    The src file is on the local disk. Add it to FS at the given dst name and the source is kept intact afterwards
 public  void copyFromLocalFile(boolean delSrc,
    Path src,
    Path dst) throws IOException 
    The src file is on the local disk. Add it to FS at the given dst name. delSrc indicates if the source should be removed
 public  void copyToLocalFile(Path src,
    Path dst) throws IOException 
    The src file is under FS, and the dst is on the local disk. Copy it from FS control to the local dst name.
 public  void copyToLocalFile(boolean delSrc,
    Path src,
    Path dst) throws IOException 
    The src file is under FS, and the dst is on the local disk. Copy it from FS control to the local dst name. delSrc indicates if the src will be removed or not.
 public FSDataOutputStream create(Path f) throws IOException 
    Opens an FSDataOutputStream at the indicated Path. Files are overwritten by default.
 public FSDataOutputStream create(Path f,
    Progressable progress) throws IOException 
    Create an FSDataOutputStream at the indicated Path with write-progress reporting. Files are overwritten by default.
 public FSDataOutputStream create(Path f,
    short replication) throws IOException 
    Opens an FSDataOutputStream at the indicated Path. Files are overwritten by default.
 public FSDataOutputStream create(Path f,
    short replication,
    Progressable progress) throws IOException 
    Opens an FSDataOutputStream at the indicated Path with write-progress reporting. Files are overwritten by default.
 public FSDataOutputStream create(Path f,
    boolean overwrite,
    int bufferSize) throws IOException 
    Opens an FSDataOutputStream at the indicated Path.
 public FSDataOutputStream create(Path f,
    boolean overwrite,
    int bufferSize,
    Progressable progress) throws IOException 
    Opens an FSDataOutputStream at the indicated Path with write-progress reporting.
 public FSDataOutputStream create(Path f,
    boolean overwrite,
    int bufferSize,
    short replication,
    long blockSize) throws IOException 
    Opens an FSDataOutputStream at the indicated Path.
 abstract public FSDataOutputStream create(Path f,
    boolean overwrite,
    int bufferSize,
    short replication,
    long blockSize,
    Progressable progress) throws IOException
    Opens an FSDataOutputStream at the indicated Path with write-progress reporting.
 public boolean createNewFile(Path f) throws IOException 
    Creates the given Path as a brand-new zero-length file. If create fails, or if it already existed, return false.
 abstract public boolean delete(Path f) throws IOException
    Delete a file
 abstract public boolean exists(Path f) throws IOException
    Check if exists.
 public static FileSystem get(Configuration conf) throws IOException 
    Returns the configured filesystem implementation.
 public static synchronized FileSystem get(URI uri,
    Configuration conf) throws IOException 
    Returns the FileSystem for this URI's scheme and authority. The scheme of the URI determines a configuration property name, fs.scheme.class whose value names the FileSystem class. The entire URI is passed to the FileSystem instance's initialize method.
 public long getBlockSize(Path f) throws IOException 
Deprecated! Use - getFileStatus() instead

 public long getContentLength(Path f) throws IOException 
    Return the number of bytes of the given path If f is a file, return the size of the file; If f is a directory, return the size of the directory tree
 public long getDefaultBlockSize() 
    Return the number of bytes that large input files should be optimally be split into to minimize i/o time.
 public short getDefaultReplication() 
    Get the default replication.
 public String[][] getFileCacheHints(Path f,
    long start,
    long len) throws IOException 
    Return a 2D array of size 1x1 or greater, containing hostnames where portions of the given file can be found. For a nonexistent file or regions, null will be returned. This call is most helpful with DFS, where it returns hostnames of machines that contain the given file. The FileSystem will simply return an elt containing 'localhost'.
 abstract public FileStatus getFileStatus(Path f) throws IOException
 public long getLength(Path f) throws IOException 
Deprecated! Use - getFileStatus() instead

 public static LocalFileSystem getLocal(Configuration conf) throws IOException 
    Get the local file syste
 public String getName() 
Deprecated! call - #getUri() instead.

 public static FileSystem getNamed(String name,
    Configuration conf) throws IOException 
Deprecated! call - #get(URI,Configuration) instead.

 public short getReplication(Path src) throws IOException 
Deprecated! Use - getFileStatus() instead

    Get replication.
 abstract public URI getUri()
    Returns a URI whose scheme and authority identify this FileSystem.
 public long getUsed() throws IOException 
    Return the total size of all files in the filesystem.
 abstract public Path getWorkingDirectory()
    Get the current working directory for the given file system
 public Path[] globPaths(Path filePattern) throws IOException 

    Return all the files that match filePattern and are not checksum files. Results are sorted by their names.

    A filename pattern is composed of regular characters and special pattern matching characters, which are:

    ?
    Matches any single character.

    *
    Matches zero or more characters.

    [abc]
    Matches a single character from character set {a,b,c}.

    [a-b]
    Matches a single character from the character range {a...b}. Note that character a must be lexicographically less than or equal to character b.

    [^a]
    Matches a single character that is not from character set or range {a}. Note that the ^ character must occur immediately to the right of the opening bracket.

    \c
    Removes (escapes) any special meaning of character c.
 public Path[] globPaths(Path filePattern,
    PathFilter filter) throws IOException 
    glob all the file names that matches filePattern and is accepted by filter.
 abstract public  void initialize(URI name,
    Configuration conf) throws IOException
    Called after a new FileSystem instance is constructed.
 public boolean isDirectory(Path f) throws IOException 
Deprecated! Use - getFileStatus() instead

 public boolean isFile(Path f) throws IOException 
    True iff the named path is a regular file.
 abstract public Path[] listPaths(Path f) throws IOException
    List files in a directory.
 public Path[] listPaths(Path[] files) throws IOException 
    Filter files in the given pathes using the default checksum filter.
 public Path[] listPaths(Path f,
    PathFilter filter) throws IOException 
    Filter files in a directory.
 public Path[] listPaths(Path[] files,
    PathFilter filter) throws IOException 
    Filter files in a list directories using user-supplied path filter.
 public  void lock(Path f,
    boolean shared) throws IOException 
Deprecated! FS - does not support file locks anymore.

    Obtain a lock on the given Path
 public Path makeQualified(Path path) 
    Make sure that a path specifies a FileSystem.
 abstract public boolean mkdirs(Path f) throws IOException
    Make the given file and all non-existent parents into directories. Has the semantics of Unix 'mkdir -p'. Existence of the directory hierarchy is not an error.
 public  void moveFromLocalFile(Path src,
    Path dst) throws IOException 
    The src file is on the local disk. Add it to FS at the given dst name, removing the source afterwards.
 public  void moveToLocalFile(Path src,
    Path dst) throws IOException 
    The src file is under FS, and the dst is on the local disk. Copy it from FS control to the local dst name. Remove the source afterwards
 public FSDataInputStream open(Path f) throws IOException 
    Opens an FSDataInputStream at the indicated Path.
 abstract public FSDataInputStream open(Path f,
    int bufferSize) throws IOException
    Opens an FSDataInputStream at the indicated Path.
 public static FileSystem parseArgs(String[] argv,
    int i,
    Configuration conf) throws IOException 
    Parse the cmd-line args, starting at i. Remove consumed args from array. We expect param in the form: '-local | -dfs '
 public  void release(Path f) throws IOException 
Deprecated! FS - does not support file locks anymore.

    Release the lock
 abstract public boolean rename(Path src,
    Path dst) throws IOException
    Renames Path src to Path dst. Can take place on local fs or remote DFS.
 public boolean setReplication(Path src,
    short replication) throws IOException 
    Set replication for an existing file.
 abstract public  void setWorkingDirectory(Path new_dir)
    Set the current working directory for the given file system. All relative paths will be resolved relative to it.
 public Path startLocalOutput(Path fsOutputFile,
    Path tmpLocalFile) throws IOException 
    Returns a local File that the user can write output to. The caller provides both the eventual FS target name and the local working file. If the FS is local, we write directly into the target. If the FS is remote, we write into the tmp local area.