hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1328057 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/master/AssignmentManager.java main/java/org/apache/hadoop/hbase/master/HMaster.java test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
Date Thu, 19 Apr 2012 18:05:31 GMT
Author: ramkrishna
Date: Thu Apr 19 18:05:31 2012
New Revision: 1328057

URL: http://svn.apache.org/viewvc?rev=1328057&view=rev
Log:
HBASE-5737 Minor Improvements related to balancer. (Ram)

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1328057&r1=1328056&r2=1328057&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Thu Apr
19 18:05:31 2012
@@ -199,7 +199,8 @@ public class AssignmentManager extends Z
    * @throws IOException 
    */
   public AssignmentManager(Server master, ServerManager serverManager,
-      CatalogTracker catalogTracker, final ExecutorService service, MasterMetrics metrics)
+      CatalogTracker catalogTracker, final LoadBalancer balancer,
+      final ExecutorService service, MasterMetrics metrics)
   throws KeeperException, IOException {
     super(master.getZooKeeper());
     this.master = master;
@@ -218,7 +219,7 @@ public class AssignmentManager extends Z
     this.zkTable = new ZKTable(this.master.getZooKeeper());
     this.maximumAssignmentAttempts =
       this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
-    this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
+    this.balancer = balancer;
     this.threadPoolExecutorService = Executors.newCachedThreadPool();
     this.masterMetrics = metrics;// can be null only with tests.
   }
@@ -1820,8 +1821,7 @@ public class AssignmentManager extends Z
 
     if (servers.isEmpty()) return null;
 
-    RegionPlan randomPlan = new RegionPlan(state.getRegion(), null,
-      balancer.randomAssignment(state.getRegion(), servers));
+    RegionPlan randomPlan = null;
     boolean newPlan = false;
     RegionPlan existingPlan = null;
 
@@ -1839,6 +1839,8 @@ public class AssignmentManager extends Z
           || existingPlan.getDestination() == null
           || drainingServers.contains(existingPlan.getDestination())) {
         newPlan = true;
+        randomPlan = new RegionPlan(state.getRegion(), null,
+            balancer.randomAssignment(state.getRegion(), servers));
         this.regionPlans.put(encodedName, randomPlan);
       }
     }
@@ -2989,6 +2991,7 @@ public class AssignmentManager extends Z
   public boolean isCarryingMeta(ServerName serverName) {
     return isCarryingRegion(serverName, HRegionInfo.FIRST_META_REGIONINFO);
   }
+  
   /**
    * Check if the shutdown server carries the specific region.
    * We have a bunch of places that store region location

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1328057&r1=1328056&r2=1328057&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Thu Apr 19 18:05:31
2012
@@ -426,9 +426,9 @@ Server {
         this, conf.getInt("hbase.master.catalog.timeout", Integer.MAX_VALUE));
     this.catalogTracker.start();
 
-    this.assignmentManager = new AssignmentManager(this, serverManager,
-        this.catalogTracker, this.executorService, this.metrics);
     this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
+    this.assignmentManager = new AssignmentManager(this, serverManager,
+        this.catalogTracker, this.balancer, this.executorService, this.metrics);
     zooKeeper.registerListenerFirst(assignmentManager);
 
     this.regionServerTracker = new RegionServerTracker(zooKeeper, this,
@@ -585,12 +585,12 @@ Server {
     org.apache.hadoop.hbase.catalog.MetaMigrationRemovingHTD.
       updateMetaWithNewHRI(this);
 
+    this.balancer.setMasterServices(this);
     // Fixup assignment manager status
     status.setStatus("Starting assignment manager");
     this.assignmentManager.joinCluster(onlineServers);
 
     this.balancer.setClusterStatus(getClusterStatus());
-    this.balancer.setMasterServices(this);
 
     // Fixing up missing daughters if any
     status.setStatus("Fixing up missing daughters");

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java?rev=1328057&r1=1328056&r2=1328057&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java Thu
Apr 19 18:05:31 2012
@@ -316,9 +316,11 @@ public class TestAssignmentManager {
 
     // We need a mocked catalog tracker.
     CatalogTracker ct = Mockito.mock(CatalogTracker.class);
+    LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
+        .getConfiguration());
     // Create an AM.
-    AssignmentManager am =
-      new AssignmentManager(this.server, this.serverManager, ct, executor, null);
+    AssignmentManager am = new AssignmentManager(this.server,
+        this.serverManager, ct, balancer, executor, null);
     try {
       // Make sure our new AM gets callbacks; once registered, can't unregister.
       // Thats ok because we make a new zk watcher for each test.
@@ -382,9 +384,11 @@ public class TestAssignmentManager {
 
     // We need a mocked catalog tracker.
     CatalogTracker ct = Mockito.mock(CatalogTracker.class);
+    LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
+        .getConfiguration());
     // Create an AM.
-    AssignmentManager am =
-      new AssignmentManager(this.server, this.serverManager, ct, executor, null);
+    AssignmentManager am = new AssignmentManager(this.server,
+        this.serverManager, ct, balancer, executor, null);
     try {
       // Make sure our new AM gets callbacks; once registered, can't unregister.
       // Thats ok because we make a new zk watcher for each test.
@@ -457,9 +461,11 @@ public class TestAssignmentManager {
     Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_A, hri, -1)).thenReturn(true);
     // Need a mocked catalog tracker.
     CatalogTracker ct = Mockito.mock(CatalogTracker.class);
+    LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
+        .getConfiguration());
     // Create an AM.
-    AssignmentManager am =
-      new AssignmentManager(this.server, this.serverManager, ct, null, null);
+    AssignmentManager am = new AssignmentManager(this.server,
+        this.serverManager, ct, balancer, null, null);
     try {
       // First make sure my mock up basically works.  Unassign a region.
       unassign(am, SERVERNAME_A, hri);
@@ -607,8 +613,10 @@ public class TestAssignmentManager {
     Mockito.when(ct.getConnection()).thenReturn(connection);
     // Create and startup an executor. Used by AM handling zk callbacks.
     ExecutorService executor = startupMasterExecutor("mockedAMExecutor");
-    AssignmentManagerWithExtrasForTesting am =
-      new AssignmentManagerWithExtrasForTesting(server, manager, ct, executor);
+    LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
+        .getConfiguration());
+    AssignmentManagerWithExtrasForTesting am = new AssignmentManagerWithExtrasForTesting(
+        server, manager, ct, balancer, executor);
     return am;
   }
 
@@ -624,10 +632,10 @@ public class TestAssignmentManager {
     AtomicBoolean gate = new AtomicBoolean(true);
 
     public AssignmentManagerWithExtrasForTesting(final Server master,
-        final ServerManager serverManager,
-        final CatalogTracker catalogTracker, final ExecutorService service)
+        final ServerManager serverManager, final CatalogTracker catalogTracker,
+        final LoadBalancer balancer, final ExecutorService service)
     throws KeeperException, IOException {
-      super(master, serverManager, catalogTracker, service, null);
+      super(master, serverManager, catalogTracker, balancer, service, null);
       this.es = service;
       this.ct = catalogTracker;
     }



Mime
View raw message