hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181480 - in /hbase/branches/0.89/src: main/java/org/apache/hadoop/hbase/util/FSUtils.java test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
Date Tue, 11 Oct 2011 02:12:11 GMT
Author: nspiegelberg
Date: Tue Oct 11 02:12:10 2011
New Revision: 1181480

URL: http://svn.apache.org/viewvc?rev=1181480&view=rev
Log:
Make sure that HLog's lease is recovered before splitting

Summary:
FSUtils#recoverFileLease make sure that lease recovery completes

Test Plan:
unit test

DiffCamp Revision: 200660
Reviewed By: nspiegelberg
CC: nspiegelberg, hkuang, hbase@lists
Revert Plan:
OK

Modified:
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
    hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1181480&r1=1181479&r2=1181480&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Tue Oct 11
02:12:10 2011
@@ -612,35 +612,14 @@ public class FSUtils {
     }
     DistributedFileSystem dfs = (DistributedFileSystem)fs;
     LOG.info("Recovering file" + p);
-    long startWaiting = System.currentTimeMillis();
 
     // Trying recovery
-    boolean recovered = false;
-    while (!recovered) {
+    while (!dfs.recoverLease(p)) {
       try {
-        dfs.recoverLease(p);
-        recovered = true;
-      } catch (IOException e) {
-        e = RemoteExceptionHandler.checkIOException(e);
-        if (e instanceof AlreadyBeingCreatedException) {
-          // We expect that we'll get this message while the lease is still
-          // within its soft limit, but if we get it past that, it means
-          // that the RS is holding onto the file even though it lost its
-          // znode. We could potentially abort after some time here.
-          long waitedFor = System.currentTimeMillis() - startWaiting;
-          if (waitedFor > FSConstants.LEASE_SOFTLIMIT_PERIOD) {
-            LOG.warn("Waited " + waitedFor + "ms for lease recovery on " + p +
-              ":" + e.getMessage());
-          }
-          try {
-            Thread.sleep(1000);
-          } catch (InterruptedException ex) {
-            throw (InterruptedIOException)
-              new InterruptedIOException().initCause(ex);
-          }
-        } else {
-          throw new IOException("Failed to open " + p + " for append", e);
-        }
+        Thread.sleep(1000);
+      } catch (InterruptedException ex) {
+        throw (InterruptedIOException)
+        new InterruptedIOException().initCause(ex);
       }
     }
     LOG.info("Finished lease recover attempt for " + p);

Modified: hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java?rev=1181480&r1=1181479&r2=1181480&view=diff
==============================================================================
--- hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
(original)
+++ hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
Tue Oct 11 02:12:10 2011
@@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hdfs.DFSClient;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.protocol.FSConstants.SafeModeAction;
 import org.apache.hadoop.hdfs.server.datanode.DataNode;
@@ -380,7 +381,7 @@ public class TestHLog  {
     }
 
     // Now try recovering the log, like the HMaster would do
-    final FileSystem recoveredFs = fs;
+    final DistributedFileSystem recoveredFs = (DistributedFileSystem)fs;
     final Configuration rlConf = conf;
 
     class RecoverLogThread extends Thread {
@@ -388,6 +389,7 @@ public class TestHLog  {
       public void run() {
           try {
             FSUtils.recoverFileLease(recoveredFs, walPath, rlConf);
+            assertTrue(recoveredFs.recoverLease(walPath));
           } catch (IOException e) {
             exception = e;
           }



Mime
View raw message