ctubbsii commented on a change in pull request #1553: Simplify some
VolumeManager tooling
URL: https://github.com/apache/accumulo/pull/1553#discussion_r389865516
##########
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:
FWIW, if Path had static factory methods rather than public constructors,
this would be easier to enforce using the method reference. (`Path::fromString`
and `Path::fromURI` instead of `Path::new`).
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services