HADOOP-1430. HBase shutdown leaves regionservers up.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@541463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2007-05-24 22:37:26 +00:00
parent 4f855ae28c
commit e4194e10e5
4 changed files with 56 additions and 21 deletions

View File

@ -17,3 +17,4 @@ Trunk (unreleased changes)
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.

4
conf/hbase-site.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
</configuration>

View File

@ -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 @@ public class HMaster implements HConstants, HMasterInterface,
msgQueue.insertElementAt(op, 0);
}
}
letRegionServersShutdown();
/*
* Clean up and close up shop
*/
@ -653,11 +668,34 @@ public class HMaster implements HConstants, HMasterInterface,
}
}
/**
* 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 class HMaster implements HConstants, HMasterInterface,
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;
}

View File

@ -142,12 +142,7 @@ public class MiniHBaseCluster implements HConstants {
e.printStackTrace();
}
}
try {
master.shutdown();
} catch(IOException e) {
e.printStackTrace();
}
master.shutdown();
for(int i = 0; i < regionServers.length; i++) {
try {
regionThreads[i].join();