HBASE-1072 Change Thread.join on exit to a timed Thread.join

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@729549 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-12-26 22:42:35 +00:00
parent cda80c2f7b
commit 39b36d225c
3 changed files with 21 additions and 6 deletions

View File

@ -117,6 +117,7 @@ Release 0.19.0 - Unreleased
(Tim Sell via Stack) (Tim Sell via Stack)
HBASE-543, HBASE-1046, HBase-1051 A region's state is kept in several places HBASE-543, HBASE-1046, HBase-1051 A region's state is kept in several places
in the master opening the possibility for race conditions in the master opening the possibility for race conditions
HBASE-1072 Change Thread.join on exit to a timed Thread.join
IMPROVEMENTS IMPROVEMENTS
HBASE-901 Add a limit to key length, check key and value length on client side HBASE-901 Add a limit to key length, check key and value length on client side

View File

@ -521,7 +521,8 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
} }
join(); join();
runThread(this.hdfsShutdownThread); runThread(this.hdfsShutdownThread,
this.conf.getLong("hbase.dfs.shutdown.wait", 30000));
LOG.info(Thread.currentThread().getName() + " exiting"); LOG.info(Thread.currentThread().getName() + " exiting");
} }
@ -529,12 +530,12 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
* Run and wait on passed thread in HRS context. * Run and wait on passed thread in HRS context.
* @param t * @param t
*/ */
public void runThread(final Thread t) { public void runThread(final Thread t, final long dfsShutdownWait) {
if (t == null) { if (t == null) {
return; return;
} }
t.start(); t.start();
Threads.shutdown(t); Threads.shutdown(t, dfsShutdownWait);
} }
/** /**

View File

@ -63,12 +63,25 @@ public class Threads {
* @param t Thread to shutdown * @param t Thread to shutdown
*/ */
public static void shutdown(final Thread t) { public static void shutdown(final Thread t) {
shutdown(t, -1);
}
/**
* Shutdown passed thread using isAlive and join.
* @param joinwait Pass -1 if we're to wait forever.
* @param t Thread to shutdown
*/
public static void shutdown(final Thread t, final long joinwait) {
while (t.isAlive()) { while (t.isAlive()) {
try { try {
t.join(); if (joinwait == -1) {
t.join();
} else {
t.join(joinwait);
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
LOG.warn(t.getName(), e); LOG.warn(t.getName() + "; joinwait=" + joinwait, e);
} }
} }
} }
} }