@ThreadSafe public abstract class BaseUnderFileSystem extends Object implements UnderFileSystem
UnderFileSystem
.UnderFileSystem.Factory, UnderFileSystem.SpaceType
Modifier and Type | Field and Description |
---|---|
static Pair<AccessControlList,DefaultAccessControlList> |
EMPTY_ACL |
protected UnderFileSystemConfiguration |
mUfsConf
UFS Configuration options.
|
protected AlluxioURI |
mUri
The UFS
AlluxioURI used to create this BaseUnderFileSystem . |
Modifier | Constructor and Description |
---|---|
protected |
BaseUnderFileSystem(AlluxioURI uri,
UnderFileSystemConfiguration ufsConf)
Constructs an
BaseUnderFileSystem . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
OutputStream |
create(String path)
Creates a file in the under file system with the indicated name.
|
boolean |
deleteDirectory(String path)
Deletes a directory from the under file system with the indicated name non-recursively.
|
boolean |
exists(String path)
Checks if a file or directory exists in under file system.
|
Pair<AccessControlList,DefaultAccessControlList> |
getAclPair(String path)
Gets the ACL and the Default ACL of a file or directory in under file system.
|
AlluxioConfiguration |
getConfiguration()
Gets the under file system configuration.
|
String |
getFingerprint(String path)
Computes and returns a fingerprint for the path.
|
UfsMode |
getOperationMode(Map<String,UfsMode> physicalUfsState)
An
UnderFileSystem may be composed of one or more "physical UFS"s. |
Fingerprint |
getParsedFingerprint(String path)
Computes and returns a fingerprint for the path.
|
Fingerprint |
getParsedFingerprint(String path,
String contentHash)
Same as
UnderFileSystem.getParsedFingerprint(String) except, will use the given content hash
as the Fingerprint.Tag.CONTENT_HASH field of the fingerprint
if non-null. |
List<String> |
getPhysicalStores()
An
UnderFileSystem may be composed of one or more "physical UFS"s. |
boolean |
isObjectStorage() |
boolean |
isSeekable()
Denotes if the under storage supports seeking.
|
UfsStatus[] |
listStatus(String path,
ListOptions options)
Returns an array of statuses of the files and directories in the directory denoted by this
abstract pathname, with options.
|
Iterator<UfsStatus> |
listStatusIterable(String path,
ListOptions options,
String startAfter,
int batchSize)
Lists the ufs statuses iteratively.
|
boolean |
mkdirs(String path)
Creates the directory named by this abstract pathname.
|
InputStream |
open(String path)
Opens an
InputStream for a file in under filesystem at the indicated path. |
void |
performListingAsync(String path,
String continuationToken,
String startAfter,
DescendantType descendantType,
boolean checkStatus,
java.util.function.Consumer<UfsLoadResult> onComplete,
java.util.function.Consumer<Throwable> onError)
Lists the ufs statuses for a given path.
|
AlluxioURI |
resolveUri(AlluxioURI ufsBaseUri,
String alluxioPath)
Returns an
AlluxioURI representation for the UnderFileSystem given a base
UFS URI, and the Alluxio path from the base. |
void |
setAclEntries(String path,
List<AclEntry> aclEntries)
Sets the access control list of a file or directory in under file system.
|
protected static String |
validatePath(String path)
Clean the path by creating a URI and turning it back to a string.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cleanup, connectFromMaster, connectFromWorker, create, createNonexistingFile, createNonexistingFile, deleteDirectory, deleteExistingDirectory, deleteExistingDirectory, deleteExistingFile, deleteFile, getBlockSizeByte, getDirectoryStatus, getExistingDirectoryStatus, getExistingFileStatus, getExistingStatus, getFileLocations, getFileLocations, getFileStatus, getFileStatus, getSpace, getStatus, getStatus, getTemporaryToken, getUnderFSType, isDirectory, isExistingDirectory, isFile, isTemporaryConnectionToken, listStatus, listStatuses, mkdirs, open, openExistingFile, openExistingFile, openPositionRead, refreshTemporaryToken, renameDirectory, renameFile, renameRenamableDirectory, renameRenamableFile, setMode, setOwner, setTemporaryTokenRefreshContext, supportsFlush
public static final Pair<AccessControlList,DefaultAccessControlList> EMPTY_ACL
protected final AlluxioURI mUri
AlluxioURI
used to create this BaseUnderFileSystem
.protected final UnderFileSystemConfiguration mUfsConf
protected BaseUnderFileSystem(AlluxioURI uri, UnderFileSystemConfiguration ufsConf)
BaseUnderFileSystem
.uri
- the AlluxioURI
used to create this ufsufsConf
- UFS configurationpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public OutputStream create(String path) throws IOException
UnderFileSystem
create
in interface UnderFileSystem
path
- the file nameOutputStream
objectIOException
public boolean deleteDirectory(String path) throws IOException
UnderFileSystem
deleteDirectory
in interface UnderFileSystem
path
- of the directory to deleteIOException
public boolean exists(String path) throws IOException
UnderFileSystem
exists
in interface UnderFileSystem
path
- the absolute pathIOException
public Pair<AccessControlList,DefaultAccessControlList> getAclPair(String path) throws IOException
UnderFileSystem
getAclPair
in interface UnderFileSystem
path
- the path to the file or directoryIOException
- if ACL is supported and enabled but cannot be retrievedpublic void setAclEntries(String path, List<AclEntry> aclEntries) throws IOException
UnderFileSystem
setAclEntries
in interface UnderFileSystem
path
- the path to the file or directoryaclEntries
- the access control list + default acl represented in a list of acl entriesIOException
public AlluxioConfiguration getConfiguration()
UnderFileSystem
getConfiguration
in interface UnderFileSystem
public String getFingerprint(String path)
UnderFileSystem
Constants.INVALID_UFS_FINGERPRINT
if there is any error.getFingerprint
in interface UnderFileSystem
path
- the path to compute the fingerprint forpublic Fingerprint getParsedFingerprint(String path)
UnderFileSystem
Fingerprint.INVALID_FINGERPRINT
if there is any error.
The default implementation relies on UnderFileSystem.getFingerprint(String)
and there is one extra
parsing. This default implementation is mainly for backward compatibility.
Override this for performance.getParsedFingerprint
in interface UnderFileSystem
path
- the path to compute the fingerprint forpublic Fingerprint getParsedFingerprint(String path, @Nullable String contentHash)
UnderFileSystem
UnderFileSystem.getParsedFingerprint(String)
except, will use the given content hash
as the Fingerprint.Tag.CONTENT_HASH
field of the fingerprint
if non-null. This is intended to be used when the file is already in Alluxio and
a fingerprint is being created based on that file where the content hash has already
been computed.getParsedFingerprint
in interface UnderFileSystem
path
- the path to compute the fingerprint forcontentHash
- is used as the Fingerprint.Tag.CONTENT_HASH
field when creating the fingerprint.public UfsMode getOperationMode(Map<String,UfsMode> physicalUfsState)
UnderFileSystem
UnderFileSystem
may be composed of one or more "physical UFS"s. This method is used
to determine the operation mode based on the physical UFS operation modes. For example, if this
UnderFileSystem
is composed of physical UFS hdfs://ns1/ and hdfs://ns2/ with read
operations split b/w the two, with physicalUfsState{hdfs://ns1/:NO_ACCESS,
hdfs://ns2/:READ_WRITE} this method can return READ_ONLY to allow reads to proceed from
hdfs://ns2/.getOperationMode
in interface UnderFileSystem
physicalUfsState
- the state of physical UFSs for this UnderFileSystem
; keys are
expected to be normalized (ending with /)public List<String> getPhysicalStores()
UnderFileSystem
UnderFileSystem
may be composed of one or more "physical UFS"s. This method
returns all underlying physical stores; normalized with only scheme and authority.getPhysicalStores
in interface UnderFileSystem
UnderFileSystem
is composed ofpublic boolean isObjectStorage()
isObjectStorage
in interface UnderFileSystem
public boolean isSeekable()
UnderFileSystem
SeekableUnderFileInputStream
in the UnderFileSystem.open(String, OpenOptions)
method.isSeekable
in interface UnderFileSystem
@Nullable public Iterator<UfsStatus> listStatusIterable(String path, ListOptions options, String startAfter, int batchSize) throws IOException
UnderFileSystem
listStatusIterable
in interface UnderFileSystem
path
- the abstract pathname to listoptions
- for list directorystartAfter
- the start after tokenbatchSize
- the batch sizenull
if this abstract pathname does not denote a directory.IOException
public void performListingAsync(String path, @Nullable String continuationToken, @Nullable String startAfter, DescendantType descendantType, boolean checkStatus, java.util.function.Consumer<UfsLoadResult> onComplete, java.util.function.Consumer<Throwable> onError)
AsyncUfsClient
UfsStatus.getName()
function for the returned values should include the full path of each
item from the UFS root (not including the bucket name for object stores).
It differs from a traditional listing in that if the input variable
checkStatus is true, the UfsStatus
for the base path should
be included at the start of the results. The function should return
immediately, and perform the operation asynchronously.performListingAsync
in interface AsyncUfsClient
path
- the path in ufscontinuationToken
- the continuation tokenstartAfter
- the start after string where the loading starts fromdescendantType
- the load descendant type (NONE/ONE/ALL)checkStatus
- if true the call will perform a GetStatus on the path
to see if an object exists, which should be returned
as part of the resultonComplete
- the callback when the load is completeonError
- the callback when the load encountered an error@Nullable public UfsStatus[] listStatus(String path, ListOptions options) throws IOException
UnderFileSystem
If this abstract pathname does not denote a directory, then this method returns null
.
Otherwise an array of statuses is returned, one for each file or directory. Names denoting the
directory itself and the directory's parent directory are not included in the result. Each
string is a path relative to the given directory.
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
listStatus
in interface UnderFileSystem
path
- the abstract pathname to listoptions
- for list directorynull
if this abstract pathname does not denote a directory.IOException
public InputStream open(String path) throws IOException
UnderFileSystem
InputStream
for a file in under filesystem at the indicated path.open
in interface UnderFileSystem
path
- the file nameInputStream
objectIOException
public boolean mkdirs(String path) throws IOException
UnderFileSystem
mkdirs
in interface UnderFileSystem
path
- the folder to createtrue
if and only if the directory was created; false
otherwiseIOException
public AlluxioURI resolveUri(AlluxioURI ufsBaseUri, String alluxioPath)
UnderFileSystem
AlluxioURI
representation for the UnderFileSystem
given a base
UFS URI, and the Alluxio path from the base.
The default implementation simply concatenates the path to the base URI. This should be
overridden if a subclass needs alternate functionality.resolveUri
in interface UnderFileSystem
ufsBaseUri
- the base AlluxioURI
in the ufsalluxioPath
- the path in Alluxio from the given baseAlluxioURI
representing the Alluxio pathCopyright © 2023. All Rights Reserved.