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:
parent
e3447cdf07
commit
2c6948780b
|
@ -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;
|
||||
|
@ -120,6 +122,40 @@ public class CompactSplitThread implements CompactionRequestor {
|
|||
+ ", 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
|
||||
if (shouldSplitRegion() && r.getCompactPriority() >= Store.PRIORITY_USER) {
|
||||
|
|
|
@ -351,6 +351,9 @@ 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) {
|
||||
|
|
|
@ -472,6 +472,25 @@ 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 {}
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ public class RSDumpServlet extends StateDumpServlet {
|
|||
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();
|
||||
PrintWriter out = new PrintWriter(os);
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue