@NotThreadSafe public final class FileSystem extends org.apache.hadoop.fs.FileSystem
FileSystem
interface. Any program working with Hadoop HDFS can work with Alluxio transparently. Note that
the performance of using this API may not be as efficient as the performance of using the Alluxio
native API defined in FileSystem
, which this API is built on top of.Modifier and Type | Field and Description |
---|---|
static String |
FIRST_COM_PATH |
protected FileSystem |
mFileSystem |
Constructor and Description |
---|
FileSystem()
Constructs a new
FileSystem . |
FileSystem(FileSystem fileSystem)
Constructs a new
FileSystem instance with a
specified FileSystem handler for tests. |
Modifier and Type | Method and Description |
---|---|
org.apache.hadoop.fs.FSDataOutputStream |
append(org.apache.hadoop.fs.Path path,
int bufferSize,
org.apache.hadoop.util.Progressable progress) |
void |
close() |
org.apache.hadoop.fs.FSDataOutputStream |
create(org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.permission.FsPermission permission,
boolean overwrite,
int bufferSize,
short replication,
long blockSize,
org.apache.hadoop.util.Progressable progress)
Attempts to create a file.
|
org.apache.hadoop.fs.FSDataOutputStream |
createNonRecursive(org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.permission.FsPermission permission,
boolean overwrite,
int bufferSize,
short replication,
long blockSize,
org.apache.hadoop.util.Progressable progress)
Deprecated.
API only for 0.20-append
|
boolean |
delete(org.apache.hadoop.fs.Path path)
Deprecated.
Use
delete(Path, boolean) instead. |
boolean |
delete(org.apache.hadoop.fs.Path path,
boolean recursive)
Attempts to delete the file or directory with the specified path.
|
protected AlluxioURI |
getAlluxioPath(org.apache.hadoop.fs.Path path)
Used to convert hadoop path to Alluxio path.
|
protected Map<String,Object> |
getConfigurationFromUri(URI uri)
Gets the connection configuration from the input uri.
|
long |
getDefaultBlockSize() |
short |
getDefaultReplication() |
org.apache.hadoop.fs.BlockLocation[] |
getFileBlockLocations(org.apache.hadoop.fs.FileStatus file,
long start,
long len) |
org.apache.hadoop.fs.FileStatus |
getFileStatus(org.apache.hadoop.fs.Path path)
If the file does not exist in Alluxio, query it from HDFS.
|
protected org.apache.hadoop.fs.Path |
getFsPath(String fsUriHeader,
URIStatus fileStatus)
Used to get FS native path from Alluxio file status.
|
protected String |
getFsScheme(URI fsUri)
Used to get FS scheme.
|
String |
getScheme()
Gets the URI scheme that maps to the
FileSystem . |
URI |
getUri() |
org.apache.hadoop.fs.Path |
getWorkingDirectory() |
void |
initialize(URI uri,
org.apache.hadoop.conf.Configuration conf)
Sets up a lazy connection to Alluxio through mFileSystem.
|
void |
initialize(URI uri,
org.apache.hadoop.conf.Configuration conf,
AlluxioConfiguration alluxioConfiguration)
Initialize the
FileSystem . |
protected boolean |
isZookeeperMode() |
org.apache.hadoop.fs.FileStatus[] |
listStatus(org.apache.hadoop.fs.Path path) |
boolean |
mkdirs(org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.permission.FsPermission permission)
Attempts to create a folder with the specified path.
|
org.apache.hadoop.fs.FSDataInputStream |
open(org.apache.hadoop.fs.Path path,
int bufferSize)
Attempts to open the specified file for reading.
|
boolean |
rename(org.apache.hadoop.fs.Path src,
org.apache.hadoop.fs.Path dst) |
void |
setOwner(org.apache.hadoop.fs.Path path,
String username,
String groupname)
Changes owner or group of a path (i.e.
|
void |
setPermission(org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.permission.FsPermission permission)
Changes permission of a path.
|
boolean |
setReplication(org.apache.hadoop.fs.Path path,
short replication) |
void |
setWorkingDirectory(org.apache.hadoop.fs.Path path) |
protected void |
validateFsUri(URI fsUri)
Validates given FS base URI for scheme and authority.
|
access, addDelegationTokens, append, append, areSymlinksEnabled, cancelDeleteOnExit, canonicalizeUri, checkPath, clearStatistics, 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, getAclStatus, getAllStatistics, getBlockSize, getCanonicalServiceName, getCanonicalUri, getChildFileSystems, getContentSummary, getDefaultBlockSize, getDefaultPort, getDefaultReplication, getDefaultUri, getDelegationToken, getFileBlockLocations, getFileChecksum, getFileChecksum, getFileLinkStatus, getFileSystemClass, getFSofPath, getHomeDirectory, getInitialWorkingDirectory, getLength, getLinkTarget, getLocal, getName, getNamed, getReplication, getServerDefaults, getServerDefaults, getStatistics, getStatistics, getStatus, getStatus, getUsed, getXAttr, getXAttrs, getXAttrs, globStatus, globStatus, isDirectory, isFile, listCorruptFileBlocks, listFiles, listLocatedStatus, listLocatedStatus, listStatus, listStatus, listStatus, listStatusIterator, listXAttrs, makeQualified, mkdirs, mkdirs, modifyAclEntries, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, newInstance, newInstance, newInstance, newInstanceLocal, open, primitiveCreate, primitiveMkdir, primitiveMkdir, printStatistics, processDeleteOnExit, removeAcl, removeAclEntries, removeDefaultAcl, removeXAttr, rename, renameSnapshot, resolveLink, resolvePath, setAcl, setDefaultUri, setDefaultUri, setTimes, setVerifyChecksum, setWriteChecksum, setXAttr, setXAttr, startLocalOutput, supportsSymlinks, truncate
public static final String FIRST_COM_PATH
protected FileSystem mFileSystem
public FileSystem()
FileSystem
.public FileSystem(FileSystem fileSystem)
FileSystem
instance with a
specified FileSystem
handler for tests.fileSystem
- handler to file systempublic String getScheme()
FileSystem
. This was
introduced in Hadoop 2.x as a means to make loading new FileSystem
s simpler.FileSystem.createFileSystem(java.net.URI,
org.apache.hadoop.conf.Configuration)
protected boolean isZookeeperMode()
protected Map<String,Object> getConfigurationFromUri(URI uri)
uri
- a Alluxio Uri that may contain connection configurationprotected void validateFsUri(URI fsUri) throws IOException, IllegalArgumentException
fsUri
- FS UriIOException
IllegalArgumentException
protected String getFsScheme(URI fsUri)
fsUri
- file system base URIprotected AlluxioURI getAlluxioPath(org.apache.hadoop.fs.Path path)
path
- the input pathprotected org.apache.hadoop.fs.Path getFsPath(String fsUriHeader, URIStatus fileStatus)
fsUriHeader
- FS URI header -> "scheme://authority"fileStatus
- Alluxio file statuspublic org.apache.hadoop.fs.FSDataOutputStream append(org.apache.hadoop.fs.Path path, int bufferSize, org.apache.hadoop.util.Progressable progress) throws IOException
append
in class org.apache.hadoop.fs.FileSystem
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class org.apache.hadoop.fs.FileSystem
IOException
public org.apache.hadoop.fs.FSDataOutputStream create(org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) throws IOException
create
in class org.apache.hadoop.fs.FileSystem
path
- path to createpermission
- permissions of the created file/folderoverwrite
- overwrite if file existsbufferSize
- the size in bytes of the buffer to be usedreplication
- under filesystem replication factor, this is ignoredblockSize
- block size in bytesprogress
- queryable progressFSDataOutputStream
created at the indicated path of a fileIOException
@Deprecated public org.apache.hadoop.fs.FSDataOutputStream createNonRecursive(org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) throws IOException
FSDataOutputStream
at the indicated Path with write-progress reporting.
Same as FileSystem.create(Path, boolean, int, short, long, Progressable)
, except fails if parent
directory doesn't already exist.
TODO(hy): We need to refactor this method after having a new internal API support (ALLUXIO-46).createNonRecursive
in class org.apache.hadoop.fs.FileSystem
path
- 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 usedreplication
- required block replication for the fileblockSize
- the size in bytes of the buffer to be usedprogress
- queryable progressIOException
setPermission(Path, FsPermission)
@Deprecated public boolean delete(org.apache.hadoop.fs.Path path) throws IOException
delete(Path, boolean)
instead.delete
in class org.apache.hadoop.fs.FileSystem
path
- path to deleteIOException
public boolean delete(org.apache.hadoop.fs.Path path, boolean recursive) throws IOException
delete
in class org.apache.hadoop.fs.FileSystem
path
- path to deleterecursive
- if true, will attempt to delete all children of the pathIOException
public long getDefaultBlockSize()
getDefaultBlockSize
in class org.apache.hadoop.fs.FileSystem
@Nullable public org.apache.hadoop.fs.BlockLocation[] getFileBlockLocations(org.apache.hadoop.fs.FileStatus file, long start, long len) throws IOException
getFileBlockLocations
in class org.apache.hadoop.fs.FileSystem
IOException
public short getDefaultReplication()
getDefaultReplication
in class org.apache.hadoop.fs.FileSystem
public boolean setReplication(org.apache.hadoop.fs.Path path, short replication) throws IOException
setReplication
in class org.apache.hadoop.fs.FileSystem
IOException
public org.apache.hadoop.fs.FileStatus getFileStatus(org.apache.hadoop.fs.Path path) throws IOException
getFileStatus
in class org.apache.hadoop.fs.FileSystem
IOException
public void setOwner(org.apache.hadoop.fs.Path path, String username, String groupname) throws IOException
setOwner
in class org.apache.hadoop.fs.FileSystem
path
- path to set owner or groupusername
- username to be setgroupname
- groupname to be setIOException
public void setPermission(org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission permission) throws IOException
setPermission
in class org.apache.hadoop.fs.FileSystem
path
- path to set permissionpermission
- permission set to pathIOException
public URI getUri()
getUri
in class org.apache.hadoop.fs.FileSystem
public org.apache.hadoop.fs.Path getWorkingDirectory()
getWorkingDirectory
in class org.apache.hadoop.fs.FileSystem
public void initialize(URI uri, org.apache.hadoop.conf.Configuration conf) throws IOException
initialize
in class org.apache.hadoop.fs.FileSystem
IOException
public void initialize(URI uri, org.apache.hadoop.conf.Configuration conf, @Nullable AlluxioConfiguration alluxioConfiguration) throws IOException
FileSystem
.uri
- file system Uriconf
- hadoop configurationalluxioConfiguration
- [optional] alluxio configurationIOException
public org.apache.hadoop.fs.FileStatus[] listStatus(org.apache.hadoop.fs.Path path) throws IOException
listStatus
in class org.apache.hadoop.fs.FileSystem
IOException
public boolean mkdirs(org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.permission.FsPermission permission) throws IOException
mkdirs
in class org.apache.hadoop.fs.FileSystem
path
- path to createpermission
- permissions to grant the created folderIOException
public org.apache.hadoop.fs.FSDataInputStream open(org.apache.hadoop.fs.Path path, int bufferSize) throws IOException
open
in class org.apache.hadoop.fs.FileSystem
path
- the file name to openbufferSize
- stream buffer size in bytes, currently unusedFSDataInputStream
at the indicated path of a fileIOException
public boolean rename(org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst) throws IOException
rename
in class org.apache.hadoop.fs.FileSystem
IOException
public void setWorkingDirectory(org.apache.hadoop.fs.Path path)
setWorkingDirectory
in class org.apache.hadoop.fs.FileSystem
Copyright © 2023. All Rights Reserved.