accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [1/3] git commit: ACCUMULO-2531 Use VolumeConfiguration instead of instance.dfs.dir in ClientOpts
Date Fri, 21 Mar 2014 22:13:40 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT be688faa6 -> 828c3b3ee
  refs/heads/master 5d0d6aa05 -> a03071cd3


ACCUMULO-2531 Use VolumeConfiguration instead of instance.dfs.dir in ClientOpts

VolumeConfiguration encompasses both instance.dfs.dir and instance.volumes.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/828c3b3e
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/828c3b3e
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/828c3b3e

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 828c3b3ee2347fcb1b05fea6f3c722fbaa25c32d
Parents: be688fa
Author: Josh Elser <elserj@apache.org>
Authored: Fri Mar 21 18:09:17 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Mar 21 18:09:17 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/core/cli/ClientOpts.java    |  8 +-
 .../accumulo/core/cli/TestClientOpts.java       | 82 ++++++++++++++++++--
 2 files changed, 81 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/828c3b3e/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
index efb910a..35a9067 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
@@ -41,6 +41,7 @@ import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.volume.VolumeConfiguration;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.trace.instrument.Trace;
 import org.apache.commons.configuration.PropertiesConfiguration;
@@ -257,10 +258,9 @@ public class ClientOpts extends Help {
         }
       };
       this.zookeepers = config.get(Property.INSTANCE_ZK_HOST);
-      //TODO ACCUMULO-2531 Need something that is capable of using instance.volumes or
-      // instance.dfs.{uri,dir} to find the instanceID
-      @SuppressWarnings("deprecation")
-      Path instanceDir = new Path(config.get(Property.INSTANCE_DFS_DIR), "instance_id");
+
+      String volDir = VolumeConfiguration.getVolumeUris(config)[0];
+      Path instanceDir = new Path(volDir, "instance_id");
       String instanceIDFromFile = ZooUtil.getInstanceIDFromHdfs(instanceDir, config);
       if (config.getBoolean(Property.INSTANCE_RPC_SSL_ENABLED))
         clientConfig.setProperty(ClientProperty.INSTANCE_RPC_SSL_ENABLED, "true");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/828c3b3e/core/src/test/java/org/apache/accumulo/core/cli/TestClientOpts.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/cli/TestClientOpts.java b/core/src/test/java/org/apache/accumulo/core/cli/TestClientOpts.java
index c2b40c4..eb7f85b 100644
--- a/core/src/test/java/org/apache/accumulo/core/cli/TestClientOpts.java
+++ b/core/src/test/java/org/apache/accumulo/core/cli/TestClientOpts.java
@@ -21,21 +21,29 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.commons.io.FileUtils;
 import org.junit.Test;
 
 import com.beust.jcommander.JCommander;
+import com.google.common.io.Files;
 
 public class TestClientOpts {
-  
+
   @Test
   public void test() {
     BatchWriterConfig cfg = new BatchWriterConfig();
-    
+
     // document the defaults
     ClientOpts args = new ClientOpts();
     BatchWriterOpts bwOpts = new BatchWriterOpts();
@@ -53,7 +61,7 @@ public class TestClientOpts {
     assertEquals(Authorizations.EMPTY, args.auths);
     assertEquals("localhost:2181", args.zookeepers);
     assertFalse(args.help);
-    
+
     JCommander jc = new JCommander();
     jc.addObject(args);
     jc.addObject(bwOpts);
@@ -73,7 +81,71 @@ public class TestClientOpts {
     assertEquals(new Authorizations("G1", "G2", "G3"), args.auths);
     assertEquals("zoohost1,zoohost2", args.zookeepers);
     assertTrue(args.help);
-    
+
   }
-  
+
+  @Test
+  public void testVolumes() throws IOException {
+    File tmpDir = Files.createTempDir();
+    try {
+      File instanceId = new File(tmpDir, "instance_id");
+      instanceId.mkdir();
+      File uuid = new File(instanceId, UUID.randomUUID().toString());
+      uuid.createNewFile();
+      // document the defaults
+      ClientOpts args = new ClientOpts();
+      File siteXml = File.createTempFile("TestClientOpts", "testVolumes-site.xml");
+      FileWriter fileWriter = new FileWriter(siteXml);
+      fileWriter.append("<configuration>\n");
+
+      fileWriter.append("<property><name>" + Property.INSTANCE_VOLUMES.getKey()
+ "</name><value>" + tmpDir.toURI().toString() + "</value></property>\n");
+      fileWriter.append("<property><name>" + ClientProperty.INSTANCE_NAME + "</name><value>foo</value></property>\n");
+
+      fileWriter.append("</configuration>\n");
+      fileWriter.close();
+
+      JCommander jc = new JCommander();
+      jc.addObject(args);
+
+      jc.parse("--site-file", siteXml.getAbsolutePath());
+
+      args.getInstance();
+    } finally {
+      FileUtils.deleteQuietly(tmpDir);
+    }
+  }
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void testInstanceDir() throws IOException {
+    File tmpDir = Files.createTempDir();
+    try {
+      File instanceId = new File(tmpDir, "instance_id");
+      instanceId.mkdir();
+      File uuid = new File(instanceId, UUID.randomUUID().toString());
+      uuid.createNewFile();
+      // document the defaults
+      ClientOpts args = new ClientOpts();
+      File siteXml = File.createTempFile("TestClientOpts", "testVolumes-site.xml");
+      FileWriter fileWriter = new FileWriter(siteXml);
+      fileWriter.append("<configuration>\n");
+
+      fileWriter.append("<property><name>" + Property.INSTANCE_DFS_DIR.getKey()
+ "</name><value>" + tmpDir.getAbsolutePath() + "</value></property>\n");
+      fileWriter.append("<property><name>" + Property.INSTANCE_DFS_URI.getKey()
+ "</name><value>file://</value></property>\n");
+      fileWriter.append("<property><name>" + ClientProperty.INSTANCE_NAME + "</name><value>foo</value></property>\n");
+
+      fileWriter.append("</configuration>\n");
+      fileWriter.close();
+
+      JCommander jc = new JCommander();
+      jc.addObject(args);
+
+      jc.parse("--site-file", siteXml.getAbsolutePath());
+
+      args.getInstance();
+    } finally {
+      FileUtils.deleteQuietly(tmpDir);
+    }
+  }
+
 }


Mime
View raw message