public final class S3RestUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
S3RestUtils.RestCallable<T>
An interface representing a callable.
|
static class |
S3RestUtils.URIStatusNameComparator
Comparator based on uri nameļ¼ treat uri name as a Long number.
|
Modifier and Type | Field and Description |
---|---|
static String |
MULTIPART_UPLOADS_METADATA_DIR |
Modifier and Type | Method and Description |
---|---|
static <T> javax.ws.rs.core.Response |
call(String resource,
S3RestUtils.RestCallable<T> callable)
Calls the given
S3RestUtils.RestCallable and handles any exceptions thrown. |
static void |
checkPathIsAlluxioDirectory(FileSystem fs,
String bucketPath)
Check if a path in alluxio is a directory.
|
static List<URIStatus> |
checkStatusesForUploadId(FileSystem fs,
AlluxioURI multipartTempDirUri,
String uploadId)
Fetches and returns the corresponding
URIStatus for both
the multipart upload temp directory and the Alluxio S3 metadata file. |
static void |
deleteExistObject(FileSystem fs,
AlluxioURI objectURI)
Delete an existing key.
|
static void |
deleteExistObject(FileSystem fs,
AlluxioURI objectURI,
Boolean recursive)
Delete an existing key.
|
static javax.ws.rs.core.MediaType |
deserializeContentType(Map<String,byte[]> xAttr)
Given xAttr, parses and returns the Content-Type header metadata
as its corresponding
MediaType , or otherwise defaults
to MediaType.APPLICATION_OCTET_STREAM_TYPE . |
static TaggingData |
deserializeTaggingHeader(String taggingHeader,
int maxHeaderMetadataSize)
Given a URL-encoded Tagging header, parses and deserializes the Tagging metadata
into a
TaggingData object. |
static TaggingData |
deserializeTags(Map<String,byte[]> xAttr)
Given xAttr, parses and deserializes the Tagging metadata
into a
TaggingData object. |
static Map<String,String> |
fromMultiValueToSingleValueMap(javax.ws.rs.core.MultivaluedMap<String,String> queryParameters,
boolean lowerCase)
Convert MultivaluedMap to a single value map.
|
static String |
getEntityTag(URIStatus status)
This helper method is used to get the ETag xAttr on an object.
|
static String |
getMultipartMetaFilepathForUploadId(String uploadId) |
static String |
getMultipartTemporaryDirForObject(String bucketPath,
String objectKey,
String uploadId) |
static WritePType |
getS3WriteType() |
static boolean |
isAuthenticationEnabled(AlluxioConfiguration conf)
Checks if authentication is enabled.
|
static String |
parsePath(String bucketPath)
Format bucket path.
|
static void |
setEntityTag(FileSystem fs,
AlluxioURI objectUri,
String entityTag)
This helper method is used to set the ETag xAttr on an object.
|
static S3Exception |
toBucketS3Exception(Exception exception,
String resource)
Convert an exception to instance of
S3Exception . |
static S3Exception |
toObjectS3Exception(Exception exception,
String resource)
Convert an exception to instance of
S3Exception . |
static String |
toS3Date(long epoch) |
public static final String MULTIPART_UPLOADS_METADATA_DIR
public static <T> javax.ws.rs.core.Response call(String resource, S3RestUtils.RestCallable<T> callable)
S3RestUtils.RestCallable
and handles any exceptions thrown.T
- the return type of the callableresource
- the resource (bucket or object) to be operated oncallable
- the callable to callpublic static String getMultipartTemporaryDirForObject(String bucketPath, String objectKey, String uploadId)
bucketPath
- the bucket path like "/bucket", "/mount/point/bucket"objectKey
- the object key like "img/2017/9/1/s3.jpg"uploadId
- the upload IDpublic static String getMultipartMetaFilepathForUploadId(String uploadId)
uploadId
- the upload IDpublic static String toS3Date(long epoch)
epoch
- the milliseconds from the epochpublic static String parsePath(String bucketPath)
bucketPath
- bucket pathpublic static S3Exception toBucketS3Exception(Exception exception, String resource)
S3Exception
.exception
- Exception thrown when process s3 object rest requestresource
- complete bucket pathS3Exception
public static S3Exception toObjectS3Exception(Exception exception, String resource)
S3Exception
.exception
- Exception thrown when process s3 object rest requestresource
- object complete pathS3Exception
public static void checkPathIsAlluxioDirectory(FileSystem fs, String bucketPath) throws S3Exception
fs
- instance of FileSystem
bucketPath
- bucket complete pathS3Exception
public static List<URIStatus> checkStatusesForUploadId(FileSystem fs, AlluxioURI multipartTempDirUri, String uploadId) throws AlluxioException, IOException
URIStatus
for both
the multipart upload temp directory and the Alluxio S3 metadata file.fs
- instance of FileSystem
multipartTempDirUri
- multipart upload tmp directory URIuploadId
- multipart upload IdAlluxioException
IOException
public static void deleteExistObject(FileSystem fs, AlluxioURI objectURI) throws IOException, AlluxioException
fs
- instance of FileSystem
objectURI
- the key uriIOException
AlluxioException
public static void deleteExistObject(FileSystem fs, AlluxioURI objectURI, Boolean recursive) throws IOException, AlluxioException
fs
- instance of FileSystem
objectURI
- the key urirecursive
- if delete option is recursiveIOException
AlluxioException
public static WritePType getS3WriteType()
public static boolean isAuthenticationEnabled(AlluxioConfiguration conf)
conf
- Alluxio configurationpublic static Map<String,String> fromMultiValueToSingleValueMap(javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, boolean lowerCase)
queryParameters
- MultivaluedMaplowerCase
- whether to use lower casepublic static javax.ws.rs.core.MediaType deserializeContentType(Map<String,byte[]> xAttr)
MediaType
, or otherwise defaults
to MediaType.APPLICATION_OCTET_STREAM_TYPE
.xAttr
- the Inode's xAttrsMediaType
corresponding to the Content-Type headerpublic static TaggingData deserializeTags(Map<String,byte[]> xAttr) throws IOException
TaggingData
object. Returns null if no data exists.xAttr
- the Inode's xAttrsTaggingData
objectIOException
public static TaggingData deserializeTaggingHeader(String taggingHeader, int maxHeaderMetadataSize) throws S3Exception
TaggingData
object. Returns null on empty strings.taggingHeader
- the URL-encoded Tagging headermaxHeaderMetadataSize
- Header user-metadata size limit validation (default max: 2 KB)
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.htmlTaggingData
objectS3Exception
public static void setEntityTag(FileSystem fs, AlluxioURI objectUri, String entityTag) throws IOException, AlluxioException
fs
- The FileSystem
used to make the gRPC requestobjectUri
- The AlluxioURI
for the object to updateentityTag
- The entity tag of the object (MD5 checksum of the object contents)IOException
AlluxioException
Copyright © 2023. All Rights Reserved.