org.apache.hadoop.fs
Class RawLocalFileSystem

java.lang.Object
  extended by org.apache.hadoop.conf.Configured
      extended by org.apache.hadoop.fs.FileSystem
          extended by org.apache.hadoop.fs.RawLocalFileSystem
All Implemented Interfaces:
Configurable

public class RawLocalFileSystem
extends FileSystem

Implement the FileSystem API for the raw local filesystem.

Author:
Mike Cafarella

Field Summary
 
Fields inherited from class org.apache.hadoop.fs.FileSystem
LOG
 
Constructor Summary
RawLocalFileSystem()
           
 
Method Summary
 void close()
          No more filesystem operations are needed.
 void completeLocalOutput(Path fsWorkingFile, Path tmpLocalFile)
          Called when we're all done writing to the target.
 void copyFromLocalFile(boolean delSrc, Path src, Path dst)
          The src file is on the local disk.
 void copyToLocalFile(boolean delSrc, Path src, Path dst)
          The src file is under FS, and the dst is on the local disk.
 FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
          Opens an FSDataOutputStream at the indicated Path with write-progress reporting.
 boolean delete(Path p)
          Delete a file
 boolean exists(Path f)
          Check if exists.
 long getBlockSize(Path filename)
          Get the block size for a particular file.
 short getDefaultReplication()
          Get the default replication.
 String[][] getFileCacheHints(Path f, long start, long len)
          Return 1x1 'localhost' cell if the file exists.
 long getLength(Path f)
          The number of bytes in a file.
 String getName()
          Deprecated.  
 short getReplication(Path f)
          Replication is not supported for the local file system.
 URI getUri()
          Returns a URI whose scheme and authority identify this FileSystem.
 Path getWorkingDirectory()
          Get the current working directory for the given file system
 void initialize(URI uri, Configuration conf)
          Called after a new FileSystem instance is constructed.
 boolean isDirectory(Path f)
          True iff the named path is a directory.
 Path[] listPaths(Path f)
          List files in a directory.
 void lock(Path p, boolean shared)
          Deprecated.  
 boolean mkdirs(Path f)
          Creates the specified directory hierarchy.
 void moveFromLocalFile(Path src, Path dst)
          The src file is on the local disk.
 FSDataInputStream open(Path f, int bufferSize)
          Opens an FSDataInputStream at the indicated Path.
 File pathToFile(Path path)
          Convert a path to a File.
 void release(Path p)
          Deprecated.  
 boolean rename(Path src, Path dst)
          Renames Path src to Path dst.
 boolean setReplication(Path src, short replication)
          Set the replication of the given file
 void setWorkingDirectory(Path newDir)
          Set the working directory to the given directory.
 Path startLocalOutput(Path fsOutputFile, Path tmpLocalFile)
          Returns a local File that the user can write output to.
 String toString()
           
 
Methods inherited from class org.apache.hadoop.fs.FileSystem
checkPath, closeAll, copyFromLocalFile, copyToLocalFile, create, create, create, create, create, create, create, createNewFile, get, get, getContentLength, getDefaultBlockSize, getLocal, getNamed, getUsed, globPaths, globPaths, isFile, listPaths, listPaths, listPaths, makeQualified, moveToLocalFile, open, parseArgs
 
Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RawLocalFileSystem

public RawLocalFileSystem()
Method Detail

pathToFile

public File pathToFile(Path path)
Convert a path to a File.


getFileCacheHints

public String[][] getFileCacheHints(Path f,
                                    long start,
                                    long len)
                             throws IOException
Return 1x1 'localhost' cell if the file exists. Return null if otherwise.

Specified by:
getFileCacheHints in class FileSystem
Throws:
IOException

getName

public String getName()
Deprecated. 

Specified by:
getName in class FileSystem

getUri

public URI getUri()
Description copied from class: FileSystem
Returns a URI whose scheme and authority identify this FileSystem.

Specified by:
getUri in class FileSystem

initialize

public void initialize(URI uri,
                       Configuration conf)
Description copied from class: FileSystem
Called after a new FileSystem instance is constructed.

Specified by:
initialize in class FileSystem
Parameters:
uri - a uri whose authority section names the host, port, etc. for this FileSystem
conf - the configuration

open

public FSDataInputStream open(Path f,
                              int bufferSize)
                       throws IOException
Description copied from class: FileSystem
Opens an FSDataInputStream at the indicated Path.

Specified by:
open in class FileSystem
Parameters:
f - the file name to open
bufferSize - the size of the buffer to be used.
Throws:
IOException

create

public FSDataOutputStream create(Path f,
                                 boolean overwrite,
                                 int bufferSize,
                                 short replication,
                                 long blockSize,
                                 Progressable progress)
                          throws IOException
Description copied from class: FileSystem
Opens an FSDataOutputStream at the indicated Path with write-progress reporting.

Specified by:
create in class FileSystem
Parameters:
f - the file name to open
overwrite - if a file with this name already exists, then if true, the file will be overwritten, and if false an error will be thrown.
bufferSize - the size of the buffer to be used.
replication - required block replication for the file.
Throws:
IOException

getReplication

public short getReplication(Path f)
                     throws IOException
Replication is not supported for the local file system.

Specified by:
getReplication in class FileSystem
Parameters:
f - file name
Returns:
file replication
Throws:
IOException

setReplication

public boolean setReplication(Path src,
                              short replication)
                       throws IOException
Set the replication of the given file

Specified by:
setReplication in class FileSystem
Parameters:
src - file name
replication - new replication
Returns:
true if successful; false if file does not exist or is a directory
Throws:
IOException

rename

public boolean rename(Path src,
                      Path dst)
               throws IOException
Description copied from class: FileSystem
Renames Path src to Path dst. Can take place on local fs or remote DFS.

Specified by:
rename in class FileSystem
Throws:
IOException

delete

public boolean delete(Path p)
               throws IOException
Description copied from class: FileSystem
Delete a file

Specified by:
delete in class FileSystem
Throws:
IOException

exists

public boolean exists(Path f)
               throws IOException
Description copied from class: FileSystem
Check if exists.

Specified by:
exists in class FileSystem
Parameters:
f - source file
Throws:
IOException

isDirectory

public boolean isDirectory(Path f)
                    throws IOException
Description copied from class: FileSystem
True iff the named path is a directory.

Specified by:
isDirectory in class FileSystem
Throws:
IOException

getLength

public long getLength(Path f)
               throws IOException
Description copied from class: FileSystem
The number of bytes in a file.

Specified by:
getLength in class FileSystem
Throws:
IOException

listPaths

public Path[] listPaths(Path f)
                 throws IOException
Description copied from class: FileSystem
List files in a directory.

Specified by:
listPaths in class FileSystem
Throws:
IOException

mkdirs

public boolean mkdirs(Path f)
               throws IOException
Creates the specified directory hierarchy. Does not treat existence as an error.

Specified by:
mkdirs in class FileSystem
Throws:
IOException

setWorkingDirectory

public void setWorkingDirectory(Path newDir)
Set the working directory to the given directory.

Specified by:
setWorkingDirectory in class FileSystem

getWorkingDirectory

public Path getWorkingDirectory()
Description copied from class: FileSystem
Get the current working directory for the given file system

Specified by:
getWorkingDirectory in class FileSystem
Returns:
the directory pathname

lock

@Deprecated
public void lock(Path p,
                            boolean shared)
          throws IOException
Deprecated. 

Description copied from class: FileSystem
Obtain a lock on the given Path

Specified by:
lock in class FileSystem
Throws:
IOException

release

@Deprecated
public void release(Path p)
             throws IOException
Deprecated. 

Description copied from class: FileSystem
Release the lock

Specified by:
release in class FileSystem
Throws:
IOException

moveFromLocalFile

public void moveFromLocalFile(Path src,
                              Path dst)
                       throws IOException
Description copied from class: FileSystem
The src file is on the local disk. Add it to FS at the given dst name, removing the source afterwards.

Overrides:
moveFromLocalFile in class FileSystem
Throws:
IOException

copyFromLocalFile

public void copyFromLocalFile(boolean delSrc,
                              Path src,
                              Path dst)
                       throws IOException
Description copied from class: FileSystem
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

Specified by:
copyFromLocalFile in class FileSystem
Throws:
IOException

copyToLocalFile

public void copyToLocalFile(boolean delSrc,
                            Path src,
                            Path dst)
                     throws IOException
Description copied from class: FileSystem
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.

Specified by:
copyToLocalFile in class FileSystem
Throws:
IOException

startLocalOutput

public Path startLocalOutput(Path fsOutputFile,
                             Path tmpLocalFile)
                      throws IOException
Description copied from class: FileSystem
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.

Specified by:
startLocalOutput in class FileSystem
Throws:
IOException

completeLocalOutput

public void completeLocalOutput(Path fsWorkingFile,
                                Path tmpLocalFile)
                         throws IOException
Description copied from class: FileSystem
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.

Specified by:
completeLocalOutput in class FileSystem
Throws:
IOException

close

public void close()
           throws IOException
Description copied from class: FileSystem
No more filesystem operations are needed. Will release any held locks.

Overrides:
close in class FileSystem
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getBlockSize

public long getBlockSize(Path filename)
Description copied from class: FileSystem
Get the block size for a particular file.

Specified by:
getBlockSize in class FileSystem
Parameters:
filename - the filename
Returns:
the number of bytes in a block

getDefaultReplication

public short getDefaultReplication()
Description copied from class: FileSystem
Get the default replication.

Specified by:
getDefaultReplication in class FileSystem


Copyright © 2006 The Apache Software Foundation