Package org.apache.hadoop.fs.s3a.impl
Class HeaderProcessing
java.lang.Object
org.apache.hadoop.fs.s3a.impl.AbstractStoreOperation
org.apache.hadoop.fs.s3a.impl.HeaderProcessing
Part of the S3A FS where object headers are
processed.
Implements all the various XAttr read operations.
Those APIs all expect byte arrays back.
Metadata cloning is also implemented here, so as
to stay in sync with custom header logic.
The standard header names are extracted from the AWS SDK.
The S3A connector does not (currently) support setting them,
though it would be possible to do so through the createFile()
builder API.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringXML content type : "application/xml".static final StringContent type of generic binary objects.static final StringDirectory content type : "application/x-directory".static final StringHTTP Referrer for logs: "Referer".static final Stringobject archive status; empty if not on S3 Glacier (i.e all normal files should be non-archived as S3A and applications don't handle archived data) Value "header.x-amz-archive-status".static final StringStandard HTTP header found on some S3 objects: "header.Cache-Control".static final StringStandard HTTP header found on some S3 objects: "header.Content-Disposition".static final StringContent encoding; can be configured: "header.Content-Encoding".static final StringStandard HTTP header found on some S3 objects: "header.Content-Language".static final StringLength XAttr: "header.Content-Length".static final StringStandard HTTP header found on some S3 objects: "header.Content-MD5".static final StringContent range: "header.Content-Range".static final StringContent type: may be set when uploading.static final Stringstatic final StringEtag Header "header.ETag".static final Stringlast modified XAttr: "header.Last-Modified".static final StringObject legal hold status.static final StringObject lock mode.static final StringISO8601 expiry date of object lock hold.static final StringReplication status for cross-region replicated objects.static final StringVersion ID; empty for non-versioned buckets/data.static final StringThe server-side encryption algorithm to use with AWS-managed keys: "header.x-amz-server-side-encryption".static final String[]Standard headers which are retrieved from HEAD Requests and set as XAttrs if the response included the relevant header.static final StringStorage Class XAttr: "header.x-amz-storage-class". -
Constructor Summary
ConstructorsConstructorDescriptionHeaderProcessing(StoreContext storeContext, HeaderProcessing.HeaderProcessingCallbacks callbacks) Construct. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloneObjectMetadata(software.amazon.awssdk.services.s3.model.HeadObjectResponse source, Map<String, String> dest, software.amazon.awssdk.services.s3.model.CopyObjectRequest.Builder copyObjectRequestBuilder) Creates a copy of the passed metadata.static StringdecodeBytes(byte[] bytes) Get the string value from the bytes.static byte[]Stringify an object and return its bytes in UTF-8 encoding.extractXAttrLongValue(byte[] data) Convert an XAttr byte array to a long.byte[]Get an XAttr name and value for a file or directory.getXAttrs(org.apache.hadoop.fs.Path path) SeeFileSystem.getXAttrs(path.SeeFileSystem.getXAttrs(path, names.listXAttrs(org.apache.hadoop.fs.Path path) SeeFileSystem.listXAttrs(path).Methods inherited from class org.apache.hadoop.fs.s3a.impl.AbstractStoreOperation
activateAuditSpan, getAuditSpan, getStoreContext
-
Field Details
-
XA_CACHE_CONTROL
Standard HTTP header found on some S3 objects: "header.Cache-Control".- See Also:
-
XA_CONTENT_DISPOSITION
Standard HTTP header found on some S3 objects: "header.Content-Disposition".- See Also:
-
XA_CONTENT_ENCODING
Content encoding; can be configured: "header.Content-Encoding".- See Also:
-
XA_CONTENT_LANGUAGE
Standard HTTP header found on some S3 objects: "header.Content-Language".- See Also:
-
XA_CONTENT_LENGTH
Length XAttr: "header.Content-Length".- See Also:
-
XA_CONTENT_MD5
Standard HTTP header found on some S3 objects: "header.Content-MD5".- See Also:
-
XA_CONTENT_RANGE
Content range: "header.Content-Range". This is returned on GET requests with ranges.- See Also:
-
XA_CONTENT_TYPE
Content type: may be set when uploading. "header.Content-Type".- See Also:
-
XA_ETAG
Etag Header "header.ETag". Also accessible viaObjectMetadata.getEtag(), where it can be retrieved viagetFileChecksum(path)if the S3A connector is enabled.- See Also:
-
XA_LAST_MODIFIED
last modified XAttr: "header.Last-Modified".- See Also:
-
XA_ARCHIVE_STATUS
object archive status; empty if not on S3 Glacier (i.e all normal files should be non-archived as S3A and applications don't handle archived data) Value "header.x-amz-archive-status".- See Also:
-
XA_OBJECT_LOCK_LEGAL_HOLD_STATUS
Object legal hold status. "header.x-amz-object-lock-legal-hold".- See Also:
-
XA_OBJECT_LOCK_MODE
Object lock mode. "header.x-amz-object-lock-mode".- See Also:
-
XA_OBJECT_LOCK_RETAIN_UNTIL_DATE
ISO8601 expiry date of object lock hold. "header.x-amz-object-lock-retain-until-date".- See Also:
-
XA_OBJECT_REPLICATION_STATUS
Replication status for cross-region replicated objects. "header.x-amz-replication-status".- See Also:
-
XA_S3_VERSION_ID
Version ID; empty for non-versioned buckets/data. "header.x-amz-version-id".- See Also:
-
XA_SERVER_SIDE_ENCRYPTION
The server-side encryption algorithm to use with AWS-managed keys: "header.x-amz-server-side-encryption".- See Also:
-
XA_ENCRYPTION_KEY_ID
- See Also:
-
XA_STORAGE_CLASS
Storage Class XAttr: "header.x-amz-storage-class".- See Also:
-
HEADER_REFERRER
HTTP Referrer for logs: "Referer". This can be found in S3 logs, but is not set as an attribute in objects. important: the header value is deliberately a mis-spelling, as that is defined in RFC-1945.- See Also:
-
XA_STANDARD_HEADERS
Standard headers which are retrieved from HEAD Requests and set as XAttrs if the response included the relevant header. -
CONTENT_TYPE_OCTET_STREAM
Content type of generic binary objects. This is the default for uploaded objects.- See Also:
-
CONTENT_TYPE_APPLICATION_XML
XML content type : "application/xml". This is application/xml, not text/xml, and is what a HEAD of / returns as the type of a root path.- See Also:
-
CONTENT_TYPE_X_DIRECTORY
Directory content type : "application/x-directory". Matches use/expectations of AWS S3 console.- See Also:
-
-
Constructor Details
-
HeaderProcessing
public HeaderProcessing(StoreContext storeContext, HeaderProcessing.HeaderProcessingCallbacks callbacks) Construct.- Parameters:
storeContext- store context.callbacks- callbacks to the store
-
-
Method Details
-
encodeBytes
Stringify an object and return its bytes in UTF-8 encoding.- Parameters:
s- source- Returns:
- encoded object or an empty buffer
-
decodeBytes
Get the string value from the bytes. if null : return null, otherwise the UTF-8 decoded bytes.- Parameters:
bytes- source bytes- Returns:
- decoded value
-
getXAttr
Get an XAttr name and value for a file or directory.- Parameters:
path- Path to get extended attributename- XAttr name.- Returns:
- byte[] XAttr value or null
- Throws:
IOException- IO failure
-
getXAttrs
SeeFileSystem.getXAttrs(path.- Parameters:
path- Path to get extended attributes- Returns:
- Map describing the XAttrs of the file or directory
- Throws:
IOException- IO failure
-
listXAttrs
SeeFileSystem.listXAttrs(path).- Parameters:
path- Path to get extended attributes- Returns:
- List of supported XAttrs
- Throws:
IOException- IO failure
-
getXAttrs
public Map<String,byte[]> getXAttrs(org.apache.hadoop.fs.Path path, List<String> names) throws IOException SeeFileSystem.getXAttrs(path, names.- Parameters:
path- Path to get extended attributesnames- XAttr names.- Returns:
- Map describing the XAttrs of the file or directory
- Throws:
IOException- IO failure
-
extractXAttrLongValue
Convert an XAttr byte array to a long. testability.- Parameters:
data- data to parse- Returns:
- either a length or none
-
cloneObjectMetadata
public static void cloneObjectMetadata(software.amazon.awssdk.services.s3.model.HeadObjectResponse source, Map<String, String> dest, software.amazon.awssdk.services.s3.model.CopyObjectRequest.Builder copyObjectRequestBuilder) Creates a copy of the passed metadata. This operation does not copy theX_HEADER_MAGIC_MARKERheader to avoid confusion. If a marker file is renamed, it loses information about any remapped file. If new fields are added to ObjectMetadata which are not present in the user metadata headers, they will not be picked up or cloned unless this operation is updated.- Parameters:
source- the source metadata to copydest- the metadata to update; this is the return value.copyObjectRequestBuilder- CopyObjectRequest builder
-