You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2020/03/09 17:47:50 UTC

[GitHub] [accumulo] ctubbsii commented on a change in pull request #1553: Simplify some VolumeManager tooling

ctubbsii commented on a change in pull request #1553: Simplify some VolumeManager tooling
URL: https://github.com/apache/accumulo/pull/1553#discussion_r389857258
 
 

 ##########
 File path: server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
 ##########
 @@ -381,35 +343,17 @@ public boolean isReady() throws IOException {
 
   @Override
   public FileStatus[] globStatus(Path pathPattern) throws IOException {
-    return getVolumeByPath(pathPattern).getFileSystem().globStatus(pathPattern);
+    return getFileSystemByPath(pathPattern).globStatus(pathPattern);
   }
 
   @Override
   public Path matchingFileSystem(Path source, Set<String> options) {
-    try {
-      if (ViewFSUtils.isViewFS(source, hadoopConf)) {
-        return ViewFSUtils.matchingFileSystem(source, options, hadoopConf);
-      }
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
-
-    URI uri1 = source.toUri();
-    for (String option : options) {
-      URI uri3 = URI.create(option);
-      if (uri1.getScheme().equals(uri3.getScheme())) {
-        String a1 = uri1.getAuthority();
-        String a2 = uri3.getAuthority();
-        if ((a1 == null && a2 == null) || (a1 != null && a1.equals(a2)))
-          return new Path(option);
-      }
-    }
-    return null;
-  }
-
-  @Override
-  public ContentSummary getContentSummary(Path dir) throws IOException {
-    return getVolumeByPath(dir).getFileSystem().getContentSummary(dir);
+    URI sourceUri = source.toUri();
+    return options.stream().filter(opt -> {
+      URI optUri = URI.create(opt);
+      return sourceUri.getScheme().equals(optUri.getScheme())
+          && Objects.equals(sourceUri.getAuthority(), optUri.getAuthority());
+    }).map((String opt) -> new Path(opt)).findFirst().orElse(null);
 
 Review comment:
   I wanted to explicitly use the String version (hence the variable type) to protect against future bugs, because Path has a constructor that takes a URI also, and it behaves differently. Using this instead of the method reference ensures we use the overloaded constructor that takes a String rather than the one that takes a URI.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services