You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2021/09/15 11:04:14 UTC

[accumulo] branch main updated: Reduce usage of VolumeManagerImpl.get

This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new ba83d8f  Reduce usage of VolumeManagerImpl.get
ba83d8f is described below

commit ba83d8fa26a8adc92ca0249780b1ddf9d7135d7a
Author: Dave Marion <dl...@apache.org>
AuthorDate: Wed Sep 15 07:04:06 2021 -0400

    Reduce usage of VolumeManagerImpl.get
    
    use ServerContext.getVolumeManager instead
    
    Closes #666
---
 .../miniclusterImpl/MiniAccumuloClusterImpl.java   |  3 +--
 .../apache/accumulo/server/util/ChangeSecret.java  | 27 +++++++++++-----------
 .../accumulo/server/client/BulkImporterTest.java   |  2 +-
 .../manager/upgrade/RootFilesUpgradeTest.java      |  3 +--
 .../apache/accumulo/tserver/logger/LogReader.java  |  4 +---
 5 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
index a5a85e7..62824a4 100644
--- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
@@ -81,7 +81,6 @@ import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.server.ServerContext;
 import org.apache.accumulo.server.ServerDirs;
 import org.apache.accumulo.server.fs.VolumeManager;
-import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.accumulo.server.init.Initialize;
 import org.apache.accumulo.server.util.AccumuloStatus;
 import org.apache.accumulo.server.util.PortUtils;
@@ -474,7 +473,7 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
 
       ConfigurationCopy cc = new ConfigurationCopy(acuConf);
       Path instanceIdPath;
-      try (var fs = VolumeManagerImpl.get(cc, hadoopConf)) {
+      try (var fs = getServerContext().getVolumeManager()) {
         instanceIdPath = serverDirs.getInstanceIdLocation(fs.getFirst());
       } catch (IOException e) {
         throw new RuntimeException(e);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java b/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
index 21495e5..e837f6f 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
@@ -36,7 +36,6 @@ import org.apache.accumulo.server.ServerContext;
 import org.apache.accumulo.server.ServerDirs;
 import org.apache.accumulo.server.cli.ServerUtilOpts;
 import org.apache.accumulo.server.fs.VolumeManager;
-import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
@@ -64,19 +63,19 @@ public class ChangeSecret {
   public static void main(String[] args) throws Exception {
     var siteConfig = SiteConfiguration.auto();
     var hadoopConf = new Configuration();
-    try (var fs = VolumeManagerImpl.get(siteConfig, hadoopConf)) {
-      ServerDirs serverDirs = new ServerDirs(siteConfig, hadoopConf);
-      verifyHdfsWritePermission(serverDirs, fs);
-
-      Opts opts = new Opts();
-      List<String> argsList = new ArrayList<>(args.length + 2);
-      argsList.add("--old");
-      argsList.add("--new");
-      argsList.addAll(Arrays.asList(args));
-      try (TraceScope clientSpan =
-          opts.parseArgsAndTrace(ChangeSecret.class.getName(), argsList.toArray(new String[0]))) {
-
-        ServerContext context = opts.getServerContext();
+    Opts opts = new Opts();
+    List<String> argsList = new ArrayList<>(args.length + 2);
+    argsList.add("--old");
+    argsList.add("--new");
+    argsList.addAll(Arrays.asList(args));
+    try (TraceScope clientSpan =
+        opts.parseArgsAndTrace(ChangeSecret.class.getName(), argsList.toArray(new String[0]))) {
+
+      ServerContext context = opts.getServerContext();
+      try (var fs = context.getVolumeManager()) {
+        ServerDirs serverDirs = new ServerDirs(siteConfig, hadoopConf);
+        verifyHdfsWritePermission(serverDirs, fs);
+
         verifyAccumuloIsDown(context, opts.oldPass);
 
         final String newInstanceId = UUID.randomUUID().toString();
diff --git a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
index f653b43..6d29ede 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java
@@ -141,7 +141,7 @@ public class BulkImporterTest {
     writer.append(new Key("iterator", "cf", "cq5"), empty);
     writer.append(new Key("xyzzy", "cf", "cq"), empty);
     writer.close();
-    try (var vm = VolumeManagerImpl.get(context.getConfiguration(), new Configuration())) {
+    try (var vm = VolumeManagerImpl.getLocalForTesting("file:///")) {
       List<TabletLocation> overlaps =
           BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file));
       assertEquals(5, overlaps.size());
diff --git a/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/RootFilesUpgradeTest.java b/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/RootFilesUpgradeTest.java
index 8686685..a5b260d 100644
--- a/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/RootFilesUpgradeTest.java
+++ b/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/RootFilesUpgradeTest.java
@@ -34,7 +34,6 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.spi.fs.RandomVolumeChooser;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.fs.VolumeManagerImpl;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.junit.Rule;
 import org.junit.Test;
@@ -162,7 +161,7 @@ public class RootFilesUpgradeTest {
     conf.set(Property.INSTANCE_VOLUMES, "file:///");
     conf.set(Property.GENERAL_VOLUME_CHOOSER, RandomVolumeChooser.class.getName());
 
-    try (var vm = VolumeManagerImpl.get(conf, new Configuration())) {
+    try (var vm = VolumeManagerImpl.getLocalForTesting("file:///")) {
 
       TestWrapper wrapper = new TestWrapper(vm, conf, "A00004.rf", "A00002.rf", "F00003.rf");
       wrapper.prepareReplacement();
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java
index a984418..2dd939b 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java
@@ -38,12 +38,10 @@ import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.server.ServerContext;
 import org.apache.accumulo.server.fs.VolumeManager;
-import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.accumulo.start.spi.KeywordExecutable;
 import org.apache.accumulo.tserver.log.DfsLogger;
 import org.apache.accumulo.tserver.log.DfsLogger.LogHeaderIncompleteException;
 import org.apache.accumulo.tserver.log.RecoveryLogsIterator;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
@@ -107,7 +105,7 @@ public class LogReader implements KeywordExecutable {
 
     var siteConfig = SiteConfiguration.auto();
     ServerContext context = new ServerContext(siteConfig);
-    try (VolumeManager fs = VolumeManagerImpl.get(siteConfig, new Configuration())) {
+    try (VolumeManager fs = context.getVolumeManager()) {
 
       Matcher rowMatcher = null;
       KeyExtent ke = null;