public class WebHdfsFileSystem extends FileSystem implements DelegationTokenRenewer.Renewable
Modifier and Type | Class and Description |
---|---|
static class |
WebHdfsFileSystem.DtRenewer
Delegation token renewer.
|
FileSystem.Statistics
Modifier and Type | Field and Description |
---|---|
static org.apache.hadoop.hdfs.web.WebHdfsFileSystem.WebHdfsDelegationTokenSelector |
DT_SELECTOR
Token selector
|
static org.apache.commons.logging.Log |
LOG |
static String |
PATH_PREFIX
Http URI: http://namenode:port/{PATH_PREFIX}/path/to/file
|
static String |
SCHEME
File System URI: {SCHEME}://namenode:port/path/to/file
|
static Text |
TOKEN_KIND
Delegation token kind
|
static int |
VERSION
WebHdfs version.
|
DEFAULT_FS, FS_DEFAULT_NAME_KEY, SHUTDOWN_HOOK_PRIORITY, statistics
Constructor and Description |
---|
WebHdfsFileSystem() |
Modifier and Type | Method and Description |
---|---|
protected void |
addRenewAction(WebHdfsFileSystem webhdfs) |
FSDataOutputStream |
append(Path f,
int bufferSize,
Progressable progress)
Append to an existing file (optional operation).
|
protected URI |
canonicalizeUri(URI uri)
Canonicalize the given URI.
|
void |
close()
No more filesystem operations are needed.
|
void |
concat(Path trg,
Path[] srcs)
Concat existing files together.
|
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.
|
void |
createSymlink(Path destination,
Path f,
boolean createParent)
Create a symlink pointing to the destination path.
|
boolean |
delete(Path f)
Delete a file
|
boolean |
delete(Path f,
boolean recursive)
Delete a file.
|
ContentSummary |
getContentSummary(Path p)
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.
|
protected int |
getDefaultPort()
Get the default port for this file system.
|
short |
getDefaultReplication()
Get the default replication.
|
protected Token<?> |
getDelegationToken() |
Token<DelegationTokenIdentifier> |
getDelegationToken(String renewer)
Get a new delegation token for this file system.
|
BlockLocation[] |
getFileBlockLocations(FileStatus status,
long offset,
long length)
Return an array containing hostnames, offset and size of
portions of the given file.
|
BlockLocation[] |
getFileBlockLocations(Path p,
long offset,
long length)
Return an array containing hostnames, offset and size of
portions of the given file.
|
MD5MD5CRC32FileChecksum |
getFileChecksum(Path p)
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.
|
static String |
getHomeDirectoryString(UserGroupInformation ugi) |
Token<?> |
getRenewToken() |
String |
getScheme()
Return the protocol scheme for the FileSystem.
|
URI |
getUri()
Returns a URI whose scheme and authority identify this FileSystem.
|
Path |
getWorkingDirectory()
Get the current working directory for the given file system
|
protected void |
initDelegationToken() |
void |
initialize(URI uri,
Configuration conf)
Called after a new FileSystem instance is constructed.
|
static boolean |
isEnabled(Configuration conf,
org.apache.commons.logging.Log log)
Is WebHDFS enabled in conf?
|
FileStatus[] |
listStatus(Path f)
List the statuses of the files/directories in the given path if the path is
a directory.
|
boolean |
mkdirs(Path f,
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.
|
void |
rename(Path src,
Path dst,
Options.Rename... options)
Renames Path src to Path dst
|
protected Token<DelegationTokenIdentifier> |
selectDelegationToken(UserGroupInformation ugi) |
<T extends TokenIdentifier> |
setDelegationToken(Token<T> token)
Set delegation token.
|
void |
setOwner(Path p,
String owner,
String group)
Set owner of a path (i.e.
|
void |
setPermission(Path p,
FsPermission permission)
Set permission of a path.
|
boolean |
setReplication(Path p,
short replication)
Set replication for an existing file.
|
void |
setTimes(Path p,
long mtime,
long atime)
Set access time of a file
|
void |
setWorkingDirectory(Path dir)
Set the current working directory for the given file system.
|
addDelegationTokens, append, append, cancelDeleteOnExit, checkPath, clearStatistics, closeAll, closeAllForUGI, completeLocalOutput, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyToLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, create, createNewFile, createNonRecursive, createNonRecursive, createNonRecursive, createSnapshot, createSnapshot, deleteOnExit, deleteSnapshot, enableSymlinks, exists, fixRelativePart, get, get, get, getAllStatistics, getBlockSize, getCanonicalServiceName, getCanonicalUri, getChildFileSystems, getDefaultBlockSize, getDefaultReplication, getDefaultUri, getFileLinkStatus, getFileSystemClass, getFSofPath, getInitialWorkingDirectory, getLength, getLinkTarget, getLocal, getName, getNamed, getReplication, getServerDefaults, getServerDefaults, 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, renameSnapshot, resolveLink, resolvePath, setDefaultUri, setDefaultUri, setVerifyChecksum, setWriteChecksum, startLocalOutput, supportsSymlinks
getConf, setConf
public static final org.apache.commons.logging.Log LOG
public static final String SCHEME
public static final int VERSION
public static final String PATH_PREFIX
public static final Text TOKEN_KIND
public static final org.apache.hadoop.hdfs.web.WebHdfsFileSystem.WebHdfsDelegationTokenSelector DT_SELECTOR
protected void addRenewAction(WebHdfsFileSystem webhdfs)
public static boolean isEnabled(Configuration conf, org.apache.commons.logging.Log log)
public String getScheme()
getScheme
in class FileSystem
webhdfs
public void initialize(URI uri, Configuration conf) throws IOException
FileSystem
initialize
in class FileSystem
uri
- a uri whose authority section names the host, port, etc.
for this FileSystemconf
- the configurationIOException
protected void initDelegationToken() throws IOException
IOException
protected Token<?> getDelegationToken() throws IOException
IOException
protected Token<DelegationTokenIdentifier> selectDelegationToken(UserGroupInformation ugi)
protected int getDefaultPort()
FileSystem
getDefaultPort
in class FileSystem
public URI getUri()
FileSystem
getUri
in class FileSystem
protected URI canonicalizeUri(URI uri)
FileSystem
canonicalizeUri
in class FileSystem
NetUtils.getCanonicalUri(URI, int)
public static String getHomeDirectoryString(UserGroupInformation ugi)
public Path getHomeDirectory()
FileSystem
getHomeDirectory
in class FileSystem
public Path getWorkingDirectory()
FileSystem
getWorkingDirectory
in class FileSystem
public void setWorkingDirectory(Path dir)
FileSystem
setWorkingDirectory
in class FileSystem
public FileStatus getFileStatus(Path f) throws IOException
FileSystem
getFileStatus
in class FileSystem
f
- The path we want information fromFileNotFoundException
- when the path does not exist;
IOException see specific implementationIOException
public boolean mkdirs(Path f, FsPermission permission) throws IOException
FileSystem
mkdirs
in class FileSystem
f
- path to createpermission
- to apply to fIOException
public void createSymlink(Path destination, Path f, boolean createParent) throws IOException
createSymlink
in class FileSystem
IOException
Hdfs.createSymlink(Path, Path, boolean)
public boolean rename(Path src, Path dst) throws IOException
FileSystem
rename
in class FileSystem
src
- path to be renameddst
- new path after renameIOException
- on failurepublic void rename(Path src, Path dst, Options.Rename... options) throws IOException
FileSystem
If OVERWRITE option is not passed as an argument, rename fails if the dst already exists.
If OVERWRITE option is passed as an argument, rename overwrites the dst if it is a file or an empty directory. Rename fails if dst is a non-empty directory.
Note that atomicity of rename is dependent on the file system implementation. Please refer to the file system documentation for details. This default implementation is non atomic.
This method is deprecated since it is a temporary method added to support the transition from FileSystem to FileContext for user applications.
rename
in class FileSystem
src
- path to be renameddst
- new path after renameIOException
- on failurepublic void setOwner(Path p, String owner, String group) throws IOException
FileSystem
setOwner
in class FileSystem
p
- The pathowner
- If it is null, the original username remains unchanged.group
- If it is null, the original groupname remains unchanged.IOException
public void setPermission(Path p, FsPermission permission) throws IOException
FileSystem
setPermission
in class FileSystem
IOException
public boolean setReplication(Path p, short replication) throws IOException
FileSystem
setReplication
in class FileSystem
p
- file namereplication
- new replicationIOException
public void setTimes(Path p, long mtime, long atime) throws IOException
FileSystem
setTimes
in class FileSystem
p
- The pathmtime
- 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.IOException
public long getDefaultBlockSize()
FileSystem
getDefaultBlockSize
in class FileSystem
public short getDefaultReplication()
FileSystem
getDefaultReplication
in class FileSystem
public void concat(Path trg, Path[] srcs) throws IOException
FileSystem
concat
in class FileSystem
trg
- the path to the target destination.srcs
- the paths to the sources to use for the concatenation.IOException
public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException
FileSystem
create
in class FileSystem
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.replication
- required block replication for the file.IOException
FileSystem.setPermission(Path, FsPermission)
public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException
FileSystem
append
in class FileSystem
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.IOException
public boolean delete(Path f) throws IOException
FileSystem
delete
in class FileSystem
IOException
public boolean delete(Path f, boolean recursive) throws IOException
FileSystem
delete
in class FileSystem
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.IOException
public FSDataInputStream open(Path f, int buffersize) throws IOException
FileSystem
open
in class FileSystem
f
- the file name to openbuffersize
- the size of the buffer to be used.IOException
public void close() throws IOException
FileSystem
close
in interface Closeable
close
in interface AutoCloseable
close
in class FileSystem
IOException
public FileStatus[] listStatus(Path f) throws IOException
FileSystem
listStatus
in class FileSystem
f
- given pathFileNotFoundException
- when the path does not exist;
IOException see specific implementationIOException
public Token<DelegationTokenIdentifier> getDelegationToken(String renewer) throws IOException
FileSystem
FileSystem.addDelegationTokens(String, Credentials)
getDelegationToken
in class FileSystem
renewer
- the account name that is allowed to renew the token.IOException
public Token<?> getRenewToken()
getRenewToken
in interface DelegationTokenRenewer.Renewable
public <T extends TokenIdentifier> void setDelegationToken(Token<T> token)
DelegationTokenRenewer.Renewable
setDelegationToken
in interface DelegationTokenRenewer.Renewable
public BlockLocation[] getFileBlockLocations(FileStatus status, long offset, long length) throws IOException
FileSystem
getFileBlockLocations
in class FileSystem
status
- FilesStatus to get data fromoffset
- offset into the given filelength
- length for which to get locations forIOException
public BlockLocation[] getFileBlockLocations(Path p, long offset, long length) throws IOException
FileSystem
getFileBlockLocations
in class FileSystem
p
- path is used to identify an FS since an FS could have
another FS that it could be delegating the call tooffset
- offset into the given filelength
- length for which to get locations forIOException
public ContentSummary getContentSummary(Path p) throws IOException
FileSystem
ContentSummary
of a given Path
.getContentSummary
in class FileSystem
p
- path to useIOException
public MD5MD5CRC32FileChecksum getFileChecksum(Path p) throws IOException
FileSystem
getFileChecksum
in class FileSystem
p
- The file pathIOException
Copyright © 2013 Apache Software Foundation. All rights reserved.