hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17673 Monitored RPC Handler not shown in the WebUI (Allan Yang)
Date Tue, 28 Feb 2017 15:44:39 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 2131c7955 -> 7d38e6126


HBASE-17673 Monitored RPC Handler not shown in the WebUI (Allan Yang)


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

Branch: refs/heads/branch-1
Commit: 7d38e6126af747fd29863c1c1439c90481efec3c
Parents: 2131c79
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Feb 28 07:44:35 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Feb 28 07:44:35 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/monitoring/TaskMonitor.java    | 12 +++++++++--
 .../hbase/monitoring/TestTaskMonitor.java       | 21 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7d38e612/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/TaskMonitor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/TaskMonitor.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/TaskMonitor.java
index c8e0a39..53db6a9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/TaskMonitor.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/TaskMonitor.java
@@ -53,6 +53,7 @@ public class TaskMonitor {
   
   private static TaskMonitor instance;
   private CircularFifoBuffer tasks = new CircularFifoBuffer(MAX_TASKS);
+  private List<TaskAndWeakRefPair> rpcTasks = Lists.newArrayList();
 
   /**
    * Get singleton instance.
@@ -88,7 +89,7 @@ public class TaskMonitor {
         new Class<?>[] { MonitoredRPCHandler.class },
         new PassthroughInvocationHandler<MonitoredRPCHandler>(stat));
     TaskAndWeakRefPair pair = new TaskAndWeakRefPair(stat, proxy);
-    tasks.add(pair);
+    rpcTasks.add(pair);
     return proxy;
   }
 
@@ -120,13 +121,20 @@ public class TaskMonitor {
    */
   public synchronized List<MonitoredTask> getTasks() {
     purgeExpiredTasks();
-    ArrayList<MonitoredTask> ret = Lists.newArrayListWithCapacity(tasks.size());
+    ArrayList<MonitoredTask> ret = Lists.newArrayListWithCapacity(tasks.size() + rpcTasks
+        .size());
     for (Iterator<TaskAndWeakRefPair> it = tasks.iterator();
          it.hasNext();) {
       TaskAndWeakRefPair pair = it.next();
       MonitoredTask t = pair.get();
       ret.add(t.clone());
     }
+    for (Iterator<TaskAndWeakRefPair> it = rpcTasks.iterator();
+         it.hasNext();) {
+      TaskAndWeakRefPair pair = it.next();
+      MonitoredTask t = pair.get();
+      ret.add(t.clone());
+    }
     return ret;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/7d38e612/hbase-server/src/test/java/org/apache/hadoop/hbase/monitoring/TestTaskMonitor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/monitoring/TestTaskMonitor.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/monitoring/TestTaskMonitor.java
index ff9bd57..d09b1d1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/monitoring/TestTaskMonitor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/monitoring/TestTaskMonitor.java
@@ -100,6 +100,27 @@ public class TestTaskMonitor {
     assertEquals("task 10", tm.getTasks().get(0).getDescription());
   }
 
+  @Test
+  public void testDoNotPurgeRPCTask() throws Exception {
+    int RPCTaskNums = 10;
+    for(int i = 0; i < RPCTaskNums; i++) {
+      TaskMonitor.get().createRPCStatus("PRCTask" + i);
+    }
+    for(int i = 0; i < TaskMonitor.MAX_TASKS; i++) {
+      TaskMonitor.get().createStatus("otherTask" + i);
+    }
+    int remainRPCTask = 0;
+    for(MonitoredTask task :TaskMonitor.get().getTasks()) {
+      if(task instanceof MonitoredRPCHandler) {
+        remainRPCTask++;
+      }
+    }
+    assertEquals("RPC Tasks have been purged!", RPCTaskNums, remainRPCTask);
+
+  }
+
+
+
 
 }
 


Mime
View raw message