accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch master updated: Fix PrintInfo command and VolumeChooserIT
Date Sun, 09 Sep 2018 09:53:37 GMT
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 de462d2  Fix PrintInfo command and VolumeChooserIT
de462d2 is described below

commit de462d25d7749ce4dc3f3b8be4565e4890f869b4
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Sun Sep 9 05:17:41 2018 -0400

    Fix PrintInfo command and VolumeChooserIT
    
    * Fix PrintInfo's incorrect use of "-site" instead of "-props" (I think
    this one may have been causing ReadWriteIT to blow up in some cases, but
    I only saw this locally, and never on Jenkins, so I'm not certain)
    
    * Fix ChooseDir implementation to correctly pass the master's
    ServerContext, so that creating new tablets didn't break for volume
    choosers which needed access to the server configuration; this fixed a
    test failure with VolumeChooserIT; also removed constructors exposed
    only for testing, because they were too easily misused for non-tests
---
 .../java/org/apache/accumulo/core/cli/ConfigOpts.java   |  2 +-
 .../org/apache/accumulo/core/file/rfile/PrintInfo.java  |  2 +-
 .../accumulo/server/fs/VolumeChooserEnvironment.java    | 17 ++---------------
 .../org/apache/accumulo/server/init/Initialize.java     |  4 ++--
 .../accumulo/server/fs/PerTableVolumeChooserTest.java   |  4 ++--
 .../accumulo/server/fs/PreferredVolumeChooserTest.java  |  4 ++--
 .../accumulo/server/fs/VolumeManagerImplTest.java       |  5 ++---
 .../org/apache/accumulo/master/tableOps/ChooseDir.java  |  3 ++-
 .../accumulo/master/tableOps/ImportTableTest.java       |  2 +-
 9 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ConfigOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ConfigOpts.java
index 4e09504..07d7c3d 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/ConfigOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/ConfigOpts.java
@@ -39,7 +39,7 @@ public class ConfigOpts extends Help {
       + "The classpath will be searched if this property is not set")
   private String propsPath;
 
-  public String getSitePath() {
+  public String getPropertiesPath() {
     return propsPath;
   }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
index 2beb686..969572c 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
@@ -184,7 +184,7 @@ public class PrintInfo implements KeywordExecutable {
       iter.printInfo(opts.printIndex);
       System.out.println();
       org.apache.accumulo.core.file.rfile.bcfile.PrintInfo
-          .main(new String[] {"-site", opts.getSitePath(), arg});
+          .main(new String[] {"-props", opts.getPropertiesPath(), arg});
 
       Map<String,ArrayList<ByteSequence>> localityGroupCF = null;
 
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java
b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java
index 4bd4733..8998811 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java
@@ -21,8 +21,6 @@ import java.util.Objects;
 import org.apache.accumulo.core.client.impl.Table;
 import org.apache.accumulo.server.ServerContext;
 
-import com.google.common.annotations.VisibleForTesting;
-
 public class VolumeChooserEnvironment {
 
   /**
@@ -38,23 +36,12 @@ public class VolumeChooserEnvironment {
   private final ChooserScope scope;
   private final Table.ID tableId;
 
-  // Also for visible for initialization
-  @VisibleForTesting
-  public VolumeChooserEnvironment(ChooserScope scope) {
-    this(scope, null);
-  }
-
   public VolumeChooserEnvironment(ChooserScope scope, ServerContext context) {
     this.context = context;
     this.scope = Objects.requireNonNull(scope);
     this.tableId = null;
   }
 
-  @VisibleForTesting
-  public VolumeChooserEnvironment(Table.ID tableId) {
-    this(tableId, null);
-  }
-
   public VolumeChooserEnvironment(Table.ID tableId, ServerContext context) {
     this.context = context;
     this.scope = ChooserScope.TABLE;
@@ -71,8 +58,8 @@ public class VolumeChooserEnvironment {
 
   public ServerContext getServerContext() {
     if (context == null) {
-      throw new IllegalStateException(
-          "Requested ServerContext from VolumeChooseEnvironment that" + " was created without
it");
+      throw new IllegalStateException("Requested ServerContext from " + getClass().getSimpleName()
+          + " that was created without it");
     }
     return context;
   }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
index 365e1bb..dd95fe8 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java
@@ -350,7 +350,7 @@ public class Initialize implements KeywordExecutable {
     UUID uuid = UUID.randomUUID();
     // the actual disk locations of the root table and tablets
     String[] configuredVolumes = VolumeConfiguration.getVolumeUris(siteConfig);
-    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(ChooserScope.INIT);
+    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(ChooserScope.INIT,
null);
     final String rootTabletDir = new Path(
         fs.choose(chooserEnv, configuredVolumes) + Path.SEPARATOR + ServerConstants.TABLE_DIR
             + Path.SEPARATOR + RootTable.ID + RootTable.ROOT_TABLET_LOCATION).toString();
@@ -484,7 +484,7 @@ public class Initialize implements KeywordExecutable {
     // initialize initial system tables config in zookeeper
     initSystemTablesConfig(zoo, Constants.ZROOT + "/" + uuid);
 
-    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(ChooserScope.INIT);
+    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(ChooserScope.INIT,
null);
     String tableMetadataTabletDir = fs.choose(chooserEnv, ServerConstants.getBaseUris(siteConfig))
         + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + MetadataTable.ID + TABLE_TABLETS_TABLET_DIR;
     String replicationTableDefaultTabletDir = fs.choose(chooserEnv,
diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java
b/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java
index bd518c3..e9a5bb4 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/fs/PerTableVolumeChooserTest.java
@@ -78,12 +78,12 @@ public class PerTableVolumeChooserTest {
   }
 
   private VolumeChooser getTableDelegate() {
-    VolumeChooserEnvironment env = new VolumeChooserEnvironment(Table.ID.of("testTable"));
+    VolumeChooserEnvironment env = new VolumeChooserEnvironment(Table.ID.of("testTable"),
null);
     return chooser.getDelegateChooser(env);
   }
 
   private VolumeChooser getDelegate(ChooserScope scope) {
-    VolumeChooserEnvironment env = new VolumeChooserEnvironment(scope);
+    VolumeChooserEnvironment env = new VolumeChooserEnvironment(scope, null);
     return chooser.getDelegateChooser(env);
   }
 
diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java
b/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java
index 053ec10..0e6ee71 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/fs/PreferredVolumeChooserTest.java
@@ -74,12 +74,12 @@ public class PreferredVolumeChooserTest {
   }
 
   private String[] chooseForTable() {
-    VolumeChooserEnvironment env = new VolumeChooserEnvironment(Table.ID.of("testTable"));
+    VolumeChooserEnvironment env = new VolumeChooserEnvironment(Table.ID.of("testTable"),
null);
     return chooser.getPreferredVolumes(env, ALL_OPTIONS);
   }
 
   private String[] choose(ChooserScope scope) {
-    VolumeChooserEnvironment env = new VolumeChooserEnvironment(scope);
+    VolumeChooserEnvironment env = new VolumeChooserEnvironment(scope, null);
     return chooser.getPreferredVolumes(env, ALL_OPTIONS);
   }
 
diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java
b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java
index 556d583..6fe3e38 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java
@@ -85,7 +85,6 @@ public class VolumeManagerImplTest {
   public void tabletDirWithTableId() throws Exception {
     String basePath = fs.getDefaultVolume().getBasePath();
     String scheme = fs.getDefaultVolume().getFileSystem().getUri().toURL().getProtocol();
-    System.out.println(basePath);
     Path expectedBase = new Path(scheme + ":" + basePath, FileType.TABLE.getDirectory());
     List<String> pathsToTest = Arrays.asList("1/default_tablet", "1/default_tablet/",
         "1/t-0000001");
@@ -99,7 +98,6 @@ public class VolumeManagerImplTest {
   public void tabletFileWithTableId() throws Exception {
     String basePath = fs.getDefaultVolume().getBasePath();
     String scheme = fs.getDefaultVolume().getFileSystem().getUri().toURL().getProtocol();
-    System.out.println(basePath);
     Path expectedBase = new Path(scheme + ":" + basePath, FileType.TABLE.getDirectory());
     List<String> pathsToTest = Arrays.asList("1/default_tablet/C0000001.rf",
         "1/t-0000001/C0000001.rf");
@@ -137,7 +135,8 @@ public class VolumeManagerImplTest {
     conf.set(Property.GENERAL_VOLUME_CHOOSER, WrongVolumeChooser.class.getName());
     thrown.expect(RuntimeException.class);
     VolumeManager vm = VolumeManagerImpl.get(conf);
-    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(Table.ID.of("sometable"));
+    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(Table.ID.of("sometable"),
+        null);
     String choice = vm.choose(chooserEnv, volumes.toArray(new String[0]));
     assertTrue("shouldn't see invalid options from misbehaving chooser.", volumes.contains(choice));
   }
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java
index 81593f9..dae0bc3 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java
@@ -51,7 +51,8 @@ class ChooseDir extends MasterRepo {
     // Constants.DEFAULT_TABLET_LOCATION has a leading slash prepended to it so we don't
need to add
     // one here
 
-    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(tableInfo.tableId);
+    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(tableInfo.tableId,
+        master.getContext());
 
     String baseDir = master.getFileSystem().choose(chooserEnv,
         ServerConstants.getBaseUris(master.getConfiguration())) + Constants.HDFS_TABLES_DIR
diff --git a/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java
b/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java
index 5f9f619..52568b2 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java
@@ -43,7 +43,7 @@ public class ImportTableTest {
     EasyMock.expect(master.getContext()).andReturn(null);
     EasyMock.expect(master.getFileSystem()).andReturn(volumeManager);
     // Choose the 2nd element
-    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(iti.tableId);
+    VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(iti.tableId, null);
     EasyMock.expect(volumeManager.choose(EasyMock.eq(chooserEnv), EasyMock.eq(tableDirs)))
         .andReturn(tableDirs[1]);
 


Mime
View raw message