hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject svn commit: r1460794 - in /hbase/branches/0.95: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ hbase-server/src/main/java/org/apache/hadoop/hbase/master/ hbase-server/src/test/j...
Date Mon, 25 Mar 2013 17:57:30 GMT
Author: jxiang
Date: Mon Mar 25 17:57:30 2013
New Revision: 1460794

URL: http://svn.apache.org/r1460794
Log:
HBASE-8173 HMaster#move wraps IOException in UnknownRegionException

Modified:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1460794&r1=1460793&r2=1460794&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Mon Mar 25 17:57:30 2013
@@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.client.Me
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.exceptions.FailedLogCloseException;
+import org.apache.hadoop.hbase.exceptions.HBaseIOException;
 import org.apache.hadoop.hbase.exceptions.HBaseSnapshotException;
 import org.apache.hadoop.hbase.exceptions.MasterNotRunningException;
 import org.apache.hadoop.hbase.exceptions.NotServingRegionException;
@@ -1516,15 +1517,15 @@ public class HBaseAdmin implements Abort
    * @throws MasterNotRunningException
    */
   public void move(final byte [] encodedRegionName, final byte [] destServerName)
-  throws UnknownRegionException, MasterNotRunningException, ZooKeeperConnectionException
{
+  throws HBaseIOException, MasterNotRunningException, ZooKeeperConnectionException {
     MasterAdminKeepAliveConnection master = connection.getKeepAliveMasterAdmin();
     try {
       MoveRegionRequest request = RequestConverter.buildMoveRegionRequest(encodedRegionName,
destServerName);
       master.moveRegion(null,request);
     } catch (ServiceException se) {
       IOException ioe = ProtobufUtil.getRemoteException(se);
-      if (ioe instanceof UnknownRegionException) {
-        throw (UnknownRegionException)ioe;
+      if (ioe instanceof HBaseIOException) {
+        throw (HBaseIOException)ioe;
       }
       LOG.error("Unexpected exception: " + se + " from calling HMaster.moveRegion");
     } catch (DeserializationException de) {

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java?rev=1460794&r1=1460793&r2=1460794&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java
Mon Mar 25 17:57:30 2013
@@ -21,14 +21,13 @@ package org.apache.hadoop.hbase.exceptio
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 
-import java.io.IOException;
 /**
  * Thrown when something happens related to region handling.
  * Subclasses have to be more specific.
  */
 @InterfaceAudience.Public
 @InterfaceStability.Stable
-public class RegionException extends IOException {
+public class RegionException extends HBaseIOException {
   private static final long serialVersionUID = 1473510258071111371L;
 
   /** default constructor */

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=1460794&r1=1460793&r2=1460794&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
Mon Mar 25 17:57:30 2013
@@ -69,6 +69,7 @@ import org.apache.hadoop.hbase.client.Me
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.exceptions.HBaseIOException;
 import org.apache.hadoop.hbase.exceptions.MasterNotRunningException;
 import org.apache.hadoop.hbase.exceptions.NotAllMetaRegionsOnlineException;
 import org.apache.hadoop.hbase.exceptions.PleaseHoldException;
@@ -1465,14 +1466,14 @@ Server {
 
     try {
       move(encodedRegionName, destServerName);
-    } catch (IOException ioe) {
+    } catch (HBaseIOException ioe) {
       throw new ServiceException(ioe);
     }
     return mrr;
   }
 
   void move(final byte[] encodedRegionName,
-      final byte[] destServerName) throws UnknownRegionException {
+      final byte[] destServerName) throws HBaseIOException {
     RegionState regionState = assignmentManager.getRegionStates().
       getRegionState(Bytes.toString(encodedRegionName));
     if (regionState == null) {
@@ -1512,10 +1513,10 @@ Server {
         this.cpHost.postMove(hri, rp.getSource(), rp.getDestination());
       }
     } catch (IOException ioe) {
-      UnknownRegionException ure = new UnknownRegionException(
-        Bytes.toStringBinary(encodedRegionName));
-      ure.initCause(ioe);
-      throw ure;
+      if (ioe instanceof HBaseIOException) {
+        throw (HBaseIOException)ioe;
+      }
+      throw new HBaseIOException(ioe);
     }
   }
 

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java?rev=1460794&r1=1460793&r2=1460794&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
Mon Mar 25 17:57:30 2013
@@ -22,8 +22,10 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.exceptions.PleaseHoldException;
+import org.apache.hadoop.hbase.exceptions.UnknownRegionException;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventHandler.EventHandlerListener;
 import org.apache.hadoop.hbase.executor.EventType;
@@ -50,11 +52,13 @@ public class TestMaster {
   private static final Log LOG = LogFactory.getLog(TestMaster.class);
   private static final byte[] TABLENAME = Bytes.toBytes("TestMaster");
   private static final byte[] FAMILYNAME = Bytes.toBytes("fam");
+  private static HBaseAdmin admin;
 
   @BeforeClass
   public static void beforeAllTests() throws Exception {
     // Start a cluster of two regionservers.
     TEST_UTIL.startMiniCluster(2);
+    admin = TEST_UTIL.getHBaseAdmin();
   }
 
   @AfterClass
@@ -125,12 +129,55 @@ public class TestMaster {
       m.move(meta.getEncodedNameAsBytes(), null);
       fail("Region should not be moved since master is not initialized");
     } catch (IOException ioe) {
-      assertTrue(ioe.getCause() instanceof PleaseHoldException);
+      assertTrue(ioe instanceof PleaseHoldException);
     } finally {
       m.initialized = true;
     }
   }
 
+  @Test
+  public void testMoveThrowsUnknownRegionException() throws IOException {
+    byte[] tableName = Bytes.toBytes("testMoveThrowsUnknownRegionException");
+    HTableDescriptor htd = new HTableDescriptor(tableName);
+    HColumnDescriptor hcd = new HColumnDescriptor("value");
+    htd.addFamily(hcd);
+
+    admin.createTable(htd, null);
+    try {
+      HRegionInfo hri = new HRegionInfo(
+        tableName, Bytes.toBytes("A"), Bytes.toBytes("Z"));
+      admin.move(hri.getEncodedNameAsBytes(), null);
+      fail("Region should not be moved since it is fake");
+    } catch (IOException ioe) {
+      assertTrue(ioe instanceof UnknownRegionException);
+    } finally {
+      TEST_UTIL.deleteTable(tableName);
+    }
+  }
+
+  @Test
+  public void testMoveThrowsPleaseHoldException() throws IOException {
+    byte[] tableName = Bytes.toBytes("testMoveThrowsPleaseHoldException");
+    HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
+    HTableDescriptor htd = new HTableDescriptor(tableName);
+    HColumnDescriptor hcd = new HColumnDescriptor("value");
+    htd.addFamily(hcd);
+
+    admin.createTable(htd, null);
+    try {
+      List<HRegionInfo> tableRegions = admin.getTableRegions(tableName);
+
+      master.initialized = false; // fake it, set back later
+      admin.move(tableRegions.get(0).getEncodedNameAsBytes(), null);
+      fail("Region should not be moved since master is not initialized");
+    } catch (IOException ioe) {
+      assertTrue(ioe instanceof PleaseHoldException);
+    } finally {
+      master.initialized = true;
+      TEST_UTIL.deleteTable(tableName);
+    }
+  }
+
   static class RegionSplitListener implements EventHandlerListener {
     CountDownLatch split, proceed;
 

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java?rev=1460794&r1=1460793&r2=1460794&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
Mon Mar 25 17:57:30 2013
@@ -35,10 +35,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.LargeTests;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.RegionTransition;
@@ -50,6 +48,7 @@ import org.apache.hadoop.hbase.client.HB
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.exceptions.HBaseIOException;
 import org.apache.hadoop.hbase.exceptions.MasterNotRunningException;
 import org.apache.hadoop.hbase.exceptions.UnknownRegionException;
 import org.apache.hadoop.hbase.exceptions.ZooKeeperConnectionException;
@@ -811,7 +810,7 @@ public class TestSplitTransactionOnClust
    */
   private int ensureTableRegionNotOnSameServerAsMeta(final HBaseAdmin admin,
       final HRegionInfo hri)
-  throws UnknownRegionException, MasterNotRunningException,
+  throws HBaseIOException, MasterNotRunningException,
   ZooKeeperConnectionException, InterruptedException {
     // Now make sure that the table region is not on same server as that hosting
     // .META.  We don't want .META. replay polluting our test when we later crash



Mime
View raw message