This is an automated email from the ASF dual-hosted git repository.

ckj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new e5e1b304 [MINOR] refactor: use general method to check the remote 
storage existence (#980)
e5e1b304 is described below

commit e5e1b304db19a8b8f1422291b28eaacba7270f4f
Author: Junfan Zhang <[email protected]>
AuthorDate: Tue Jul 18 19:26:24 2023 +0800

    [MINOR] refactor: use general method to check the remote storage existence 
(#980)
    
    ### What changes were proposed in this pull request?
    
    In #259 , we introduce some general method to check the storage types. So
    this patch is to refactor the remaining part of this.
    
    ### Why are the changes needed?
    
    Refactor to optimize the remote storage checking.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UTs
---
 .../main/java/org/apache/uniffle/client/util/ClientUtils.java    | 9 +--------
 .../main/java/org/apache/uniffle/storage/util/StorageType.java   | 4 ++++
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git 
a/client/src/main/java/org/apache/uniffle/client/util/ClientUtils.java 
b/client/src/main/java/org/apache/uniffle/client/util/ClientUtils.java
index 0dc7747e..78044669 100644
--- a/client/src/main/java/org/apache/uniffle/client/util/ClientUtils.java
+++ b/client/src/main/java/org/apache/uniffle/client/util/ClientUtils.java
@@ -72,7 +72,7 @@ public class ClientUtils {
       String storageType,
       ShuffleWriteClient shuffleWriteClient) {
     RemoteStorageInfo remoteStorage = defaultRemoteStorage;
-    if (requireRemoteStorage(storageType)) {
+    if (storageType != null && 
StorageType.withRemoteStorage(StorageType.valueOf(storageType))) {
       if (remoteStorage.isEmpty() && dynamicConfEnabled) {
         // fallback to dynamic conf on coordinator
         remoteStorage = shuffleWriteClient.fetchRemoteStorage(appId);
@@ -85,13 +85,6 @@ public class ClientUtils {
     return remoteStorage;
   }
 
-  private static boolean requireRemoteStorage(String storageType) {
-    return StorageType.MEMORY_HDFS.name().equals(storageType)
-        || StorageType.MEMORY_LOCALFILE_HDFS.name().equals(storageType)
-        || StorageType.HDFS.name().equals(storageType)
-        || StorageType.LOCALFILE_HDFS.name().equals(storageType);
-  }
-
   @SuppressWarnings("rawtypes")
   public static boolean waitUntilDoneOrFail(
       List<CompletableFuture<Boolean>> futures, boolean allowFastFail) {
diff --git 
a/storage/src/main/java/org/apache/uniffle/storage/util/StorageType.java 
b/storage/src/main/java/org/apache/uniffle/storage/util/StorageType.java
index ee420d27..c7427556 100644
--- a/storage/src/main/java/org/apache/uniffle/storage/util/StorageType.java
+++ b/storage/src/main/java/org/apache/uniffle/storage/util/StorageType.java
@@ -47,4 +47,8 @@ public enum StorageType {
   public static boolean withHadoop(StorageType storageType) {
     return (storageType.getVal() & HDFS.getVal()) != 0;
   }
+
+  public static boolean withRemoteStorage(StorageType storageType) {
+    return withHadoop(storageType);
+  }
 }

Reply via email to