Review Board 1.7.22


hbase-5328 Small changes to Master to make it more testable

Review Request #4436 - Created March 21, 2012 and updated

Michael Stack
hbase-5328
Reviewers
hbase
hbase-git
M src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
  Make this class public so its waitForRoot(long) can be used by HMaster.
  Remove the stalling waitForRoot no arg.
M src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
  Javadoc.  Add check if stopped flag cycling waiting on assignment.
M src/main/java/org/apache/hadoop/hbase/master/HMaster.java
  Moved check if schema change flag out to a method rather than
  have it on tail of constructor.
  Moved other initialization stuff like get of assignment manager
  and server manager out into methods so could be intercepted by
  tests and mocking.
  Change how we wait on root so we sleep 100ms at a time and always
  check stopped flag rather than block for ever.
  Added more checking if stopped flag.
  Added flag for when rpc server is up, mostly for tests.
M src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
  Unused import.
M src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
  Comment.
M src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
  Remove unused code.
M src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java
  Change how we wait on root.  DOn't use removed method.
A src/test/java/org/apache/hadoop/hbase/master/MockRegionS

 
src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
Revision beaff97 New Change
[20] 182 lines
[+20] [+] public class CatalogTracker {
183
      Abortable abortable, final int defaultTimeout)
183
      Abortable abortable, final int defaultTimeout)
184
  throws IOException {
184
  throws IOException {
185
    this(zk, conf, HConnectionManager.getConnection(conf), abortable, defaultTimeout);
185
    this(zk, conf, HConnectionManager.getConnection(conf), abortable, defaultTimeout);
186
  }
186
  }
187

    
   
187

   
188
  CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
188
  public CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
189
      HConnection connection, Abortable abortable, final int defaultTimeout)
189
      HConnection connection, Abortable abortable, final int defaultTimeout)
190
  throws IOException {
190
  throws IOException {
191
    this.connection = connection;
191
    this.connection = connection;
192
    if (abortable == null) {
192
    if (abortable == null) {
193
      // A connection is abortable.
193
      // A connection is abortable.
[+20] [20] 114 lines
[+20] [+] public ServerName getMetaLocation() {
308
    ServerName sn = getMetaLocation();
308
    ServerName sn = getMetaLocation();
309
    return sn != null? sn: MetaReader.getMetaRegionLocation(this);
309
    return sn != null? sn: MetaReader.getMetaRegionLocation(this);
310
  }
310
  }
311

    
   
311

   
312
  /**
312
  /**
313
   * Waits indefinitely for availability of <code>-ROOT-</code>.  Used during

   
314
   * cluster startup.

   
315
   * @throws InterruptedException if interrupted while waiting

   
316
   */

   
317
  public void waitForRoot()

   
318
  throws InterruptedException {

   
319
    this.rootRegionTracker.blockUntilAvailable();

   
320
  }

   
321

    
   

   
322
  /**

   
323
   * Gets the current location for <code>-ROOT-</code> if available and waits
313
   * Gets the current location for <code>-ROOT-</code> if available and waits
324
   * for up to the specified timeout if not immediately available.  Returns null
314
   * for up to the specified timeout if not immediately available.  Returns null
325
   * if the timeout elapses before root is available.
315
   * if the timeout elapses before root is available.
326
   * @param timeout maximum time to wait for root availability, in milliseconds
316
   * @param timeout maximum time to wait for root availability, in milliseconds
327
   * @return {@link ServerName} for server hosting <code>-ROOT-</code> or null
317
   * @return {@link ServerName} for server hosting <code>-ROOT-</code> or null
328
   * if none available
318
   * if none available
329
   * @throws InterruptedException if interrupted while waiting
319
   * @throws InterruptedException if interrupted while waiting
330
   * @throws NotAllMetaRegionsOnlineException if root not available before
320
   * @throws NotAllMetaRegionsOnlineException if root not available before
331
   * timeout
321
   * timeout
332
   */
322
   */
333
  ServerName waitForRoot(final long timeout)
323
  public ServerName waitForRoot(final long timeout)
334
  throws InterruptedException, NotAllMetaRegionsOnlineException {
324
  throws InterruptedException, NotAllMetaRegionsOnlineException {
335
    ServerName sn = rootRegionTracker.waitRootRegionLocation(timeout);
325
    ServerName sn = rootRegionTracker.waitRootRegionLocation(timeout);
336
    if (sn == null) {
326
    if (sn == null) {
337
      throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
327
      throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
338
    }
328
    }
[+20] [20] 371 lines
src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Revision d47ef10 New Change
 
src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Revision cd1755f New Change
 
src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
Revision a929e31 New Change
 
src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
Revision 7f97b01 New Change
 
src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
Revision 79b6604 New Change
 
src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java
Revision 90fa45a New Change
 
src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
New File
 
src/test/java/org/apache/hadoop/hbase/master/Mocking.java
New File
 
src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
Revision 841649a New Change
 
src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
New File
 
  1. src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java: Loading...
  2. src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java: Loading...
  3. src/main/java/org/apache/hadoop/hbase/master/HMaster.java: Loading...
  4. src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java: Loading...
  5. src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java: Loading...
  6. src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java: Loading...
  7. src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java: Loading...
  8. src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java: Loading...
  9. src/test/java/org/apache/hadoop/hbase/master/Mocking.java: Loading...
  10. src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java: Loading...
  11. src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java: Loading...