hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r648110 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/Leases.java src/java/org/apache/hadoop/hbase/master/ServerManager.java src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Date Tue, 15 Apr 2008 03:36:40 GMT
Author: stack
Date: Mon Apr 14 20:36:39 2008
New Revision: 648110

URL: http://svn.apache.org/viewvc?rev=648110&view=rev
Log:
HBASE-12 when hbase regionserver restarts, it says "impossible state for createLease()"

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Leases.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=648110&r1=648109&r2=648110&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Mon Apr 14 20:36:39 2008
@@ -4,6 +4,8 @@
    HBASE-573   HBase does not read hadoop-*.xml for dfs configuration after 
                moving out hadoop/contrib
    HBASE-11    Unexpected exits corrupt DFS
+   HBASE-12    When hbase regionserver restarts, it says "impossible state for
+               createLease()"
 
 Release 0.1.1 - 04/11/2008
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Leases.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Leases.java?rev=648110&r1=648109&r2=648110&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Leases.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/Leases.java Mon Apr 14 20:36:39 2008
@@ -29,6 +29,8 @@
 import java.util.concurrent.DelayQueue;
 import java.util.concurrent.TimeUnit;
 
+import java.io.IOException;
+
 /**
  * Leases
  *
@@ -125,8 +127,10 @@
    * 
    * @param leaseName name of the lease
    * @param listener listener that will process lease expirations
+   * @throws LeaseStillHeldException 
    */
-  public void createLease(String leaseName, final LeaseListener listener) {
+  public void createLease(String leaseName, final LeaseListener listener)
+  throws LeaseStillHeldException {
     if (stopRequested) {
       return;
     }
@@ -134,13 +138,28 @@
         System.currentTimeMillis() + leasePeriod);
     synchronized (leaseQueue) {
       if (leases.containsKey(leaseName)) {
-        throw new IllegalStateException("lease '" + leaseName +
-            "' already exists");
+        throw new LeaseStillHeldException(leaseName);
       }
       leases.put(leaseName, lease);
       leaseQueue.add(lease);
     }
   }
+
+  /**
+   * Thrown if we are asked create a lease but lease on passed name already
+   * exists.
+   */
+  public static class LeaseStillHeldException extends IOException {
+    private final String leaseName;
+    
+    public LeaseStillHeldException(final String name) {
+      this.leaseName = name;
+    }
+    
+    public String getName() {
+      return this.leaseName;
+    }
+  }
   
   /**
    * Renew a lease
@@ -229,4 +248,4 @@
       this.expirationTime = expirationTime;
     }
   }
-}
\ No newline at end of file
+}

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=648110&r1=648109&r2=648110&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java Mon Apr
14 20:36:39 2008
@@ -90,7 +90,12 @@
     // server expecially if it just shutdown and came back up near-immediately
     // after.
     if (!master.closed.get()) {
-      serverLeases.createLease(s, new ServerExpirer(s));
+      try {
+        serverLeases.createLease(s, new ServerExpirer(s));
+      } catch (Leases.LeaseStillHeldException e) {
+        LOG.debug("Lease still held on " + e.getName());
+        return;
+      }
     }
     HServerLoad load = serversToLoad.remove(s);
     if (load != null) {

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=648110&r1=648109&r2=648110&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Mon
Apr 14 20:36:39 2008
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.util.Arrays;
@@ -46,6 +47,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.dfs.AlreadyBeingCreatedException;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -685,11 +687,17 @@
           LOG.debug("Done telling master we are up");
         }
         break;
-      } catch(IOException e) {
+      } catch (Leases.LeaseStillHeldException e) {
+        LOG.info("Lease " + e.getName() + " already held on master. Check " +
+          "DNS configuration so that all region servers are" +
+          "reporting their true IPs and not 127.0.0.1. Otherwise, this" +
+          "problem should resolve itself after the lease period of " +
+          this.conf.get("hbase.master.lease.period")
+          + " seconds expires over on the master");
+      } catch (IOException e) {
         LOG.warn("error telling master we are up", e);
-        sleeper.sleep(lastMsg);
-        continue;
       }
+      sleeper.sleep(lastMsg);
     }
     return result;
   }



Mime
View raw message