accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject git commit: ACCUMULO-2246 made MiniAccumloConfig getters return what was set
Date Wed, 26 Feb 2014 17:48:46 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT b45313beb -> b5b38d889


ACCUMULO-2246 made MiniAccumloConfig getters return what was set


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: b5b38d889b8d873041595eec6969000f3711aa96
Parents: b45313b
Author: Keith Turner <kturner@apache.org>
Authored: Wed Feb 26 12:44:15 2014 -0500
Committer: Keith Turner <kturner@apache.org>
Committed: Wed Feb 26 12:44:15 2014 -0500

----------------------------------------------------------------------
 .../accumulo/minicluster/MiniAccumuloConfig.java   |  4 ++--
 .../minicluster/impl/MiniAccumuloConfigImpl.java   | 17 +++++++++++++++--
 .../minicluster/MiniAccumuloClusterTest.java       | 14 ++++++++++++++
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/b5b38d88/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
index d5c9da0..092af2a 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
@@ -133,7 +133,7 @@ public class MiniAccumuloConfig {
    * @return a copy of the site config
    */
   public Map<String,String> getSiteConfig() {
-    return impl.getSiteConfig();
+    return impl.getConfiguredSiteConfig();
   }
 
   /**
@@ -151,7 +151,7 @@ public class MiniAccumuloConfig {
    * @since 1.6.0
    */
   public int getZooKeeperPort() {
-    return impl.getZooKeeperPort();
+    return impl.getConfiguredZookeeperPort();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/b5b38d88/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
index 2c1b326..b25aa1f 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
@@ -37,6 +37,7 @@ public class MiniAccumuloConfigImpl {
   private File dir = null;
   private String rootPassword = null;
   private Map<String,String> siteConfig = new HashMap<String,String>();
+  private Map<String,String> configuredSiteConig = new HashMap<String,String>();
   private int numTservers = 2;
   private Map<ServerType,Long> memoryConfig = new HashMap<ServerType,Long>();
   private boolean jdwpEnabled = false;
@@ -52,7 +53,9 @@ public class MiniAccumuloConfigImpl {
   private File logDir;
   private File walogDir;
 
-  private Integer zooKeeperPort;
+  private int zooKeeperPort = 0;
+  private int configuredZookeeperPort = 0;
+
   private long defaultMemorySize = 128 * 1024 * 1024;
 
   private boolean initialized = false;
@@ -122,7 +125,7 @@ public class MiniAccumuloConfigImpl {
       mergePropWithRandomPort(Property.GC_PORT.getKey());
 
       // zookeeper port should be set explicitly in this class, not just on the site config
-      if (zooKeeperPort == null)
+      if (zooKeeperPort == 0)
         zooKeeperPort = PortUtils.getRandomFreePort();
       siteConfig.put(Property.INSTANCE_ZK_HOST.getKey(), "localhost:" + zooKeeperPort);
       initialized = true;
@@ -179,6 +182,7 @@ public class MiniAccumuloConfigImpl {
    */
   public MiniAccumuloConfigImpl setSiteConfig(Map<String,String> siteConfig) {
     this.siteConfig = new HashMap<String,String>(siteConfig);
+    this.configuredSiteConig = new HashMap<String,String>(siteConfig);
     return this;
   }
 
@@ -191,6 +195,7 @@ public class MiniAccumuloConfigImpl {
    * @since 1.6.0
    */
   public MiniAccumuloConfigImpl setZooKeeperPort(int zooKeeperPort) {
+    this.configuredZookeeperPort = zooKeeperPort;
     this.zooKeeperPort = zooKeeperPort;
     return this;
   }
@@ -237,6 +242,10 @@ public class MiniAccumuloConfigImpl {
     return new HashMap<String,String>(siteConfig);
   }
 
+  public Map<String,String> getConfiguredSiteConfig() {
+    return new HashMap<String,String>(configuredSiteConig);
+  }
+
   /**
    * @return name of configured instance
    * 
@@ -255,6 +264,10 @@ public class MiniAccumuloConfigImpl {
     return zooKeeperPort;
   }
 
+  public int getConfiguredZookeeperPort() {
+    return configuredZookeeperPort;
+  }
+
   File getLibDir() {
     return libDir;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/b5b38d88/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
index 4d774e4..5251e2d 100644
--- a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
+++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
 
 import java.io.File;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.UUID;
@@ -68,6 +69,10 @@ public class MiniAccumuloClusterTest {
     testDir.mkdir();
 
     MiniAccumuloConfig config = new MiniAccumuloConfig(testDir, "superSecret").setJDWPEnabled(true);
+    config.setZooKeeperPort(0);
+    HashMap<String,String> site = new HashMap<String,String>();
+    site.put(Property.TSERV_WORKQ_THREADS.getKey(), "2");
+    config.setSiteConfig(site);
     accumulo = new MiniAccumuloCluster(config);
     accumulo.start();
   }
@@ -208,6 +213,15 @@ public class MiniAccumuloClusterTest {
     }
   }
 
+  @Test
+  public void testConfig() {
+    // ensure what user passed in is what comes back
+    Assert.assertEquals(0, accumulo.getConfig().getZooKeeperPort());
+    HashMap<String,String> site = new HashMap<String,String>();
+    site.put(Property.TSERV_WORKQ_THREADS.getKey(), "2");
+    Assert.assertEquals(site, accumulo.getConfig().getSiteConfig());
+  }
+
   @AfterClass
   public static void tearDownMiniCluster() throws Exception {
     accumulo.stop();


Mime
View raw message