HBASE-2730 Expose RS work queue contents on web UI

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1360179 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-07-11 14:06:20 +00:00
parent e3447cdf07
commit 2c6948780b
4 changed files with 90 additions and 3 deletions

View File

@ -20,6 +20,8 @@
package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import java.util.Iterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
@ -119,6 +121,40 @@ public class CompactSplitThread implements CompactionRequestor {
+ smallCompactions.getQueue().size() + ")"
+ ", split_queue=" + splits.getQueue().size();
}
public String dumpQueue() {
StringBuffer queueLists = new StringBuffer();
queueLists.append("Compaction/Split Queue dump:\n");
queueLists.append(" LargeCompation Queue:\n");
BlockingQueue<Runnable> lq = largeCompactions.getQueue();
Iterator it = lq.iterator();
while(it.hasNext()){
queueLists.append(" "+it.next().toString());
queueLists.append("\n");
}
if( smallCompactions != null ){
queueLists.append("\n");
queueLists.append(" SmallCompation Queue:\n");
lq = smallCompactions.getQueue();
it = lq.iterator();
while(it.hasNext()){
queueLists.append(" "+it.next().toString());
queueLists.append("\n");
}
}
queueLists.append("\n");
queueLists.append(" Split Queue:\n");
lq = splits.getQueue();
it = lq.iterator();
while(it.hasNext()){
queueLists.append(" "+it.next().toString());
queueLists.append("\n");
}
return queueLists.toString();
}
public synchronized boolean requestSplit(final HRegion r) {
// don't split regions that are blocking

View File

@ -350,7 +350,10 @@ public class HRegionServer implements ClientProtocol,
/** region server process name */
public static final String REGIONSERVER = "regionserver";
/** region server configuration name */
public static final String REGIONSERVER_CONF = "regionserver_conf";
/*
* Space is reserved in HRS constructor and then released when aborting to
* recover from an OOME. See HBASE-706. TODO: Make this percentage of the heap
@ -1575,6 +1578,7 @@ public class HRegionServer implements ClientProtocol,
this.infoServer.addServlet("status", "/rs-status", RSStatusServlet.class);
this.infoServer.addServlet("dump", "/dump", RSDumpServlet.class);
this.infoServer.setAttribute(REGIONSERVER, this);
this.infoServer.setAttribute(REGIONSERVER_CONF, conf);
this.infoServer.start();
break;
} catch (BindException e) {

View File

@ -472,7 +472,26 @@ class MemStoreFlusher extends HasThread implements FlushRequester {
wakeupFlushThread();
}
}
@Override
public String toString() {
return "flush_queue="
+ flushQueue.size();
}
public String dumpQueue() {
StringBuilder queueList = new StringBuilder();
queueList.append("Flush Queue Queue dump:\n");
queueList.append(" Flush Queue:\n");
java.util.Iterator<FlushQueueEntry> it = flushQueue.iterator();
while(it.hasNext()){
queueList.append(" "+it.next().toString());
queueList.append("\n");
}
return queueList.toString();
}
interface FlushQueueEntry extends Delayed {}
/**

View File

@ -46,6 +46,10 @@ public class RSDumpServlet extends StateDumpServlet {
HRegionServer hrs = (HRegionServer)getServletContext().getAttribute(
HRegionServer.REGIONSERVER);
assert hrs != null : "No RS in context!";
Configuration hrsconf = (Configuration)getServletContext().getAttribute(
HRegionServer.REGIONSERVER_CONF);
assert hrsconf != null : "No RS conf in context";
response.setContentType("text/plain");
OutputStream os = response.getOutputStream();
@ -82,6 +86,30 @@ public class RSDumpServlet extends StateDumpServlet {
long tailKb = getTailKbParam(request);
LogMonitoring.dumpTailOfLogs(out, tailKb);
out.println("\n\nRS Queue:");
out.println(LINE);
if(isShowQueueDump(hrsconf)) {
dumpQueue(hrs, out);
}
out.flush();
}
}
private boolean isShowQueueDump(Configuration conf){
return conf.getBoolean("hbase.regionserver.servlet.show.queuedump", true);
}
private void dumpQueue(HRegionServer hrs, PrintWriter out)
throws IOException {
// 1. Print out Compaction/Split Queue
out.println("Compaction/Split Queue summary: "
+ hrs.compactSplitThread.toString() );
out.println(hrs.compactSplitThread.dumpQueue());
// 2. Print out flush Queue
out.println("\nFlush Queue summary: "
+ hrs.cacheFlusher.toString());
out.println(hrs.cacheFlusher.dumpQueue());
}
}