ndimiduk commented on a change in pull request #807: HBASE-23259: Ability to 
start minicluster with pre-determined master ports
URL: https://github.com/apache/hbase/pull/807#discussion_r344965339
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
 ##########
 @@ -183,6 +177,47 @@ public LocalHBaseCluster(final Configuration conf, final 
int noMasters,
     }
   }
 
+  /**
+   * Create new LocalHBaseCluster using pre-defined master rpc ports. Every 
other port is picked
+   * randomly. This also populates the master addresses in the base and region 
server configs.
+   * @param conf Base configuration to use for the cluster.
+   * @param noMasters Number of masters.
+   * @param noRegionServers Number of region servers.
+   * @param masterClass Impl of master class
+   * @param regionServerClass Impl of RS class
+   * @param masterPorts Array of ports, 2 per master (RPC/INFO) to use.
+   */
+  public LocalHBaseCluster(final Configuration conf, final int noMasters,
+      final int noRegionServers, final Class<? extends HMaster> masterClass,
+      final Class<? extends HRegionServer> regionServerClass, final 
List<Integer> masterPorts)
+      throws IOException {
+    this.conf = conf;
+    Preconditions.checkArgument(masterPorts.size() == noMasters);
+    
Preconditions.checkArgument(conf.getBoolean(LocalHBaseCluster.ASSIGN_RANDOM_PORTS,
 false));
+    this.masterClass = (Class<? extends HMaster>)
+        conf.getClass(HConstants.MASTER_IMPL, masterClass);
+    this.regionServerClass =
+        (Class<? extends 
HRegionServer>)conf.getClass(HConstants.REGION_SERVER_IMPL,
+        regionServerClass);
+    // Every port except the master ports are random.
+    conf.set(HConstants.MASTER_INFO_PORT, "0");
 
 Review comment:
   You say the caller should specify pairs of ports for RPC/INFO, yet the INFO 
port is always random. Shouldn't this `conf.set` be inside the for-loop?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to