[
https://issues.apache.org/jira/browse/HADOOP-19187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17869596#comment-17869596
]
ASF GitHub Bot commented on HADOOP-19187:
-----------------------------------------
anujmodi2021 commented on code in PR #6879:
URL: https://github.com/apache/hadoop/pull/6879#discussion_r1696682772
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java:
##########
@@ -1810,18 +1804,28 @@ private void initializeClient(URI uri, String
fileSystemName,
LOG.trace("Initializing AbfsClient for {}", baseUrl);
if (tokenProvider != null) {
- this.client = new AbfsClient(baseUrl, creds, abfsConfiguration,
+ this.clientHandler = new AbfsClientHandler(baseUrl, creds,
abfsConfiguration,
tokenProvider, encryptionContextProvider,
populateAbfsClientContext());
} else {
- this.client = new AbfsClient(baseUrl, creds, abfsConfiguration,
+ this.clientHandler = new AbfsClientHandler(baseUrl, creds,
abfsConfiguration,
sasTokenProvider, encryptionContextProvider,
populateAbfsClientContext());
}
+ this.client = getClientHandler().getClient();
LOG.trace("AbfsClient init complete");
}
+ private AbfsServiceType identifyAbfsServiceTypeFromUrl() {
Review Comment:
Sure, sounds better
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java:
##########
@@ -1059,203 +666,44 @@ public boolean appendSuccessCheckOp(AbfsRestOperation
op, final String path,
return false;
}
- public AbfsRestOperation flush(final String path, final long position,
+ public abstract AbfsRestOperation flush(String path, long position,
boolean retainUncommittedData, boolean isClose,
- final String cachedSasToken, final String leaseId,
+ String cachedSasToken, String leaseId,
ContextEncryptionAdapter contextEncryptionAdapter, TracingContext
tracingContext)
- throws AzureBlobFileSystemException {
- final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
- addEncryptionKeyRequestHeaders(path, requestHeaders, false,
- contextEncryptionAdapter, tracingContext);
- // JDK7 does not support PATCH, so to workaround the issue we will use
- // PUT and specify the real method in the X-Http-Method-Override header.
- requestHeaders.add(new AbfsHttpHeader(X_HTTP_METHOD_OVERRIDE,
- HTTP_METHOD_PATCH));
- if (leaseId != null) {
- requestHeaders.add(new AbfsHttpHeader(X_MS_LEASE_ID, leaseId));
- }
-
- final AbfsUriQueryBuilder abfsUriQueryBuilder =
createDefaultUriQueryBuilder();
- abfsUriQueryBuilder.addQuery(QUERY_PARAM_ACTION, FLUSH_ACTION);
- abfsUriQueryBuilder.addQuery(QUERY_PARAM_POSITION,
Long.toString(position));
- abfsUriQueryBuilder.addQuery(QUERY_PARAM_RETAIN_UNCOMMITTED_DATA,
String.valueOf(retainUncommittedData));
- abfsUriQueryBuilder.addQuery(QUERY_PARAM_CLOSE, String.valueOf(isClose));
-
- // AbfsInputStream/AbfsOutputStream reuse SAS tokens for better performance
- String sasTokenForReuse = appendSASTokenToQuery(path,
SASTokenProvider.WRITE_OPERATION,
- abfsUriQueryBuilder, cachedSasToken);
-
- final URL url = createRequestUrl(path, abfsUriQueryBuilder.toString());
- final AbfsRestOperation op = getAbfsRestOperation(
- AbfsRestOperationType.Flush,
- HTTP_METHOD_PUT,
- url,
- requestHeaders, sasTokenForReuse);
- op.execute(tracingContext);
- return op;
- }
-
- public AbfsRestOperation setPathProperties(final String path, final String
properties,
- final TracingContext
tracingContext, final ContextEncryptionAdapter contextEncryptionAdapter)
- throws AzureBlobFileSystemException {
- final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
- addEncryptionKeyRequestHeaders(path, requestHeaders, false,
- contextEncryptionAdapter, tracingContext);
- // JDK7 does not support PATCH, so to workaround the issue we will use
- // PUT and specify the real method in the X-Http-Method-Override header.
- requestHeaders.add(new AbfsHttpHeader(X_HTTP_METHOD_OVERRIDE,
- HTTP_METHOD_PATCH));
-
- requestHeaders.add(new AbfsHttpHeader(X_MS_PROPERTIES, properties));
+ throws AzureBlobFileSystemException;
- final AbfsUriQueryBuilder abfsUriQueryBuilder =
createDefaultUriQueryBuilder();
- abfsUriQueryBuilder.addQuery(QUERY_PARAM_ACTION, SET_PROPERTIES_ACTION);
- appendSASTokenToQuery(path, SASTokenProvider.SET_PROPERTIES_OPERATION,
abfsUriQueryBuilder);
-
- final URL url = createRequestUrl(path, abfsUriQueryBuilder.toString());
- final AbfsRestOperation op = getAbfsRestOperation(
- AbfsRestOperationType.SetPathProperties,
- HTTP_METHOD_PUT,
- url,
- requestHeaders);
- op.execute(tracingContext);
- return op;
- }
-
- public AbfsRestOperation getPathStatus(final String path,
- final boolean includeProperties, final TracingContext tracingContext,
- final ContextEncryptionAdapter contextEncryptionAdapter)
- throws AzureBlobFileSystemException {
- final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
- final AbfsUriQueryBuilder abfsUriQueryBuilder =
createDefaultUriQueryBuilder();
- String operation = SASTokenProvider.GET_PROPERTIES_OPERATION;
- if (!includeProperties) {
- // The default action (operation) is implicitly to get properties and
this action requires read permission
- // because it reads user defined properties. If the action is getStatus
or getAclStatus, then
- // only traversal (execute) permission is required.
- abfsUriQueryBuilder.addQuery(HttpQueryParams.QUERY_PARAM_ACTION,
AbfsHttpConstants.GET_STATUS);
- operation = SASTokenProvider.GET_STATUS_OPERATION;
- } else {
- addEncryptionKeyRequestHeaders(path, requestHeaders, false,
- contextEncryptionAdapter,
- tracingContext);
- }
- abfsUriQueryBuilder.addQuery(HttpQueryParams.QUERY_PARAM_UPN,
String.valueOf(abfsConfiguration.isUpnUsed()));
- appendSASTokenToQuery(path, operation, abfsUriQueryBuilder);
-
- final URL url = createRequestUrl(path, abfsUriQueryBuilder.toString());
- final AbfsRestOperation op = getAbfsRestOperation(
- AbfsRestOperationType.GetPathStatus,
- HTTP_METHOD_HEAD,
- url,
- requestHeaders);
- op.execute(tracingContext);
- return op;
- }
-
- public AbfsRestOperation read(final String path,
- final long position,
- final byte[] buffer,
- final int bufferOffset,
- final int bufferLength,
- final String eTag,
+ public abstract AbfsRestOperation flush(byte[] buffer,
+ String path,
+ boolean isClose,
+ String cachedSasToken,
+ String leaseId,
+ String eTag,
+ TracingContext tracingContext) throws AzureBlobFileSystemException;
+
+ public abstract AbfsRestOperation setPathProperties(String path,
Hashtable<String, String> properties,
+ TracingContext tracingContext, ContextEncryptionAdapter
contextEncryptionAdapter)
+ throws AzureBlobFileSystemException;
+
+ public abstract AbfsRestOperation getPathStatus(String path,
Review Comment:
Added
> ABFS: [FnsOverBlob]Making AbfsClient Abstract for supporting both DFS and
> Blob Endpoint
> ---------------------------------------------------------------------------------------
>
> Key: HADOOP-19187
> URL: https://issues.apache.org/jira/browse/HADOOP-19187
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs/azure
> Affects Versions: 3.4.0
> Reporter: Anuj Modi
> Assignee: Anuj Modi
> Priority: Major
> Labels: pull-request-available
>
> Azure Services support two different set of APIs.
> Blob:
> [https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api]
>
> DFS:
> [https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/operation-groups]
>
> As per the plan in HADOOP-19179, this task enables ABFS Driver to work with
> both set of APIs as per the requirement.
> Scope of this task is to refactor the ABfsClient so that ABFSStore can choose
> to interact with the client it wants based on the endpoint configured by user.
> The blob endpoint support will remain "Unsupported" until the whole code is
> checked-in and well tested.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]