hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1514154 - in /hbase/branches/0.95/hbase-server/src: main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/master/balancer/ test/java/org/apache/hadoop/hbase/master/
Date Thu, 15 Aug 2013 04:35:45 GMT
Author: stack
Date: Thu Aug 15 04:35:45 2013
New Revision: 1514154

URL: http://svn.apache.org/r1514154
Log:
HBASE-9191 Update Loadbalancer method to throw HBaseIOException

Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerChore.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1514154&r1=1514153&r2=1514154&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Thu Aug 15 04:35:45 2013
@@ -45,6 +45,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.HBaseIOException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
@@ -950,8 +951,12 @@ public class AssignmentManager extends Z
             if (regionState != null) {
               // When there are more than one region server a new RS is selected as the
               // destination and the same is updated in the regionplan. (HBASE-5546)
-              getRegionPlan(regionState.getRegion(), sn, true);
-              new ClosedRegionHandler(server, this, regionState.getRegion()).process();
+              try {
+                getRegionPlan(regionState.getRegion(), sn, true);
+                new ClosedRegionHandler(server, this, regionState.getRegion()).process();
+              } catch (HBaseIOException e) {
+                LOG.warn("Failed to get region plan", e);
+              }
             }
           }
           break;
@@ -1824,7 +1829,11 @@ public class AssignmentManager extends Z
     RegionOpeningState regionOpenState;
     for (int i = 1; i <= maximumAttempts && !server.isStopped(); i++) {
       if (plan == null) { // Get a server for the region at first
-        plan = getRegionPlan(region, forceNewPlan);
+        try {
+          plan = getRegionPlan(region, forceNewPlan);
+        } catch (HBaseIOException e) {
+          LOG.warn("Failed to get region plan", e);
+        }
       }
       if (plan == null) {
         LOG.warn("Unable to determine a plan to assign " + region);
@@ -1989,8 +1998,12 @@ public class AssignmentManager extends Z
         // The new plan could be the same as the existing plan since we don't
         // exclude the server of the original plan, which should not be
         // excluded since it could be the only server up now.
-        RegionPlan newPlan = getRegionPlan(region, true);
-
+        RegionPlan newPlan = null;
+        try {
+          newPlan = getRegionPlan(region, true);
+        } catch (HBaseIOException e) {
+          LOG.warn("Failed to get region plan", e);
+        }
         if (newPlan == null) {
           if (tomActivated) {
             this.timeoutMonitor.setAllRegionServersOffline(true);
@@ -2091,7 +2104,7 @@ public class AssignmentManager extends Z
    * if no servers to assign, it returns null).
    */
   private RegionPlan getRegionPlan(final HRegionInfo region,
-      final boolean forceNewPlan) {
+      final boolean forceNewPlan)  throws HBaseIOException  {
     return getRegionPlan(region, null, forceNewPlan);
   }
 
@@ -2105,7 +2118,7 @@ public class AssignmentManager extends Z
    * if no servers to assign, it returns null).
    */
   private RegionPlan getRegionPlan(final HRegionInfo region,
-      final ServerName serverToExclude, final boolean forceNewPlan) {
+      final ServerName serverToExclude, final boolean forceNewPlan) throws HBaseIOException
{
     // Pickup existing plan or make a new one
     final String encodedName = region.getEncodedName();
     final List<ServerName> destServers =

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1514154&r1=1514153&r2=1514154&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Thu Aug 15 04:35:45 2013
@@ -1473,7 +1473,7 @@ MasterServices, Server {
     return balancerCutoffTime;
   }
 
-  public boolean balance() {
+  public boolean balance() throws HBaseIOException {
     // if master not initialized, don't run balancer.
     if (!this.initialized) {
       LOG.debug("Master has not been initialized, don't run balancer.");
@@ -1558,7 +1558,11 @@ MasterServices, Server {
 
   @Override
   public BalanceResponse balance(RpcController c, BalanceRequest request) throws ServiceException
{
-    return BalanceResponse.newBuilder().setBalancerRan(balance()).build();
+    try {
+      return BalanceResponse.newBuilder().setBalancerRan(balance()).build();
+    } catch (HBaseIOException ex) {
+      throw new ServiceException(ex);
+    }
   }
 
   enum BalanceSwitchMode {

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java?rev=1514154&r1=1514153&r2=1514154&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/LoadBalancer.java
Thu Aug 15 04:35:45 2013
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.hbase.ClusterStatus;
+import org.apache.hadoop.hbase.HBaseIOException;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.ServerName;
 
@@ -64,7 +65,8 @@ public interface LoadBalancer extends Co
    * @param clusterState
    * @return List of plans
    */
-  List<RegionPlan> balanceCluster(Map<ServerName, List<HRegionInfo>> clusterState);
+  List<RegionPlan> balanceCluster(Map<ServerName,
+      List<HRegionInfo>> clusterState) throws HBaseIOException;
 
   /**
    * Perform a Round Robin assignment of regions.
@@ -75,7 +77,7 @@ public interface LoadBalancer extends Co
   Map<ServerName, List<HRegionInfo>> roundRobinAssignment(
     List<HRegionInfo> regions,
     List<ServerName> servers
-  );
+  ) throws HBaseIOException;
 
   /**
    * Assign regions to the previously hosting region server
@@ -86,7 +88,7 @@ public interface LoadBalancer extends Co
   Map<ServerName, List<HRegionInfo>> retainAssignment(
     Map<HRegionInfo, ServerName> regions,
     List<ServerName> servers
-  );
+  ) throws HBaseIOException;
 
   /**
    * Sync assign a region
@@ -97,7 +99,7 @@ public interface LoadBalancer extends Co
   Map<HRegionInfo, ServerName> immediateAssignment(
     List<HRegionInfo> regions,
     List<ServerName> servers
-  );
+  ) throws HBaseIOException;
 
   /**
    * Get a random region server from the list
@@ -107,5 +109,5 @@ public interface LoadBalancer extends Co
    */
   ServerName randomAssignment(
     HRegionInfo regionInfo, List<ServerName> servers
-  );
+  ) throws HBaseIOException;
 }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerChore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerChore.java?rev=1514154&r1=1514153&r2=1514154&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerChore.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerChore.java
Thu Aug 15 04:35:45 2013
@@ -18,8 +18,11 @@
 
 package org.apache.hadoop.hbase.master.balancer;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.HBaseIOException;
 import org.apache.hadoop.hbase.master.HMaster;
 
 /**
@@ -28,6 +31,7 @@ import org.apache.hadoop.hbase.master.HM
  */
 @InterfaceAudience.Private
 public class BalancerChore extends Chore {
+  private static final Log LOG = LogFactory.getLog(BalancerChore.class);
 
   private final HMaster master;
 
@@ -40,6 +44,10 @@ public class BalancerChore extends Chore
 
   @Override
   protected void chore() {
-    master.balance();
+    try {
+      master.balance();
+    } catch (HBaseIOException e) {
+      LOG.error("Failed to balance.", e);
+    }
   }
 }

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java?rev=1514154&r1=1514153&r2=1514154&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java
Thu Aug 15 04:35:45 2013
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseIOException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -93,7 +94,7 @@ public class TestRegionPlacement {
   }
 
   @Test
-  public void testFavoredNodesPresentForRoundRobinAssignment() {
+  public void testFavoredNodesPresentForRoundRobinAssignment() throws HBaseIOException {
     LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(TEST_UTIL.getConfiguration());
     balancer.setMasterServices(TEST_UTIL.getMiniHBaseCluster().getMaster());
     List<ServerName> servers = new ArrayList<ServerName>();
@@ -153,7 +154,7 @@ public class TestRegionPlacement {
   }
 
   @Test
-  public void testFavoredNodesPresentForRandomAssignment() {
+  public void testFavoredNodesPresentForRandomAssignment() throws HBaseIOException {
     LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(TEST_UTIL.getConfiguration());
     balancer.setMasterServices(TEST_UTIL.getMiniHBaseCluster().getMaster());
     List<ServerName> servers = new ArrayList<ServerName>();



Mime
View raw message