From 39b36d225c96c1c2a735e7195ab811258b1fe1d8 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 26 Dec 2008 22:42:35 +0000 Subject: [PATCH] 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 --- CHANGES.txt | 1 + .../hbase/regionserver/HRegionServer.java | 7 ++++--- .../org/apache/hadoop/hbase/util/Threads.java | 19 ++++++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 2c971414bdc..96e5d01e641 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -117,6 +117,7 @@ Release 0.19.0 - Unreleased (Tim Sell via Stack) HBASE-543, HBASE-1046, HBase-1051 A region's state is kept in several places in the master opening the possibility for race conditions + HBASE-1072 Change Thread.join on exit to a timed Thread.join IMPROVEMENTS HBASE-901 Add a limit to key length, check key and value length on client side diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index e8ae3d5382e..41a6bc8852a 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -521,7 +521,8 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable { } join(); - runThread(this.hdfsShutdownThread); + runThread(this.hdfsShutdownThread, + this.conf.getLong("hbase.dfs.shutdown.wait", 30000)); 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. * @param t */ - public void runThread(final Thread t) { + public void runThread(final Thread t, final long dfsShutdownWait) { if (t == null) { return; } t.start(); - Threads.shutdown(t); + Threads.shutdown(t, dfsShutdownWait); } /** diff --git a/src/java/org/apache/hadoop/hbase/util/Threads.java b/src/java/org/apache/hadoop/hbase/util/Threads.java index 41c40c3ae25..78415eeb3e5 100644 --- a/src/java/org/apache/hadoop/hbase/util/Threads.java +++ b/src/java/org/apache/hadoop/hbase/util/Threads.java @@ -63,12 +63,25 @@ public class Threads { * @param t Thread to shutdown */ 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()) { try { - t.join(); + if (joinwait == -1) { + t.join(); + } else { + t.join(joinwait); + } } catch (InterruptedException e) { - LOG.warn(t.getName(), e); + LOG.warn(t.getName() + "; joinwait=" + joinwait, e); } } } -} +} \ No newline at end of file