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/master/HMaster.java
Diff Revision 1 Diff Revision 2
[20] 304 lines
[+20] [+] public class HMaster extends HasThread
305
   * @param c
305
   * @param c
306
   * @return True if instant schema enabled.
306
   * @return True if instant schema enabled.
307
   */
307
   */
308
  private boolean getSupportInstantSchemaChanges(final Configuration c) {
308
  private boolean getSupportInstantSchemaChanges(final Configuration c) {
309
    boolean b = c.getBoolean("hbase.instant.schema.alter.enabled", false);
309
    boolean b = c.getBoolean("hbase.instant.schema.alter.enabled", false);
310
    if (b) {
310
    LOG.debug("Instant schema change enabled=" + b + ".");
311
      LOG.debug("Instant schema change enabled. All schema alter operations " +

   
312
        "will happen through ZK.");

   
313
    } else {

   
314
      LOG.debug("Instant schema change disabled. All schema alter operations " +

   
315
        "will happen normally.");

   
316
    }

   
317
    return b;
311
    return b;
318
  }
312
  }
319

    
   
313

   
320
  /**
314
  /**
321
   * Stall startup if we are designated a backup master; i.e. we want someone
315
   * Stall startup if we are designated a backup master; i.e. we want someone
[+20] [20] 1586 lines
[+20] [+] public HTableDescriptor[] getHTableDescriptors(List<String> tableNames) {
1908
   * @return the average load
1902
   * @return the average load
1909
   */
1903
   */
1910
  public double getAverageLoad() {
1904
  public double getAverageLoad() {
1911
    return this.assignmentManager.getAverageLoad();
1905
    return this.assignmentManager.getAverageLoad();
1912
  }
1906
  }

    
   
1907
  

    
   
1908
  /**

    
   
1909
   * Special method, only used by hbck.

    
   
1910
   */

    
   
1911
  @Override

    
   
1912
  public void offline(final byte[] regionName) 

    
   
1913
  throws IOException {

    
   
1914
    Pair<HRegionInfo, ServerName> pair =

    
   
1915
      MetaReader.getRegion(this.catalogTracker, regionName);

    
   
1916
    if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));

    
   
1917
    HRegionInfo hri = pair.getFirst();

    
   
1918
    this.assignmentManager.regionOffline(hri);    

    
   
1919
  }
1913

    
   
1920

   
1914
  /**
1921
  /**
1915
   * Utility for constructing an instance of the passed HMaster class.
1922
   * Utility for constructing an instance of the passed HMaster class.
1916
   * @param masterClass
1923
   * @param masterClass
1917
   * @param conf
1924
   * @param conf
[+20] [20] 39 lines
src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java
Diff Revision 1 Diff Revision 2
 
src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
Diff Revision 1 Diff Revision 2
 
src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
Diff Revision 1 Diff Revision 2
 
  1. src/main/java/org/apache/hadoop/hbase/master/HMaster.java: Loading...
  2. src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java: Loading...
  3. src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java: Loading...
  4. src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java: Loading...