hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [14/52] [partial] hbase-site git commit: Published site at a55af38689fbe273e716ebbf6191e9515986dbf3.
Date Thu, 14 Jul 2016 19:46:37 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/975096b1/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.TrackingThreadPoolExecutor.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.TrackingThreadPoolExecutor.html b/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.TrackingThreadPoolExecutor.html
index 94356e6..47fdd86 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.TrackingThreadPoolExecutor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.TrackingThreadPoolExecutor.html
@@ -127,208 +127,217 @@
 <span class="sourceLineNo">119</span>    return executor;<a name="line.119"></a>
 <span class="sourceLineNo">120</span>  }<a name="line.120"></a>
 <span class="sourceLineNo">121</span><a name="line.121"></a>
-<span class="sourceLineNo">122</span><a name="line.122"></a>
-<span class="sourceLineNo">123</span>  public void startExecutorService(final ExecutorType type, final int maxThreads) {<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    String name = type.getExecutorName(this.servername);<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    if (isExecutorServiceRunning(name)) {<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      LOG.debug("Executor service " + toString() + " already running on " +<a name="line.126"></a>
-<span class="sourceLineNo">127</span>          this.servername);<a name="line.127"></a>
-<span class="sourceLineNo">128</span>      return;<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    }<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    startExecutorService(name, maxThreads);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>  }<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>  public void submit(final EventHandler eh) {<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    Executor executor = getExecutor(eh.getEventType().getExecutorServiceType());<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    if (executor == null) {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      // This happens only when events are submitted after shutdown() was<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      // called, so dropping them should be "ok" since it means we're<a name="line.137"></a>
-<span class="sourceLineNo">138</span>      // shutting down.<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      LOG.error("Cannot submit [" + eh + "] because the executor is missing." +<a name="line.139"></a>
-<span class="sourceLineNo">140</span>        " Is this process shutting down?");<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    } else {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      executor.submit(eh);<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
-<span class="sourceLineNo">144</span>  }<a name="line.144"></a>
-<span class="sourceLineNo">145</span><a name="line.145"></a>
-<span class="sourceLineNo">146</span>  public Map&lt;String, ExecutorStatus&gt; getAllExecutorStatuses() {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    Map&lt;String, ExecutorStatus&gt; ret = Maps.newHashMap();<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    for (Map.Entry&lt;String, Executor&gt; e : executorMap.entrySet()) {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>      ret.put(e.getKey(), e.getValue().getStatus());<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    return ret;<a name="line.151"></a>
-<span class="sourceLineNo">152</span>  }<a name="line.152"></a>
-<span class="sourceLineNo">153</span>  <a name="line.153"></a>
-<span class="sourceLineNo">154</span>  /**<a name="line.154"></a>
-<span class="sourceLineNo">155</span>   * Executor instance.<a name="line.155"></a>
-<span class="sourceLineNo">156</span>   */<a name="line.156"></a>
-<span class="sourceLineNo">157</span>  static class Executor {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    // how long to retain excess threads<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    static final long keepAliveTimeInMillis = 1000;<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    // the thread pool executor that services the requests<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    final TrackingThreadPoolExecutor threadPoolExecutor;<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    // work queue to use - unbounded queue<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    final BlockingQueue&lt;Runnable&gt; q = new LinkedBlockingQueue&lt;Runnable&gt;();<a name="line.163"></a>
-<span class="sourceLineNo">164</span>    private final String name;<a name="line.164"></a>
-<span class="sourceLineNo">165</span>    private static final AtomicLong seqids = new AtomicLong(0);<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    private final long id;<a name="line.166"></a>
-<span class="sourceLineNo">167</span><a name="line.167"></a>
-<span class="sourceLineNo">168</span>    protected Executor(String name, int maxThreads) {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      this.id = seqids.incrementAndGet();<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      this.name = name;<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      // create the thread pool executor<a name="line.171"></a>
-<span class="sourceLineNo">172</span>      this.threadPoolExecutor = new TrackingThreadPoolExecutor(<a name="line.172"></a>
-<span class="sourceLineNo">173</span>          maxThreads, maxThreads,<a name="line.173"></a>
-<span class="sourceLineNo">174</span>          keepAliveTimeInMillis, TimeUnit.MILLISECONDS, q);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      // name the threads for this threadpool<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      tfb.setNameFormat(this.name + "-%d");<a name="line.177"></a>
-<span class="sourceLineNo">178</span>      this.threadPoolExecutor.setThreadFactory(tfb.build());<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    }<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>    /**<a name="line.181"></a>
-<span class="sourceLineNo">182</span>     * Submit the event to the queue for handling.<a name="line.182"></a>
-<span class="sourceLineNo">183</span>     * @param event<a name="line.183"></a>
-<span class="sourceLineNo">184</span>     */<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    void submit(final EventHandler event) {<a name="line.185"></a>
-<span class="sourceLineNo">186</span>      // If there is a listener for this type, make sure we call the before<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      // and after process methods.<a name="line.187"></a>
-<span class="sourceLineNo">188</span>      this.threadPoolExecutor.execute(event);<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    }<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    <a name="line.190"></a>
-<span class="sourceLineNo">191</span>    public String toString() {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>      return getClass().getSimpleName() + "-" + id + "-" + name;<a name="line.192"></a>
+<span class="sourceLineNo">122</span>  @VisibleForTesting<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  public ThreadPoolExecutor getExecutorThreadPool(final ExecutorType type) {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    return getExecutor(type).getThreadPoolExecutor();<a name="line.124"></a>
+<span class="sourceLineNo">125</span>  }<a name="line.125"></a>
+<span class="sourceLineNo">126</span><a name="line.126"></a>
+<span class="sourceLineNo">127</span>  public void startExecutorService(final ExecutorType type, final int maxThreads) {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    String name = type.getExecutorName(this.servername);<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    if (isExecutorServiceRunning(name)) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      LOG.debug("Executor service " + toString() + " already running on " +<a name="line.130"></a>
+<span class="sourceLineNo">131</span>          this.servername);<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      return;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    }<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    startExecutorService(name, maxThreads);<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
+<span class="sourceLineNo">136</span><a name="line.136"></a>
+<span class="sourceLineNo">137</span>  public void submit(final EventHandler eh) {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    Executor executor = getExecutor(eh.getEventType().getExecutorServiceType());<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    if (executor == null) {<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      // This happens only when events are submitted after shutdown() was<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      // called, so dropping them should be "ok" since it means we're<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      // shutting down.<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      LOG.error("Cannot submit [" + eh + "] because the executor is missing." +<a name="line.143"></a>
+<span class="sourceLineNo">144</span>        " Is this process shutting down?");<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    } else {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>      executor.submit(eh);<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    }<a name="line.147"></a>
+<span class="sourceLineNo">148</span>  }<a name="line.148"></a>
+<span class="sourceLineNo">149</span><a name="line.149"></a>
+<span class="sourceLineNo">150</span>  public Map&lt;String, ExecutorStatus&gt; getAllExecutorStatuses() {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    Map&lt;String, ExecutorStatus&gt; ret = Maps.newHashMap();<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    for (Map.Entry&lt;String, Executor&gt; e : executorMap.entrySet()) {<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      ret.put(e.getKey(), e.getValue().getStatus());<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    }<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    return ret;<a name="line.155"></a>
+<span class="sourceLineNo">156</span>  }<a name="line.156"></a>
+<span class="sourceLineNo">157</span><a name="line.157"></a>
+<span class="sourceLineNo">158</span>  /**<a name="line.158"></a>
+<span class="sourceLineNo">159</span>   * Executor instance.<a name="line.159"></a>
+<span class="sourceLineNo">160</span>   */<a name="line.160"></a>
+<span class="sourceLineNo">161</span>  static class Executor {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    // how long to retain excess threads<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    static final long keepAliveTimeInMillis = 1000;<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    // the thread pool executor that services the requests<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    final TrackingThreadPoolExecutor threadPoolExecutor;<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    // work queue to use - unbounded queue<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    final BlockingQueue&lt;Runnable&gt; q = new LinkedBlockingQueue&lt;Runnable&gt;();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    private final String name;<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    private static final AtomicLong seqids = new AtomicLong(0);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>    private final long id;<a name="line.170"></a>
+<span class="sourceLineNo">171</span><a name="line.171"></a>
+<span class="sourceLineNo">172</span>    protected Executor(String name, int maxThreads) {<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      this.id = seqids.incrementAndGet();<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      this.name = name;<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      // create the thread pool executor<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      this.threadPoolExecutor = new TrackingThreadPoolExecutor(<a name="line.176"></a>
+<span class="sourceLineNo">177</span>          maxThreads, maxThreads,<a name="line.177"></a>
+<span class="sourceLineNo">178</span>          keepAliveTimeInMillis, TimeUnit.MILLISECONDS, q);<a name="line.178"></a>
+<span class="sourceLineNo">179</span>      // name the threads for this threadpool<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      tfb.setNameFormat(this.name + "-%d");<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      this.threadPoolExecutor.setThreadFactory(tfb.build());<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    }<a name="line.183"></a>
+<span class="sourceLineNo">184</span><a name="line.184"></a>
+<span class="sourceLineNo">185</span>    /**<a name="line.185"></a>
+<span class="sourceLineNo">186</span>     * Submit the event to the queue for handling.<a name="line.186"></a>
+<span class="sourceLineNo">187</span>     * @param event<a name="line.187"></a>
+<span class="sourceLineNo">188</span>     */<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    void submit(final EventHandler event) {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      // If there is a listener for this type, make sure we call the before<a name="line.190"></a>
+<span class="sourceLineNo">191</span>      // and after process methods.<a name="line.191"></a>
+<span class="sourceLineNo">192</span>      this.threadPoolExecutor.execute(event);<a name="line.192"></a>
 <span class="sourceLineNo">193</span>    }<a name="line.193"></a>
 <span class="sourceLineNo">194</span><a name="line.194"></a>
-<span class="sourceLineNo">195</span>    public ExecutorStatus getStatus() {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      List&lt;EventHandler&gt; queuedEvents = Lists.newArrayList();<a name="line.196"></a>
-<span class="sourceLineNo">197</span>      for (Runnable r : q) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>        if (!(r instanceof EventHandler)) {<a name="line.198"></a>
-<span class="sourceLineNo">199</span>          LOG.warn("Non-EventHandler " + r + " queued in " + name);<a name="line.199"></a>
-<span class="sourceLineNo">200</span>          continue;<a name="line.200"></a>
-<span class="sourceLineNo">201</span>        }<a name="line.201"></a>
-<span class="sourceLineNo">202</span>        queuedEvents.add((EventHandler)r);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      <a name="line.204"></a>
-<span class="sourceLineNo">205</span>      List&lt;RunningEventStatus&gt; running = Lists.newArrayList();<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      for (Map.Entry&lt;Thread, Runnable&gt; e :<a name="line.206"></a>
-<span class="sourceLineNo">207</span>          threadPoolExecutor.getRunningTasks().entrySet()) {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>        Runnable r = e.getValue();<a name="line.208"></a>
-<span class="sourceLineNo">209</span>        if (!(r instanceof EventHandler)) {<a name="line.209"></a>
-<span class="sourceLineNo">210</span>          LOG.warn("Non-EventHandler " + r + " running in " + name);<a name="line.210"></a>
-<span class="sourceLineNo">211</span>          continue;<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        }<a name="line.212"></a>
-<span class="sourceLineNo">213</span>        running.add(new RunningEventStatus(e.getKey(), (EventHandler)r));<a name="line.213"></a>
-<span class="sourceLineNo">214</span>      }<a name="line.214"></a>
-<span class="sourceLineNo">215</span>      <a name="line.215"></a>
-<span class="sourceLineNo">216</span>      return new ExecutorStatus(this, queuedEvents, running);<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    }<a name="line.217"></a>
-<span class="sourceLineNo">218</span>  }<a name="line.218"></a>
-<span class="sourceLineNo">219</span> <a name="line.219"></a>
-<span class="sourceLineNo">220</span>  /**<a name="line.220"></a>
-<span class="sourceLineNo">221</span>   * A subclass of ThreadPoolExecutor that keeps track of the Runnables that<a name="line.221"></a>
-<span class="sourceLineNo">222</span>   * are executing at any given point in time.<a name="line.222"></a>
-<span class="sourceLineNo">223</span>   */<a name="line.223"></a>
-<span class="sourceLineNo">224</span>  static class TrackingThreadPoolExecutor extends ThreadPoolExecutor {<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    private ConcurrentMap&lt;Thread, Runnable&gt; running = Maps.newConcurrentMap(); <a name="line.225"></a>
-<span class="sourceLineNo">226</span>      <a name="line.226"></a>
-<span class="sourceLineNo">227</span>    public TrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize,<a name="line.227"></a>
-<span class="sourceLineNo">228</span>        long keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue) {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);<a name="line.229"></a>
-<span class="sourceLineNo">230</span>    }<a name="line.230"></a>
-<span class="sourceLineNo">231</span><a name="line.231"></a>
-<span class="sourceLineNo">232</span>    @Override<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    protected void afterExecute(Runnable r, Throwable t) {<a name="line.233"></a>
-<span class="sourceLineNo">234</span>      super.afterExecute(r, t);<a name="line.234"></a>
-<span class="sourceLineNo">235</span>      running.remove(Thread.currentThread());<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    }<a name="line.236"></a>
-<span class="sourceLineNo">237</span><a name="line.237"></a>
-<span class="sourceLineNo">238</span>    @Override<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    protected void beforeExecute(Thread t, Runnable r) {<a name="line.239"></a>
-<span class="sourceLineNo">240</span>      Runnable oldPut = running.put(t, r);<a name="line.240"></a>
-<span class="sourceLineNo">241</span>      assert oldPut == null : "inconsistency for thread " + t;<a name="line.241"></a>
-<span class="sourceLineNo">242</span>      super.beforeExecute(t, r);<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    }<a name="line.243"></a>
-<span class="sourceLineNo">244</span>   <a name="line.244"></a>
-<span class="sourceLineNo">245</span>    /**<a name="line.245"></a>
-<span class="sourceLineNo">246</span>     * @return a map of the threads currently running tasks<a name="line.246"></a>
-<span class="sourceLineNo">247</span>     * inside this executor. Each key is an active thread,<a name="line.247"></a>
-<span class="sourceLineNo">248</span>     * and the value is the task that is currently running.<a name="line.248"></a>
-<span class="sourceLineNo">249</span>     * Note that this is not a stable snapshot of the map.<a name="line.249"></a>
-<span class="sourceLineNo">250</span>     */<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    public ConcurrentMap&lt;Thread, Runnable&gt; getRunningTasks() {<a name="line.251"></a>
-<span class="sourceLineNo">252</span>      return running;<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
-<span class="sourceLineNo">254</span>  }<a name="line.254"></a>
-<span class="sourceLineNo">255</span><a name="line.255"></a>
-<span class="sourceLineNo">256</span>  /**<a name="line.256"></a>
-<span class="sourceLineNo">257</span>   * A snapshot of the status of a particular executor. This includes<a name="line.257"></a>
-<span class="sourceLineNo">258</span>   * the contents of the executor's pending queue, as well as the<a name="line.258"></a>
-<span class="sourceLineNo">259</span>   * threads and events currently being processed.<a name="line.259"></a>
-<span class="sourceLineNo">260</span>   *<a name="line.260"></a>
-<span class="sourceLineNo">261</span>   * This is a consistent snapshot that is immutable once constructed.<a name="line.261"></a>
-<span class="sourceLineNo">262</span>   */<a name="line.262"></a>
-<span class="sourceLineNo">263</span>  public static class ExecutorStatus {<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    final Executor executor;<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    final List&lt;EventHandler&gt; queuedEvents;<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    final List&lt;RunningEventStatus&gt; running;<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>    ExecutorStatus(Executor executor,<a name="line.268"></a>
-<span class="sourceLineNo">269</span>        List&lt;EventHandler&gt; queuedEvents,<a name="line.269"></a>
-<span class="sourceLineNo">270</span>        List&lt;RunningEventStatus&gt; running) {<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      this.executor = executor;<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      this.queuedEvents = queuedEvents;<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      this.running = running;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    }<a name="line.274"></a>
-<span class="sourceLineNo">275</span>   <a name="line.275"></a>
-<span class="sourceLineNo">276</span>    /**<a name="line.276"></a>
-<span class="sourceLineNo">277</span>     * Dump a textual representation of the executor's status<a name="line.277"></a>
-<span class="sourceLineNo">278</span>     * to the given writer.<a name="line.278"></a>
-<span class="sourceLineNo">279</span>     *<a name="line.279"></a>
-<span class="sourceLineNo">280</span>     * @param out the stream to write to<a name="line.280"></a>
-<span class="sourceLineNo">281</span>     * @param indent a string prefix for each line, used for indentation<a name="line.281"></a>
-<span class="sourceLineNo">282</span>     */<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    public void dumpTo(Writer out, String indent) throws IOException {<a name="line.283"></a>
-<span class="sourceLineNo">284</span>      out.write(indent + "Status for executor: " + executor + "\n");<a name="line.284"></a>
-<span class="sourceLineNo">285</span>      out.write(indent + "=======================================\n");<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      out.write(indent + queuedEvents.size() + " events queued, " +<a name="line.286"></a>
-<span class="sourceLineNo">287</span>          running.size() + " running\n");<a name="line.287"></a>
-<span class="sourceLineNo">288</span>      if (!queuedEvents.isEmpty()) {<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        out.write(indent + "Queued:\n");<a name="line.289"></a>
-<span class="sourceLineNo">290</span>        for (EventHandler e : queuedEvents) {<a name="line.290"></a>
-<span class="sourceLineNo">291</span>          out.write(indent + "  " + e + "\n");<a name="line.291"></a>
-<span class="sourceLineNo">292</span>        }<a name="line.292"></a>
-<span class="sourceLineNo">293</span>        out.write("\n");<a name="line.293"></a>
-<span class="sourceLineNo">294</span>      }<a name="line.294"></a>
-<span class="sourceLineNo">295</span>      if (!running.isEmpty()) {<a name="line.295"></a>
-<span class="sourceLineNo">296</span>        out.write(indent + "Running:\n");<a name="line.296"></a>
-<span class="sourceLineNo">297</span>        for (RunningEventStatus stat : running) {<a name="line.297"></a>
-<span class="sourceLineNo">298</span>          out.write(indent + "  Running on thread '" +<a name="line.298"></a>
-<span class="sourceLineNo">299</span>              stat.threadInfo.getThreadName() +<a name="line.299"></a>
-<span class="sourceLineNo">300</span>              "': " + stat.event + "\n");<a name="line.300"></a>
-<span class="sourceLineNo">301</span>          out.write(ThreadMonitoring.formatThreadInfo(<a name="line.301"></a>
-<span class="sourceLineNo">302</span>              stat.threadInfo, indent + "  "));<a name="line.302"></a>
-<span class="sourceLineNo">303</span>          out.write("\n");<a name="line.303"></a>
-<span class="sourceLineNo">304</span>        }<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      }<a name="line.305"></a>
-<span class="sourceLineNo">306</span>      out.flush();<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    }<a name="line.307"></a>
-<span class="sourceLineNo">308</span>  }<a name="line.308"></a>
-<span class="sourceLineNo">309</span><a name="line.309"></a>
-<span class="sourceLineNo">310</span>  /**<a name="line.310"></a>
-<span class="sourceLineNo">311</span>   * The status of a particular event that is in the middle of being<a name="line.311"></a>
-<span class="sourceLineNo">312</span>   * handled by an executor.<a name="line.312"></a>
-<span class="sourceLineNo">313</span>   */<a name="line.313"></a>
-<span class="sourceLineNo">314</span>  public static class RunningEventStatus {<a name="line.314"></a>
-<span class="sourceLineNo">315</span>    final ThreadInfo threadInfo;<a name="line.315"></a>
-<span class="sourceLineNo">316</span>    final EventHandler event;<a name="line.316"></a>
-<span class="sourceLineNo">317</span><a name="line.317"></a>
-<span class="sourceLineNo">318</span>    public RunningEventStatus(Thread t, EventHandler event) {<a name="line.318"></a>
-<span class="sourceLineNo">319</span>      this.threadInfo = ThreadMonitoring.getThreadInfo(t);<a name="line.319"></a>
-<span class="sourceLineNo">320</span>      this.event = event;<a name="line.320"></a>
-<span class="sourceLineNo">321</span>    }<a name="line.321"></a>
-<span class="sourceLineNo">322</span>  }<a name="line.322"></a>
-<span class="sourceLineNo">323</span>}<a name="line.323"></a>
+<span class="sourceLineNo">195</span>    TrackingThreadPoolExecutor getThreadPoolExecutor() {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      return threadPoolExecutor;<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    }<a name="line.197"></a>
+<span class="sourceLineNo">198</span><a name="line.198"></a>
+<span class="sourceLineNo">199</span>    @Override<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    public String toString() {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>      return getClass().getSimpleName() + "-" + id + "-" + name;<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    }<a name="line.202"></a>
+<span class="sourceLineNo">203</span><a name="line.203"></a>
+<span class="sourceLineNo">204</span>    public ExecutorStatus getStatus() {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      List&lt;EventHandler&gt; queuedEvents = Lists.newArrayList();<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      for (Runnable r : q) {<a name="line.206"></a>
+<span class="sourceLineNo">207</span>        if (!(r instanceof EventHandler)) {<a name="line.207"></a>
+<span class="sourceLineNo">208</span>          LOG.warn("Non-EventHandler " + r + " queued in " + name);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>          continue;<a name="line.209"></a>
+<span class="sourceLineNo">210</span>        }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        queuedEvents.add((EventHandler)r);<a name="line.211"></a>
+<span class="sourceLineNo">212</span>      }<a name="line.212"></a>
+<span class="sourceLineNo">213</span><a name="line.213"></a>
+<span class="sourceLineNo">214</span>      List&lt;RunningEventStatus&gt; running = Lists.newArrayList();<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      for (Map.Entry&lt;Thread, Runnable&gt; e :<a name="line.215"></a>
+<span class="sourceLineNo">216</span>          threadPoolExecutor.getRunningTasks().entrySet()) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        Runnable r = e.getValue();<a name="line.217"></a>
+<span class="sourceLineNo">218</span>        if (!(r instanceof EventHandler)) {<a name="line.218"></a>
+<span class="sourceLineNo">219</span>          LOG.warn("Non-EventHandler " + r + " running in " + name);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>          continue;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        }<a name="line.221"></a>
+<span class="sourceLineNo">222</span>        running.add(new RunningEventStatus(e.getKey(), (EventHandler)r));<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      }<a name="line.223"></a>
+<span class="sourceLineNo">224</span><a name="line.224"></a>
+<span class="sourceLineNo">225</span>      return new ExecutorStatus(this, queuedEvents, running);<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    }<a name="line.226"></a>
+<span class="sourceLineNo">227</span>  }<a name="line.227"></a>
+<span class="sourceLineNo">228</span><a name="line.228"></a>
+<span class="sourceLineNo">229</span>  /**<a name="line.229"></a>
+<span class="sourceLineNo">230</span>   * A subclass of ThreadPoolExecutor that keeps track of the Runnables that<a name="line.230"></a>
+<span class="sourceLineNo">231</span>   * are executing at any given point in time.<a name="line.231"></a>
+<span class="sourceLineNo">232</span>   */<a name="line.232"></a>
+<span class="sourceLineNo">233</span>  static class TrackingThreadPoolExecutor extends ThreadPoolExecutor {<a name="line.233"></a>
+<span class="sourceLineNo">234</span>    private ConcurrentMap&lt;Thread, Runnable&gt; running = Maps.newConcurrentMap();<a name="line.234"></a>
+<span class="sourceLineNo">235</span><a name="line.235"></a>
+<span class="sourceLineNo">236</span>    public TrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize,<a name="line.236"></a>
+<span class="sourceLineNo">237</span>        long keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue) {<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    }<a name="line.239"></a>
+<span class="sourceLineNo">240</span><a name="line.240"></a>
+<span class="sourceLineNo">241</span>    @Override<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    protected void afterExecute(Runnable r, Throwable t) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      super.afterExecute(r, t);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      running.remove(Thread.currentThread());<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    }<a name="line.245"></a>
+<span class="sourceLineNo">246</span><a name="line.246"></a>
+<span class="sourceLineNo">247</span>    @Override<a name="line.247"></a>
+<span class="sourceLineNo">248</span>    protected void beforeExecute(Thread t, Runnable r) {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>      Runnable oldPut = running.put(t, r);<a name="line.249"></a>
+<span class="sourceLineNo">250</span>      assert oldPut == null : "inconsistency for thread " + t;<a name="line.250"></a>
+<span class="sourceLineNo">251</span>      super.beforeExecute(t, r);<a name="line.251"></a>
+<span class="sourceLineNo">252</span>    }<a name="line.252"></a>
+<span class="sourceLineNo">253</span><a name="line.253"></a>
+<span class="sourceLineNo">254</span>    /**<a name="line.254"></a>
+<span class="sourceLineNo">255</span>     * @return a map of the threads currently running tasks<a name="line.255"></a>
+<span class="sourceLineNo">256</span>     * inside this executor. Each key is an active thread,<a name="line.256"></a>
+<span class="sourceLineNo">257</span>     * and the value is the task that is currently running.<a name="line.257"></a>
+<span class="sourceLineNo">258</span>     * Note that this is not a stable snapshot of the map.<a name="line.258"></a>
+<span class="sourceLineNo">259</span>     */<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    public ConcurrentMap&lt;Thread, Runnable&gt; getRunningTasks() {<a name="line.260"></a>
+<span class="sourceLineNo">261</span>      return running;<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    }<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  }<a name="line.263"></a>
+<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">265</span>  /**<a name="line.265"></a>
+<span class="sourceLineNo">266</span>   * A snapshot of the status of a particular executor. This includes<a name="line.266"></a>
+<span class="sourceLineNo">267</span>   * the contents of the executor's pending queue, as well as the<a name="line.267"></a>
+<span class="sourceLineNo">268</span>   * threads and events currently being processed.<a name="line.268"></a>
+<span class="sourceLineNo">269</span>   *<a name="line.269"></a>
+<span class="sourceLineNo">270</span>   * This is a consistent snapshot that is immutable once constructed.<a name="line.270"></a>
+<span class="sourceLineNo">271</span>   */<a name="line.271"></a>
+<span class="sourceLineNo">272</span>  public static class ExecutorStatus {<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    final Executor executor;<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    final List&lt;EventHandler&gt; queuedEvents;<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    final List&lt;RunningEventStatus&gt; running;<a name="line.275"></a>
+<span class="sourceLineNo">276</span><a name="line.276"></a>
+<span class="sourceLineNo">277</span>    ExecutorStatus(Executor executor,<a name="line.277"></a>
+<span class="sourceLineNo">278</span>        List&lt;EventHandler&gt; queuedEvents,<a name="line.278"></a>
+<span class="sourceLineNo">279</span>        List&lt;RunningEventStatus&gt; running) {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      this.executor = executor;<a name="line.280"></a>
+<span class="sourceLineNo">281</span>      this.queuedEvents = queuedEvents;<a name="line.281"></a>
+<span class="sourceLineNo">282</span>      this.running = running;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>    }<a name="line.283"></a>
+<span class="sourceLineNo">284</span><a name="line.284"></a>
+<span class="sourceLineNo">285</span>    /**<a name="line.285"></a>
+<span class="sourceLineNo">286</span>     * Dump a textual representation of the executor's status<a name="line.286"></a>
+<span class="sourceLineNo">287</span>     * to the given writer.<a name="line.287"></a>
+<span class="sourceLineNo">288</span>     *<a name="line.288"></a>
+<span class="sourceLineNo">289</span>     * @param out the stream to write to<a name="line.289"></a>
+<span class="sourceLineNo">290</span>     * @param indent a string prefix for each line, used for indentation<a name="line.290"></a>
+<span class="sourceLineNo">291</span>     */<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    public void dumpTo(Writer out, String indent) throws IOException {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      out.write(indent + "Status for executor: " + executor + "\n");<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      out.write(indent + "=======================================\n");<a name="line.294"></a>
+<span class="sourceLineNo">295</span>      out.write(indent + queuedEvents.size() + " events queued, " +<a name="line.295"></a>
+<span class="sourceLineNo">296</span>          running.size() + " running\n");<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      if (!queuedEvents.isEmpty()) {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        out.write(indent + "Queued:\n");<a name="line.298"></a>
+<span class="sourceLineNo">299</span>        for (EventHandler e : queuedEvents) {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>          out.write(indent + "  " + e + "\n");<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        }<a name="line.301"></a>
+<span class="sourceLineNo">302</span>        out.write("\n");<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      }<a name="line.303"></a>
+<span class="sourceLineNo">304</span>      if (!running.isEmpty()) {<a name="line.304"></a>
+<span class="sourceLineNo">305</span>        out.write(indent + "Running:\n");<a name="line.305"></a>
+<span class="sourceLineNo">306</span>        for (RunningEventStatus stat : running) {<a name="line.306"></a>
+<span class="sourceLineNo">307</span>          out.write(indent + "  Running on thread '" +<a name="line.307"></a>
+<span class="sourceLineNo">308</span>              stat.threadInfo.getThreadName() +<a name="line.308"></a>
+<span class="sourceLineNo">309</span>              "': " + stat.event + "\n");<a name="line.309"></a>
+<span class="sourceLineNo">310</span>          out.write(ThreadMonitoring.formatThreadInfo(<a name="line.310"></a>
+<span class="sourceLineNo">311</span>              stat.threadInfo, indent + "  "));<a name="line.311"></a>
+<span class="sourceLineNo">312</span>          out.write("\n");<a name="line.312"></a>
+<span class="sourceLineNo">313</span>        }<a name="line.313"></a>
+<span class="sourceLineNo">314</span>      }<a name="line.314"></a>
+<span class="sourceLineNo">315</span>      out.flush();<a name="line.315"></a>
+<span class="sourceLineNo">316</span>    }<a name="line.316"></a>
+<span class="sourceLineNo">317</span>  }<a name="line.317"></a>
+<span class="sourceLineNo">318</span><a name="line.318"></a>
+<span class="sourceLineNo">319</span>  /**<a name="line.319"></a>
+<span class="sourceLineNo">320</span>   * The status of a particular event that is in the middle of being<a name="line.320"></a>
+<span class="sourceLineNo">321</span>   * handled by an executor.<a name="line.321"></a>
+<span class="sourceLineNo">322</span>   */<a name="line.322"></a>
+<span class="sourceLineNo">323</span>  public static class RunningEventStatus {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    final ThreadInfo threadInfo;<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    final EventHandler event;<a name="line.325"></a>
+<span class="sourceLineNo">326</span><a name="line.326"></a>
+<span class="sourceLineNo">327</span>    public RunningEventStatus(Thread t, EventHandler event) {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      this.threadInfo = ThreadMonitoring.getThreadInfo(t);<a name="line.328"></a>
+<span class="sourceLineNo">329</span>      this.event = event;<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    }<a name="line.330"></a>
+<span class="sourceLineNo">331</span>  }<a name="line.331"></a>
+<span class="sourceLineNo">332</span>}<a name="line.332"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/975096b1/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.html b/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.html
index 94356e6..47fdd86 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorService.html
@@ -127,208 +127,217 @@
 <span class="sourceLineNo">119</span>    return executor;<a name="line.119"></a>
 <span class="sourceLineNo">120</span>  }<a name="line.120"></a>
 <span class="sourceLineNo">121</span><a name="line.121"></a>
-<span class="sourceLineNo">122</span><a name="line.122"></a>
-<span class="sourceLineNo">123</span>  public void startExecutorService(final ExecutorType type, final int maxThreads) {<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    String name = type.getExecutorName(this.servername);<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    if (isExecutorServiceRunning(name)) {<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      LOG.debug("Executor service " + toString() + " already running on " +<a name="line.126"></a>
-<span class="sourceLineNo">127</span>          this.servername);<a name="line.127"></a>
-<span class="sourceLineNo">128</span>      return;<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    }<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    startExecutorService(name, maxThreads);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>  }<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>  public void submit(final EventHandler eh) {<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    Executor executor = getExecutor(eh.getEventType().getExecutorServiceType());<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    if (executor == null) {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      // This happens only when events are submitted after shutdown() was<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      // called, so dropping them should be "ok" since it means we're<a name="line.137"></a>
-<span class="sourceLineNo">138</span>      // shutting down.<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      LOG.error("Cannot submit [" + eh + "] because the executor is missing." +<a name="line.139"></a>
-<span class="sourceLineNo">140</span>        " Is this process shutting down?");<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    } else {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      executor.submit(eh);<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
-<span class="sourceLineNo">144</span>  }<a name="line.144"></a>
-<span class="sourceLineNo">145</span><a name="line.145"></a>
-<span class="sourceLineNo">146</span>  public Map&lt;String, ExecutorStatus&gt; getAllExecutorStatuses() {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    Map&lt;String, ExecutorStatus&gt; ret = Maps.newHashMap();<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    for (Map.Entry&lt;String, Executor&gt; e : executorMap.entrySet()) {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>      ret.put(e.getKey(), e.getValue().getStatus());<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    return ret;<a name="line.151"></a>
-<span class="sourceLineNo">152</span>  }<a name="line.152"></a>
-<span class="sourceLineNo">153</span>  <a name="line.153"></a>
-<span class="sourceLineNo">154</span>  /**<a name="line.154"></a>
-<span class="sourceLineNo">155</span>   * Executor instance.<a name="line.155"></a>
-<span class="sourceLineNo">156</span>   */<a name="line.156"></a>
-<span class="sourceLineNo">157</span>  static class Executor {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    // how long to retain excess threads<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    static final long keepAliveTimeInMillis = 1000;<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    // the thread pool executor that services the requests<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    final TrackingThreadPoolExecutor threadPoolExecutor;<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    // work queue to use - unbounded queue<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    final BlockingQueue&lt;Runnable&gt; q = new LinkedBlockingQueue&lt;Runnable&gt;();<a name="line.163"></a>
-<span class="sourceLineNo">164</span>    private final String name;<a name="line.164"></a>
-<span class="sourceLineNo">165</span>    private static final AtomicLong seqids = new AtomicLong(0);<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    private final long id;<a name="line.166"></a>
-<span class="sourceLineNo">167</span><a name="line.167"></a>
-<span class="sourceLineNo">168</span>    protected Executor(String name, int maxThreads) {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      this.id = seqids.incrementAndGet();<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      this.name = name;<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      // create the thread pool executor<a name="line.171"></a>
-<span class="sourceLineNo">172</span>      this.threadPoolExecutor = new TrackingThreadPoolExecutor(<a name="line.172"></a>
-<span class="sourceLineNo">173</span>          maxThreads, maxThreads,<a name="line.173"></a>
-<span class="sourceLineNo">174</span>          keepAliveTimeInMillis, TimeUnit.MILLISECONDS, q);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      // name the threads for this threadpool<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      tfb.setNameFormat(this.name + "-%d");<a name="line.177"></a>
-<span class="sourceLineNo">178</span>      this.threadPoolExecutor.setThreadFactory(tfb.build());<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    }<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>    /**<a name="line.181"></a>
-<span class="sourceLineNo">182</span>     * Submit the event to the queue for handling.<a name="line.182"></a>
-<span class="sourceLineNo">183</span>     * @param event<a name="line.183"></a>
-<span class="sourceLineNo">184</span>     */<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    void submit(final EventHandler event) {<a name="line.185"></a>
-<span class="sourceLineNo">186</span>      // If there is a listener for this type, make sure we call the before<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      // and after process methods.<a name="line.187"></a>
-<span class="sourceLineNo">188</span>      this.threadPoolExecutor.execute(event);<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    }<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    <a name="line.190"></a>
-<span class="sourceLineNo">191</span>    public String toString() {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>      return getClass().getSimpleName() + "-" + id + "-" + name;<a name="line.192"></a>
+<span class="sourceLineNo">122</span>  @VisibleForTesting<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  public ThreadPoolExecutor getExecutorThreadPool(final ExecutorType type) {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    return getExecutor(type).getThreadPoolExecutor();<a name="line.124"></a>
+<span class="sourceLineNo">125</span>  }<a name="line.125"></a>
+<span class="sourceLineNo">126</span><a name="line.126"></a>
+<span class="sourceLineNo">127</span>  public void startExecutorService(final ExecutorType type, final int maxThreads) {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    String name = type.getExecutorName(this.servername);<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    if (isExecutorServiceRunning(name)) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      LOG.debug("Executor service " + toString() + " already running on " +<a name="line.130"></a>
+<span class="sourceLineNo">131</span>          this.servername);<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      return;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    }<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    startExecutorService(name, maxThreads);<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
+<span class="sourceLineNo">136</span><a name="line.136"></a>
+<span class="sourceLineNo">137</span>  public void submit(final EventHandler eh) {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    Executor executor = getExecutor(eh.getEventType().getExecutorServiceType());<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    if (executor == null) {<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      // This happens only when events are submitted after shutdown() was<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      // called, so dropping them should be "ok" since it means we're<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      // shutting down.<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      LOG.error("Cannot submit [" + eh + "] because the executor is missing." +<a name="line.143"></a>
+<span class="sourceLineNo">144</span>        " Is this process shutting down?");<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    } else {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>      executor.submit(eh);<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    }<a name="line.147"></a>
+<span class="sourceLineNo">148</span>  }<a name="line.148"></a>
+<span class="sourceLineNo">149</span><a name="line.149"></a>
+<span class="sourceLineNo">150</span>  public Map&lt;String, ExecutorStatus&gt; getAllExecutorStatuses() {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    Map&lt;String, ExecutorStatus&gt; ret = Maps.newHashMap();<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    for (Map.Entry&lt;String, Executor&gt; e : executorMap.entrySet()) {<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      ret.put(e.getKey(), e.getValue().getStatus());<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    }<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    return ret;<a name="line.155"></a>
+<span class="sourceLineNo">156</span>  }<a name="line.156"></a>
+<span class="sourceLineNo">157</span><a name="line.157"></a>
+<span class="sourceLineNo">158</span>  /**<a name="line.158"></a>
+<span class="sourceLineNo">159</span>   * Executor instance.<a name="line.159"></a>
+<span class="sourceLineNo">160</span>   */<a name="line.160"></a>
+<span class="sourceLineNo">161</span>  static class Executor {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    // how long to retain excess threads<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    static final long keepAliveTimeInMillis = 1000;<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    // the thread pool executor that services the requests<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    final TrackingThreadPoolExecutor threadPoolExecutor;<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    // work queue to use - unbounded queue<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    final BlockingQueue&lt;Runnable&gt; q = new LinkedBlockingQueue&lt;Runnable&gt;();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    private final String name;<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    private static final AtomicLong seqids = new AtomicLong(0);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>    private final long id;<a name="line.170"></a>
+<span class="sourceLineNo">171</span><a name="line.171"></a>
+<span class="sourceLineNo">172</span>    protected Executor(String name, int maxThreads) {<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      this.id = seqids.incrementAndGet();<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      this.name = name;<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      // create the thread pool executor<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      this.threadPoolExecutor = new TrackingThreadPoolExecutor(<a name="line.176"></a>
+<span class="sourceLineNo">177</span>          maxThreads, maxThreads,<a name="line.177"></a>
+<span class="sourceLineNo">178</span>          keepAliveTimeInMillis, TimeUnit.MILLISECONDS, q);<a name="line.178"></a>
+<span class="sourceLineNo">179</span>      // name the threads for this threadpool<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      tfb.setNameFormat(this.name + "-%d");<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      this.threadPoolExecutor.setThreadFactory(tfb.build());<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    }<a name="line.183"></a>
+<span class="sourceLineNo">184</span><a name="line.184"></a>
+<span class="sourceLineNo">185</span>    /**<a name="line.185"></a>
+<span class="sourceLineNo">186</span>     * Submit the event to the queue for handling.<a name="line.186"></a>
+<span class="sourceLineNo">187</span>     * @param event<a name="line.187"></a>
+<span class="sourceLineNo">188</span>     */<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    void submit(final EventHandler event) {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      // If there is a listener for this type, make sure we call the before<a name="line.190"></a>
+<span class="sourceLineNo">191</span>      // and after process methods.<a name="line.191"></a>
+<span class="sourceLineNo">192</span>      this.threadPoolExecutor.execute(event);<a name="line.192"></a>
 <span class="sourceLineNo">193</span>    }<a name="line.193"></a>
 <span class="sourceLineNo">194</span><a name="line.194"></a>
-<span class="sourceLineNo">195</span>    public ExecutorStatus getStatus() {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      List&lt;EventHandler&gt; queuedEvents = Lists.newArrayList();<a name="line.196"></a>
-<span class="sourceLineNo">197</span>      for (Runnable r : q) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>        if (!(r instanceof EventHandler)) {<a name="line.198"></a>
-<span class="sourceLineNo">199</span>          LOG.warn("Non-EventHandler " + r + " queued in " + name);<a name="line.199"></a>
-<span class="sourceLineNo">200</span>          continue;<a name="line.200"></a>
-<span class="sourceLineNo">201</span>        }<a name="line.201"></a>
-<span class="sourceLineNo">202</span>        queuedEvents.add((EventHandler)r);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      <a name="line.204"></a>
-<span class="sourceLineNo">205</span>      List&lt;RunningEventStatus&gt; running = Lists.newArrayList();<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      for (Map.Entry&lt;Thread, Runnable&gt; e :<a name="line.206"></a>
-<span class="sourceLineNo">207</span>          threadPoolExecutor.getRunningTasks().entrySet()) {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>        Runnable r = e.getValue();<a name="line.208"></a>
-<span class="sourceLineNo">209</span>        if (!(r instanceof EventHandler)) {<a name="line.209"></a>
-<span class="sourceLineNo">210</span>          LOG.warn("Non-EventHandler " + r + " running in " + name);<a name="line.210"></a>
-<span class="sourceLineNo">211</span>          continue;<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        }<a name="line.212"></a>
-<span class="sourceLineNo">213</span>        running.add(new RunningEventStatus(e.getKey(), (EventHandler)r));<a name="line.213"></a>
-<span class="sourceLineNo">214</span>      }<a name="line.214"></a>
-<span class="sourceLineNo">215</span>      <a name="line.215"></a>
-<span class="sourceLineNo">216</span>      return new ExecutorStatus(this, queuedEvents, running);<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    }<a name="line.217"></a>
-<span class="sourceLineNo">218</span>  }<a name="line.218"></a>
-<span class="sourceLineNo">219</span> <a name="line.219"></a>
-<span class="sourceLineNo">220</span>  /**<a name="line.220"></a>
-<span class="sourceLineNo">221</span>   * A subclass of ThreadPoolExecutor that keeps track of the Runnables that<a name="line.221"></a>
-<span class="sourceLineNo">222</span>   * are executing at any given point in time.<a name="line.222"></a>
-<span class="sourceLineNo">223</span>   */<a name="line.223"></a>
-<span class="sourceLineNo">224</span>  static class TrackingThreadPoolExecutor extends ThreadPoolExecutor {<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    private ConcurrentMap&lt;Thread, Runnable&gt; running = Maps.newConcurrentMap(); <a name="line.225"></a>
-<span class="sourceLineNo">226</span>      <a name="line.226"></a>
-<span class="sourceLineNo">227</span>    public TrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize,<a name="line.227"></a>
-<span class="sourceLineNo">228</span>        long keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue) {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);<a name="line.229"></a>
-<span class="sourceLineNo">230</span>    }<a name="line.230"></a>
-<span class="sourceLineNo">231</span><a name="line.231"></a>
-<span class="sourceLineNo">232</span>    @Override<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    protected void afterExecute(Runnable r, Throwable t) {<a name="line.233"></a>
-<span class="sourceLineNo">234</span>      super.afterExecute(r, t);<a name="line.234"></a>
-<span class="sourceLineNo">235</span>      running.remove(Thread.currentThread());<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    }<a name="line.236"></a>
-<span class="sourceLineNo">237</span><a name="line.237"></a>
-<span class="sourceLineNo">238</span>    @Override<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    protected void beforeExecute(Thread t, Runnable r) {<a name="line.239"></a>
-<span class="sourceLineNo">240</span>      Runnable oldPut = running.put(t, r);<a name="line.240"></a>
-<span class="sourceLineNo">241</span>      assert oldPut == null : "inconsistency for thread " + t;<a name="line.241"></a>
-<span class="sourceLineNo">242</span>      super.beforeExecute(t, r);<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    }<a name="line.243"></a>
-<span class="sourceLineNo">244</span>   <a name="line.244"></a>
-<span class="sourceLineNo">245</span>    /**<a name="line.245"></a>
-<span class="sourceLineNo">246</span>     * @return a map of the threads currently running tasks<a name="line.246"></a>
-<span class="sourceLineNo">247</span>     * inside this executor. Each key is an active thread,<a name="line.247"></a>
-<span class="sourceLineNo">248</span>     * and the value is the task that is currently running.<a name="line.248"></a>
-<span class="sourceLineNo">249</span>     * Note that this is not a stable snapshot of the map.<a name="line.249"></a>
-<span class="sourceLineNo">250</span>     */<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    public ConcurrentMap&lt;Thread, Runnable&gt; getRunningTasks() {<a name="line.251"></a>
-<span class="sourceLineNo">252</span>      return running;<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
-<span class="sourceLineNo">254</span>  }<a name="line.254"></a>
-<span class="sourceLineNo">255</span><a name="line.255"></a>
-<span class="sourceLineNo">256</span>  /**<a name="line.256"></a>
-<span class="sourceLineNo">257</span>   * A snapshot of the status of a particular executor. This includes<a name="line.257"></a>
-<span class="sourceLineNo">258</span>   * the contents of the executor's pending queue, as well as the<a name="line.258"></a>
-<span class="sourceLineNo">259</span>   * threads and events currently being processed.<a name="line.259"></a>
-<span class="sourceLineNo">260</span>   *<a name="line.260"></a>
-<span class="sourceLineNo">261</span>   * This is a consistent snapshot that is immutable once constructed.<a name="line.261"></a>
-<span class="sourceLineNo">262</span>   */<a name="line.262"></a>
-<span class="sourceLineNo">263</span>  public static class ExecutorStatus {<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    final Executor executor;<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    final List&lt;EventHandler&gt; queuedEvents;<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    final List&lt;RunningEventStatus&gt; running;<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>    ExecutorStatus(Executor executor,<a name="line.268"></a>
-<span class="sourceLineNo">269</span>        List&lt;EventHandler&gt; queuedEvents,<a name="line.269"></a>
-<span class="sourceLineNo">270</span>        List&lt;RunningEventStatus&gt; running) {<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      this.executor = executor;<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      this.queuedEvents = queuedEvents;<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      this.running = running;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    }<a name="line.274"></a>
-<span class="sourceLineNo">275</span>   <a name="line.275"></a>
-<span class="sourceLineNo">276</span>    /**<a name="line.276"></a>
-<span class="sourceLineNo">277</span>     * Dump a textual representation of the executor's status<a name="line.277"></a>
-<span class="sourceLineNo">278</span>     * to the given writer.<a name="line.278"></a>
-<span class="sourceLineNo">279</span>     *<a name="line.279"></a>
-<span class="sourceLineNo">280</span>     * @param out the stream to write to<a name="line.280"></a>
-<span class="sourceLineNo">281</span>     * @param indent a string prefix for each line, used for indentation<a name="line.281"></a>
-<span class="sourceLineNo">282</span>     */<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    public void dumpTo(Writer out, String indent) throws IOException {<a name="line.283"></a>
-<span class="sourceLineNo">284</span>      out.write(indent + "Status for executor: " + executor + "\n");<a name="line.284"></a>
-<span class="sourceLineNo">285</span>      out.write(indent + "=======================================\n");<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      out.write(indent + queuedEvents.size() + " events queued, " +<a name="line.286"></a>
-<span class="sourceLineNo">287</span>          running.size() + " running\n");<a name="line.287"></a>
-<span class="sourceLineNo">288</span>      if (!queuedEvents.isEmpty()) {<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        out.write(indent + "Queued:\n");<a name="line.289"></a>
-<span class="sourceLineNo">290</span>        for (EventHandler e : queuedEvents) {<a name="line.290"></a>
-<span class="sourceLineNo">291</span>          out.write(indent + "  " + e + "\n");<a name="line.291"></a>
-<span class="sourceLineNo">292</span>        }<a name="line.292"></a>
-<span class="sourceLineNo">293</span>        out.write("\n");<a name="line.293"></a>
-<span class="sourceLineNo">294</span>      }<a name="line.294"></a>
-<span class="sourceLineNo">295</span>      if (!running.isEmpty()) {<a name="line.295"></a>
-<span class="sourceLineNo">296</span>        out.write(indent + "Running:\n");<a name="line.296"></a>
-<span class="sourceLineNo">297</span>        for (RunningEventStatus stat : running) {<a name="line.297"></a>
-<span class="sourceLineNo">298</span>          out.write(indent + "  Running on thread '" +<a name="line.298"></a>
-<span class="sourceLineNo">299</span>              stat.threadInfo.getThreadName() +<a name="line.299"></a>
-<span class="sourceLineNo">300</span>              "': " + stat.event + "\n");<a name="line.300"></a>
-<span class="sourceLineNo">301</span>          out.write(ThreadMonitoring.formatThreadInfo(<a name="line.301"></a>
-<span class="sourceLineNo">302</span>              stat.threadInfo, indent + "  "));<a name="line.302"></a>
-<span class="sourceLineNo">303</span>          out.write("\n");<a name="line.303"></a>
-<span class="sourceLineNo">304</span>        }<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      }<a name="line.305"></a>
-<span class="sourceLineNo">306</span>      out.flush();<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    }<a name="line.307"></a>
-<span class="sourceLineNo">308</span>  }<a name="line.308"></a>
-<span class="sourceLineNo">309</span><a name="line.309"></a>
-<span class="sourceLineNo">310</span>  /**<a name="line.310"></a>
-<span class="sourceLineNo">311</span>   * The status of a particular event that is in the middle of being<a name="line.311"></a>
-<span class="sourceLineNo">312</span>   * handled by an executor.<a name="line.312"></a>
-<span class="sourceLineNo">313</span>   */<a name="line.313"></a>
-<span class="sourceLineNo">314</span>  public static class RunningEventStatus {<a name="line.314"></a>
-<span class="sourceLineNo">315</span>    final ThreadInfo threadInfo;<a name="line.315"></a>
-<span class="sourceLineNo">316</span>    final EventHandler event;<a name="line.316"></a>
-<span class="sourceLineNo">317</span><a name="line.317"></a>
-<span class="sourceLineNo">318</span>    public RunningEventStatus(Thread t, EventHandler event) {<a name="line.318"></a>
-<span class="sourceLineNo">319</span>      this.threadInfo = ThreadMonitoring.getThreadInfo(t);<a name="line.319"></a>
-<span class="sourceLineNo">320</span>      this.event = event;<a name="line.320"></a>
-<span class="sourceLineNo">321</span>    }<a name="line.321"></a>
-<span class="sourceLineNo">322</span>  }<a name="line.322"></a>
-<span class="sourceLineNo">323</span>}<a name="line.323"></a>
+<span class="sourceLineNo">195</span>    TrackingThreadPoolExecutor getThreadPoolExecutor() {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      return threadPoolExecutor;<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    }<a name="line.197"></a>
+<span class="sourceLineNo">198</span><a name="line.198"></a>
+<span class="sourceLineNo">199</span>    @Override<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    public String toString() {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>      return getClass().getSimpleName() + "-" + id + "-" + name;<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    }<a name="line.202"></a>
+<span class="sourceLineNo">203</span><a name="line.203"></a>
+<span class="sourceLineNo">204</span>    public ExecutorStatus getStatus() {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      List&lt;EventHandler&gt; queuedEvents = Lists.newArrayList();<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      for (Runnable r : q) {<a name="line.206"></a>
+<span class="sourceLineNo">207</span>        if (!(r instanceof EventHandler)) {<a name="line.207"></a>
+<span class="sourceLineNo">208</span>          LOG.warn("Non-EventHandler " + r + " queued in " + name);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>          continue;<a name="line.209"></a>
+<span class="sourceLineNo">210</span>        }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        queuedEvents.add((EventHandler)r);<a name="line.211"></a>
+<span class="sourceLineNo">212</span>      }<a name="line.212"></a>
+<span class="sourceLineNo">213</span><a name="line.213"></a>
+<span class="sourceLineNo">214</span>      List&lt;RunningEventStatus&gt; running = Lists.newArrayList();<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      for (Map.Entry&lt;Thread, Runnable&gt; e :<a name="line.215"></a>
+<span class="sourceLineNo">216</span>          threadPoolExecutor.getRunningTasks().entrySet()) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        Runnable r = e.getValue();<a name="line.217"></a>
+<span class="sourceLineNo">218</span>        if (!(r instanceof EventHandler)) {<a name="line.218"></a>
+<span class="sourceLineNo">219</span>          LOG.warn("Non-EventHandler " + r + " running in " + name);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>          continue;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        }<a name="line.221"></a>
+<span class="sourceLineNo">222</span>        running.add(new RunningEventStatus(e.getKey(), (EventHandler)r));<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      }<a name="line.223"></a>
+<span class="sourceLineNo">224</span><a name="line.224"></a>
+<span class="sourceLineNo">225</span>      return new ExecutorStatus(this, queuedEvents, running);<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    }<a name="line.226"></a>
+<span class="sourceLineNo">227</span>  }<a name="line.227"></a>
+<span class="sourceLineNo">228</span><a name="line.228"></a>
+<span class="sourceLineNo">229</span>  /**<a name="line.229"></a>
+<span class="sourceLineNo">230</span>   * A subclass of ThreadPoolExecutor that keeps track of the Runnables that<a name="line.230"></a>
+<span class="sourceLineNo">231</span>   * are executing at any given point in time.<a name="line.231"></a>
+<span class="sourceLineNo">232</span>   */<a name="line.232"></a>
+<span class="sourceLineNo">233</span>  static class TrackingThreadPoolExecutor extends ThreadPoolExecutor {<a name="line.233"></a>
+<span class="sourceLineNo">234</span>    private ConcurrentMap&lt;Thread, Runnable&gt; running = Maps.newConcurrentMap();<a name="line.234"></a>
+<span class="sourceLineNo">235</span><a name="line.235"></a>
+<span class="sourceLineNo">236</span>    public TrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize,<a name="line.236"></a>
+<span class="sourceLineNo">237</span>        long keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue) {<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    }<a name="line.239"></a>
+<span class="sourceLineNo">240</span><a name="line.240"></a>
+<span class="sourceLineNo">241</span>    @Override<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    protected void afterExecute(Runnable r, Throwable t) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      super.afterExecute(r, t);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      running.remove(Thread.currentThread());<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    }<a name="line.245"></a>
+<span class="sourceLineNo">246</span><a name="line.246"></a>
+<span class="sourceLineNo">247</span>    @Override<a name="line.247"></a>
+<span class="sourceLineNo">248</span>    protected void beforeExecute(Thread t, Runnable r) {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>      Runnable oldPut = running.put(t, r);<a name="line.249"></a>
+<span class="sourceLineNo">250</span>      assert oldPut == null : "inconsistency for thread " + t;<a name="line.250"></a>
+<span class="sourceLineNo">251</span>      super.beforeExecute(t, r);<a name="line.251"></a>
+<span class="sourceLineNo">252</span>    }<a name="line.252"></a>
+<span class="sourceLineNo">253</span><a name="line.253"></a>
+<span class="sourceLineNo">254</span>    /**<a name="line.254"></a>
+<span class="sourceLineNo">255</span>     * @return a map of the threads currently running tasks<a name="line.255"></a>
+<span class="sourceLineNo">256</span>     * inside this executor. Each key is an active thread,<a name="line.256"></a>
+<span class="sourceLineNo">257</span>     * and the value is the task that is currently running.<a name="line.257"></a>
+<span class="sourceLineNo">258</span>     * Note that this is not a stable snapshot of the map.<a name="line.258"></a>
+<span class="sourceLineNo">259</span>     */<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    public ConcurrentMap&lt;Thread, Runnable&gt; getRunningTasks() {<a name="line.260"></a>
+<span class="sourceLineNo">261</span>      return running;<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    }<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  }<a name="line.263"></a>
+<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">265</span>  /**<a name="line.265"></a>
+<span class="sourceLineNo">266</span>   * A snapshot of the status of a particular executor. This includes<a name="line.266"></a>
+<span class="sourceLineNo">267</span>   * the contents of the executor's pending queue, as well as the<a name="line.267"></a>
+<span class="sourceLineNo">268</span>   * threads and events currently being processed.<a name="line.268"></a>
+<span class="sourceLineNo">269</span>   *<a name="line.269"></a>
+<span class="sourceLineNo">270</span>   * This is a consistent snapshot that is immutable once constructed.<a name="line.270"></a>
+<span class="sourceLineNo">271</span>   */<a name="line.271"></a>
+<span class="sourceLineNo">272</span>  public static class ExecutorStatus {<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    final Executor executor;<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    final List&lt;EventHandler&gt; queuedEvents;<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    final List&lt;RunningEventStatus&gt; running;<a name="line.275"></a>
+<span class="sourceLineNo">276</span><a name="line.276"></a>
+<span class="sourceLineNo">277</span>    ExecutorStatus(Executor executor,<a name="line.277"></a>
+<span class="sourceLineNo">278</span>        List&lt;EventHandler&gt; queuedEvents,<a name="line.278"></a>
+<span class="sourceLineNo">279</span>        List&lt;RunningEventStatus&gt; running) {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      this.executor = executor;<a name="line.280"></a>
+<span class="sourceLineNo">281</span>      this.queuedEvents = queuedEvents;<a name="line.281"></a>
+<span class="sourceLineNo">282</span>      this.running = running;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>    }<a name="line.283"></a>
+<span class="sourceLineNo">284</span><a name="line.284"></a>
+<span class="sourceLineNo">285</span>    /**<a name="line.285"></a>
+<span class="sourceLineNo">286</span>     * Dump a textual representation of the executor's status<a name="line.286"></a>
+<span class="sourceLineNo">287</span>     * to the given writer.<a name="line.287"></a>
+<span class="sourceLineNo">288</span>     *<a name="line.288"></a>
+<span class="sourceLineNo">289</span>     * @param out the stream to write to<a name="line.289"></a>
+<span class="sourceLineNo">290</span>     * @param indent a string prefix for each line, used for indentation<a name="line.290"></a>
+<span class="sourceLineNo">291</span>     */<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    public void dumpTo(Writer out, String indent) throws IOException {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      out.write(indent + "Status for executor: " + executor + "\n");<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      out.write(indent + "=======================================\n");<a name="line.294"></a>
+<span class="sourceLineNo">295</span>      out.write(indent + queuedEvents.size() + " events queued, " +<a name="line.295"></a>
+<span class="sourceLineNo">296</span>          running.size() + " running\n");<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      if (!queuedEvents.isEmpty()) {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        out.write(indent + "Queued:\n");<a name="line.298"></a>
+<span class="sourceLineNo">299</span>        for (EventHandler e : queuedEvents) {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>          out.write(indent + "  " + e + "\n");<a name="line.300"></a>
+<span class="sourceLineNo">301</span>        }<a name="line.301"></a>
+<span class="sourceLineNo">302</span>        out.write("\n");<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      }<a name="line.303"></a>
+<span class="sourceLineNo">304</span>      if (!running.isEmpty()) {<a name="line.304"></a>
+<span class="sourceLineNo">305</span>        out.write(indent + "Running:\n");<a name="line.305"></a>
+<span class="sourceLineNo">306</span>        for (RunningEventStatus stat : running) {<a name="line.306"></a>
+<span class="sourceLineNo">307</span>          out.write(indent + "  Running on thread '" +<a name="line.307"></a>
+<span class="sourceLineNo">308</span>              stat.threadInfo.getThreadName() +<a name="line.308"></a>
+<span class="sourceLineNo">309</span>              "': " + stat.event + "\n");<a name="line.309"></a>
+<span class="sourceLineNo">310</span>          out.write(ThreadMonitoring.formatThreadInfo(<a name="line.310"></a>
+<span class="sourceLineNo">311</span>              stat.threadInfo, indent + "  "));<a name="line.311"></a>
+<span class="sourceLineNo">312</span>          out.write("\n");<a name="line.312"></a>
+<span class="sourceLineNo">313</span>        }<a name="line.313"></a>
+<span class="sourceLineNo">314</span>      }<a name="line.314"></a>
+<span class="sourceLineNo">315</span>      out.flush();<a name="line.315"></a>
+<span class="sourceLineNo">316</span>    }<a name="line.316"></a>
+<span class="sourceLineNo">317</span>  }<a name="line.317"></a>
+<span class="sourceLineNo">318</span><a name="line.318"></a>
+<span class="sourceLineNo">319</span>  /**<a name="line.319"></a>
+<span class="sourceLineNo">320</span>   * The status of a particular event that is in the middle of being<a name="line.320"></a>
+<span class="sourceLineNo">321</span>   * handled by an executor.<a name="line.321"></a>
+<span class="sourceLineNo">322</span>   */<a name="line.322"></a>
+<span class="sourceLineNo">323</span>  public static class RunningEventStatus {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    final ThreadInfo threadInfo;<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    final EventHandler event;<a name="line.325"></a>
+<span class="sourceLineNo">326</span><a name="line.326"></a>
+<span class="sourceLineNo">327</span>    public RunningEventStatus(Thread t, EventHandler event) {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      this.threadInfo = ThreadMonitoring.getThreadInfo(t);<a name="line.328"></a>
+<span class="sourceLineNo">329</span>      this.event = event;<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    }<a name="line.330"></a>
+<span class="sourceLineNo">331</span>  }<a name="line.331"></a>
+<span class="sourceLineNo">332</span>}<a name="line.332"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/975096b1/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorType.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorType.html b/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorType.html
index 7d12685..c893d0b 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorType.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/executor/ExecutorType.html
@@ -55,18 +55,19 @@
 <span class="sourceLineNo">047</span>  RS_PARALLEL_SEEK           (26),<a name="line.47"></a>
 <span class="sourceLineNo">048</span>  RS_LOG_REPLAY_OPS          (27),<a name="line.48"></a>
 <span class="sourceLineNo">049</span>  RS_REGION_REPLICA_FLUSH_OPS  (28),<a name="line.49"></a>
-<span class="sourceLineNo">050</span>  RS_COMPACTED_FILES_DISCHARGER (29);<a name="line.50"></a>
-<span class="sourceLineNo">051</span><a name="line.51"></a>
-<span class="sourceLineNo">052</span>  ExecutorType(int value) {}<a name="line.52"></a>
-<span class="sourceLineNo">053</span><a name="line.53"></a>
-<span class="sourceLineNo">054</span>  /**<a name="line.54"></a>
-<span class="sourceLineNo">055</span>   * @param serverName<a name="line.55"></a>
-<span class="sourceLineNo">056</span>   * @return Conflation of the executor type and the passed servername.<a name="line.56"></a>
-<span class="sourceLineNo">057</span>   */<a name="line.57"></a>
-<span class="sourceLineNo">058</span>  String getExecutorName(String serverName) {<a name="line.58"></a>
-<span class="sourceLineNo">059</span>    return this.toString() + "-" + serverName.replace("%", "%%");<a name="line.59"></a>
-<span class="sourceLineNo">060</span>  }<a name="line.60"></a>
-<span class="sourceLineNo">061</span>}<a name="line.61"></a>
+<span class="sourceLineNo">050</span>  RS_COMPACTED_FILES_DISCHARGER (29),<a name="line.50"></a>
+<span class="sourceLineNo">051</span>  RS_OPEN_PRIORITY_REGION    (30);<a name="line.51"></a>
+<span class="sourceLineNo">052</span><a name="line.52"></a>
+<span class="sourceLineNo">053</span>  ExecutorType(int value) {}<a name="line.53"></a>
+<span class="sourceLineNo">054</span><a name="line.54"></a>
+<span class="sourceLineNo">055</span>  /**<a name="line.55"></a>
+<span class="sourceLineNo">056</span>   * @param serverName<a name="line.56"></a>
+<span class="sourceLineNo">057</span>   * @return Conflation of the executor type and the passed servername.<a name="line.57"></a>
+<span class="sourceLineNo">058</span>   */<a name="line.58"></a>
+<span class="sourceLineNo">059</span>  String getExecutorName(String serverName) {<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    return this.toString() + "-" + serverName.replace("%", "%%");<a name="line.60"></a>
+<span class="sourceLineNo">061</span>  }<a name="line.61"></a>
+<span class="sourceLineNo">062</span>}<a name="line.62"></a>
 
 
 


Mime
View raw message