You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2020/03/06 22:22:32 UTC
[accumulo] branch master updated: Use Set instead of array for
ViewFSUtils (#1551)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new 9e802b8 Use Set instead of array for ViewFSUtils (#1551)
9e802b8 is described below
commit 9e802b8d2ad27c2f3db3a14d07321c969598c3b0
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Fri Mar 6 17:07:15 2020 -0500
Use Set instead of array for ViewFSUtils (#1551)
Resolves a comment from code review on #1551
---
.../org/apache/accumulo/server/fs/ViewFSUtils.java | 3 ++-
.../accumulo/server/fs/VolumeManagerImpl.java | 2 +-
.../apache/accumulo/server/fs/ViewFSUtilsTest.java | 30 ++++++++++++++--------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/ViewFSUtils.java b/server/base/src/main/java/org/apache/accumulo/server/fs/ViewFSUtils.java
index 5263c32..af5a466 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/ViewFSUtils.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/ViewFSUtils.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.server.fs;
import java.io.IOException;
+import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -45,7 +46,7 @@ public class ViewFSUtils {
return fs.getClass().getName().equals(VIEWFS_CLASSNAME);
}
- public static Path matchingFileSystem(Path source, String[] options, Configuration conf)
+ public static Path matchingFileSystem(Path source, Set<String> options, Configuration conf)
throws IOException {
if (!isViewFS(source, conf))
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
index 2e3b31e..d181bad 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
@@ -388,7 +388,7 @@ public class VolumeManagerImpl implements VolumeManager {
public Path matchingFileSystem(Path source, Set<String> options) {
try {
if (ViewFSUtils.isViewFS(source, hadoopConf)) {
- return ViewFSUtils.matchingFileSystem(source, options.toArray(new String[0]), hadoopConf);
+ return ViewFSUtils.matchingFileSystem(source, options, hadoopConf);
}
} catch (IOException e) {
throw new RuntimeException(e);
diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/ViewFSUtilsTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/ViewFSUtilsTest.java
index f28d463..0826c5c 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/fs/ViewFSUtilsTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/fs/ViewFSUtilsTest.java
@@ -23,6 +23,10 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -30,10 +34,12 @@ import org.junit.Test;
public class ViewFSUtilsTest {
- private String[] shuffle(String... inputs) {
- // code below will modify array
- Collections.shuffle(Arrays.asList(inputs));
- return inputs;
+ private Set<String> shuffle(String... inputs) {
+ List<String> inputsArray = Arrays.asList(inputs);
+ // shuffle will modify array, because ArrayList implements RandomAccess
+ Collections.shuffle(inputsArray);
+ // preserve the shuffled array as an insertion-ordered set
+ return inputsArray.stream().collect(Collectors.toCollection(LinkedHashSet::new));
}
@Test
@@ -45,11 +51,12 @@ public class ViewFSUtilsTest {
conf.set("fs.viewfs.mounttable.default.link./ns2", "file:///tmp/ns2");
conf.set("fs.viewfs.mounttable.default.link./ns22", "file:///tmp/ns22");
- String[] tablesDirs1 =
+ Set<String> tablesDirs1 =
shuffle("viewfs:///ns1/accumulo/tables", "viewfs:///ns2/accumulo/tables",
"viewfs:///ns22/accumulo/tables", "viewfs:///ns/accumulo/tables");
- String[] tablesDirs2 = shuffle("viewfs:/ns1/accumulo/tables", "viewfs:/ns2/accumulo/tables",
- "viewfs:/ns22/accumulo/tables", "viewfs:/ns/accumulo/tables");
+ Set<String> tablesDirs2 =
+ shuffle("viewfs:/ns1/accumulo/tables", "viewfs:/ns2/accumulo/tables",
+ "viewfs:/ns22/accumulo/tables", "viewfs:/ns/accumulo/tables");
for (String ns : Arrays.asList("ns1", "ns2", "ns22", "ns")) {
Path match = ViewFSUtils.matchingFileSystem(new Path("viewfs:/" + ns + "/bulk_import_01"),
@@ -82,13 +89,14 @@ public class ViewFSUtilsTest {
conf.set("fs.viewfs.mounttable.default.link./ns1/C", "file:///tmp/3");
conf.set("fs.viewfs.mounttable.default.link./ns2", "file:///tmp/3");
- String[] tablesDirs1 =
+ Set<String> tablesDirs1 =
shuffle("viewfs:///ns1/accumulo/tables", "viewfs:///ns1/A/accumulo/tables",
"viewfs:///ns1/AA/accumulo/tables", "viewfs:///ns1/C/accumulo/tables",
"viewfs:///ns2/accumulo/tables", "viewfs:///accumulo/tables");
- String[] tablesDirs2 = shuffle("viewfs:/ns1/accumulo/tables", "viewfs:/ns1/A/accumulo/tables",
- "viewfs:/ns1/AA/accumulo/tables", "viewfs:/ns1/C/accumulo/tables",
- "viewfs:/ns2/accumulo/tables", "viewfs:/accumulo/tables");
+ Set<String> tablesDirs2 =
+ shuffle("viewfs:/ns1/accumulo/tables", "viewfs:/ns1/A/accumulo/tables",
+ "viewfs:/ns1/AA/accumulo/tables", "viewfs:/ns1/C/accumulo/tables",
+ "viewfs:/ns2/accumulo/tables", "viewfs:/accumulo/tables");
for (String ns : Arrays.asList("", "/ns1", "/ns1/A", "/ns1/AA", "/ns1/C", "/ns2")) {
Path match = ViewFSUtils.matchingFileSystem(new Path("viewfs:" + ns + "/bulk_import_01"),