hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-14168 Avoid useless retry for DoNotRetryIOException in TableRecordReaderImpl (zhouyingchao)
Date Fri, 31 Jul 2015 16:25:52 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 4f4bb55a4 -> 569639a1a


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/569639a1
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/569639a1
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/569639a1

Branch: refs/heads/branch-1.2
Commit: 569639a1a85c79dd23026601d6cb38bbf0937aa1
Parents: 4f4bb55
Author: tedyu <yuzhihong@gmail.com>
Authored: Fri Jul 31 09:25:46 2015 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Fri Jul 31 09:25:46 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/569639a1/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/569639a1/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/569639a1/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 edc8cbe..ff19879 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
@@ -242,9 +242,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;
         }
@@ -293,8 +293,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
    */
@@ -305,12 +304,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/569639a1/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 566a642..c53510f 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);


Mime
View raw message