-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19645. [ABFS][ReadAheadV2] Improve Metrics for Read Calls to identify type of read done. #7837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-19645. [ABFS][ReadAheadV2] Improve Metrics for Read Calls to identify type of read done. #7837
Changes from 3 commits
ea1572a
42ecdd0
224f712
9a87ad5
0d926b1
9bb6cdb
69ffec4
132893f
6345ec9
9059784
c787d3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,7 @@ public class TracingContext { | |
| //final concatenated ID list set into x-ms-client-request-id header | ||
| private String header = EMPTY_STRING; | ||
| private String ingressHandler = EMPTY_STRING; | ||
| private String position = EMPTY_STRING; | ||
| private String position = String.valueOf(0); // position of read/write in remote file | ||
| private String metricResults = EMPTY_STRING; | ||
| private String metricHeader = EMPTY_STRING; | ||
| private ReadType readType = ReadType.UNKNOWN_READ; | ||
|
|
@@ -80,7 +80,7 @@ public class TracingContext { | |
| * will not change this field. In case {@link #primaryRequestId} is non-null, | ||
| * this field shall not be set. | ||
| */ | ||
| private String primaryRequestIdForRetry; | ||
| private String primaryRequestIdForRetry = EMPTY_STRING; | ||
| private Integer operatedBlobCount = 1; // Only relevant for rename-delete over blob endpoint where it will be explicitly set. | ||
|
||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(AbfsClient.class); | ||
|
|
@@ -200,8 +200,8 @@ public void setListener(Listener listener) { | |
| * <li>ingressHandler</li> | ||
| * <li>position of read/write in the remote file</li> | ||
| * <li>operatedBlobCount - number of blobs operated on by this request</li> | ||
| * <li>httpOperationHeader - suffix for network library used</li> | ||
| * <li>operationSpecificHeader - different operation types can publish info relevant to that operation</li> | ||
| * <li>httpOperationHeader - suffix for network library used</li> | ||
| * </ul> | ||
| * @param httpOperation AbfsHttpOperation instance to set header into | ||
| * connection | ||
|
|
@@ -214,7 +214,7 @@ public void constructHeader(AbfsHttpOperation httpOperation, String previousFail | |
| clientRequestId = UUID.randomUUID().toString(); | ||
| switch (format) { | ||
| case ALL_ID_FORMAT: | ||
| header = TracingHeaderVersion.V1.getVersion() + COLON | ||
| header = TracingHeaderVersion.getCurrentVersion() + COLON | ||
| + clientCorrelationID + COLON | ||
| + clientRequestId + COLON | ||
| + fileSystemID + COLON | ||
|
|
@@ -225,19 +225,19 @@ public void constructHeader(AbfsHttpOperation httpOperation, String previousFail | |
| + ingressHandler + COLON | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these empty string checks are needed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With empty checks we cannot have a fixed schema. We need the proper defined schema where each position after split is fixed for all the headers and analysis can be done easily without worrying about the position of info we need to analyse. |
||
| + position + COLON | ||
| + operatedBlobCount + COLON | ||
| + httpOperation.getTracingContextSuffix() + COLON | ||
| + getOperationSpecificHeader(opType); | ||
| + getOperationSpecificHeader(opType) + COLON | ||
| + httpOperation.getTracingContextSuffix(); | ||
|
|
||
| metricHeader += !(metricResults.trim().isEmpty()) ? metricResults : EMPTY_STRING; | ||
| break; | ||
| case TWO_ID_FORMAT: | ||
| header = TracingHeaderVersion.V1.getVersion() + COLON | ||
| header = TracingHeaderVersion.getCurrentVersion() + COLON | ||
| + clientCorrelationID + COLON + clientRequestId; | ||
| metricHeader += !(metricResults.trim().isEmpty()) ? metricResults : EMPTY_STRING; | ||
| break; | ||
| default: | ||
| //case SINGLE_ID_FORMAT | ||
| header = TracingHeaderVersion.V1.getVersion() + COLON | ||
| header = TracingHeaderVersion.getCurrentVersion() + COLON | ||
| + clientRequestId; | ||
| metricHeader += !(metricResults.trim().isEmpty()) ? metricResults : EMPTY_STRING; | ||
| } | ||
|
|
@@ -275,17 +275,15 @@ private String getPrimaryRequestIdForHeader(final Boolean isRetry) { | |
| return primaryRequestIdForRetry; | ||
| } | ||
|
|
||
| private String addFailureReasons(final String header, | ||
| final String previousFailure, String retryPolicyAbbreviation) { | ||
| if (previousFailure == null) { | ||
| return header; | ||
| } | ||
| if (CONNECTION_TIMEOUT_ABBREVIATION.equals(previousFailure) && retryPolicyAbbreviation != null) { | ||
| return String.format("%s_%s_%s", header, previousFailure, retryPolicyAbbreviation); | ||
| } | ||
| return String.format("%s_%s", header, previousFailure); | ||
| } | ||
|
|
||
| /** | ||
| * Get the retry header string in format retryCount_failureReason_retryPolicyAbbreviation | ||
| * retryCount is always there and 0 for first request. | ||
| * failureReason is null for first request | ||
| * retryPolicyAbbreviation is only present when request fails with ConnectionTimeout | ||
| * @param previousFailure Previous failure reason, null if not a retried request | ||
| * @param retryPolicyAbbreviation Abbreviation of retry policy used to get retry interval | ||
| * @return String representing the retry header | ||
| */ | ||
| private String getRetryHeader(final String previousFailure, String retryPolicyAbbreviation) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add javadoc to all newly added methods
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can remove the addFailureReasons method- it has no usage now
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken |
||
| String retryHeader = String.format("%d", retryCount); | ||
| if (previousFailure == null) { | ||
|
|
@@ -297,6 +295,11 @@ private String getRetryHeader(final String previousFailure, String retryPolicyAb | |
| return String.format("%s_%s", retryHeader, previousFailure); | ||
| } | ||
|
|
||
| /** | ||
| * Get the operation specific header for the current operation type. | ||
| * @param opType The operation type for which the header is needed | ||
| * @return String representing the operation specific header | ||
| */ | ||
| private String getOperationSpecificHeader(FSOperationType opType) { | ||
| // Similar header can be added for other operations in the future. | ||
| switch (opType) { | ||
|
|
@@ -307,6 +310,10 @@ private String getOperationSpecificHeader(FSOperationType opType) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the operation specific header for read operations. | ||
| * @return String representing the read specific header | ||
| */ | ||
| private String getReadSpecificHeader() { | ||
| // More information on read can be added to this header in the future. | ||
| // As underscore separated values. | ||
|
|
@@ -372,14 +379,14 @@ public void setPosition(final String position) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Sets the read type for the current operation. | ||
| * @param readType the read type to set, must not be null. | ||
| */ | ||
| public void setReadType(ReadType readType) { | ||
| this.readType = readType; | ||
| if (listener != null) { | ||
| listener.updateReadType(readType); | ||
| } | ||
| } | ||
|
|
||
| public ReadType getReadType() { | ||
| return readType; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,33 +18,55 @@ | |
|
|
||
| package org.apache.hadoop.fs.azurebfs.utils; | ||
|
|
||
| /** | ||
| * Enum representing the version of the tracing header used in Azure Blob File System (ABFS). | ||
| * It defines two versions: V0 and V1, with their respective field counts. | ||
| * Any changes to the tracing header should introduce a new version so that every | ||
| * version has a fixed predefined schema of fields. | ||
| */ | ||
| public enum TracingHeaderVersion { | ||
|
|
||
| /** | ||
| * Version 0 of the tracing header, which has no version prefix and contains 8 permanent and a few optional fields. | ||
| * This is the initial version of the tracing header. | ||
| */ | ||
| V0("", 8), | ||
| /** | ||
| * Version 1 of the tracing header, which includes a version prefix and has 13 permanent fields. | ||
| * This version is used for the current tracing header schema. | ||
| * Schema: version:clientCorrelationId:clientRequestId:fileSystemId | ||
| * :primaryRequestId:streamId:opType:retryHeader:ingressHandler | ||
| * :position:operatedBlobCount:operationSpecificHeader:httpOperationHeader | ||
| */ | ||
| V1("v1", 13); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the next versions would be V1.1/V1.2- so should we consider starting with V1.0/V1.1?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So every time we add a new header, we need to add a new version ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will have simple version strings like v0, v1, v2 and so on. This will help reduce char count in clientReqId. With any new changes in the schema of Tracing Header (add/delete/rearrange) we need to bump up version and update the schema and getCurrentVersion method to return the latest version. |
||
|
|
||
| private final String version; | ||
| private final String versionString; | ||
| private final int fieldCount; | ||
|
|
||
| TracingHeaderVersion(String version, int fieldCount) { | ||
| this.version = version; | ||
| TracingHeaderVersion(String versionString, int fieldCount) { | ||
| this.versionString = versionString; | ||
| this.fieldCount = fieldCount; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return version; | ||
| return versionString; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the latest version of the tracing header. Any changes done to the | ||
| * schema of tracing context header should be accompanied by a version bump. | ||
| * @return the latest version of the tracing header. | ||
| */ | ||
| public static TracingHeaderVersion getCurrentVersion() { | ||
| return V1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to be updated everytime a new version is introduced, can it be dynamically fetched ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to update it to the latest version every time we do a version upgrade. |
||
| } | ||
|
|
||
| public int getFieldCount() { | ||
| return V1.fieldCount; | ||
| return fieldCount; | ||
| } | ||
|
|
||
| public String getVersion() { | ||
| return V1.version; | ||
| public String getVersionString() { | ||
| return versionString; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.