@ThreadSafe public class S3AUnderFileSystem extends ObjectUnderFileSystem
UnderFileSystem
implementation based on the aws-java-sdk-s3 library.Modifier and Type | Class and Description |
---|---|
protected class |
S3AUnderFileSystem.S3AObjectListingChunk
Wrapper over S3
ListObjectsV2Request . |
protected class |
S3AUnderFileSystem.S3AObjectListingChunkV1
Wrapper over S3
ListObjectsRequest . |
ObjectUnderFileSystem.DeleteBuffer, ObjectUnderFileSystem.ObjectListingChunk, ObjectUnderFileSystem.ObjectPermissions, ObjectUnderFileSystem.ObjectStatus, ObjectUnderFileSystem.ObjectStoreOperation<T>, ObjectUnderFileSystem.OperationBuffer<T>, ObjectUnderFileSystem.RenameBuffer, ObjectUnderFileSystem.UfsStatusIterator
UnderFileSystem.Factory, UnderFileSystem.SpaceType
Modifier and Type | Field and Description |
---|---|
protected static String |
DIR_HASH
Static hash for a directory's empty contents.
|
protected static long |
MULTIPART_COPY_THRESHOLD
Threshold to do multipart copy.
|
mExecutorService, mRootKeySupplier, PATH_SEPARATOR, PATH_SEPARATOR_CHAR
EMPTY_ACL, mUfsConf, mUri
Modifier | Constructor and Description |
---|---|
protected |
S3AUnderFileSystem(AlluxioURI uri,
com.amazonaws.services.s3.AmazonS3 amazonS3Client,
software.amazon.awssdk.services.s3.S3AsyncClient asyncClient,
String bucketName,
ExecutorService executor,
com.amazonaws.services.s3.transfer.TransferManager transferManager,
UnderFileSystemConfiguration conf,
boolean streamingUploadEnabled,
boolean multipartUploadEnabled)
Constructor for
S3AUnderFileSystem . |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up the under file system.
|
void |
close() |
protected boolean |
copyObject(String src,
String dst)
Copies an object to another key.
|
static com.amazonaws.services.s3.AmazonS3 |
createAmazonS3(com.amazonaws.auth.AWSCredentialsProvider credentialsProvider,
com.amazonaws.ClientConfiguration clientConf,
com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration endpointConfiguration,
UnderFileSystemConfiguration conf)
Create an AmazonS3 client.
|
static software.amazon.awssdk.services.s3.S3AsyncClient |
createAmazonS3Async(UnderFileSystemConfiguration conf,
com.amazonaws.ClientConfiguration clientConf)
Create an async S3 client.
|
static com.amazonaws.auth.AWSCredentialsProvider |
createAwsCredentialsProvider(UnderFileSystemConfiguration conf) |
boolean |
createEmptyObject(String key)
Creates a zero-byte object used to encode a directory.
|
protected static com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration |
createEndpointConfiguration(UnderFileSystemConfiguration conf,
com.amazonaws.ClientConfiguration clientConf)
Creates an endpoint configuration.
|
static S3AUnderFileSystem |
createInstance(AlluxioURI uri,
UnderFileSystemConfiguration conf)
Constructs a new instance of
S3AUnderFileSystem . |
protected OutputStream |
createObject(String key)
Creates an
OutputStream for object uploads. |
protected 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.
|
protected String |
getBucketName() |
protected com.amazonaws.services.s3.AmazonS3 |
getClient() |
protected com.google.common.util.concurrent.ListeningExecutorService |
getExecutor() |
protected String |
getFolderSuffix()
Get suffix used to encode a directory.
|
protected boolean |
getMultipartUploadEnabled() |
protected 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.ObjectStatus |
getObjectStatus(String key)
Get metadata information about object.
|
protected ObjectUnderFileSystem.ObjectPermissions |
getPermissions()
Permissions for the mounted bucket.
|
protected String |
getRootKey()
Get full path of root in object store.
|
protected boolean |
getStreamingUploadEnabled() |
protected com.amazonaws.services.s3.transfer.TransferManager |
getTransferManager() |
String |
getUnderFSType()
Returns the name of the under filesystem implementation.
|
protected InputStream |
openObject(String key,
OpenOptions options,
RetryPolicy retryPolicy)
Internal function to open an input stream to an object.
|
S3APositionReader |
openPositionRead(String path,
long fileLength)
Opens a file for position read.
|
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.
|
protected void |
setClient(com.amazonaws.services.s3.AmazonS3 client) |
void |
setMode(String path,
short mode)
Changes posix file mode.
|
void |
setOwner(String path,
String user,
String group)
Sets the user and group of the given path.
|
connectFromMaster, connectFromWorker, convertToFolderName, create, createNonexistingFile, createNonexistingFile, deleteDirectory, deleteExistingDirectory, deleteExistingDirectory, deleteExistingFile, deleteFile, getBlockSizeByte, getChildName, getDirectoryStatus, getExistingDirectoryStatus, getExistingFileStatus, getExistingStatus, getFileLocations, getFileLocations, getFileStatus, getListingChunkLength, getListingChunkLengthMax, getObjectListingChunkForPath, getObjectListingChunkForPath, getParentPath, getSpace, getStatus, isDirectory, isExistingDirectory, isFile, isObjectStorage, isRoot, listInternal, listStatus, listStatus, listStatusIterable, mkdirs, mkdirsInternal, open, openExistingFile, openExistingFile, parentExists, renameDirectory, renameFile, renameRenamableDirectory, renameRenamableFile, retryOnException, stripPrefixIfPresent, supportsFlush
create, deleteDirectory, exists, getAclPair, getConfiguration, getFingerprint, getOperationMode, getParsedFingerprint, getParsedFingerprint, getPhysicalStores, isSeekable, mkdirs, open, resolveUri, setAclEntries, validatePath
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFileStatus, getStatus, getTemporaryToken, isTemporaryConnectionToken, listStatuses, refreshTemporaryToken, setTemporaryTokenRefreshContext
protected static final String DIR_HASH
protected static final long MULTIPART_COPY_THRESHOLD
protected S3AUnderFileSystem(AlluxioURI uri, com.amazonaws.services.s3.AmazonS3 amazonS3Client, software.amazon.awssdk.services.s3.S3AsyncClient asyncClient, String bucketName, ExecutorService executor, com.amazonaws.services.s3.transfer.TransferManager transferManager, UnderFileSystemConfiguration conf, boolean streamingUploadEnabled, boolean multipartUploadEnabled)
S3AUnderFileSystem
.uri
- the AlluxioURI
for this UFSamazonS3Client
- AWS-SDK S3 clientasyncClient
- AWS S3 async clientbucketName
- bucket name of user's configured Alluxio bucketexecutor
- the executor for executing upload taskstransferManager
- Transfer Manager for efficient I/O to S3conf
- configuration for this S3A ufsstreamingUploadEnabled
- whether streaming upload is enabledmultipartUploadEnabled
- whether multipart upload is enabledpublic static com.amazonaws.auth.AWSCredentialsProvider createAwsCredentialsProvider(UnderFileSystemConfiguration conf)
conf
- the configuration for this UFSAWSCredentialsProvider
instancepublic static S3AUnderFileSystem createInstance(AlluxioURI uri, UnderFileSystemConfiguration conf)
S3AUnderFileSystem
.uri
- the AlluxioURI
for this UFSconf
- the configuration for this UFSS3AUnderFileSystem
instancepublic static software.amazon.awssdk.services.s3.S3AsyncClient createAmazonS3Async(UnderFileSystemConfiguration conf, com.amazonaws.ClientConfiguration clientConf)
conf
- the confclientConf
- the client confpublic static com.amazonaws.services.s3.AmazonS3 createAmazonS3(com.amazonaws.auth.AWSCredentialsProvider credentialsProvider, com.amazonaws.ClientConfiguration clientConf, com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration endpointConfiguration, UnderFileSystemConfiguration conf)
credentialsProvider
- the credential providerclientConf
- the client configendpointConfiguration
- the endpoint configconf
- the Ufs config@Nullable protected static com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration createEndpointConfiguration(UnderFileSystemConfiguration conf, com.amazonaws.ClientConfiguration clientConf)
conf
- the alluxio confclientConf
- the aws confpublic S3APositionReader openPositionRead(String path, long fileLength)
UnderFileSystem
path
- the path to readfileLength
- the file lengthpublic String getUnderFSType()
UnderFileSystem
public void setOwner(String path, String user, String group)
UnderFileSystem
path
- the path of the fileuser
- the new owner to set, unchanged if nullgroup
- the new group to set, unchanged if nullpublic void setMode(String path, short mode)
UnderFileSystem
path
- the path of the filemode
- the mode to set in short format, e.g. 0777public void cleanup()
UnderFileSystem
cleanup
in interface UnderFileSystem
cleanup
in class ObjectUnderFileSystem
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class ObjectUnderFileSystem
protected boolean copyObject(String src, String dst)
ObjectUnderFileSystem
copyObject
in class ObjectUnderFileSystem
src
- the source key to copydst
- the destination key to copy toprotected com.amazonaws.services.s3.AmazonS3 getClient()
protected void setClient(com.amazonaws.services.s3.AmazonS3 client)
protected String getBucketName()
protected com.google.common.util.concurrent.ListeningExecutorService getExecutor()
protected com.amazonaws.services.s3.transfer.TransferManager getTransferManager()
protected boolean getStreamingUploadEnabled()
protected boolean getMultipartUploadEnabled()
public boolean createEmptyObject(String key)
ObjectUnderFileSystem
createEmptyObject
in class ObjectUnderFileSystem
key
- the key to createprotected OutputStream createObject(String key) throws IOException
ObjectUnderFileSystem
OutputStream
for object uploads.createObject
in class ObjectUnderFileSystem
key
- ufs key including scheme and bucketIOException
protected boolean deleteObject(String key)
ObjectUnderFileSystem
deleteObject
in class ObjectUnderFileSystem
key
- the key to deleteprotected List<String> deleteObjects(List<String> keys) throws IOException
ObjectUnderFileSystem
deleteObjects
in class ObjectUnderFileSystem
keys
- the list of keys to deleteIOException
protected String getFolderSuffix()
ObjectUnderFileSystem
getFolderSuffix
in class ObjectUnderFileSystem
@Nullable protected ObjectUnderFileSystem.ObjectListingChunk getObjectListingChunk(String key, boolean recursive) throws IOException
ObjectUnderFileSystem
getObjectListingChunk
in class ObjectUnderFileSystem
key
- pseudo-directory key excluding header and bucketrecursive
- whether to request immediate children only, or all descendantsIOException
@Nullable protected ObjectUnderFileSystem.ObjectListingChunk getObjectListingChunk(String key, boolean recursive, @Nullable String startAfter, int batchSize) throws IOException
ObjectUnderFileSystem
getObjectListingChunk
in class ObjectUnderFileSystem
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
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
performListingAsync
in class BaseUnderFileSystem
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 protected ObjectUnderFileSystem.ObjectStatus getObjectStatus(String key)
ObjectUnderFileSystem
getObjectStatus
in class ObjectUnderFileSystem
key
- ufs key to get metadata forObjectUnderFileSystem.ObjectStatus
if key exists and successful, otherwise nullprotected ObjectUnderFileSystem.ObjectPermissions getPermissions()
ObjectUnderFileSystem
getPermissions
in class ObjectUnderFileSystem
protected String getRootKey()
ObjectUnderFileSystem
getRootKey
in class ObjectUnderFileSystem
protected InputStream openObject(String key, OpenOptions options, RetryPolicy retryPolicy)
ObjectUnderFileSystem
openObject
in class ObjectUnderFileSystem
key
- the key to openoptions
- the open optionsretryPolicy
- the retry policy of the opened stream to solve eventual consistency issueInputStream
to read from keyCopyright © 2023. All Rights Reserved.