You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/08/22 02:09:29 UTC

[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #168: [Improvement] Should match from pathToStorages when appId does not exist in appIdToStorages

jerqi commented on code in PR #168:
URL: https://github.com/apache/incubator-uniffle/pull/168#discussion_r950950588


##########
server/src/main/java/org/apache/uniffle/server/storage/HdfsStorageManager.java:
##########
@@ -108,13 +114,25 @@ public void registerRemoteStorage(String appId, RemoteStorageInfo remoteStorageI
     appIdToStorages.putIfAbsent(appId, pathToStorages.get(remoteStorage));
   }
 
-  private HdfsStorage getStorageByAppId(String appId) {
+  public HdfsStorage getStorageByAppId(String appId) {
     if (!appIdToStorages.containsKey(appId)) {
-      String msg = "Can't find HDFS storage for appId[" + appId + "]";
-      LOG.error(msg);
-      // outside should deal with null situation
-      // todo: it's better to have a fake storage for null situation
-      return null;
+      synchronized (this) {
+        FileSystem fs;
+        try {
+          List<Path> appStoragePath = pathToStorages.keySet().stream().map(
+              basePath -> new Path(basePath + Constants.KEY_SPLIT_CHAR + appId)).collect(Collectors.toList());
+          for (Path path : appStoragePath) {
+            fs = HadoopFilesystemProvider.getFilesystem(path, hadoopConf);
+            if (fs.isDirectory(path)) {
+              return new HdfsStorage(path.getParent().toString(), hadoopConf);
+            }
+          }
+        } catch (Exception e) {
+          LOG.error("Some error happened when fileSystem got the file status.");
+          e.printStackTrace();

Review Comment:
   Why do we use `printStackTrace`,  it print the error stack in the stdout, could we print the error stack in the log?



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org