hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1352772 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/io/hfile/ main/java/org/apache/hadoop/hbase/ipc/ main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/reg...
Date Fri, 22 Jun 2012 04:37:46 GMT
Author: mbautin
Date: Fri Jun 22 04:37:40 2012
New Revision: 1352772

URL: http://svn.apache.org/viewvc?rev=1352772&view=rev
Log:
[HBASE-4367] [89-fb] Deadlock in MemStore flusher due to JDK internally synchronizing on current
thread

Author: mbautin

Summary: Back-porting Todd's HasThread approach to fixing MemStoreFlusher deadlock to 89-fb.
Also, replacing "extends Thread" with "extends HasThread" wherever possible, except for a
few trivial cases where there are no synchronized methods.

Test Plan: Unit tests

Reviewers: liyintang, kannan

Reviewed By: liyintang

Differential Revision: https://reviews.facebook.net/D3771

Added:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/HasThread.java
Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Chore.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Leases.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/Threads.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MultithreadedTestUtil.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedAction.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedReader.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedWriter.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/manual/utils/HdfsAppender.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Chore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Chore.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Chore.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Chore.java Fri Jun 22 04:37:40
2012
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.util.HasThread;
 import org.apache.hadoop.hbase.util.Sleeper;
 
 /**
@@ -33,7 +34,7 @@ import org.apache.hadoop.hbase.util.Slee
  * Don't subclass Chore if the task relies on being woken up for something to
  * do, such as an entry being added to a queue, etc.
  */
-public abstract class Chore extends Thread {
+public abstract class Chore extends HasThread {
   private final Log LOG = LogFactory.getLog(this.getClass());
   private final Sleeper sleeper;
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Leases.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Leases.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Leases.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/Leases.java Fri Jun 22 04:37:40
2012
@@ -30,6 +30,7 @@ import java.util.concurrent.DelayQueue;
 import java.util.concurrent.TimeUnit;
 
 import java.io.IOException;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * Leases
@@ -46,11 +47,11 @@ import java.io.IOException;
  * You should close() the instance if you want to clean up the thread properly.
  *
  * <p>
- * NOTE: This class extends Thread rather than Chore because the sleep time
+ * NOTE: This class extends HasThread rather than Chore because the sleep time
  * can be interrupted when there is something to do, rather than the Chore
  * sleep time which is invariant.
  */
-public class Leases extends Thread {
+public class Leases extends HasThread {
   private static final Log LOG = LogFactory.getLog(Leases.class.getName());
   private final int leasePeriod;
   private final int leaseCheckFrequency;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java Fri
Jun 22 04:37:40 2012
@@ -30,6 +30,8 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.HasThread;
+
 import java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;
@@ -290,7 +292,7 @@ public class LocalHBaseCluster {
       }
     }
     if (this.masters != null) {
-      for (Thread t : this.masters) {
+      for (HasThread t : this.masters) {
         if (t.isAlive()) {
           try {
             t.join();

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
Fri Jun 22 04:37:40 2012
@@ -44,12 +44,11 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.io.HeapSize;
 import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
-import org.apache.hadoop.hbase.io.hfile.BlockType.BlockCategory;
-import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.metrics.SchemaMetrics;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.ClassSize;
 import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hbase.util.HasThread;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
@@ -598,7 +597,7 @@ public class LruBlockCache implements Bl
    *
    * Thread is triggered into action by {@link LruBlockCache#runEviction()}
    */
-  private static class EvictionThread extends Thread {
+  private static class EvictionThread extends HasThread {
     private WeakReference<LruBlockCache> cache;
 
     public EvictionThread(LruBlockCache cache) {

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java Fri
Jun 22 04:37:40 2012
@@ -62,6 +62,7 @@ import org.apache.hadoop.ipc.RemoteExcep
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /** A client for an IPC service.  IPC calls take a single {@link Writable} as a
  * parameter, and return a {@link Writable} as their value.  A service runs on
@@ -211,7 +212,7 @@ public class HBaseClient {
   /** Thread that reads responses and notifies callers.  Each connection owns a
    * socket connected to a remote address.  Calls are multiplexed through this
    * socket: responses may be delivered out of order. */
-  private class Connection extends Thread {
+  private class Connection extends HasThread {
     private ConnectionId remoteId;
     private Socket socket = null;                 // connected socket
     private DataInputStream in;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java Fri
Jun 22 04:37:40 2012
@@ -75,6 +75,7 @@ import org.apache.hadoop.io.compress.Dec
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /** An abstract IPC service.  IPC calls take a single {@link Writable} as a
  * parameter, and return a {@link Writable} as their value.  A service runs on
@@ -273,7 +274,7 @@ public abstract class HBaseServer {
   }
 
   /** Listens on the socket. Creates jobs for the handler threads*/
-  private class Listener extends Thread {
+  private class Listener extends HasThread {
 
     private ServerSocketChannel acceptChannel = null; //the accept channel
     private Selector selector = null; //the selector that we use for the server
@@ -564,7 +565,7 @@ public abstract class HBaseServer {
   }
 
   // Sends responses of RPC back to clients.
-  private class Responder extends Thread {
+  private class Responder extends HasThread {
     private Selector writeSelector;
     private int pending;         // connections waiting to register
 
@@ -1034,7 +1035,7 @@ public abstract class HBaseServer {
   }
 
   /** Handles queued calls . */
-  private class Handler extends Thread {
+  private class Handler extends HasThread {
     static final int BUFFER_INITIAL_SIZE = 1024;
     private MonitoredRPCHandler status;
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Fri Jun 22 04:37:40 2012
@@ -19,6 +19,7 @@ import org.apache.hadoop.hbase.HServerIn
 import org.apache.hadoop.hbase.master.AssignmentPlan.POSITION;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.Threads;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * Manages the preferences for assigning regions to specific servers.
@@ -234,7 +235,7 @@ public class AssignmentManager {
     return this.assignmentPlan.getAssignmentUpdateTS(region);
   }
 
-  private class TransientAssignmentHandler extends Thread {
+  private class TransientAssignmentHandler extends HasThread {
     @Override
     public void run() {
       LOG.debug("Started TransientAssignmentHandler");

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri Jun
22 04:37:40 2012
@@ -103,6 +103,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hbase.util.HasThread;
 import org.apache.hadoop.hbase.util.InfoServer;
 import org.apache.hadoop.hbase.util.InjectionEvent;
 import org.apache.hadoop.hbase.util.InjectionHandler;
@@ -134,7 +135,7 @@ import com.google.common.collect.Lists;
  * @see HMasterRegionInterface
  * @see Watcher
  */
-public class HMaster extends Thread implements HMasterInterface,
+public class HMaster extends HasThread implements HMasterInterface,
     HMasterRegionInterface, Watcher, StoppableMaster {
   // MASTER is name of the webapp and the attribute name used stuffing this
   //instance into web context.

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
Fri Jun 22 04:37:40 2012
@@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.util.Thre
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.Watcher.Event.EventType;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * The ServerManager class manages info about region servers - HServerInfo,
@@ -1083,7 +1084,7 @@ public class ServerManager {
   }
 
   // should ServerTimeoutMonitor and ServerMonitor be merged XXX?
-  private class ServerTimeoutMonitor extends Thread {
+  private class ServerTimeoutMonitor extends HasThread {
     private final Log LOG =
         LogFactory.getLog(ServerTimeoutMonitor.class.getName());
     int timeout;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Fri Jun 22 04:37:40 2012
@@ -137,6 +137,7 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.Watcher.Event.EventType;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * HRegionServer makes a set of HRegions available to clients.  It checks in with
@@ -1990,7 +1991,7 @@ public class HRegionServer implements HR
   /*
    * Thread to run close of a region.
    */
-  private static class RegionCloserThread extends Thread {
+  private static class RegionCloserThread extends HasThread {
     private final HRegion r;
 
     protected RegionCloserThread(final HRegion r) {
@@ -2032,7 +2033,7 @@ public class HRegionServer implements HR
       this.lock.writeLock().unlock();
     }
     // Run region closes in parallel.
-    Set<Thread> threads = new HashSet<Thread>();
+    List<HasThread> threads = new ArrayList<HasThread>();
     try {
       for (final HRegion r : regionsToClose) {
         RegionCloserThread t = new RegionCloserThread(r);
@@ -2040,7 +2041,7 @@ public class HRegionServer implements HR
         threads.add(t);
       }
     } finally {
-      for (Thread t : threads) {
+      for (HasThread t : threads) {
         while (t.isAlive()) {
           try {
             t.join();

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
Fri Jun 22 04:37:40 2012
@@ -41,6 +41,7 @@ import org.apache.hadoop.hbase.thrift.ge
 import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
 import org.apache.hadoop.hbase.thrift.generated.TRowResult;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.HasThread;
 import org.apache.thrift.TException;
 
 /**
@@ -53,7 +54,7 @@ import org.apache.thrift.TException;
  * <p>
  * This can be enabled with <i>hbase.regionserver.export.thrift</i> set to true.
  */
-public class HRegionThriftServer extends Thread {
+public class HRegionThriftServer extends HasThread {
 
   public static final Log LOG = LogFactory.getLog(HRegionThriftServer.class);
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java
Fri Jun 22 04:37:40 2012
@@ -31,15 +31,16 @@ import org.apache.hadoop.util.StringUtil
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantLock;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * Runs periodically to determine if the HLog should be rolled.
  *
- * NOTE: This class extends Thread rather than Chore because the sleep time
+ * NOTE: This class extends HasThread rather than Chore because the sleep time
  * can be interrupted when there is something to do, rather than the Chore
  * sleep time which is invariant.
  */
-class LogRoller extends Thread implements LogRollListener {
+class LogRoller extends HasThread implements LogRollListener {
   static final Log LOG = LogFactory.getLog(LogRoller.class);
   private final ReentrantLock rollLock = new ReentrantLock();
   private final AtomicBoolean rollLog = new AtomicBoolean(false);

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
Fri Jun 22 04:37:40 2012
@@ -25,6 +25,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.HasThread;
 import org.apache.hadoop.util.StringUtils;
 
 import java.io.IOException;
@@ -43,13 +44,13 @@ import java.util.concurrent.locks.Reentr
 /**
  * Thread that flushes cache on request
  *
- * NOTE: This class extends Thread rather than Chore because the sleep time
+ * NOTE: This class extends HasThread rather than Chore because the sleep time
  * can be interrupted when there is something to do, rather than the Chore
  * sleep time which is invariant.
  *
  * @see FlushRequester
  */
-class MemStoreFlusher extends Thread implements FlushRequester {
+class MemStoreFlusher extends HasThread implements FlushRequester {
   static final Log LOG = LogFactory.getLog(MemStoreFlusher.class);
   // These two data members go together.  Any entry in the one must have
   // a corresponding entry in the other.

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java
Fri Jun 22 04:37:40 2012
@@ -235,4 +235,4 @@ class ShutdownHook {
     donothing.start();
     ShutdownHook.install(conf, fs, new DoNothingStoppable(), donothing);
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
Fri Jun 22 04:37:40 2012
@@ -83,6 +83,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.ClassSize;
 import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hbase.util.HasThread;
 import org.apache.hadoop.hbase.util.RuntimeExceptionAbortStrategy;
 import org.apache.hadoop.hbase.util.RuntimeHaltAbortStrategy;
 import org.apache.hadoop.hbase.util.Threads;
@@ -422,7 +423,7 @@ public class HLog implements Syncable {
     }
 
     logSyncerThread = new LogSyncer(this.optionalFlushInterval);
-    Threads.setDaemonThreadRunning(logSyncerThread,
+    Threads.setDaemonThreadRunning(logSyncerThread.getThread(),
         Thread.currentThread().getName() + ".logSyncer");
   }
 
@@ -949,7 +950,7 @@ public class HLog implements Syncable {
    * This thread is responsible to call syncFs and buffer up the writers while
    * it happens.
    */
-   class LogSyncer extends Thread {
+   class LogSyncer extends HasThread {
 
     // Using fairness to make sure locks are given in order
     private final ReentrantLock lock = new ReentrantLock(true);
@@ -1088,7 +1089,7 @@ public class HLog implements Syncable {
             // after logRollPending became true. So syncing here is not
             // required.
             //
-            // If log roll is pending then either the old log file has been 
+            // If log roll is pending then either the old log file has been
             // synced but not closed. Or old log file has been successfully
             // closed but a new one has not yet been created. In the latter
             // case this.writer will be NULL
@@ -2163,4 +2164,4 @@ public class HLog implements Syncable {
   public void kill() {
     logSyncerThread.interrupt();
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
Fri Jun 22 04:37:40 2012
@@ -53,6 +53,7 @@ import java.util.concurrent.PriorityBloc
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantLock;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * Class that handles the source of a replication stream.
@@ -66,7 +67,7 @@ import java.util.concurrent.locks.Reentr
  * <p/>
  *
  */
-public class ReplicationSource extends Thread
+public class ReplicationSource extends HasThread
     implements ReplicationSourceInterface {
 
   private static final Log LOG = LogFactory.getLog(ReplicationSource.class);

Added: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/HasThread.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/HasThread.java?rev=1352772&view=auto
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/HasThread.java (added)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/HasThread.java Fri Jun
22 04:37:40 2012
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.util;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+
+/**
+ * Abstract class which contains a Thread and delegates the common Thread
+ * methods to that instance.
+ *
+ * The purpose of this class is to workaround Sun JVM bug #6915621, in which
+ * something internal to the JDK uses Thread.currentThread() as a monitor
+ * lock. This can produce deadlocks like HBASE-4367, HBASE-4101, etc.
+ */
+public abstract class HasThread implements Runnable {
+  private final Thread thread;
+
+  public HasThread() {
+    this.thread = new Thread(this);
+  }
+
+  public HasThread(String name) {
+    this.thread = new Thread(this, name);
+  }
+
+  public Thread getThread() {
+    return thread;
+  }
+
+  public abstract void run();
+
+  //// Begin delegation to Thread
+
+  public final String getName() {
+    return thread.getName();
+  }
+
+  public void interrupt() {
+    thread.interrupt();
+  }
+
+  public final boolean isAlive() {
+    return thread.isAlive();
+  }
+
+  public boolean isInterrupted() {
+    return thread.isInterrupted();
+  }
+
+  public final void setDaemon(boolean on) {
+    thread.setDaemon(on);
+  }
+
+  public final void setName(String name) {
+    thread.setName(name);
+  }
+
+  public final void setPriority(int newPriority) {
+    thread.setPriority(newPriority);
+  }
+
+  public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) {
+    thread.setUncaughtExceptionHandler(eh);
+  }
+
+  public void start() {
+    thread.start();
+  }
+
+  public final void join() throws InterruptedException {
+    thread.join();
+  }
+
+  public final void join(long millis, int nanos) throws InterruptedException {
+    thread.join(millis, nanos);
+  }
+
+  public final void join(long millis) throws InterruptedException {
+    thread.join(millis);
+  }
+
+  public static void sleep(long millis) throws InterruptedException {
+    Thread.sleep(millis);
+  }
+  //// End delegation to Thread
+}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/Threads.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/Threads.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/Threads.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/Threads.java Fri Jun
22 04:37:40 2012
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * Thread Utility
@@ -47,6 +48,12 @@ public class Threads {
     return setDaemonThreadRunning(t, name, null);
   }
 
+  public static HasThread setDaemonThreadRunning(final HasThread t,
+      final String name) {
+    setDaemonThreadRunning(t.getThread(), name, null);
+    return t;
+  }
+
   /**
    * Utility method that sets name, daemon status and starts passed thread.
    * @param t thread to frob
@@ -66,6 +73,12 @@ public class Threads {
     return t;
   }
 
+  public static HasThread setDaemonThreadRunning(final HasThread t,
+      final String name, final UncaughtExceptionHandler handler) {
+    setDaemonThreadRunning(t.getThread(), name, handler);
+    return t;
+  }
+
   /**
    * Shutdown passed thread using isAlive and join.
    * @param t Thread to shutdown
@@ -74,6 +87,10 @@ public class Threads {
     shutdown(t, 0);
   }
 
+  public static void shutdown(final HasThread t) {
+    shutdown(t.getThread(), 0);
+  }
+
   /**
    * Shutdown passed thread using isAlive and join.
    * @param joinwait Pass 0 if we're to wait forever.
@@ -89,7 +106,10 @@ public class Threads {
       }
     }
   }
-
+  
+  public static void shutdown(final HasThread t, final long joinwait) {
+    shutdown(t.getThread(), joinwait);
+  }
 
   /**
    * @param t Waits on the passed thread to die dumping a threaddump every

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java
Fri Jun 22 04:37:40 2012
@@ -206,7 +206,7 @@ public abstract class HBaseClusterTestCa
         threadDumpingJoin(t);
       }
     }
-    threadDumpingJoin(this.cluster.getMaster());
+    threadDumpingJoin(this.cluster.getMaster().getThread());
   }
 
   protected void threadDumpingJoin(final Thread t) {

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java Fri
Jun 22 04:37:40 2012
@@ -41,6 +41,7 @@ import org.apache.hadoop.hdfs.Distribute
 import org.apache.hadoop.io.MapWritable;
 import org.apache.hadoop.security.UnixUserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * This class creates a single process HBase cluster.

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MultithreadedTestUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MultithreadedTestUtil.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MultithreadedTestUtil.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/MultithreadedTestUtil.java
Fri Jun 22 04:37:40 2012
@@ -25,6 +25,7 @@ import java.util.HashSet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.util.HasThread;
 
 public abstract class MultithreadedTestUtil {
 
@@ -102,7 +103,7 @@ public abstract class MultithreadedTestU
    * A thread that can be added to a test context, and properly
    * passes exceptions through.
    */
-  public static abstract class TestThread extends Thread {
+  public static abstract class TestThread extends HasThread {
     protected final TestContext ctx;
     protected boolean stopped;
 

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedAction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedAction.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedAction.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedAction.java
Fri Jun 22 04:37:40 2012
@@ -27,7 +27,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 
-
 public abstract class MultiThreadedAction
 {
   private static final Log LOG = LogFactory.getLog(MultiThreadedAction.class);

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedReader.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedReader.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedReader.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedReader.java
Fri Jun 22 04:37:40 2012
@@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.client.HT
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.HasThread;
 
 public class MultiThreadedReader extends MultiThreadedAction {
   private static final Log LOG = LogFactory.getLog(MultiThreadedReader.class);
@@ -256,4 +257,4 @@ public class MultiThreadedReader extends
       }
     }
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedWriter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedWriter.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedWriter.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/loadtest/MultiThreadedWriter.java
Fri Jun 22 04:37:40 2012
@@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.HasThread;
 
 public class MultiThreadedWriter extends MultiThreadedAction
 {

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/manual/utils/HdfsAppender.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/manual/utils/HdfsAppender.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/manual/utils/HdfsAppender.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/manual/utils/HdfsAppender.java
Fri Jun 22 04:37:40 2012
@@ -31,11 +31,12 @@ import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  *  Runs a continuous loop, appending files to measure perf
  */
-public class HdfsAppender extends Thread
+public class HdfsAppender extends HasThread
 {
   private static final Log LOG = LogFactory.getLog(HdfsAppender.class);
 

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Fri Jun 22 04:37:40 2012
@@ -72,6 +72,7 @@ import org.apache.hadoop.hbase.util.Thre
 
 import com.google.common.collect.Lists;
 
+import org.apache.hadoop.hbase.util.HasThread;
 
 /**
  * Basic stand-alone testing of HRegion.
@@ -184,7 +185,7 @@ public class TestHRegion extends HBaseTe
    * Thread that does get on single row until 'done' flag is flipped.  If an
    * exception causes us to fail, it records it.
    */
-  class GetTillDoneOrException extends Thread {
+  class GetTillDoneOrException extends HasThread {
     private final Get g;
     private final AtomicBoolean done;
     private final AtomicInteger count;
@@ -2407,7 +2408,7 @@ public class TestHRegion extends HBaseTe
     flushThread.checkNoError();
   }
 
-  protected class FlushThread extends Thread {
+  protected class FlushThread extends HasThread {
     private volatile boolean done;
     private Throwable error = null;
 
@@ -2537,7 +2538,7 @@ public class TestHRegion extends HBaseTe
     flushThread.checkNoError();
   }
 
-  protected class PutThread extends Thread {
+  protected class PutThread extends HasThread {
     private volatile boolean done;
     private volatile int numPutsFinished = 0;
 

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java
Fri Jun 22 04:37:40 2012
@@ -19,6 +19,7 @@ import static org.junit.Assert.*;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.apache.hadoop.hbase.util.HasThread;
 
 public class TestHRegionServerFileSystemFailure {
   private static final Log LOG = LogFactory
@@ -43,7 +44,7 @@ public class TestHRegionServerFileSystem
     TEST_UTIL.shutdownMiniCluster();
   }
 
-  private static class TableLoader extends Thread {
+  private static class TableLoader extends HasThread {
     private final HTable table;
 
     public TableLoader(HTable table) {

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
Fri Jun 22 04:37:40 2012
@@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.util.Byte
 import com.google.common.base.Joiner;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /** memstore test case */
 public class TestMemStore extends TestCase {
@@ -376,7 +377,7 @@ public class TestMemStore extends TestCa
   }
 
 
-  private static class ReadOwnWritesTester extends Thread {
+  private static class ReadOwnWritesTester extends HasThread {
     static final int NUM_TRIES = 1000;
 
     final byte[] row;

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java?rev=1352772&r1=1352771&r2=1352772&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java
Fri Jun 22 04:37:40 2012
@@ -58,6 +58,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.apache.hadoop.hbase.util.HasThread;
 
 /** JUnit test case for HLog */
 public class TestHLog  {
@@ -385,7 +386,7 @@ public class TestHLog  {
     final DistributedFileSystem recoveredFs = (DistributedFileSystem)fs;
     final Configuration rlConf = conf;
 
-    class RecoverLogThread extends Thread {
+    class RecoverLogThread extends HasThread {
       public Exception exception = null;
       public void run() {
           try {



Mime
View raw message