You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2015/07/31 18:23:21 UTC

hbase git commit: HBASE-14168 Avoid useless retry for DoNotRetryIOException in TableRecordReaderImpl (zhouyingchao)

Repository: hbase
Updated Branches:
  refs/heads/master f1f0d9966 -> 11d7beed6


HBASE-14168 Avoid useless retry for DoNotRetryIOException in TableRecordReaderImpl (zhouyingchao)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/11d7beed
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/11d7beed
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/11d7beed

Branch: refs/heads/master
Commit: 11d7beed64299579f4cc9d1bfc2a5a2900c66825
Parents: f1f0d99
Author: tedyu <yu...@gmail.com>
Authored: Fri Jul 31 09:23:17 2015 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Fri Jul 31 09:23:17 2015 -0700

----------------------------------------------------------------------
 .../hbase/mapred/TableRecordReaderImpl.java       |  7 ++++++-
 .../hbase/mapreduce/TableRecordReaderImpl.java    |  7 ++++++-
 .../hadoop/hbase/mapred/TestTableInputFormat.java | 12 +++++-------
 .../hbase/mapreduce/TestTableInputFormat.java     | 18 ++++++++----------
 4 files changed, 25 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/11d7beed/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java
index a3daf7a..6356106 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.ScannerCallable;
 import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.mapreduce.TableInputFormat;
@@ -213,7 +214,11 @@ public class TableRecordReaderImpl {
           }
         }
       } catch (IOException e) {
-        // try to handle all IOExceptions by restarting
+        // do not retry if the exception tells us not to do so
+        if (e instanceof DoNotRetryIOException) {
+          throw e;
+        }
+        // try to handle all other IOExceptions by restarting
         // the scanner, if the second call fails, it will be rethrown
         LOG.debug("recovered from " + StringUtils.stringifyException(e));
         if (lastSuccessfulRow == null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/11d7beed/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java
index 5bd8d15..23f59e6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.ScannerCallable;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.client.metrics.ScanMetrics;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.mapreduce.Counter;
@@ -215,7 +216,11 @@ public class TableRecordReaderImpl {
           }
         }
       } catch (IOException e) {
-        // try to handle all IOExceptions by restarting
+        // do not retry if the exception tells us not to do so
+        if (e instanceof DoNotRetryIOException) {
+          throw e;
+        }
+        // try to handle all other IOExceptions by restarting
         // the scanner, if the second call fails, it will be rethrown
         LOG.info("recovered from " + StringUtils.stringifyException(e));
         if (lastSuccessfulRow == null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/11d7beed/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
index 3497cdf..e0b7a0b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapred/TestTableInputFormat.java
@@ -243,9 +243,9 @@ public class TestTableInputFormat {
           doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe
           ResultScanner scanner = mock(ResultScanner.class);
 
-          invocation.callRealMethod(); // simulate UnknownScannerException
+          invocation.callRealMethod(); // simulate NotServingRegionException
           doThrow(
-              new UnknownScannerException("Injected simulated TimeoutException"))
+              new NotServingRegionException("Injected simulated TimeoutException"))
               .when(scanner).next();
           return scanner;
         }
@@ -294,8 +294,7 @@ public class TestTableInputFormat {
   }
 
   /**
-   * Run test assuming UnknownScannerException (which is a type of
-   * DoNotRetryIOException) using mapred api.
+   * Run test assuming NotServingRegionException using mapred api.
    * 
    * @throws org.apache.hadoop.hbase.DoNotRetryIOException
    */
@@ -306,12 +305,11 @@ public class TestTableInputFormat {
   }
 
   /**
-   * Run test assuming UnknownScannerException (which is a type of
-   * DoNotRetryIOException) using mapred api.
+   * Run test assuming NotServingRegionException using mapred api.
    * 
    * @throws org.apache.hadoop.hbase.DoNotRetryIOException
    */
-  @Test(expected = org.apache.hadoop.hbase.DoNotRetryIOException.class)
+  @Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
   public void testTableRecordReaderScannerTimeoutTwice() throws IOException {
     Table htable = createDNRIOEScannerTable("table5".getBytes(), 2);
     runTestMapred(htable);

http://git-wip-us.apache.org/repos/asf/hbase/blob/11d7beed/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
index bc2d08f..eb25972 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
@@ -227,8 +227,8 @@ public class TestTableInputFormat {
   }
 
   /**
-   * Create a table that throws a DoNoRetryIOException on first scanner next
-   * call
+   * Create a table that throws a NotServingRegionException on first scanner 
+   * next call
    *
    * @throws IOException
    */
@@ -247,9 +247,9 @@ public class TestTableInputFormat {
           doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe
           ResultScanner scanner = mock(ResultScanner.class);
 
-          invocation.callRealMethod(); // simulate UnknownScannerException
+          invocation.callRealMethod(); // simulate NotServingRegionException 
           doThrow(
-              new UnknownScannerException("Injected simulated TimeoutException"))
+              new NotServingRegionException("Injected simulated TimeoutException"))
               .when(scanner).next();
           return scanner;
         }
@@ -304,8 +304,7 @@ public class TestTableInputFormat {
   }
 
   /**
-   * Run test assuming UnknownScannerException (which is a type of
-   * DoNotRetryIOException) using newer mapreduce api
+   * Run test assuming NotServingRegionException using newer mapreduce api
    * 
    * @throws InterruptedException
    * @throws org.apache.hadoop.hbase.DoNotRetryIOException
@@ -318,13 +317,12 @@ public class TestTableInputFormat {
   }
 
   /**
-   * Run test assuming UnknownScannerException (which is a type of
-   * DoNotRetryIOException) using newer mapreduce api
+   * Run test assuming NotServingRegionException using newer mapreduce api
    * 
    * @throws InterruptedException
-   * @throws org.apache.hadoop.hbase.DoNotRetryIOException
+   * @throws org.apache.hadoop.hbase.NotServingRegionException
    */
-  @Test(expected = org.apache.hadoop.hbase.DoNotRetryIOException.class)
+  @Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
   public void testTableRecordReaderScannerTimeoutMapreduceTwice()
       throws IOException, InterruptedException {
     Table htable = createDNRIOEScannerTable("table5-mr".getBytes(), 2);