[
https://issues.apache.org/jira/browse/HADOOP-19802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18060291#comment-18060291
]
ASF GitHub Bot commented on HADOOP-19802:
-----------------------------------------
anmolanmol1234 commented on code in PR #8229:
URL: https://github.com/apache/hadoop/pull/8229#discussion_r2840025184
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java:
##########
@@ -2359,4 +2362,110 @@ private void findParentPathsForMarkerCreation(Path
path, TracingContext tracingC
}
} while (current != null && !current.isRoot());
}
+
+ /**
+ * Lists containers in the storage account using the Blob service endpoint.
+ *
+ * @param prefix optional prefix to filter container names
+ * @param continuation optional continuation token for paginated results
+ * @param tracingContext tracing context for the REST call
+ * @return response containing listed containers and continuation token
+ * @throws IOException if the operation fails or the response cannot be
parsed
+ */
+ public ContainerListResponseData listContainers(
+ final String prefix,
+ final String continuation,
+ final TracingContext tracingContext) throws IOException {
+ final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
+ final AbfsUriQueryBuilder queryBuilder = createDefaultUriQueryBuilder();
+ queryBuilder.addQuery(QUERY_PARAM_COMP, LIST);
+ if (prefix != null && !prefix.isEmpty()) {
+ queryBuilder.addQuery(QUERY_PARAM_PREFIX, prefix);
+ }
+ queryBuilder.addQuery(HttpQueryParams.QUERY_PARAM_MARKER, continuation);
+ appendSASTokenToQuery(EMPTY_STRING,
SASTokenProvider.LIST_CONTAINERS_OPERATION, queryBuilder);
+ URL accountUrl = new URL(getBaseUrl().getProtocol(),
getBaseUrl().getHost(), ROOT_PATH);
+ final URL url = createRequestUrl(accountUrl, EMPTY_STRING,
queryBuilder.toString());
+ final AbfsRestOperation op = getAbfsRestOperation(
+ AbfsRestOperationType.ListContainers,
+ HTTP_METHOD_GET,
+ url,
+ requestHeaders);
+ op.execute(tracingContext);
+ return parseListContainersResponse(op.getResult());
+ }
+
+ /**
+ * Parses the List Containers response returned by the Blob service.
+ *
+ * @param result HTTP operation containing the list containers response
+ * @return parsed container listing with continuation token
+ * @throws AzureBlobFileSystemException if response parsing fails
+ */
+ private ContainerListResponseData parseListContainersResponse(
+ final AbfsHttpOperation result)
+ throws AzureBlobFileSystemException {
+ try (InputStream stream = result.getListResultStream()) {
+ try {
+ final SAXParser saxParser = saxParserThreadLocal.get();
+ saxParser.reset();
+ final ContainerListResponseData responseData =
+ new ContainerListResponseData();
+ saxParser.parse(stream, new ContainerListXmlParser(responseData));
+ LOG.debug("ListContainers listed {} containers with {} as continuation
token",
+ responseData.getContainers().size(),
+ responseData.getContinuationToken());
+ return responseData;
+ } catch (SAXException | IOException ex) {
+ throw new AbfsDriverException(ERR_BLOB_LIST_PARSING, ex);
+ }
+ } catch (AbfsDriverException ex) {
+ // Throw as it is to avoid multiple wrapping.
+ LOG.error("Unable to deserialize list containers response", ex);
+ throw ex;
+ } catch (Exception ex) {
+ LOG.error("Unable to get stream for list containers response", ex);
+ throw new AbfsDriverException(ERR_BLOB_LIST_PARSING, ex);
+ }
+ }
+
+ /**
+ * Deletes a container from the storage account using the Blob service
endpoint.
+ *
+ * @param container name of the container to delete (must be a single path
segment)
+ * @param tracingContext tracing context for the REST call
+ * @return REST operation representing the delete request
+ * @throws AzureBlobFileSystemException if the delete operation fails
+ */
+ public AbfsRestOperation deleteContainer(
+ final String container,
+ final TracingContext tracingContext)
+ throws AzureBlobFileSystemException, MalformedURLException {
+
+ if (container == null || container.isEmpty()) {
Review Comment:
taken
> ABFS: Remove SDK dependency in hadoop-azure
> -------------------------------------------
>
> Key: HADOOP-19802
> URL: https://issues.apache.org/jira/browse/HADOOP-19802
> Project: Hadoop Common
> Issue Type: Sub-task
> Affects Versions: 3.4.2
> Reporter: Anmol Asrani
> Assignee: Anmol Asrani
> Priority: Major
> Labels: pull-request-available
>
> Remove use of SDK from hadoop-azure
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]