org.apache.hadoop.fs.viewfs
Class ViewFileSystem

java.lang.Object
  extended by org.apache.hadoop.conf.Configured
      extended by org.apache.hadoop.fs.FileSystem
          extended by org.apache.hadoop.fs.viewfs.ViewFileSystem
All Implemented Interfaces:
Closeable, Configurable

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class ViewFileSystem
extends FileSystem

ViewFileSystem (extends the FileSystem interface) implements a client-side mount table. Its spec and implementation is identical to ViewFs.


Field Summary
 
Fields inherited from class org.apache.hadoop.fs.FileSystem
DEFAULT_FS, FS_DEFAULT_NAME_KEY, LOG, SHUTDOWN_HOOK_PRIORITY, statistics
 
Constructor Summary
ViewFileSystem()
          This is the constructor with the signature needed by FileSystem.createFileSystem(URI, Configuration) After this constructor is called initialize() is called.
ViewFileSystem(Configuration conf)
          Convenience Constructor for apps to call directly
 
Method Summary
 FSDataOutputStream append(Path f, int bufferSize, Progressable progress)
          Append to an existing file (optional operation).
 FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
          Create an FSDataOutputStream at the indicated Path with write-progress reporting.
 FSDataOutputStream createNonRecursive(Path f, FsPermission permission, EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize, Progressable progress)
          Opens an FSDataOutputStream at the indicated Path with write-progress reporting.
 boolean delete(Path f)
          Delete a file
 boolean delete(Path f, boolean recursive)
          Delete a file.
 FileSystem[] getChildFileSystems()
          Get all the immediate child FileSystems embedded in this FileSystem.
 ContentSummary getContentSummary(Path f)
          Return the ContentSummary of a given Path.
 long getDefaultBlockSize()
          Return the number of bytes that large input files should be optimally be split into to minimize i/o time.
 long getDefaultBlockSize(Path f)
          Return the number of bytes that large input files should be optimally be split into to minimize i/o time.
 short getDefaultReplication()
          Get the default replication.
 short getDefaultReplication(Path f)
          Get the default replication for a path.
 BlockLocation[] getFileBlockLocations(FileStatus fs, long start, long len)
          Return an array containing hostnames, offset and size of portions of the given file.
 FileChecksum getFileChecksum(Path f)
          Get the checksum of a file.
 FileStatus getFileStatus(Path f)
          Return a file status object that represents the path.
 Path getHomeDirectory()
          Return the current user's home directory in this filesystem.
 org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint[] getMountPoints()
           
 String getScheme()
          Return the protocol scheme for the FileSystem.
 FsServerDefaults getServerDefaults()
          Return a set of server default configuration values
 FsServerDefaults getServerDefaults(Path f)
          Return a set of server default configuration values
 Path getTrashCanLocation(Path f)
           
 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 theUri, Configuration conf)
          Called after a new FileSystem instance is constructed.
 FileStatus[] listStatus(Path f)
          List the statuses of the files/directories in the given path if the path is a directory.
 boolean mkdirs(Path dir, FsPermission permission)
          Make the given file and all non-existent parents into directories.
 FSDataInputStream open(Path f, int bufferSize)
          Opens an FSDataInputStream at the indicated Path.
 boolean rename(Path src, Path dst)
          Renames Path src to Path dst.
 Path resolvePath(Path f)
          Return the fully-qualified path of path f resolving the path through any symlinks or mount point
 void setOwner(Path f, String username, String groupname)
          Set owner of a path (i.e.
 void setPermission(Path f, FsPermission permission)
          Set permission of a path.
 boolean setReplication(Path f, short replication)
          Set replication for an existing file.
 void setTimes(Path f, long mtime, long atime)
          Set access time of a file
 void setVerifyChecksum(boolean verifyChecksum)
          Set the verify checksum flag.
 void setWorkingDirectory(Path new_dir)
          Set the current working directory for the given file system.
 void setWriteChecksum(boolean writeChecksum)
          Set the write checksum flag.
 
Methods inherited from class org.apache.hadoop.fs.FileSystem
append, append, cancelDeleteOnExit, canonicalizeUri, checkPath, clearStatistics, close, closeAll, closeAllForUGI, completeLocalOutput, concat, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyToLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, create, createNewFile, createNonRecursive, createNonRecursive, createSnapshot, createSnapshot, createSymlink, deleteOnExit, deleteSnapshot, enableSymlinks, exists, fixRelativePart, get, get, get, getAllStatistics, getBlockSize, getCanonicalUri, getDefaultPort, getDefaultUri, getFileBlockLocations, getFileLinkStatus, getFileSystemClass, getFSofPath, getInitialWorkingDirectory, getLength, getLinkTarget, getLocal, getName, getNamed, getReplication, getStatistics, getStatistics, getStatus, getStatus, getUsed, globStatus, globStatus, isDirectory, isFile, isSymlinksEnabled, listCorruptFileBlocks, listFiles, listLocatedStatus, listLocatedStatus, listStatus, listStatus, listStatus, makeQualified, mkdirs, mkdirs, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, newInstance, newInstance, newInstance, newInstanceLocal, open, primitiveCreate, primitiveMkdir, primitiveMkdir, printStatistics, processDeleteOnExit, rename, renameSnapshot, resolveLink, setDefaultUri, setDefaultUri, startLocalOutput, supportsSymlinks
 
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
 

Constructor Detail

ViewFileSystem

public ViewFileSystem()
               throws IOException
This is the constructor with the signature needed by FileSystem.createFileSystem(URI, Configuration) After this constructor is called initialize() is called.

Throws:
IOException

ViewFileSystem

public ViewFileSystem(Configuration conf)
               throws IOException
Convenience Constructor for apps to call directly

Parameters:
conf -
Throws:
IOException
Method Detail

getScheme

public String getScheme()
Return the protocol scheme for the FileSystem.

Overrides:
getScheme in class FileSystem
Returns:
viewfs

initialize

public void initialize(URI theUri,
                       Configuration conf)
                throws IOException
Called after a new FileSystem instance is constructed.

Overrides:
initialize in class FileSystem
Parameters:
theUri - a uri whose authority section names the host, port, etc. for this FileSystem
conf - the configuration
Throws:
IOException

getTrashCanLocation

public Path getTrashCanLocation(Path f)
                         throws FileNotFoundException
Throws:
FileNotFoundException

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

resolvePath

public Path resolvePath(Path f)
                 throws IOException
Description copied from class: FileSystem
Return the fully-qualified path of path f resolving the path through any symlinks or mount point

Overrides:
resolvePath in class FileSystem
Parameters:
f - path to be resolved
Returns:
fully qualified path
Throws:
FileNotFoundException
IOException

getHomeDirectory

public Path getHomeDirectory()
Description copied from class: FileSystem
Return the current user's home directory in this filesystem. The default implementation returns "/user/$USER/".

Overrides:
getHomeDirectory 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

setWorkingDirectory

public void setWorkingDirectory(Path new_dir)
Description copied from class: FileSystem
Set the current working directory for the given file system. All relative paths will be resolved relative to it.

Specified by:
setWorkingDirectory in class FileSystem

append

public FSDataOutputStream append(Path f,
                                 int bufferSize,
                                 Progressable progress)
                          throws IOException
Description copied from class: FileSystem
Append to an existing file (optional operation).

Specified by:
append in class FileSystem
Parameters:
f - the existing file to be appended.
bufferSize - the size of the buffer to be used.
progress - for reporting progress if it is not null.
Throws:
IOException

createNonRecursive

public FSDataOutputStream createNonRecursive(Path f,
                                             FsPermission permission,
                                             EnumSet<CreateFlag> flags,
                                             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. Same as create(), except fails if parent directory doesn't already exist.

Overrides:
createNonRecursive in class FileSystem
Parameters:
f - the file name to open
flags - CreateFlags to use for this stream.
bufferSize - the size of the buffer to be used.
replication - required block replication for the file.
Throws:
IOException
See Also:
FileSystem.setPermission(Path, FsPermission)

create

public FSDataOutputStream create(Path f,
                                 FsPermission permission,
                                 boolean overwrite,
                                 int bufferSize,
                                 short replication,
                                 long blockSize,
                                 Progressable progress)
                          throws IOException
Description copied from class: FileSystem
Create 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
See Also:
FileSystem.setPermission(Path, FsPermission)

delete

public boolean delete(Path f,
                      boolean recursive)
               throws org.apache.hadoop.security.AccessControlException,
                      FileNotFoundException,
                      IOException
Description copied from class: FileSystem
Delete a file.

Specified by:
delete in class FileSystem
Parameters:
f - the path to delete.
recursive - if path is a directory and set to true, the directory is deleted else throws an exception. In case of a file the recursive can be set to either true or false.
Returns:
true if delete is successful else false.
Throws:
IOException
org.apache.hadoop.security.AccessControlException
FileNotFoundException

delete

public boolean delete(Path f)
               throws org.apache.hadoop.security.AccessControlException,
                      FileNotFoundException,
                      IOException
Description copied from class: FileSystem
Delete a file

Overrides:
delete in class FileSystem
Throws:
org.apache.hadoop.security.AccessControlException
FileNotFoundException
IOException

getFileBlockLocations

public BlockLocation[] getFileBlockLocations(FileStatus fs,
                                             long start,
                                             long len)
                                      throws IOException
Description copied from class: FileSystem
Return an array containing hostnames, offset and size of portions of the given file. 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'.

Overrides:
getFileBlockLocations in class FileSystem
Parameters:
fs - FilesStatus to get data from
start - offset into the given file
len - length for which to get locations for
Throws:
IOException

getFileChecksum

public FileChecksum getFileChecksum(Path f)
                             throws org.apache.hadoop.security.AccessControlException,
                                    FileNotFoundException,
                                    IOException
Description copied from class: FileSystem
Get the checksum of a file.

Overrides:
getFileChecksum in class FileSystem
Parameters:
f - The file path
Returns:
The file checksum. The default return value is null, which indicates that no checksum algorithm is implemented in the corresponding FileSystem.
Throws:
org.apache.hadoop.security.AccessControlException
FileNotFoundException
IOException

getFileStatus

public FileStatus getFileStatus(Path f)
                         throws org.apache.hadoop.security.AccessControlException,
                                FileNotFoundException,
                                IOException
Description copied from class: FileSystem
Return a file status object that represents the path.

Specified by:
getFileStatus in class FileSystem
Parameters:
f - The path we want information from
Returns:
a FileStatus object
Throws:
FileNotFoundException - when the path does not exist; IOException see specific implementation
org.apache.hadoop.security.AccessControlException
IOException

listStatus

public FileStatus[] listStatus(Path f)
                        throws org.apache.hadoop.security.AccessControlException,
                               FileNotFoundException,
                               IOException
Description copied from class: FileSystem
List the statuses of the files/directories in the given path if the path is a directory.

Specified by:
listStatus in class FileSystem
Parameters:
f - given path
Returns:
the statuses of the files/directories in the given patch
Throws:
FileNotFoundException - when the path does not exist; IOException see specific implementation
org.apache.hadoop.security.AccessControlException
IOException

mkdirs

public boolean mkdirs(Path dir,
                      FsPermission permission)
               throws IOException
Description copied from class: FileSystem
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.

Specified by:
mkdirs in class FileSystem
Parameters:
dir - path to create
permission - to apply to f
Throws:
IOException

open

public FSDataInputStream open(Path f,
                              int bufferSize)
                       throws org.apache.hadoop.security.AccessControlException,
                              FileNotFoundException,
                              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:
org.apache.hadoop.security.AccessControlException
FileNotFoundException
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
Parameters:
src - path to be renamed
dst - new path after rename
Returns:
true if rename is successful
Throws:
IOException - on failure

setOwner

public void setOwner(Path f,
                     String username,
                     String groupname)
              throws org.apache.hadoop.security.AccessControlException,
                     FileNotFoundException,
                     IOException
Description copied from class: FileSystem
Set owner of a path (i.e. a file or a directory). The parameters username and groupname cannot both be null.

Overrides:
setOwner in class FileSystem
Parameters:
f - The path
username - If it is null, the original username remains unchanged.
groupname - If it is null, the original groupname remains unchanged.
Throws:
org.apache.hadoop.security.AccessControlException
FileNotFoundException
IOException

setPermission

public void setPermission(Path f,
                          FsPermission permission)
                   throws org.apache.hadoop.security.AccessControlException,
                          FileNotFoundException,
                          IOException
Description copied from class: FileSystem
Set permission of a path.

Overrides:
setPermission in class FileSystem
Throws:
org.apache.hadoop.security.AccessControlException
FileNotFoundException
IOException

setReplication

public boolean setReplication(Path f,
                              short replication)
                       throws org.apache.hadoop.security.AccessControlException,
                              FileNotFoundException,
                              IOException
Description copied from class: FileSystem
Set replication for an existing file.

Overrides:
setReplication in class FileSystem
Parameters:
f - file name
replication - new replication
Returns:
true if successful; false if file does not exist or is a directory
Throws:
IOException
org.apache.hadoop.security.AccessControlException
FileNotFoundException

setTimes

public void setTimes(Path f,
                     long mtime,
                     long atime)
              throws org.apache.hadoop.security.AccessControlException,
                     FileNotFoundException,
                     IOException
Description copied from class: FileSystem
Set access time of a file

Overrides:
setTimes in class FileSystem
Parameters:
f - The path
mtime - Set the modification time of this file. The number of milliseconds since Jan 1, 1970. A value of -1 means that this call should not set modification time.
atime - Set the access time of this file. The number of milliseconds since Jan 1, 1970. A value of -1 means that this call should not set access time.
Throws:
org.apache.hadoop.security.AccessControlException
FileNotFoundException
IOException

setVerifyChecksum

public void setVerifyChecksum(boolean verifyChecksum)
Description copied from class: FileSystem
Set the verify checksum flag. This is only applicable if the corresponding FileSystem supports checksum. By default doesn't do anything.

Overrides:
setVerifyChecksum in class FileSystem

getDefaultBlockSize

public long getDefaultBlockSize()
Description copied from class: FileSystem
Return the number of bytes that large input files should be optimally be split into to minimize i/o time.

Overrides:
getDefaultBlockSize in class FileSystem

getDefaultReplication

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

Overrides:
getDefaultReplication in class FileSystem

getServerDefaults

public FsServerDefaults getServerDefaults()
                                   throws IOException
Description copied from class: FileSystem
Return a set of server default configuration values

Overrides:
getServerDefaults in class FileSystem
Returns:
server default configuration values
Throws:
IOException

getDefaultBlockSize

public long getDefaultBlockSize(Path f)
Description copied from class: FileSystem
Return the number of bytes that large input files should be optimally be split into to minimize i/o time. The given path will be used to locate the actual filesystem. The full path does not have to exist.

Overrides:
getDefaultBlockSize in class FileSystem
Parameters:
f - path of file
Returns:
the default block size for the path's filesystem

getDefaultReplication

public short getDefaultReplication(Path f)
Description copied from class: FileSystem
Get the default replication for a path. The given path will be used to locate the actual filesystem. The full path does not have to exist.

Overrides:
getDefaultReplication in class FileSystem
Parameters:
f - of the file
Returns:
default replication for the path's filesystem

getServerDefaults

public FsServerDefaults getServerDefaults(Path f)
                                   throws IOException
Description copied from class: FileSystem
Return a set of server default configuration values

Overrides:
getServerDefaults in class FileSystem
Parameters:
f - path is used to identify an FS since an FS could have another FS that it could be delegating the call to
Returns:
server default configuration values
Throws:
IOException

getContentSummary

public ContentSummary getContentSummary(Path f)
                                 throws IOException
Description copied from class: FileSystem
Return the ContentSummary of a given Path.

Overrides:
getContentSummary in class FileSystem
Parameters:
f - path to use
Throws:
IOException

setWriteChecksum

public void setWriteChecksum(boolean writeChecksum)
Description copied from class: FileSystem
Set the write checksum flag. This is only applicable if the corresponding FileSystem supports checksum. By default doesn't do anything.

Overrides:
setWriteChecksum in class FileSystem

getChildFileSystems

public FileSystem[] getChildFileSystems()
Description copied from class: FileSystem
Get all the immediate child FileSystems embedded in this FileSystem. It does not recurse and get grand children. If a FileSystem has multiple child FileSystems, then it should return a unique list of those FileSystems. Default is to return null to signify no children.

Returns:
FileSystems used by this FileSystem

getMountPoints

public org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint[] getMountPoints()


Copyright © 2013 Apache Software Foundation. All Rights Reserved.