public class HadoopFileSystem extends FileSystem implements java.io.Closeable
FileSystem.WriteMode
Constructor and Description |
---|
HadoopFileSystem(org.apache.hadoop.conf.Configuration hadoopConfig,
org.apache.hadoop.fs.FileSystem hadoopfileSystem) |
Modifier and Type | Method and Description |
---|---|
HadoopDataOutputStream |
append(Path path) |
void |
close() |
HadoopDataOutputStream |
create(Path f)
Create a file system with the OVERWRITE
|
FSDataOutputStream |
create(Path f,
FileSystem.WriteMode writeMode)
Create a file system with the specific write mdoe
|
boolean |
delete(Path f,
boolean recursive) |
boolean |
exists(Path f)
Check if the given path exsits
|
long |
getDefaultBlockSize() |
BlockLocation[] |
getFileBlockLocations(FileStatus file,
long start,
long len)
Return an array containing hostnames, offset and size of
portions of the given file.
|
FileStatus |
getFileStatus(Path f)
It returns the status of the file respective to the path given by the user.
|
org.apache.hadoop.fs.FileSystem |
getHadoopFileSystem() |
java.net.URI |
getUri()
Returns a URI whose scheme and authority identify this file system.
|
Path |
getWorkingDirectory()
Get the working Directory
|
void |
initialize(java.net.URI name)
Called after a new FileSystem instance is constructed.
|
boolean |
isDistributedFS() |
FileStatus[] |
listFiles(Path f)
List the statuses of the files/directories in the given path if the path is
a directory.
|
FileStatus[] |
listStatus(Path f) |
boolean |
mkdirs(Path f) |
HadoopDataInputStream |
open(Path f)
This method open and return the input stream object respective to the path
|
HadoopDataInputStream |
open(Path f,
int bufferSize) |
boolean |
rename(Path src,
Path dst) |
void |
setWorkingDirectory(Path path1)
Set the working Directory
|
isDirectory, isFile, isSymlink
public HadoopFileSystem(org.apache.hadoop.conf.Configuration hadoopConfig, org.apache.hadoop.fs.FileSystem hadoopfileSystem)
public org.apache.hadoop.fs.FileSystem getHadoopFileSystem()
public Path getWorkingDirectory()
getWorkingDirectory
in class FileSystem
public void setWorkingDirectory(Path path1)
setWorkingDirectory
in class FileSystem
public java.net.URI getUri()
FileSystem
getUri
in class FileSystem
public void initialize(java.net.URI name)
initialize
in class FileSystem
name
- a URI
whose authority section names the host, port, etc.
for this file systempublic FileStatus getFileStatus(Path f) throws java.io.IOException
getFileStatus
in class FileSystem
f
- The path we want information fromjava.io.FileNotFoundException
- when the path does not exist;
IOException see specific implementationjava.io.IOException
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws java.io.IOException
FileSystem
getFileBlockLocations
in class FileSystem
java.io.IOException
public HadoopDataInputStream open(Path f, int bufferSize) throws java.io.IOException
open
in class FileSystem
java.io.IOException
public HadoopDataInputStream open(Path f) throws java.io.IOException
open
in class FileSystem
f
- Open an data input stream at the indicated pathjava.io.IOException
public HadoopDataOutputStream create(Path f) throws java.io.IOException
FileSystem
create
in class FileSystem
f
- pathjava.io.IOException
- if an error occurspublic FSDataOutputStream create(Path f, FileSystem.WriteMode writeMode) throws java.io.IOException
FileSystem
create
in class FileSystem
f
- pathwriteMode
- weather overwrite or not, when creating new filesjava.io.IOException
- if an error occurspublic HadoopDataOutputStream append(Path path) throws java.io.IOException
java.io.IOException
public boolean delete(Path f, boolean recursive) throws java.io.IOException
delete
in class FileSystem
java.io.IOException
public boolean exists(Path f) throws java.io.IOException
FileSystem
exists
in class FileSystem
java.io.IOException
public FileStatus[] listStatus(Path f) throws java.io.IOException
listStatus
in class FileSystem
java.io.IOException
public boolean mkdirs(Path f) throws java.io.IOException
mkdirs
in class FileSystem
java.io.IOException
public boolean rename(Path src, Path dst) throws java.io.IOException
rename
in class FileSystem
java.io.IOException
public long getDefaultBlockSize()
getDefaultBlockSize
in class FileSystem
public boolean isDistributedFS()
isDistributedFS
in class FileSystem
public FileStatus[] listFiles(Path f) throws java.io.IOException
listFiles
in class FileSystem
f
- given pathjava.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException