hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject svn commit: r1478880 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/wal/HLogFactory.java test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java
Date Fri, 03 May 2013 17:19:28 GMT
Author: jxiang
Date: Fri May  3 17:19:27 2013
New Revision: 1478880

URL: http://svn.apache.org/r1478880
Log:
HBASE-8485 Retry to open a HLog on more exceptions

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogFactory.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogFactory.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogFactory.java?rev=1478880&r1=1478879&r2=1478880&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogFactory.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogFactory.java
Fri May  3 17:19:27 2013
@@ -34,7 +34,6 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.regionserver.wal.HLog.Reader;
 import org.apache.hadoop.hbase.regionserver.wal.HLog.Writer;
-import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.CancelableProgressable;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 
@@ -129,7 +128,9 @@ public class HLogFactory {
             }
           } catch (IOException e) {
             String msg = e.getMessage();
-            if (msg != null && msg.contains("Cannot obtain block length")) {
+            if (msg != null && (msg.contains("Cannot obtain block length")
+                || msg.contains("Could not obtain the last block")
+                || msg.matches("Blocklist for [^ ]* has changed.*"))) {
               if (++nbAttempt == 1) {
                 LOG.warn("Lease should have recovered. This is not expected. Will retry",
e);
               }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java?rev=1478880&r1=1478879&r2=1478880&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLogSplit.java
Fri May  3 17:19:27 2013
@@ -889,7 +889,8 @@ public class TestHLogSplit {
     fs.initialize(fs.getUri(), conf);
 
     FileSystem spiedFs = Mockito.spy(fs);
-    // The "Cannot obtain block length" part is very important,
+    // The "Cannot obtain block length", "Could not obtain the last block",
+    // and "Blocklist for [^ ]* has changed.*" part is very important,
     // that's how it comes out of HDFS. If HDFS changes the exception
     // message, this test needs to be adjusted accordingly.
     //
@@ -898,11 +899,14 @@ public class TestHLogSplit {
     // last block is under recovery, HDFS may have problem to obtain
     // the block length, in which case, retry may help.
     Mockito.doAnswer(new Answer<FSDataInputStream>() {
+      private final String[] errors = new String[] {
+        "Cannot obtain block length", "Could not obtain the last block",
+        "Blocklist for " + OLDLOGDIR + " has changed"};
       private int count = 0;
 
       public FSDataInputStream answer(InvocationOnMock invocation) throws Throwable {
-            if (count++ < 3) {
-                throw new IOException("Cannot obtain block length");
+            if (count < 3) {
+                throw new IOException(errors[count++]);
             }
             return (FSDataInputStream)invocation.callRealMethod();
         }



Mime
View raw message