hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r541463 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt conf/hbase-site.xml src/java/org/apache/hadoop/hbase/HMaster.java src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java
Date Thu, 24 May 2007 22:37:27 GMT
Author: jimk
Date: Thu May 24 15:37:26 2007
New Revision: 541463

URL: http://svn.apache.org/viewvc?view=rev&rev=541463
Log:
HADOOP-1430. HBase shutdown leaves regionservers up.

Added:
    lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-site.xml
Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?view=diff&rev=541463&r1=541462&r2=541463
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Thu May 24 15:37:26 2007
@@ -17,3 +17,4 @@
   8. HADOOP-1424. TestHBaseCluster fails with IllegalMonitorStateException. Fix
      regression introduced by HADOOP-1397.
   9. HADOOP-1426. Make hbase scripts executable + add test classes to CLASSPATH.
+ 10. HADOOP-1430. HBase shutdown leaves regionservers up.

Added: lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-site.xml
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-site.xml?view=auto&rev=541463
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-site.xml (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-site.xml Thu May 24 15:37:26 2007
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<configuration>
+</configuration>

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java?view=diff&rev=541463&r1=541462&r2=541463
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java Thu
May 24 15:37:26 2007
@@ -15,19 +15,33 @@
  */
 package org.apache.hadoop.hbase;
 
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.SortedMap;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.conf.*;
-import org.apache.hadoop.io.*;
-import org.apache.hadoop.fs.*;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.ipc.*;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.hadoop.io.DataInputBuffer;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.util.StringUtils;
 
-import java.io.*;
-import java.util.*;
-
 /**
  * HMaster is the "master server" for a HBase.
  * There is only one HMaster for a single HBase deployment.
@@ -604,7 +618,8 @@
         msgQueue.insertElementAt(op, 0);
       }
     }
-
+    letRegionServersShutdown();
+    
     /*
      * Clean up and close up shop
      */
@@ -653,11 +668,34 @@
     }
   }
   
+  /**
+   * Wait on regionservers to report in.  Then, they notice the HMaster
+   * is going down and will shut themselves down.
+   */
+  private void letRegionServersShutdown() {
+    long regionServerMsgInterval =
+      conf.getLong("hbase.regionserver.msginterval", 15 * 1000);
+    // Wait for 3 * hbase.regionserver.msginterval intervals or until all
+    // regionservers report in as closed.
+    long endTime = System.currentTimeMillis() + (regionServerMsgInterval * 3);
+    while (endTime > System.currentTimeMillis() &&
+        this.serversToServerInfo.size() > 0) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Waiting on regionservers: " + this.serversToServerInfo);
+      }
+      try {
+        Thread.sleep(threadWakeFrequency);
+      } catch (InterruptedException e) {
+        // Ignore interrupt.
+      }
+    }
+  }
+  
   /** 
    * Turn off the HMaster.  Sets a flag so that the main thread know to shut
    * things down in an orderly fashion.
    */
-  public void shutdown() throws IOException {
+  public void shutdown() {
     TimerTask tt = new TimerTask() {
       @Override
       public void run() {
@@ -711,13 +749,10 @@
   public HMsg[] regionServerReport(HServerInfo serverInfo, HMsg msgs[]) throws IOException
{
     String server = serverInfo.getServerAddress().toString().trim();
 
-    if(closed) {
+    if (closed) {
       // We're shutting down. Tell the server to go away.
       serversToServerInfo.remove(server);
-
-      HMsg returnMsgs[] = {
-          new HMsg(HMsg.MSG_REGIONSERVER_STOP)
-      };
+      HMsg returnMsgs[] = {new HMsg(HMsg.MSG_REGIONSERVER_STOP)};
       return returnMsgs;
     }
 

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java?view=diff&rev=541463&r1=541462&r2=541463
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/MiniHBaseCluster.java
Thu May 24 15:37:26 2007
@@ -142,12 +142,7 @@
         e.printStackTrace();
       }
     }
-    try {
-      master.shutdown();
-      
-    } catch(IOException e) {
-      e.printStackTrace();
-    }
+    master.shutdown();
     for(int i = 0; i < regionServers.length; i++) {
       try {
         regionThreads[i].join();



Mime
View raw message