saxenapranav commented on code in PR #6846: URL: https://github.com/apache/hadoop/pull/6846#discussion_r1624280747
########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientHandler.java: ########## @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.fs.azurebfs.services; + +import org.apache.hadoop.fs.azurebfs.constants.AbfsServiceType; +import org.apache.hadoop.util.Preconditions; + +/** + * AbfsClientHandler is a class that provides a way to get the AbfsClient + * based on the service type. + */ +public class AbfsClientHandler { + private final AbfsServiceType defaultServiceType; + private final AbfsClient dfsAbfsClient; + private final AbfsClient blobAbfsClient; + + public AbfsClientHandler(AbfsServiceType defaultServiceType, + AbfsClient dfsAbfsClient, AbfsClient blobAbfsClient) { + this.blobAbfsClient = blobAbfsClient; + this.dfsAbfsClient = dfsAbfsClient; + this.defaultServiceType = defaultServiceType; + } + + public AbfsClient getClient() { + if (defaultServiceType == AbfsServiceType.DFS) { + Preconditions.checkNotNull(dfsAbfsClient, "DFS client is not initialized"); + return dfsAbfsClient; + } else { + Preconditions.checkNotNull(dfsAbfsClient, "Blob client is not initialized"); + return blobAbfsClient; + } + } + + public AbfsClient getClient(AbfsServiceType serviceType) { + if (serviceType == AbfsServiceType.DFS) { + Preconditions.checkNotNull(dfsAbfsClient, "DFS client is not initialized"); + return dfsAbfsClient; + } else { + Preconditions.checkNotNull(dfsAbfsClient, "Blob client is not initialized"); + return blobAbfsClient; + } + } + + public AbfsDfsClient getDfsClient() { + Preconditions.checkNotNull(dfsAbfsClient, "DFS client is not initialized"); + return (AbfsDfsClient) dfsAbfsClient; + } + + public AbfsBlobClient getBlobClient() { + Preconditions.checkNotNull(blobAbfsClient, "Blob client is not initialized"); + return (AbfsBlobClient) blobAbfsClient; Review Comment: we can directly have fields of AbfsBlobClient and AbfsDfsClient, this would remove need of runtime casting. ########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java: ########## @@ -284,9 +293,26 @@ public AzureBlobFileSystemStore( "abfs-bounded"); } + public void validateConfiguredServiceType(TracingContext tracingContext) + throws AzureBlobFileSystemException { + // Todo: [FnsOverBlob] - Remove this check, Failing FS Init with Blob Endpoint Until FNS over Blob is ready. + if (getConfiguredServiceType() == AbfsServiceType.BLOB) { + throw new InvalidConfigurationValueException(FS_DEFAULT_NAME_KEY); Review Comment: we should also inform what is wrong with the config. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org