Package org.apache.hadoop.fs.store.audit
Class HttpReferrerAuditHeader
java.lang.Object
org.apache.hadoop.fs.store.audit.HttpReferrerAuditHeader
Contains all the logic for generating an HTTP "Referer"
entry; includes escaping query params.
Tests for this are in
org.apache.hadoop.fs.s3a.audit.TestHttpReferrerAuditHeader
so as to verify that header generation in the S3A auditors, and
S3 log parsing, all work.
This header may be shared across multiple threads at the same time. so some methods are marked as synchronized, specifically those reading or writing the attribute map.
For the same reason, maps and lists passed down during construction are copied into thread safe structures.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFormat of path to build: "/hadoop/1/%3$s/%2$s/". -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Get a builder.Build the referrer string.static StringescapeToPathElement(CharSequence source) Perform any escaping to valid path elements in advance of new URI() doing this itself.extractQueryParameters(String header) Split up the string.getPath1()getPath2()static StringmaybeStripWrappedQuotes(String header) Strip any quotes from around a header.voidSet an attribute.toString()
-
Field Details
-
REFERRER_PATH_FORMAT
Format of path to build: "/hadoop/1/%3$s/%2$s/". the params passed in are (context ID, span ID, op). UpdateTestHttpReferrerAuditHeader.SAMPLE_LOG_ENTRYon changes- See Also:
-
-
Method Details
-
buildHttpReferrer
Build the referrer string. This includes dynamically evaluating all of the evaluated attributes. If there is an error creating the string it will be logged once per entry, and "" returned.- Returns:
- a referrer string or ""
-
set
Set an attribute. If the value is non-null/empty, it will be used as a query parameter.- Parameters:
key- key to setvalue- value.
-
getContextId
-
getOperationName
-
getSpanId
-
getPath1
-
getPath2
-
toString
-
escapeToPathElement
Perform any escaping to valid path elements in advance of new URI() doing this itself. Only path separators need to be escaped/converted at this point.- Parameters:
source- source string- Returns:
- an escaped path element.
-
maybeStripWrappedQuotes
Strip any quotes from around a header. This is needed when processing log entries.- Parameters:
header- field.- Returns:
- field without quotes.
-
extractQueryParameters
Split up the string. Uses httpClient: make sure it is on the classpath. Any query param with a name but no value, e.g ?something is returned in the map with an empty string as the value.- Parameters:
header- URI to parse- Returns:
- a map of parameters.
- Throws:
URISyntaxException- failure to build URI from header.
-
builder
Get a builder.- Returns:
- a new builder.
-