You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2015/08/11 20:38:58 UTC
hbase git commit: HBASE-14168 Avoid useless retry for
DoNotRetryIOException in TableRecordReaderImpl (zhouyingchao)
Repository: hbase
Updated Branches:
refs/heads/0.98 8ef7678a4 -> 02203303e
HBASE-14168 Avoid useless retry for DoNotRetryIOException in TableRecordReaderImpl (zhouyingchao)
Conflicts:
hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableRecordReaderImpl.java
hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableInputFormat.java
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/02203303
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/02203303
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/02203303
Branch: refs/heads/0.98
Commit: 02203303e84284e9df835c961e84ca0308c1a089
Parents: 8ef7678
Author: tedyu <yu...@gmail.com>
Authored: Fri Jul 31 09:24:39 2015 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Tue Aug 11 10:14:58 2015 -0700
----------------------------------------------------------------------
.../hbase/mapred/TableRecordReaderImpl.java | 7 +++++-
.../hbase/mapreduce/TableRecordReaderImpl.java | 7 +++++-
.../hbase/mapred/TestTableInputFormat.java | 12 +++++-----
.../hbase/mapreduce/TestTableInputFormat.java | 23 +++++++++-----------
4 files changed, 27 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/02203303/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 faac3e2..99063bc 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
@@ -22,6 +22,7 @@ import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
@@ -214,7 +215,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/02203303/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 176fd9b..faabb80 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.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.ScannerCallable;
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.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.util.Bytes;
@@ -214,7 +215,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/02203303/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 a79e499..e9fe776 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
@@ -238,9 +238,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;
}
@@ -289,8 +289,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
*/
@@ -301,12 +300,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 {
HTable htable = createDNRIOEScannerTable("table5".getBytes(), 2);
runTestMapred(htable);
http://git-wip-us.apache.org/repos/asf/hbase/blob/02203303/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 0356100..67277f4 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
@@ -52,7 +52,6 @@ import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.JobConfigurable;
import org.apache.hadoop.mapred.MiniMRCluster;
import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
import org.junit.AfterClass;
import org.junit.Before;
@@ -222,8 +221,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
*/
@@ -242,9 +241,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;
}
@@ -299,9 +298,8 @@ 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
*/
@@ -313,13 +311,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 {
HTable htable = createDNRIOEScannerTable("table5-mr".getBytes(), 2);