hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1328063 - in /hbase/branches/0.94/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:14:44 GMT
Author: ramkrishna
Date: Thu Apr 19 18:14:43 2012
New Revision: 1328063

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

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

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1328063&r1=1328062&r2=1328063&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Thu Apr 19 18:14:43 2012
@@ -193,8 +193,8 @@ public class AssignmentManager extends Z
    * @throws IOException 
    */
   public AssignmentManager(Server master, ServerManager serverManager,
-      CatalogTracker catalogTracker, final ExecutorService service)
-  throws KeeperException, IOException {
+      CatalogTracker catalogTracker, final LoadBalancer balancer,
+      final ExecutorService service) throws KeeperException, IOException {
     super(master.getZooKeeper());
     this.master = master;
     this.serverManager = serverManager;
@@ -212,7 +212,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();
   }
 
@@ -1807,8 +1807,7 @@ public class AssignmentManager extends Z
 
     if (servers.isEmpty()) return null;
 
-    RegionPlan randomPlan = new RegionPlan(state.getRegion(), null,
-      balancer.randomAssignment(servers));
+    RegionPlan randomPlan = null;
     boolean newPlan = false;
     RegionPlan existingPlan = null;
 
@@ -1826,6 +1825,8 @@ public class AssignmentManager extends Z
           || existingPlan.getDestination() == null
           || drainingServers.contains(existingPlan.getDestination())) {
         newPlan = true;
+        randomPlan = new RegionPlan(state.getRegion(), null, balancer
+            .randomAssignment(servers));
         this.regionPlans.put(encodedName, randomPlan);
       }
     }

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1328063&r1=1328062&r2=1328063&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Thu Apr
19 18:14:43 2012
@@ -412,9 +412,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.balancer = LoadBalancerFactory.getLoadBalancer(conf);
+    this.assignmentManager = new AssignmentManager(this, serverManager,
+        this.catalogTracker, this.balancer, this.executorService);
     zooKeeper.registerListenerFirst(assignmentManager);
 
     this.regionServerTracker = new RegionServerTracker(zooKeeper, this,

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java?rev=1328063&r1=1328062&r2=1328063&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
Thu Apr 19 18:14:43 2012
@@ -306,9 +306,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);
+    AssignmentManager am = new AssignmentManager(this.server,
+        this.serverManager, ct, balancer, executor);
     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.
@@ -371,9 +373,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);
+      new AssignmentManager(this.server, this.serverManager, ct, balancer, executor);
     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.
@@ -470,9 +474,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);
+      new AssignmentManager(this.server, this.serverManager, ct, balancer, null);
     try {
       // First make sure my mock up basically works.  Unassign a region.
       unassign(am, SERVERNAME_A, hri);
@@ -584,8 +590,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;
   }
 
@@ -601,10 +609,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);
+      super(master, serverManager, catalogTracker, balancer, service);
       this.es = service;
       this.ct = catalogTracker;
     }



Mime
View raw message