Repository: kudu
Updated Branches:
  refs/heads/master 016ae9c23 -> b0209c16d


[java client] Allow to pass extra flags to tservers/masters

This path adds a couple of methods to MiniKuduClusterBuilder so that
a test can pass extra flags to the daemons. Another change is that
the builder is now a protected static final field of BaseKuduTest
so that subclasses can set flags before starting the cluster.

This is required for TestHybridTime to pass for a follow up patch.

Change-Id: If9ecf0d22c0b49e2a07d5e3cf21c762e0790361a
Reviewed-on: http://gerrit.cloudera.org:8080/5299
Tested-by: Kudu Jenkins
Reviewed-by: Mike Percy <mpe...@apache.org>


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

Branch: refs/heads/master
Commit: b0209c16d2f1c328c7412e0d749ee4227cfa730c
Parents: 016ae9c
Author: David Alves <dral...@apache.org>
Authored: Wed Nov 30 18:38:13 2016 -0800
Committer: Mike Percy <mpe...@apache.org>
Committed: Thu Dec 1 16:43:50 2016 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/BaseKuduTest.java    |  7 +++-
 .../org/apache/kudu/client/MiniKuduCluster.java | 37 ++++++++++++++++++--
 2 files changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/b0209c16/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
----------------------------------------------------------------------
diff --git 
a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java 
b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
index fdc74dd..a25e74a 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
@@ -63,6 +63,10 @@ public class BaseKuduTest {
 
   private static MiniKuduCluster miniCluster;
 
+  // Expose the MiniKuduCluster builder so that subclasses can alter the 
builder.
+  protected static final MiniKuduCluster.MiniKuduClusterBuilder 
miniClusterBuilder =
+      new MiniKuduCluster.MiniKuduClusterBuilder();
+
   // Comma separate describing the master addresses and ports.
   protected static String masterAddresses;
   protected static List<HostAndPort> masterHostPorts;
@@ -77,11 +81,12 @@ public class BaseKuduTest {
   public static void setUpBeforeClass() throws Exception {
     LOG.info("Setting up before class...");
 
-    miniCluster = new MiniKuduCluster.MiniKuduClusterBuilder()
+    miniCluster = miniClusterBuilder
         .numMasters(NUM_MASTERS)
         .numTservers(NUM_TABLET_SERVERS)
         .defaultTimeoutMs(DEFAULT_SLEEP)
         .build();
+
     masterAddresses = miniCluster.getMasterAddresses();
     masterHostPorts = miniCluster.getMasterHostPorts();
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/b0209c16/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
----------------------------------------------------------------------
diff --git 
a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java 
b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
index 2ddc5e7..8e79dca 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
@@ -39,6 +39,7 @@ import com.google.common.base.Joiner;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.base.Stopwatch;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.net.HostAndPort;
@@ -75,6 +76,8 @@ public class MiniKuduCluster implements AutoCloseable {
   private final List<String> pathsToDelete = new ArrayList<>();
   private final List<HostAndPort> masterHostPorts = new ArrayList<>();
   private List<Integer> tserverPorts = new ArrayList<>();
+  private ImmutableList<String> extraTserverFlags;
+  private ImmutableList<String> extraMasterFlags;
 
   // Client we can use for common operations.
   private final KuduClient syncClient;
@@ -90,8 +93,12 @@ public class MiniKuduCluster implements AutoCloseable {
   private MiniKuduCluster(int numMasters,
                           int numTservers,
                           final int defaultTimeoutMs,
-                          boolean enableKerberos) throws Exception {
+                          boolean enableKerberos,
+                          final List<String> extraTserverFlags,
+                          final List<String> extraMasterFlags) throws 
Exception {
     this.defaultTimeoutMs = defaultTimeoutMs;
+    this.extraTserverFlags = ImmutableList.copyOf(extraTserverFlags);
+    this.extraMasterFlags = ImmutableList.copyOf(extraMasterFlags);
 
     if (enableKerberos) {
       miniKdc = MiniKdc.withDefaults();
@@ -209,6 +216,8 @@ public class MiniKuduCluster implements AutoCloseable {
         commandLine.add("--server_require_kerberos");
       }
 
+      commandLine.addAll(extraTserverFlags);
+
       tserverProcesses.put(rpcPort, configureAndStartProcess(rpcPort, 
commandLine));
       commandLines.put(rpcPort, commandLine);
 
@@ -273,6 +282,7 @@ public class MiniKuduCluster implements AutoCloseable {
           "--rpc_bind_addresses=" + bindHost + ":" + port,
           "--webserver_port=" + masterWebPorts.get(i),
           "--raft_heartbeat_interval_ms=200"); // make leader elections faster 
for faster tests
+
       if (numMasters > 1) {
         commandLine.add("--master_addresses=" + masterAddresses);
       }
@@ -283,6 +293,8 @@ public class MiniKuduCluster implements AutoCloseable {
         commandLine.add("--server_require_kerberos");
       }
 
+      commandLine.addAll(extraMasterFlags);
+
       masterProcesses.put(port, configureAndStartProcess(port, commandLine));
       commandLines.put(port, commandLine);
 
@@ -563,6 +575,8 @@ public class MiniKuduCluster implements AutoCloseable {
     private int numTservers = 3;
     private int defaultTimeoutMs = 50000;
     private boolean enableKerberos = false;
+    private List<String> extraTserverFlags = new ArrayList<>();
+    private List<String> extraMasterFlags = new ArrayList<>();
 
     public MiniKuduClusterBuilder numMasters(int numMasters) {
       this.numMasters = numMasters;
@@ -594,8 +608,27 @@ public class MiniKuduCluster implements AutoCloseable {
       return this;
     }
 
+    /**
+     * Adds a new flag to be passed to the Tablet Server daemons on start.
+     * @return this instance
+     */
+    public MiniKuduClusterBuilder addTserverFlag(String flag) {
+      this.extraTserverFlags.add(flag);
+      return this;
+    }
+
+    /**
+     * Adds a new flag to be passed to the Master daemons on start.
+     * @return this instance
+     */
+    public MiniKuduClusterBuilder addMasterFlag(String flag) {
+      this.extraMasterFlags.add(flag);
+      return this;
+    }
+
     public MiniKuduCluster build() throws Exception {
-      return new MiniKuduCluster(numMasters, numTservers, defaultTimeoutMs, 
enableKerberos);
+      return new MiniKuduCluster(numMasters, numTservers, defaultTimeoutMs,
+          enableKerberos, extraTserverFlags, extraMasterFlags);
     }
   }
 }

Reply via email to