morningman commented on code in PR #48369:
URL: https://github.com/apache/doris/pull/48369#discussion_r1982590612


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HdfsStorageVault.java:
##########
@@ -85,17 +90,66 @@ public HdfsStorageVault(String name, boolean ifNotExists, 
boolean setAsDefault)
     }
 
     @Override
-    public void modifyProperties(Map<String, String> properties) throws 
DdlException {
-        for (Map.Entry<String, String> kv : properties.entrySet()) {
+    public void modifyProperties(Map<String, String> newProperties) throws 
DdlException {
+        for (Map.Entry<String, String> kv : newProperties.entrySet()) {
             replaceIfEffectiveValue(this.properties, kv.getKey(), 
kv.getValue());
         }
+        checkConnectivity(this.properties);
     }
 
     @Override
     public Map<String, String> getCopiedProperties() {
         return Maps.newHashMap(properties);
     }
 
+    public static void checkConnectivity(Map<String, String> newProperties) 
throws DdlException {
+        if (newProperties.containsKey(S3Properties.VALIDITY_CHECK)
+                && 
newProperties.get(S3Properties.VALIDITY_CHECK).equalsIgnoreCase("false")) {
+            return;
+        }
+
+        String hadoopFsName = null;
+        String pathPrefix = null;
+        for (Map.Entry<String, String> property : newProperties.entrySet()) {
+            if (property.getKey().equalsIgnoreCase(HADOOP_FS_NAME)) {
+                hadoopFsName = property.getValue();
+            } else if (property.getKey().equalsIgnoreCase(VAULT_PATH_PREFIX)) {
+                pathPrefix = property.getValue();
+            }
+        }
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(hadoopFsName), "%s 
is null or empty", HADOOP_FS_NAME);
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(pathPrefix), "%s is 
null or empty", VAULT_PATH_PREFIX);
+
+        try (DFSFileSystem dfsFileSystem = new DFSFileSystem(newProperties)) {
+            String remotePath = hadoopFsName + "/" + pathPrefix + 
"/checkConnectivity";
+            Status st = dfsFileSystem.makeDir(remotePath);
+            if (st != Status.OK) {
+                throw new DdlException(
+                        "checkConnectivity(makeDir) failed, status: " + st + 
", properties: " + new PrintableMap<>(
+                                newProperties, "=", true, false, true, false));
+            }
+
+            st = dfsFileSystem.exists(remotePath);
+            if (st != Status.OK) {
+                throw new DdlException(
+                        "checkConnectivity(exist) failed, status: " + st + ", 
properties: " + new PrintableMap<>(
+                                newProperties, "=", true, false, true, false));
+            }
+
+            st = dfsFileSystem.delete(remotePath);
+            if (st != Status.OK) {
+                throw new DdlException(
+                        "checkConnectivity(exist) failed, status: " + st + ", 
properties: " + new PrintableMap<>(
+                                newProperties, "=", true, false, true, false));
+            }
+        } catch (IOException e) {
+            LOG.warn("checkConnectivity failed, properties:{}", new 
PrintableMap<>(

Review Comment:
   I think we'd better print vault name in log



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HdfsStorageVault.java:
##########
@@ -85,17 +90,66 @@ public HdfsStorageVault(String name, boolean ifNotExists, 
boolean setAsDefault)
     }
 
     @Override
-    public void modifyProperties(Map<String, String> properties) throws 
DdlException {
-        for (Map.Entry<String, String> kv : properties.entrySet()) {
+    public void modifyProperties(Map<String, String> newProperties) throws 
DdlException {
+        for (Map.Entry<String, String> kv : newProperties.entrySet()) {
             replaceIfEffectiveValue(this.properties, kv.getKey(), 
kv.getValue());
         }
+        checkConnectivity(this.properties);
     }
 
     @Override
     public Map<String, String> getCopiedProperties() {
         return Maps.newHashMap(properties);
     }
 
+    public static void checkConnectivity(Map<String, String> newProperties) 
throws DdlException {
+        if (newProperties.containsKey(S3Properties.VALIDITY_CHECK)
+                && 
newProperties.get(S3Properties.VALIDITY_CHECK).equalsIgnoreCase("false")) {
+            return;
+        }
+
+        String hadoopFsName = null;
+        String pathPrefix = null;
+        for (Map.Entry<String, String> property : newProperties.entrySet()) {
+            if (property.getKey().equalsIgnoreCase(HADOOP_FS_NAME)) {
+                hadoopFsName = property.getValue();
+            } else if (property.getKey().equalsIgnoreCase(VAULT_PATH_PREFIX)) {
+                pathPrefix = property.getValue();
+            }
+        }
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(hadoopFsName), "%s 
is null or empty", HADOOP_FS_NAME);
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(pathPrefix), "%s is 
null or empty", VAULT_PATH_PREFIX);
+
+        try (DFSFileSystem dfsFileSystem = new DFSFileSystem(newProperties)) {
+            String remotePath = hadoopFsName + "/" + pathPrefix + 
"/checkConnectivity";
+            Status st = dfsFileSystem.makeDir(remotePath);

Review Comment:
   What is `checkConnectivity` already exists?



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/HdfsStorageVault.java:
##########
@@ -85,17 +90,66 @@ public HdfsStorageVault(String name, boolean ifNotExists, 
boolean setAsDefault)
     }
 
     @Override
-    public void modifyProperties(Map<String, String> properties) throws 
DdlException {
-        for (Map.Entry<String, String> kv : properties.entrySet()) {
+    public void modifyProperties(Map<String, String> newProperties) throws 
DdlException {
+        for (Map.Entry<String, String> kv : newProperties.entrySet()) {
             replaceIfEffectiveValue(this.properties, kv.getKey(), 
kv.getValue());
         }
+        checkConnectivity(this.properties);

Review Comment:
   I suggest to create a new interface to call this `checkConnectivity`, not 
put it in `modifyProperties`.
   Because other developer may call this method in replay logic, for example, 
and it is very error prone



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to