@PublicApi @ThreadSafe public class BaseFileSystem extends Object implements FileSystem
FileSystem
interface. Developers can extend this class
instead of implementing the interface. This implementation reads and writes data through
FileInStream
and FileOutStream
. This class is thread safe.FileSystem.Factory
Modifier and Type | Field and Description |
---|---|
protected FileSystemContext |
mFileSystemContext |
Modifier | Constructor and Description |
---|---|
protected |
BaseFileSystem(FileSystemContext context)
Constructs a new base file system.
|
Modifier and Type | Method and Description |
---|---|
void |
createDirectory(AlluxioURI path)
Convenience method for
FileSystem.createDirectory(AlluxioURI, CreateDirectoryOptions) with
default options. |
void |
createDirectory(AlluxioURI path,
CreateDirectoryOptions options)
Creates a directory.
|
FileOutStream |
createFile(AlluxioURI path)
Convenience method for
FileSystem.createFile(AlluxioURI, CreateFileOptions) with default options. |
FileOutStream |
createFile(AlluxioURI path,
CreateFileOptions options)
Creates a file.
|
void |
delete(AlluxioURI path)
Convenience method for
FileSystem.delete(AlluxioURI, DeleteOptions) with default options. |
void |
delete(AlluxioURI path,
DeleteOptions options)
Deletes a file or a directory.
|
boolean |
exists(AlluxioURI path)
Convenience method for
FileSystem.exists(AlluxioURI, ExistsOptions) with default options. |
boolean |
exists(AlluxioURI path,
ExistsOptions options)
Checks whether a path exists in Alluxio space.
|
void |
free(AlluxioURI path)
Convenience method for
FileSystem.free(AlluxioURI, FreeOptions) with default options. |
void |
free(AlluxioURI path,
FreeOptions options)
Evicts any data under the given path from Alluxio space, but does not delete the data from the
UFS.
|
static BaseFileSystem |
get(FileSystemContext context) |
Map<String,MountPointInfo> |
getMountTable()
Lists all mount points and their corresponding under storage addresses.
|
URIStatus |
getStatus(AlluxioURI path)
Convenience method for
FileSystem.getStatus(AlluxioURI, GetStatusOptions) with default options. |
URIStatus |
getStatus(AlluxioURI path,
GetStatusOptions options)
Gets the
URIStatus object that represents the metadata of an Alluxio path. |
List<URIStatus> |
listStatus(AlluxioURI path)
Convenience method for
FileSystem.listStatus(AlluxioURI, ListStatusOptions) with default options. |
List<URIStatus> |
listStatus(AlluxioURI path,
ListStatusOptions options)
If the path is a directory, returns the
URIStatus of all the direct entries in it. |
void |
loadMetadata(AlluxioURI path)
Deprecated.
since version 1.1 and will be removed in version 2.0
|
void |
loadMetadata(AlluxioURI path,
LoadMetadataOptions options)
Deprecated.
since version 1.1 and will be removed in version 2.0
|
void |
mount(AlluxioURI alluxioPath,
AlluxioURI ufsPath)
Convenience method for
FileSystem.mount(AlluxioURI, AlluxioURI, MountOptions) with default
options. |
void |
mount(AlluxioURI alluxioPath,
AlluxioURI ufsPath,
MountOptions options)
Mounts a UFS subtree to the given Alluxio path.
|
FileInStream |
openFile(AlluxioURI path)
Convenience method for
FileSystem.openFile(AlluxioURI, OpenFileOptions) with default options. |
FileInStream |
openFile(AlluxioURI path,
OpenFileOptions options)
Opens a file for reading.
|
void |
rename(AlluxioURI src,
AlluxioURI dst)
Convenience method for
FileSystem.rename(AlluxioURI, AlluxioURI, RenameOptions) with default
options. |
void |
rename(AlluxioURI src,
AlluxioURI dst,
RenameOptions options)
Renames an existing Alluxio path to another Alluxio path in Alluxio.
|
void |
setAttribute(AlluxioURI path)
Convenience method for
FileSystem.setAttribute(AlluxioURI, SetAttributeOptions) with default
options. |
void |
setAttribute(AlluxioURI path,
SetAttributeOptions options)
Sets any number of a path's attributes, such as TTL and pin status.
|
void |
unmount(AlluxioURI path)
Convenience method for
FileSystem.unmount(AlluxioURI, UnmountOptions) with default options. |
void |
unmount(AlluxioURI path,
UnmountOptions options)
Unmounts a UFS subtree identified by the given Alluxio path.
|
protected final FileSystemContext mFileSystemContext
protected BaseFileSystem(FileSystemContext context)
context
- file system contextpublic static BaseFileSystem get(FileSystemContext context)
context
- file system contextBaseFileSystem
public void createDirectory(AlluxioURI path) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException
FileSystem
FileSystem.createDirectory(AlluxioURI, CreateDirectoryOptions)
with
default options.createDirectory
in interface FileSystem
path
- the path of the directory to create in Alluxio spaceFileAlreadyExistsException
- if there is already a file or directory at the given pathInvalidPathException
- if the path is invalidIOException
AlluxioException
public void createDirectory(AlluxioURI path, CreateDirectoryOptions options) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException
FileSystem
createDirectory
in interface FileSystem
path
- the path of the directory to create in Alluxio spaceoptions
- options to associate with this operationFileAlreadyExistsException
- if there is already a file or directory at the given pathInvalidPathException
- if the path is invalidIOException
AlluxioException
public FileOutStream createFile(AlluxioURI path) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException
FileSystem
FileSystem.createFile(AlluxioURI, CreateFileOptions)
with default options.createFile
in interface FileSystem
path
- the path of the file to create in Alluxio spaceFileOutStream
which will write data to the newly created fileFileAlreadyExistsException
- if there is already a file at the given pathInvalidPathException
- if the path is invalidIOException
AlluxioException
public FileOutStream createFile(AlluxioURI path, CreateFileOptions options) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException
FileSystem
createFile
in interface FileSystem
path
- the path of the file to create in Alluxio spaceoptions
- options to associate with this operationFileOutStream
which will write data to the newly created fileFileAlreadyExistsException
- if there is already a file at the given pathInvalidPathException
- if the path is invalidIOException
AlluxioException
public void delete(AlluxioURI path) throws DirectoryNotEmptyException, FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.delete(AlluxioURI, DeleteOptions)
with default options.delete
in interface FileSystem
path
- the path to delete in Alluxio spaceDirectoryNotEmptyException
- if recursive is false and the path is a nonempty directoryFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
public void delete(AlluxioURI path, DeleteOptions options) throws DirectoryNotEmptyException, FileDoesNotExistException, IOException, AlluxioException
FileSystem
delete
in interface FileSystem
path
- the path to delete in Alluxio spaceoptions
- options to associate with this operationDirectoryNotEmptyException
- if recursive is false and the path is a nonempty directoryFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
public boolean exists(AlluxioURI path) throws InvalidPathException, IOException, AlluxioException
FileSystem
FileSystem.exists(AlluxioURI, ExistsOptions)
with default options.exists
in interface FileSystem
path
- the path in questionInvalidPathException
- if the path is invalidIOException
AlluxioException
public boolean exists(AlluxioURI path, ExistsOptions options) throws InvalidPathException, IOException, AlluxioException
FileSystem
exists
in interface FileSystem
path
- the path in questionoptions
- options to associate with this operationInvalidPathException
- if the path is invalidIOException
AlluxioException
public void free(AlluxioURI path) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.free(AlluxioURI, FreeOptions)
with default options.free
in interface FileSystem
path
- the path to free in Alluxio spaceFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
public void free(AlluxioURI path, FreeOptions options) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
free
in interface FileSystem
path
- the path to free in Alluxio spaceoptions
- options to associate with this operationFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
public URIStatus getStatus(AlluxioURI path) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.getStatus(AlluxioURI, GetStatusOptions)
with default options.getStatus
in interface FileSystem
path
- the path to obtain information aboutURIStatus
of the fileFileDoesNotExistException
- if the path does not existIOException
AlluxioException
public URIStatus getStatus(AlluxioURI path, GetStatusOptions options) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
URIStatus
object that represents the metadata of an Alluxio path.getStatus
in interface FileSystem
path
- the path to obtain information aboutoptions
- options to associate with this operationURIStatus
of the fileFileDoesNotExistException
- if the path does not existIOException
AlluxioException
public List<URIStatus> listStatus(AlluxioURI path) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.listStatus(AlluxioURI, ListStatusOptions)
with default options.listStatus
in interface FileSystem
path
- the path to list information aboutURIStatus
s containing information about the files and directories
which are children of the given pathFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
public List<URIStatus> listStatus(AlluxioURI path, ListStatusOptions options) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
URIStatus
of all the direct entries in it.
Otherwise returns a list with a single URIStatus
element for the file.listStatus
in interface FileSystem
path
- the path to list information aboutoptions
- options to associate with this operationURIStatus
s containing information about the files and directories
which are children of the given pathFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
@Deprecated public void loadMetadata(AlluxioURI path) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem.loadMetadata(AlluxioURI, LoadMetadataOptions)
with default
options.loadMetadata
in interface FileSystem
path
- the path for which to load metadata from UFSFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
@Deprecated public void loadMetadata(AlluxioURI path, LoadMetadataOptions options) throws FileDoesNotExistException, IOException, AlluxioException
loadMetadata
in interface FileSystem
path
- the path for which to load metadata from UFSoptions
- options to associate with this operationFileDoesNotExistException
- if the given path does not existIOException
AlluxioException
public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath) throws IOException, AlluxioException
FileSystem
FileSystem.mount(AlluxioURI, AlluxioURI, MountOptions)
with default
options.mount
in interface FileSystem
alluxioPath
- an Alluxio path to mount the data toufsPath
- a UFS path to mount the data fromIOException
AlluxioException
public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, MountOptions options) throws IOException, AlluxioException
FileSystem
AlluxioException
will be thrown.
This method does not transfer any data or metadata from the UFS. It simply establishes the
connection between the given Alluxio path and UFS path.mount
in interface FileSystem
alluxioPath
- an Alluxio path to mount the data toufsPath
- a UFS path to mount the data fromoptions
- options to associate with this operationIOException
AlluxioException
public Map<String,MountPointInfo> getMountTable() throws IOException, AlluxioException
FileSystem
getMountTable
in interface FileSystem
MountPointInfo
IOException
AlluxioException
public FileInStream openFile(AlluxioURI path) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.openFile(AlluxioURI, OpenFileOptions)
with default options.openFile
in interface FileSystem
path
- the file to read fromFileInStream
for the given pathFileDoesNotExistException
- if the given file does not existIOException
AlluxioException
public FileInStream openFile(AlluxioURI path, OpenFileOptions options) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
openFile
in interface FileSystem
path
- the file to read fromoptions
- options to associate with this operationFileInStream
for the given pathFileDoesNotExistException
- if the given file does not existIOException
AlluxioException
public void rename(AlluxioURI src, AlluxioURI dst) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.rename(AlluxioURI, AlluxioURI, RenameOptions)
with default
options.rename
in interface FileSystem
src
- the path of the source, this must already existdst
- the path of the destination, this path should not existFileDoesNotExistException
- if the given file does not existIOException
AlluxioException
public void rename(AlluxioURI src, AlluxioURI dst, RenameOptions options) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
rename
in interface FileSystem
src
- the path of the source, this must already existdst
- the path of the destination, this path should not existoptions
- options to associate with this operationFileDoesNotExistException
- if the given file does not existIOException
AlluxioException
public void setAttribute(AlluxioURI path) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
FileSystem.setAttribute(AlluxioURI, SetAttributeOptions)
with default
options.setAttribute
in interface FileSystem
path
- the path to set attributes forFileDoesNotExistException
- if the given file does not existIOException
AlluxioException
public void setAttribute(AlluxioURI path, SetAttributeOptions options) throws FileDoesNotExistException, IOException, AlluxioException
FileSystem
setAttribute
in interface FileSystem
path
- the path to set attributes foroptions
- options to associate with this operationFileDoesNotExistException
- if the given file does not existIOException
AlluxioException
public void unmount(AlluxioURI path) throws IOException, AlluxioException
FileSystem
FileSystem.unmount(AlluxioURI, UnmountOptions)
with default options.unmount
in interface FileSystem
path
- an Alluxio path, this must be a mount pointIOException
AlluxioException
public void unmount(AlluxioURI path, UnmountOptions options) throws IOException, AlluxioException
FileSystem
unmount
in interface FileSystem
path
- an Alluxio path, this must be a mount pointoptions
- options to associate with this operationIOException
AlluxioException
Copyright © 2023. All Rights Reserved.