hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenh...@apache.org
Subject hbase git commit: HBASE-15720 Print row locks at the debug dump page
Date Thu, 28 Apr 2016 03:45:34 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 3d4f02670 -> e8b37422c


HBASE-15720 Print row locks at the debug dump page


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e8b37422
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e8b37422
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e8b37422

Branch: refs/heads/master
Commit: e8b37422c3217bf6794607e3d88d01b99321eda5
Parents: 3d4f026
Author: chenheng <chenheng@apache.org>
Authored: Thu Apr 28 11:40:29 2016 +0800
Committer: chenheng <chenheng@apache.org>
Committed: Thu Apr 28 11:40:29 2016 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegion.java      | 11 ++++++++++
 .../hbase/regionserver/RSDumpServlet.java       | 21 +++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e8b37422/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 72238cc..1210253 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -5167,6 +5167,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
         rowLockContext.cleanUp();
         throw new IOException("Timed out waiting for lock for row: " + rowKey);
       }
+      rowLockContext.setThreadName(Thread.currentThread().getName());
       return result;
     } catch (InterruptedException ie) {
       LOG.warn("Thread interrupted waiting for lock on row: " + rowKey);
@@ -5194,6 +5195,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
     }
   }
 
+  public ConcurrentHashMap<HashedBytes, RowLockContext> getLockedRows() {
+    return lockedRows;
+  }
+
   @VisibleForTesting
   class RowLockContext {
     private final HashedBytes row;
@@ -5201,6 +5206,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
     final AtomicBoolean usable = new AtomicBoolean(true);
     final AtomicInteger count = new AtomicInteger(0);
     final Object lock = new Object();
+    private String threadName;
 
     RowLockContext(HashedBytes row) {
       this.row = row;
@@ -5239,12 +5245,17 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver,
Regi
       }
     }
 
+    public void setThreadName(String threadName) {
+      this.threadName = threadName;
+    }
+
     @Override
     public String toString() {
       return "RowLockContext{" +
           "row=" + row +
           ", readWriteLock=" + readWriteLock +
           ", count=" + count +
+          ", threadName=" + threadName +
           '}';
     }
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e8b37422/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
index 77b68ec..0c69bd9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java
@@ -23,7 +23,6 @@ import java.io.OutputStream;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.util.Date;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -69,6 +68,10 @@ public class RSDumpServlet extends StateDumpServlet {
     out.println(LINE);
     TaskMonitor.get().dumpAsText(out);
 
+    out.println("\n\nRowLocks:");
+    out.println(LINE);
+    dumpRowLock(hrs, out);
+
     out.println("\n\nExecutors:");
     out.println(LINE);
     dumpExecutors(hrs.getExecutorService(), out);
@@ -100,6 +103,22 @@ public class RSDumpServlet extends StateDumpServlet {
     out.flush();
   }
 
+  public static void dumpRowLock(HRegionServer hrs, PrintWriter out) {
+    StringBuilder sb = new StringBuilder();
+    for (Region region : hrs.getOnlineRegions()) {
+      HRegion hRegion = (HRegion)region;
+      if (hRegion.getLockedRows().size() > 0) {
+        for (HRegion.RowLockContext rowLockContext : hRegion.getLockedRows().values()) {
+          sb.setLength(0);
+          sb.append(hRegion.getTableDesc().getTableName()).append(",")
+            .append(hRegion.getRegionInfo().getEncodedName()).append(",");
+          sb.append(rowLockContext.toString());
+          out.println(sb.toString());
+        }
+      }
+    }
+  }
+
   public static void dumpQueue(HRegionServer hrs, PrintWriter out)
       throws IOException {
     if (hrs.compactSplitThread != null) {


Mime
View raw message