|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.conf.Configured
org.apache.hadoop.fs.FileSystem
public abstract class FileSystem
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 | |
---|---|
static Logger |
LOG
|
Constructor Summary | |
---|---|
protected |
FileSystem(Configuration conf)
|
Method Summary | |
---|---|
abstract void |
close()
No more filesystem operations are needed. |
abstract void |
completeLocalInput(File localFile)
Called when we're all done writing to the target. |
abstract void |
completeLocalOutput(File fsOutputFile,
File tmpLocalFile)
Called when we're all done writing to the target. |
abstract void |
copyFromLocalFile(File src,
File dst)
The src file is on the local disk. |
abstract void |
copyToLocalFile(File src,
File dst)
The src file is under FS2, and the dst is on the local disk. |
FSDataOutputStream |
create(File f)
Opens an FSDataOutputStream at the indicated File. |
FSDataOutputStream |
create(File f,
boolean overwrite,
int bufferSize)
Opens an FSDataOutputStream at the indicated File. |
boolean |
createNewFile(File f)
Creates the given File as a brand-new zero-length file. |
abstract FSOutputStream |
createRaw(File f,
boolean overwrite)
Opens an OutputStream at the indicated File. |
boolean |
delete(File f)
Deletes File |
abstract boolean |
deleteRaw(File f)
Deletes File |
abstract boolean |
exists(File f)
Check if exists |
static FileSystem |
get(Configuration conf)
Returns the configured filesystem implementation. |
abstract long |
getBlockSize()
Return the number of bytes that large input files should be optimally be split into to minimize i/o time. |
static File |
getChecksumFile(File file)
Return the name of the checksum file associated with a file. |
abstract String[][] |
getFileCacheHints(File f,
long start,
long len)
Return a 2D array of size 1x1 or greater, containing hostnames where portions of the given file can be found. |
abstract long |
getLength(File f)
The number of bytes in a file. |
abstract String |
getName()
Returns a name for this filesystem, suitable to pass to getNamed(String,Configuration) . |
static FileSystem |
getNamed(String name,
Configuration conf)
Returns a named filesystem. |
abstract File |
getWorkingDirectory()
Get the current working directory for the given file system |
abstract boolean |
isAbsolute(File f)
True iff the named path is absolute. |
static boolean |
isChecksumFile(File file)
Return true iff file is a checksum file name. |
abstract boolean |
isDirectory(File f)
True iff the named path is a directory. |
boolean |
isFile(File f)
True iff the named path is a regular file. |
File[] |
listFiles(File f)
List files in a directory. |
File[] |
listFiles(File f,
FileFilter filter)
Filter files in a directory. |
abstract File[] |
listFilesRaw(File f)
List files in a directory. |
abstract void |
lock(File f,
boolean shared)
Obtain a lock on the given File |
abstract void |
mkdirs(File f)
Make the given file and all non-existent parents into directories. |
abstract void |
moveFromLocalFile(File src,
File dst)
The src file is on the local disk. |
FSDataInputStream |
open(File f)
Opens an FSDataInputStream at the indicated File. |
FSDataInputStream |
open(File f,
int bufferSize)
Opens an FSDataInputStream at the indicated File. |
abstract FSInputStream |
openRaw(File f)
Opens an InputStream for the indicated File, whether local or via DFS. |
static FileSystem |
parseArgs(String[] argv,
int i,
Configuration conf)
Deprecated. use fs.default.name config option instead |
abstract void |
release(File f)
Release the lock |
boolean |
rename(File src,
File dst)
Renames File src to File dst. |
abstract boolean |
renameRaw(File src,
File dst)
Renames File src to File dst. |
abstract void |
reportChecksumFailure(File f,
FSInputStream in,
long start,
long length,
int crc)
Report a checksum error to the file system. |
abstract void |
setWorkingDirectory(File new_dir)
Set the current working directory for the given file system. |
abstract File |
startLocalInput(File fsInputFile,
File tmpLocalFile)
Returns a local File that the user can read from. |
abstract File |
startLocalOutput(File fsOutputFile,
File tmpLocalFile)
Returns a local File that the user can write output to. |
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, toString, wait, wait, wait |
Field Detail |
---|
public static final Logger LOG
Constructor Detail |
---|
protected FileSystem(Configuration conf)
Method Detail |
---|
public static FileSystem parseArgs(String[] argv, int i, Configuration conf) throws IOException
IOException
public static FileSystem get(Configuration conf) throws IOException
IOException
public abstract String getName()
getNamed(String,Configuration)
.
public static FileSystem getNamed(String name, Configuration conf) throws IOException
IOException
public static File getChecksumFile(File file)
public static boolean isChecksumFile(File file)
public abstract String[][] getFileCacheHints(File f, long start, long len) throws IOException
IOException
public FSDataInputStream open(File f, int bufferSize) throws IOException
f
- the file name to openbufferSize
- the size of the buffer to be used.
IOException
public FSDataInputStream open(File f) throws IOException
f
- the file to open
IOException
public abstract FSInputStream openRaw(File f) throws IOException
IOException
public FSDataOutputStream create(File f) throws IOException
IOException
public FSDataOutputStream create(File f, boolean overwrite, int bufferSize) throws IOException
f
- the file name to openoverwrite
- 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.
IOException
public abstract FSOutputStream createRaw(File f, boolean overwrite) throws IOException
f
- the file name to openoverwrite
- if a file with this name already exists, then if true,
the file will be overwritten, and if false an error will be thrown.
IOException
public boolean createNewFile(File f) throws IOException
IOException
public boolean rename(File src, File dst) throws IOException
IOException
public abstract boolean renameRaw(File src, File dst) throws IOException
IOException
public boolean delete(File f) throws IOException
IOException
public abstract boolean deleteRaw(File f) throws IOException
IOException
public abstract boolean exists(File f) throws IOException
IOException
public abstract boolean isDirectory(File f) throws IOException
IOException
public boolean isFile(File f) throws IOException
IOException
public abstract boolean isAbsolute(File f)
public abstract long getLength(File f) throws IOException
IOException
public File[] listFiles(File f) throws IOException
IOException
public abstract File[] listFilesRaw(File f) throws IOException
IOException
public File[] listFiles(File f, FileFilter filter) throws IOException
IOException
public abstract void setWorkingDirectory(File new_dir)
new_dir
- public abstract File getWorkingDirectory()
public abstract void mkdirs(File f) throws IOException
IOException
public abstract void lock(File f, boolean shared) throws IOException
IOException
public abstract void release(File f) throws IOException
IOException
public abstract void copyFromLocalFile(File src, File dst) throws IOException
IOException
public abstract void moveFromLocalFile(File src, File dst) throws IOException
IOException
public abstract void copyToLocalFile(File src, File dst) throws IOException
IOException
public abstract File startLocalOutput(File fsOutputFile, File tmpLocalFile) throws IOException
IOException
public abstract void completeLocalOutput(File fsOutputFile, File tmpLocalFile) throws IOException
IOException
public abstract File startLocalInput(File fsInputFile, File tmpLocalFile) throws IOException
IOException
public abstract void completeLocalInput(File localFile) throws IOException
IOException
public abstract void close() throws IOException
IOException
public abstract void reportChecksumFailure(File f, FSInputStream in, long start, long length, int crc)
f
- the file name containing the errorin
- the stream open on the filestart
- the position of the beginning of the bad data in the filelength
- the length of the bad data in the filecrc
- the expected CRC32 of the datapublic abstract long getBlockSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |