@ThreadSafe public abstract class ObjectUnderFileSystem extends BaseUnderFileSystem
UnderFileSystem
. Object Stores implementing the
UnderFileSystem
interface should derive from this class.Modifier and Type | Class and Description |
---|---|
protected class |
ObjectUnderFileSystem.DeleteBuffer
Object keys added to a
ObjectUnderFileSystem.DeleteBuffer will be deleted in batches. |
static interface |
ObjectUnderFileSystem.ObjectListingChunk
A chunk of listing results.
|
static class |
ObjectUnderFileSystem.ObjectPermissions
Permissions in object UFS.
|
protected static class |
ObjectUnderFileSystem.ObjectStatus
Information about a single object in object UFS.
|
protected static interface |
ObjectUnderFileSystem.ObjectStoreOperation<T>
Represents an object store operation.
|
protected class |
ObjectUnderFileSystem.OperationBuffer<T>
Operations added to this buffer are performed concurrently.
|
protected class |
ObjectUnderFileSystem.RenameBuffer
File paths added to a
ObjectUnderFileSystem.RenameBuffer will be renamed concurrently. |
class |
ObjectUnderFileSystem.UfsStatusIterator
The UFS status iterator that iterates the ufs statuses and fetches the chunk by lazy.
|
UnderFileSystem.Factory, UnderFileSystem.SpaceType
Modifier and Type | Field and Description |
---|---|
protected ExecutorService |
mExecutorService
Executor service used for parallel UFS operations such as bulk deletes.
|
protected java.util.function.Supplier<String> |
mRootKeySupplier
The root key of an object fs.
|
protected static String |
PATH_SEPARATOR
Value used to indicate nested structure.
|
protected static char |
PATH_SEPARATOR_CHAR
Value used to indicate nested structure.
|
EMPTY_ACL, mUfsConf, mUri
Modifier | Constructor and Description |
---|---|
protected |
ObjectUnderFileSystem(AlluxioURI uri,
UnderFileSystemConfiguration ufsConf)
Constructs an
ObjectUnderFileSystem . |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up the under file system.
|
void |
close() |
void |
connectFromMaster(String hostname)
Takes any necessary actions required to establish a connection to the under file system from
the given master host e.g.
|
void |
connectFromWorker(String hostname)
Takes any necessary actions required to establish a connection to the under file system from
the given worker host e.g.
|
protected String |
convertToFolderName(String key)
Appends the directory suffix to the key.
|
protected abstract boolean |
copyObject(String src,
String dst)
Copies an object to another key.
|
OutputStream |
create(String path,
CreateOptions options)
Creates a file in the under file system with the specified
CreateOptions . |
abstract boolean |
createEmptyObject(String key)
Creates a zero-byte object used to encode a directory.
|
OutputStream |
createNonexistingFile(String path)
Creates a file in the under file system with the indicated name.
|
OutputStream |
createNonexistingFile(String path,
CreateOptions options)
Creates a file in the under file system with the specified
CreateOptions . |
protected abstract OutputStream |
createObject(String key)
Creates an
OutputStream for object uploads. |
boolean |
deleteDirectory(String path,
DeleteOptions options)
Deletes a directory from the under file system with the indicated name.
|
boolean |
deleteExistingDirectory(String path)
Deletes a directory from the under file system.
|
boolean |
deleteExistingDirectory(String path,
DeleteOptions options)
Deletes a directory from the under file system with the indicated name.
|
boolean |
deleteExistingFile(String path)
Deletes a file from the under file system with the indicated name.
|
boolean |
deleteFile(String path)
Deletes a file from the under file system with the indicated name.
|
protected abstract boolean |
deleteObject(String key)
Internal function to delete a key.
|
protected List<String> |
deleteObjects(List<String> keys)
Internal function to delete a list of keys.
|
long |
getBlockSizeByte(String path)
Gets the block size in bytes.
|
protected String |
getChildName(String child,
String parent)
Gets the child name based on the parent name.
|
UfsDirectoryStatus |
getDirectoryStatus(String path)
Gets the directory status.
|
UfsDirectoryStatus |
getExistingDirectoryStatus(String path)
Gets the directory status.
|
UfsFileStatus |
getExistingFileStatus(String path)
Gets the file status.
|
UfsStatus |
getExistingStatus(String path)
Gets the file or directory status.
|
List<String> |
getFileLocations(String path)
Gets the list of locations of the indicated path.
|
List<String> |
getFileLocations(String path,
FileLocationOptions options)
Gets the list of locations of the indicated path given options.
|
UfsFileStatus |
getFileStatus(String path,
GetStatusOptions options)
Gets the file status.
|
protected abstract String |
getFolderSuffix()
Get suffix used to encode a directory.
|
protected int |
getListingChunkLength(AlluxioConfiguration conf)
The number of items to query in a single listing chunk.
|
protected int |
getListingChunkLengthMax()
Maximum number of items in a single listing chunk supported by the under store.
|
protected abstract ObjectUnderFileSystem.ObjectListingChunk |
getObjectListingChunk(String key,
boolean recursive)
Gets a (partial) object listing result for the given key.
|
protected ObjectUnderFileSystem.ObjectListingChunk |
getObjectListingChunk(String key,
boolean recursive,
String startAfter,
int batchSize)
Gets a (partial) object listing result for the given key.
|
protected ObjectUnderFileSystem.ObjectListingChunk |
getObjectListingChunkForPath(String path,
boolean recursive) |
protected ObjectUnderFileSystem.ObjectListingChunk |
getObjectListingChunkForPath(String path,
boolean recursive,
String startAfter,
int batchSize)
Gets a (partial) object listing for the given path.
|
protected abstract ObjectUnderFileSystem.ObjectStatus |
getObjectStatus(String key)
Get metadata information about object.
|
protected String |
getParentPath(String path)
Get parent path.
|
protected abstract ObjectUnderFileSystem.ObjectPermissions |
getPermissions()
Permissions for the mounted bucket.
|
protected abstract String |
getRootKey()
Get full path of root in object store.
|
long |
getSpace(String path,
UnderFileSystem.SpaceType type)
Queries the under file system about the space of the indicated path (e.g., space left, space
used and etc).
|
UfsStatus |
getStatus(String path,
GetStatusOptions options)
Gets the file or directory status.
|
boolean |
isDirectory(String path)
Checks if a directory exists in under file system.
|
boolean |
isExistingDirectory(String path)
Checks if a directory exists in under file system.
|
boolean |
isFile(String path)
Checks if a file exists in under file system.
|
boolean |
isObjectStorage() |
protected boolean |
isRoot(String path)
Checks if the path is the root.
|
protected UfsStatus[] |
listInternal(String path,
ListOptions options)
Lists the files in the given path, the paths will be their logical names and not contain the
folder suffix.
|
UfsStatus[] |
listStatus(String path)
Returns an array of statuses of the files and directories in the directory denoted by this
abstract pathname.
|
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,
MkdirsOptions options)
Creates the directory named by this abstract pathname, with specified
MkdirsOptions . |
protected boolean |
mkdirsInternal(String key)
Creates a directory flagged file with the key and folder suffix.
|
InputStream |
open(String path,
OpenOptions options)
Opens an
InputStream for a file in under filesystem at the indicated path. |
InputStream |
openExistingFile(String path)
Opens an
InputStream for a file in under filesystem at the indicated path. |
InputStream |
openExistingFile(String path,
OpenOptions options)
Opens an
InputStream for a file in under filesystem at the indicated path. |
protected abstract InputStream |
openObject(String key,
OpenOptions options,
RetryPolicy retryPolicy)
Internal function to open an input stream to an object.
|
protected boolean |
parentExists(String path)
Treating the object store as a file system, checks if the parent directory exists.
|
boolean |
renameDirectory(String src,
String dst)
Renames a directory from
src to dst in under file system. |
boolean |
renameFile(String src,
String dst)
Renames a file from
src to dst in under file system. |
boolean |
renameRenamableDirectory(String src,
String dst)
Renames a directory from
src to dst in under file system. |
boolean |
renameRenamableFile(String src,
String dst)
Renames a file from
src to dst in under file system. |
protected <T> T |
retryOnException(ObjectUnderFileSystem.ObjectStoreOperation<T> op,
java.util.function.Supplier<String> description)
Retries the given object store operation when it throws exceptions
to resolve eventual consistency issue.
|
String |
stripPrefixIfPresent(String path)
Strips the bucket prefix or the preceding path separator from the path if it is present.
|
boolean |
supportsFlush()
Whether this type of UFS supports flush.
|
create, deleteDirectory, exists, getAclPair, getConfiguration, getFingerprint, getOperationMode, getParsedFingerprint, getParsedFingerprint, getPhysicalStores, isSeekable, mkdirs, open, performListingAsync, resolveUri, setAclEntries, validatePath
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFileStatus, getStatus, getTemporaryToken, getUnderFSType, isTemporaryConnectionToken, listStatuses, openPositionRead, refreshTemporaryToken, setMode, setOwner, setTemporaryTokenRefreshContext
protected static final char PATH_SEPARATOR_CHAR
protected static final String PATH_SEPARATOR
PATH_SEPARATOR_CHAR
.protected ExecutorService mExecutorService
protected final java.util.function.Supplier<String> mRootKeySupplier
protected ObjectUnderFileSystem(AlluxioURI uri, UnderFileSystemConfiguration ufsConf)
ObjectUnderFileSystem
.uri
- the AlluxioURI
used to create this ufsufsConf
- UFS configurationpublic void cleanup() throws IOException
UnderFileSystem
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class BaseUnderFileSystem
IOException
public void connectFromMaster(String hostname)
UnderFileSystem
Depending on the implementation this may be a no-op
hostname
- the host that wants to connect to the under file systempublic void connectFromWorker(String hostname)
UnderFileSystem
Depending on the implementation this may be a no-op
hostname
- the host that wants to connect to the under file systempublic OutputStream create(String path, CreateOptions options) throws IOException
UnderFileSystem
CreateOptions
.
Implementations should make sure that the path under creation appears in listings only
after a successful close and that contents are written in its entirety or not at all.path
- the file nameoptions
- the options for createOutputStream
objectIOException
public OutputStream createNonexistingFile(String path) throws IOException
UnderFileSystem
UnderFileSystem.create(String)
but
deals with the delete-then-create eventual consistency issue.path
- the file nameOutputStream
objectIOException
public OutputStream createNonexistingFile(String path, CreateOptions options) throws IOException
UnderFileSystem
CreateOptions
.
Similar to UnderFileSystem.create(String, CreateOptions)
but
deals with the delete-then-create eventual consistency issue.path
- the file nameoptions
- the options for createOutputStream
objectIOException
public boolean deleteFile(String path) throws IOException
UnderFileSystem
path
- of the file to deleteIOException
public boolean deleteExistingFile(String path) throws IOException
UnderFileSystem
UnderFileSystem.deleteFile(String)
but
deals with the create-then-delete eventual consistency issue.path
- of the file to deleteIOException
public boolean deleteDirectory(String path, DeleteOptions options) throws IOException
UnderFileSystem
path
- of the directory to deleteoptions
- for directory delete semanticsIOException
public boolean deleteExistingDirectory(String path) throws IOException
UnderFileSystem
UnderFileSystem.deleteDirectory(String)
but
deals with the create-delete eventual consistency issue.path
- of the directory to deleteIOException
public boolean deleteExistingDirectory(String path, DeleteOptions options) throws IOException
UnderFileSystem
UnderFileSystem.deleteDirectory(String, DeleteOptions)
but
deals with the create-then-delete eventual consistency issue.path
- of the directory to deleteoptions
- for directory delete semanticsIOException
public long getBlockSizeByte(String path) throws IOException
path
- the file nameIOException
public UfsDirectoryStatus getDirectoryStatus(String path) throws IOException
UnderFileSystem
path
- the path to the directoryFileNotFoundException
- when the path does not existIOException
public UfsDirectoryStatus getExistingDirectoryStatus(String path) throws IOException
UnderFileSystem
UnderFileSystem.getDirectoryStatus(String)
but
deals with the write-then-get-status eventual consistency issue.path
- the path to the directoryIOException
@Nullable public List<String> getFileLocations(String path) throws IOException
UnderFileSystem
path
- the file nameIOException
@Nullable public List<String> getFileLocations(String path, FileLocationOptions options) throws IOException
UnderFileSystem
path
- the file nameoptions
- method optionsIOException
public long getSpace(String path, UnderFileSystem.SpaceType type) throws IOException
UnderFileSystem
path
- the path to querytype
- the type of queriesIOException
public UfsFileStatus getFileStatus(String path, GetStatusOptions options) throws IOException
UnderFileSystem
path
- the path to the fileoptions
- method optionsFileNotFoundException
- when the path does not existIOException
public UfsFileStatus getExistingFileStatus(String path) throws IOException
UnderFileSystem
UnderFileSystem.getFileStatus(String)
but
deals with the write-then-get-status eventual consistency issue.path
- the path to the fileIOException
public UfsStatus getStatus(String path, GetStatusOptions options) throws IOException
UnderFileSystem
path
- the path to get the statusoptions
- method optionsFileNotFoundException
- when the path does not existIOException
public UfsStatus getExistingStatus(String path) throws IOException
UnderFileSystem
UnderFileSystem.getStatus(String)
but
deals with the write-then-get-status eventual consistency issue.path
- the path to get the statusIOException
public boolean isDirectory(String path) throws IOException
UnderFileSystem
path
- the absolute directory pathIOException
public boolean isExistingDirectory(String path) throws IOException
UnderFileSystem
UnderFileSystem.isDirectory(String)
but
deals with the write-then-list eventual consistency issue.path
- the absolute directory pathIOException
public boolean isFile(String path) throws IOException
UnderFileSystem
path
- the absolute file pathIOException
public boolean isObjectStorage()
isObjectStorage
in interface UnderFileSystem
isObjectStorage
in class BaseUnderFileSystem
public UfsStatus[] listStatus(String path) 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 in the directory.
Names denoting the directory itself and the directory's parent directory are not included in
the result. Each string is a file name rather than a complete path.
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.
path
- the abstract pathname to listnull
if this abstract pathname does not denote a directory.IOException
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
listStatus
in class BaseUnderFileSystem
path
- the abstract pathname to listoptions
- for list directorynull
if this abstract pathname does not denote a directory.IOException
@Nullable public Iterator<UfsStatus> listStatusIterable(String path, ListOptions options, String startAfter, int batchSize) throws IOException
UnderFileSystem
listStatusIterable
in interface UnderFileSystem
listStatusIterable
in class BaseUnderFileSystem
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 boolean mkdirs(String path, MkdirsOptions options) throws IOException
UnderFileSystem
MkdirsOptions
. If the folder already exists, the method returns false.path
- the folder to createoptions
- the options for mkdirstrue
if and only if the directory was created; false
otherwiseIOException
public InputStream open(String path, OpenOptions options) throws IOException
UnderFileSystem
InputStream
for a file in under filesystem at the indicated path.path
- the file nameoptions
- to open input streamInputStream
objectIOException
public InputStream openExistingFile(String path) throws IOException
UnderFileSystem
InputStream
for a file in under filesystem at the indicated path.
Similar to UnderFileSystem.open(String)
but
deals with the write-then-read eventual consistency issue.path
- the file nameInputStream
objectIOException
public InputStream openExistingFile(String path, OpenOptions options) throws IOException
UnderFileSystem
InputStream
for a file in under filesystem at the indicated path.
Similar to UnderFileSystem.open(String, OpenOptions)
but
deals with the write-then-read eventual consistency issue.path
- the file nameoptions
- to open input streamInputStream
objectIOException
public boolean renameDirectory(String src, String dst) throws IOException
UnderFileSystem
src
to dst
in under file system.src
- the source directory pathdst
- the destination directory pathIOException
public boolean renameRenamableDirectory(String src, String dst) throws IOException
UnderFileSystem
src
to dst
in under file system.
Similar to UnderFileSystem.renameDirectory(String, String)
but
deals with the write-src-then-rename and delete-dst-then-rename eventual consistency issue.src
- the source directory pathdst
- the destination directory pathIOException
public boolean renameFile(String src, String dst) throws IOException
UnderFileSystem
src
to dst
in under file system.src
- the source file pathdst
- the destination file pathIOException
public boolean renameRenamableFile(String src, String dst) throws IOException
UnderFileSystem
src
to dst
in under file system.
Similar to UnderFileSystem.renameFile(String, String)
but
deals with the write-src-then-rename and delete-dst-then-rename eventual consistency issue.src
- the source file pathdst
- the destination file pathIOException
public boolean supportsFlush() throws IOException
UnderFileSystem
IOException
public abstract boolean createEmptyObject(String key)
key
- the key to createprotected abstract OutputStream createObject(String key) throws IOException
OutputStream
for object uploads.key
- ufs key including scheme and bucketIOException
protected String convertToFolderName(String key)
key
- the key to convertprotected abstract boolean copyObject(String src, String dst) throws IOException
src
- the source key to copydst
- the destination key to copy toIOException
protected abstract boolean deleteObject(String key) throws IOException
key
- the key to deleteIOException
protected List<String> deleteObjects(List<String> keys) throws IOException
keys
- the list of keys to deleteIOException
protected abstract ObjectUnderFileSystem.ObjectPermissions getPermissions()
protected int getListingChunkLengthMax()
protected int getListingChunkLength(AlluxioConfiguration conf)
@Nullable protected abstract ObjectUnderFileSystem.ObjectStatus getObjectStatus(String key) throws IOException
key
- ufs key to get metadata forObjectUnderFileSystem.ObjectStatus
if key exists and successful, otherwise nullIOException
@Nullable protected String getParentPath(String path)
path
- ufs path including scheme and bucketprotected boolean isRoot(String path)
path
- ufs path including scheme and bucketprotected String getChildName(String child, String parent) throws IOException
child
- the key of the childparent
- the key of the parentIOException
protected abstract String getFolderSuffix()
@Nullable protected ObjectUnderFileSystem.ObjectListingChunk getObjectListingChunk(String key, boolean recursive, String startAfter, int batchSize) throws IOException
key
- pseudo-directory key excluding header and bucketrecursive
- whether to request immediate children only, or all descendantsstartAfter
- indicates where the listing startsbatchSize
- the batch size of each chunkIOException
@Nullable protected abstract ObjectUnderFileSystem.ObjectListingChunk getObjectListingChunk(String key, boolean recursive) throws IOException
key
- pseudo-directory key excluding header and bucketrecursive
- whether to request immediate children only, or all descendantsIOException
protected ObjectUnderFileSystem.ObjectListingChunk getObjectListingChunkForPath(String path, boolean recursive) throws IOException
IOException
@Nullable protected ObjectUnderFileSystem.ObjectListingChunk getObjectListingChunkForPath(String path, boolean recursive, String startAfter, int batchSize) throws IOException
path
- of pseudo-directoryrecursive
- whether to request immediate children only, or all descendantsIOException
protected abstract String getRootKey()
@Nullable protected UfsStatus[] listInternal(String path, ListOptions options) throws IOException
path
- the key to listoptions
- for listingIOException
protected boolean mkdirsInternal(String key)
key
- the key to create a folderprotected abstract InputStream openObject(String key, OpenOptions options, RetryPolicy retryPolicy) throws IOException
key
- the key to openoptions
- the open optionsretryPolicy
- the retry policy of the opened stream to solve eventual consistency issueInputStream
to read from keyIOException
protected boolean parentExists(String path) throws IOException
path
- the path to checkIOException
public String stripPrefixIfPresent(String path)
path
- the path to stripprotected <T> T retryOnException(ObjectUnderFileSystem.ObjectStoreOperation<T> op, java.util.function.Supplier<String> description) throws IOException
op
- the object store operation to retrydescription
- the description regarding the operationIOException
Copyright © 2023. All Rights Reserved.