hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [19/39] hbase-site git commit: Published site at 66469733ec9bffb236c143b858e5748182ad71b3.
Date Thu, 25 Oct 2018 14:54:56 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/client/example/RefreshHFilesClient.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/example/RefreshHFilesClient.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/example/RefreshHFilesClient.html
index 4e0832e..0c6debe 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/example/RefreshHFilesClient.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/example/RefreshHFilesClient.html
@@ -30,78 +30,106 @@
 <span class="sourceLineNo">022</span>import java.io.Closeable;<a name="line.22"></a>
 <span class="sourceLineNo">023</span>import java.io.IOException;<a name="line.23"></a>
 <span class="sourceLineNo">024</span>import org.apache.hadoop.conf.Configuration;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.HConstants;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.TableName;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.client.ConnectionFactory;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.client.Table;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.client.coprocessor.Batch;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils.BlockingRpcCallback;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.ipc.ServerRpcController;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.protobuf.generated.RefreshHFilesProtos;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.slf4j.Logger;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.slf4j.LoggerFactory;<a name="line.36"></a>
-<span class="sourceLineNo">037</span><a name="line.37"></a>
-<span class="sourceLineNo">038</span>/**<a name="line.38"></a>
-<span class="sourceLineNo">039</span> * This client class is for invoking the refresh HFile function deployed on the<a name="line.39"></a>
-<span class="sourceLineNo">040</span> * Region Server side via the RefreshHFilesService.<a name="line.40"></a>
-<span class="sourceLineNo">041</span> */<a name="line.41"></a>
-<span class="sourceLineNo">042</span>@InterfaceAudience.Private<a name="line.42"></a>
-<span class="sourceLineNo">043</span>public class RefreshHFilesClient implements Closeable {<a name="line.43"></a>
-<span class="sourceLineNo">044</span>  private static final Logger LOG = LoggerFactory.getLogger(RefreshHFilesClient.class);<a name="line.44"></a>
-<span class="sourceLineNo">045</span>  private final Connection connection;<a name="line.45"></a>
-<span class="sourceLineNo">046</span><a name="line.46"></a>
-<span class="sourceLineNo">047</span>  /**<a name="line.47"></a>
-<span class="sourceLineNo">048</span>   * Constructor with Conf object<a name="line.48"></a>
-<span class="sourceLineNo">049</span>   *<a name="line.49"></a>
-<span class="sourceLineNo">050</span>   * @param cfg<a name="line.50"></a>
-<span class="sourceLineNo">051</span>   */<a name="line.51"></a>
-<span class="sourceLineNo">052</span>  public RefreshHFilesClient(Configuration cfg) {<a name="line.52"></a>
-<span class="sourceLineNo">053</span>    try {<a name="line.53"></a>
-<span class="sourceLineNo">054</span>      this.connection = ConnectionFactory.createConnection(cfg);<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    } catch (IOException e) {<a name="line.55"></a>
-<span class="sourceLineNo">056</span>      throw new RuntimeException(e);<a name="line.56"></a>
-<span class="sourceLineNo">057</span>    }<a name="line.57"></a>
-<span class="sourceLineNo">058</span>  }<a name="line.58"></a>
-<span class="sourceLineNo">059</span><a name="line.59"></a>
-<span class="sourceLineNo">060</span>  @Override<a name="line.60"></a>
-<span class="sourceLineNo">061</span>  public void close() throws IOException {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>    if (this.connection != null &amp;&amp; !this.connection.isClosed()) {<a name="line.62"></a>
-<span class="sourceLineNo">063</span>      this.connection.close();<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    }<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  }<a name="line.65"></a>
-<span class="sourceLineNo">066</span><a name="line.66"></a>
-<span class="sourceLineNo">067</span>  public void refreshHFiles(final TableName tableName) throws Throwable {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    try (Table table = connection.getTable(tableName)) {<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      refreshHFiles(table);<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    }<a name="line.70"></a>
-<span class="sourceLineNo">071</span>  }<a name="line.71"></a>
-<span class="sourceLineNo">072</span><a name="line.72"></a>
-<span class="sourceLineNo">073</span>  public void refreshHFiles(final Table table) throws Throwable {<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    final RefreshHFilesProtos.RefreshHFilesRequest request = RefreshHFilesProtos.RefreshHFilesRequest<a name="line.74"></a>
-<span class="sourceLineNo">075</span>                                                               .getDefaultInstance();<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    table.coprocessorService(RefreshHFilesProtos.RefreshHFilesService.class, HConstants.EMPTY_START_ROW,<a name="line.76"></a>
-<span class="sourceLineNo">077</span>                             HConstants.EMPTY_END_ROW,<a name="line.77"></a>
-<span class="sourceLineNo">078</span>                             new Batch.Call&lt;RefreshHFilesProtos.RefreshHFilesService,<a name="line.78"></a>
-<span class="sourceLineNo">079</span>                                             RefreshHFilesProtos.RefreshHFilesResponse&gt;() {<a name="line.79"></a>
-<span class="sourceLineNo">080</span>                               @Override<a name="line.80"></a>
-<span class="sourceLineNo">081</span>                               public RefreshHFilesProtos.RefreshHFilesResponse call(<a name="line.81"></a>
-<span class="sourceLineNo">082</span>                                 RefreshHFilesProtos.RefreshHFilesService refreshHFilesService)<a name="line.82"></a>
-<span class="sourceLineNo">083</span>                                 throws IOException {<a name="line.83"></a>
-<span class="sourceLineNo">084</span>                                 ServerRpcController controller = new ServerRpcController();<a name="line.84"></a>
-<span class="sourceLineNo">085</span>                                 BlockingRpcCallback&lt;RefreshHFilesProtos.RefreshHFilesResponse&gt; rpcCallback =<a name="line.85"></a>
-<span class="sourceLineNo">086</span>                                   new BlockingRpcCallback&lt;&gt;();<a name="line.86"></a>
-<span class="sourceLineNo">087</span>                                 refreshHFilesService.refreshHFiles(controller, request, rpcCallback);<a name="line.87"></a>
-<span class="sourceLineNo">088</span>                                 if (controller.failedOnException()) {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>                                   throw controller.getFailedOn();<a name="line.89"></a>
-<span class="sourceLineNo">090</span>                                 }<a name="line.90"></a>
-<span class="sourceLineNo">091</span>                                 return rpcCallback.get();<a name="line.91"></a>
-<span class="sourceLineNo">092</span>                               }<a name="line.92"></a>
-<span class="sourceLineNo">093</span>                             });<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    LOG.debug("Done refreshing HFiles");<a name="line.94"></a>
-<span class="sourceLineNo">095</span>  }<a name="line.95"></a>
-<span class="sourceLineNo">096</span>}<a name="line.96"></a>
+<span class="sourceLineNo">025</span>import org.apache.hadoop.conf.Configured;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HConstants;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.TableName;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.client.ConnectionFactory;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.client.Table;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.coprocessor.Batch;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils.BlockingRpcCallback;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.ipc.ServerRpcController;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.protobuf.generated.RefreshHFilesProtos;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.util.Tool;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.util.ToolRunner;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.slf4j.Logger;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.slf4j.LoggerFactory;<a name="line.40"></a>
+<span class="sourceLineNo">041</span><a name="line.41"></a>
+<span class="sourceLineNo">042</span>/**<a name="line.42"></a>
+<span class="sourceLineNo">043</span> * This client class is for invoking the refresh HFile function deployed on the<a name="line.43"></a>
+<span class="sourceLineNo">044</span> * Region Server side via the RefreshHFilesService.<a name="line.44"></a>
+<span class="sourceLineNo">045</span> */<a name="line.45"></a>
+<span class="sourceLineNo">046</span>@InterfaceAudience.Private<a name="line.46"></a>
+<span class="sourceLineNo">047</span>public class RefreshHFilesClient extends Configured implements Tool, Closeable {<a name="line.47"></a>
+<span class="sourceLineNo">048</span>  private static final Logger LOG = LoggerFactory.getLogger(RefreshHFilesClient.class);<a name="line.48"></a>
+<span class="sourceLineNo">049</span>  private final Connection connection;<a name="line.49"></a>
+<span class="sourceLineNo">050</span><a name="line.50"></a>
+<span class="sourceLineNo">051</span>  /**<a name="line.51"></a>
+<span class="sourceLineNo">052</span>   * Constructor with Conf object<a name="line.52"></a>
+<span class="sourceLineNo">053</span>   *<a name="line.53"></a>
+<span class="sourceLineNo">054</span>   * @param cfg<a name="line.54"></a>
+<span class="sourceLineNo">055</span>   */<a name="line.55"></a>
+<span class="sourceLineNo">056</span>  public RefreshHFilesClient(Configuration cfg) {<a name="line.56"></a>
+<span class="sourceLineNo">057</span>    try {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>      this.connection = ConnectionFactory.createConnection(cfg);<a name="line.58"></a>
+<span class="sourceLineNo">059</span>    } catch (IOException e) {<a name="line.59"></a>
+<span class="sourceLineNo">060</span>      throw new RuntimeException(e);<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>
+<span class="sourceLineNo">063</span><a name="line.63"></a>
+<span class="sourceLineNo">064</span>  @Override<a name="line.64"></a>
+<span class="sourceLineNo">065</span>  public void close() throws IOException {<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    if (this.connection != null &amp;&amp; !this.connection.isClosed()) {<a name="line.66"></a>
+<span class="sourceLineNo">067</span>      this.connection.close();<a name="line.67"></a>
+<span class="sourceLineNo">068</span>    }<a name="line.68"></a>
+<span class="sourceLineNo">069</span>  }<a name="line.69"></a>
+<span class="sourceLineNo">070</span><a name="line.70"></a>
+<span class="sourceLineNo">071</span>  public void refreshHFiles(final TableName tableName) throws Throwable {<a name="line.71"></a>
+<span class="sourceLineNo">072</span>    try (Table table = connection.getTable(tableName)) {<a name="line.72"></a>
+<span class="sourceLineNo">073</span>      refreshHFiles(table);<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    }<a name="line.74"></a>
+<span class="sourceLineNo">075</span>  }<a name="line.75"></a>
+<span class="sourceLineNo">076</span><a name="line.76"></a>
+<span class="sourceLineNo">077</span>  public void refreshHFiles(final Table table) throws Throwable {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    final RefreshHFilesProtos.RefreshHFilesRequest request = RefreshHFilesProtos.RefreshHFilesRequest<a name="line.78"></a>
+<span class="sourceLineNo">079</span>                                                               .getDefaultInstance();<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    table.coprocessorService(RefreshHFilesProtos.RefreshHFilesService.class, HConstants.EMPTY_START_ROW,<a name="line.80"></a>
+<span class="sourceLineNo">081</span>                             HConstants.EMPTY_END_ROW,<a name="line.81"></a>
+<span class="sourceLineNo">082</span>                             new Batch.Call&lt;RefreshHFilesProtos.RefreshHFilesService,<a name="line.82"></a>
+<span class="sourceLineNo">083</span>                                             RefreshHFilesProtos.RefreshHFilesResponse&gt;() {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>                               @Override<a name="line.84"></a>
+<span class="sourceLineNo">085</span>                               public RefreshHFilesProtos.RefreshHFilesResponse call(<a name="line.85"></a>
+<span class="sourceLineNo">086</span>                                 RefreshHFilesProtos.RefreshHFilesService refreshHFilesService)<a name="line.86"></a>
+<span class="sourceLineNo">087</span>                                 throws IOException {<a name="line.87"></a>
+<span class="sourceLineNo">088</span>                                 ServerRpcController controller = new ServerRpcController();<a name="line.88"></a>
+<span class="sourceLineNo">089</span>                                 BlockingRpcCallback&lt;RefreshHFilesProtos.RefreshHFilesResponse&gt; rpcCallback =<a name="line.89"></a>
+<span class="sourceLineNo">090</span>                                   new BlockingRpcCallback&lt;&gt;();<a name="line.90"></a>
+<span class="sourceLineNo">091</span>                                 refreshHFilesService.refreshHFiles(controller, request, rpcCallback);<a name="line.91"></a>
+<span class="sourceLineNo">092</span>                                 if (controller.failedOnException()) {<a name="line.92"></a>
+<span class="sourceLineNo">093</span>                                   throw controller.getFailedOn();<a name="line.93"></a>
+<span class="sourceLineNo">094</span>                                 }<a name="line.94"></a>
+<span class="sourceLineNo">095</span>                                 return rpcCallback.get();<a name="line.95"></a>
+<span class="sourceLineNo">096</span>                               }<a name="line.96"></a>
+<span class="sourceLineNo">097</span>                             });<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    LOG.debug("Done refreshing HFiles");<a name="line.98"></a>
+<span class="sourceLineNo">099</span>  }<a name="line.99"></a>
+<span class="sourceLineNo">100</span><a name="line.100"></a>
+<span class="sourceLineNo">101</span>  @Override<a name="line.101"></a>
+<span class="sourceLineNo">102</span>  public int run(String[] args) throws Exception {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    if (args.length != 1) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>      String message = "When there are multiple HBase clusters are sharing a common root dir, "<a name="line.104"></a>
+<span class="sourceLineNo">105</span>          + "especially for read replica cluster (see detail in HBASE-18477), please consider to "<a name="line.105"></a>
+<span class="sourceLineNo">106</span>          + "use this tool manually sync the flushed HFiles from the source cluster.";<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      message += "\nUsage: " + this.getClass().getName() + " tableName";<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      System.out.println(message);<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      return -1;<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    }<a name="line.110"></a>
+<span class="sourceLineNo">111</span>    final TableName tableName = TableName.valueOf(args[0]);<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    try {<a name="line.112"></a>
+<span class="sourceLineNo">113</span>      refreshHFiles(tableName);<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    } catch (Throwable t) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      LOG.error("Refresh HFiles from table " + tableName.getNameAsString() + "  failed: ", t);<a name="line.115"></a>
+<span class="sourceLineNo">116</span>      return -1;<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    }<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    return 0;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>  }<a name="line.119"></a>
+<span class="sourceLineNo">120</span><a name="line.120"></a>
+<span class="sourceLineNo">121</span>  public static void main(String[] args) throws Exception {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    ToolRunner.run(new RefreshHFilesClient(HBaseConfiguration.create()), args);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  }<a name="line.123"></a>
+<span class="sourceLineNo">124</span>}<a name="line.124"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionChore.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionChore.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionChore.html
index 7e9572c..801dc55 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionChore.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionChore.html
@@ -139,7 +139,7 @@
 <span class="sourceLineNo">131</span><a name="line.131"></a>
 <span class="sourceLineNo">132</span>  public static final String ASSIGN_MAX_ATTEMPTS =<a name="line.132"></a>
 <span class="sourceLineNo">133</span>      "hbase.assignment.maximum.attempts";<a name="line.133"></a>
-<span class="sourceLineNo">134</span>  private static final int DEFAULT_ASSIGN_MAX_ATTEMPTS = 10;<a name="line.134"></a>
+<span class="sourceLineNo">134</span>  private static final int DEFAULT_ASSIGN_MAX_ATTEMPTS = Integer.MAX_VALUE;<a name="line.134"></a>
 <span class="sourceLineNo">135</span><a name="line.135"></a>
 <span class="sourceLineNo">136</span>  /** Region in Transition metrics threshold time */<a name="line.136"></a>
 <span class="sourceLineNo">137</span>  public static final String METRICS_RIT_STUCK_WARNING_THRESHOLD =<a name="line.137"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionStat.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionStat.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionStat.html
index 7e9572c..801dc55 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionStat.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.RegionInTransitionStat.html
@@ -139,7 +139,7 @@
 <span class="sourceLineNo">131</span><a name="line.131"></a>
 <span class="sourceLineNo">132</span>  public static final String ASSIGN_MAX_ATTEMPTS =<a name="line.132"></a>
 <span class="sourceLineNo">133</span>      "hbase.assignment.maximum.attempts";<a name="line.133"></a>
-<span class="sourceLineNo">134</span>  private static final int DEFAULT_ASSIGN_MAX_ATTEMPTS = 10;<a name="line.134"></a>
+<span class="sourceLineNo">134</span>  private static final int DEFAULT_ASSIGN_MAX_ATTEMPTS = Integer.MAX_VALUE;<a name="line.134"></a>
 <span class="sourceLineNo">135</span><a name="line.135"></a>
 <span class="sourceLineNo">136</span>  /** Region in Transition metrics threshold time */<a name="line.136"></a>
 <span class="sourceLineNo">137</span>  public static final String METRICS_RIT_STUCK_WARNING_THRESHOLD =<a name="line.137"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.html
index 7e9572c..801dc55 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/AssignmentManager.html
@@ -139,7 +139,7 @@
 <span class="sourceLineNo">131</span><a name="line.131"></a>
 <span class="sourceLineNo">132</span>  public static final String ASSIGN_MAX_ATTEMPTS =<a name="line.132"></a>
 <span class="sourceLineNo">133</span>      "hbase.assignment.maximum.attempts";<a name="line.133"></a>
-<span class="sourceLineNo">134</span>  private static final int DEFAULT_ASSIGN_MAX_ATTEMPTS = 10;<a name="line.134"></a>
+<span class="sourceLineNo">134</span>  private static final int DEFAULT_ASSIGN_MAX_ATTEMPTS = Integer.MAX_VALUE;<a name="line.134"></a>
 <span class="sourceLineNo">135</span><a name="line.135"></a>
 <span class="sourceLineNo">136</span>  /** Region in Transition metrics threshold time */<a name="line.136"></a>
 <span class="sourceLineNo">137</span>  public static final String METRICS_RIT_STUCK_WARNING_THRESHOLD =<a name="line.137"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.html
index 387eb34..9ee37c0 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/AbstractProcedureScheduler.html
@@ -94,209 +94,219 @@
 <span class="sourceLineNo">086</span>  }<a name="line.86"></a>
 <span class="sourceLineNo">087</span><a name="line.87"></a>
 <span class="sourceLineNo">088</span>  @Override<a name="line.88"></a>
-<span class="sourceLineNo">089</span>  public void addFront(Iterator&lt;Procedure&gt; procedureIterator) {<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    schedLock();<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    try {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>      int count = 0;<a name="line.92"></a>
-<span class="sourceLineNo">093</span>      while (procedureIterator.hasNext()) {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        Procedure procedure = procedureIterator.next();<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        if (LOG.isTraceEnabled()) {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>          LOG.trace("Wake " + procedure);<a name="line.96"></a>
-<span class="sourceLineNo">097</span>        }<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        push(procedure, /* addFront= */ true, /* notify= */false);<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        count++;<a name="line.99"></a>
-<span class="sourceLineNo">100</span>      }<a name="line.100"></a>
-<span class="sourceLineNo">101</span>      wakePollIfNeeded(count);<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    } finally {<a name="line.102"></a>
-<span class="sourceLineNo">103</span>      schedUnlock();<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    }<a name="line.104"></a>
-<span class="sourceLineNo">105</span>  }<a name="line.105"></a>
-<span class="sourceLineNo">106</span><a name="line.106"></a>
-<span class="sourceLineNo">107</span>  @Override<a name="line.107"></a>
-<span class="sourceLineNo">108</span>  public void addBack(final Procedure procedure) {<a name="line.108"></a>
-<span class="sourceLineNo">109</span>    push(procedure, false, true);<a name="line.109"></a>
+<span class="sourceLineNo">089</span>  public void addFront(final Procedure procedure, boolean notify) {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    push(procedure, true, notify);<a name="line.90"></a>
+<span class="sourceLineNo">091</span>  }<a name="line.91"></a>
+<span class="sourceLineNo">092</span><a name="line.92"></a>
+<span class="sourceLineNo">093</span>  @Override<a name="line.93"></a>
+<span class="sourceLineNo">094</span>  public void addFront(Iterator&lt;Procedure&gt; procedureIterator) {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>    schedLock();<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    try {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      int count = 0;<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      while (procedureIterator.hasNext()) {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        Procedure procedure = procedureIterator.next();<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        if (LOG.isTraceEnabled()) {<a name="line.100"></a>
+<span class="sourceLineNo">101</span>          LOG.trace("Wake " + procedure);<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        }<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        push(procedure, /* addFront= */ true, /* notify= */false);<a name="line.103"></a>
+<span class="sourceLineNo">104</span>        count++;<a name="line.104"></a>
+<span class="sourceLineNo">105</span>      }<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      wakePollIfNeeded(count);<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    } finally {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      schedUnlock();<a name="line.108"></a>
+<span class="sourceLineNo">109</span>    }<a name="line.109"></a>
 <span class="sourceLineNo">110</span>  }<a name="line.110"></a>
 <span class="sourceLineNo">111</span><a name="line.111"></a>
-<span class="sourceLineNo">112</span>  protected void push(final Procedure procedure, final boolean addFront, final boolean notify) {<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    schedLock();<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    try {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>      enqueue(procedure, addFront);<a name="line.115"></a>
-<span class="sourceLineNo">116</span>      if (notify) {<a name="line.116"></a>
-<span class="sourceLineNo">117</span>        schedWaitCond.signal();<a name="line.117"></a>
-<span class="sourceLineNo">118</span>      }<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    } finally {<a name="line.119"></a>
-<span class="sourceLineNo">120</span>      schedUnlock();<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><a name="line.123"></a>
-<span class="sourceLineNo">124</span>  // ==========================================================================<a name="line.124"></a>
-<span class="sourceLineNo">125</span>  //  Poll related<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  // ==========================================================================<a name="line.126"></a>
-<span class="sourceLineNo">127</span>  /**<a name="line.127"></a>
-<span class="sourceLineNo">128</span>   * Fetch one Procedure from the queue<a name="line.128"></a>
-<span class="sourceLineNo">129</span>   * NOTE: this method is called with the sched lock held.<a name="line.129"></a>
-<span class="sourceLineNo">130</span>   * @return the Procedure to execute, or null if nothing is available.<a name="line.130"></a>
-<span class="sourceLineNo">131</span>   */<a name="line.131"></a>
-<span class="sourceLineNo">132</span>  protected abstract Procedure dequeue();<a name="line.132"></a>
+<span class="sourceLineNo">112</span>  @Override<a name="line.112"></a>
+<span class="sourceLineNo">113</span>  public void addBack(final Procedure procedure) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    push(procedure, false, true);<a name="line.114"></a>
+<span class="sourceLineNo">115</span>  }<a name="line.115"></a>
+<span class="sourceLineNo">116</span><a name="line.116"></a>
+<span class="sourceLineNo">117</span>  @Override<a name="line.117"></a>
+<span class="sourceLineNo">118</span>  public void addBack(final Procedure procedure, boolean notify) {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    push(procedure, false, notify);<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>  protected void push(final Procedure procedure, final boolean addFront, final boolean notify) {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    schedLock();<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    try {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>      enqueue(procedure, addFront);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      if (notify) {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        schedWaitCond.signal();<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      }<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    } finally {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      schedUnlock();<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><a name="line.133"></a>
-<span class="sourceLineNo">134</span>  @Override<a name="line.134"></a>
-<span class="sourceLineNo">135</span>  public Procedure poll() {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>    return poll(-1);<a name="line.136"></a>
-<span class="sourceLineNo">137</span>  }<a name="line.137"></a>
-<span class="sourceLineNo">138</span><a name="line.138"></a>
-<span class="sourceLineNo">139</span>  @Override<a name="line.139"></a>
-<span class="sourceLineNo">140</span>  public Procedure poll(long timeout, TimeUnit unit) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    return poll(unit.toNanos(timeout));<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  }<a name="line.142"></a>
+<span class="sourceLineNo">134</span>  // ==========================================================================<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  //  Poll related<a name="line.135"></a>
+<span class="sourceLineNo">136</span>  // ==========================================================================<a name="line.136"></a>
+<span class="sourceLineNo">137</span>  /**<a name="line.137"></a>
+<span class="sourceLineNo">138</span>   * Fetch one Procedure from the queue<a name="line.138"></a>
+<span class="sourceLineNo">139</span>   * NOTE: this method is called with the sched lock held.<a name="line.139"></a>
+<span class="sourceLineNo">140</span>   * @return the Procedure to execute, or null if nothing is available.<a name="line.140"></a>
+<span class="sourceLineNo">141</span>   */<a name="line.141"></a>
+<span class="sourceLineNo">142</span>  protected abstract Procedure dequeue();<a name="line.142"></a>
 <span class="sourceLineNo">143</span><a name="line.143"></a>
-<span class="sourceLineNo">144</span>  @edu.umd.cs.findbugs.annotations.SuppressWarnings("WA_AWAIT_NOT_IN_LOOP")<a name="line.144"></a>
-<span class="sourceLineNo">145</span>  public Procedure poll(final long nanos) {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    schedLock();<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    try {<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      if (!running) {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>        LOG.debug("the scheduler is not running");<a name="line.149"></a>
-<span class="sourceLineNo">150</span>        return null;<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      }<a name="line.151"></a>
-<span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>      if (!queueHasRunnables()) {<a name="line.153"></a>
-<span class="sourceLineNo">154</span>        // WA_AWAIT_NOT_IN_LOOP: we are not in a loop because we want the caller<a name="line.154"></a>
-<span class="sourceLineNo">155</span>        // to take decisions after a wake/interruption.<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        if (nanos &lt; 0) {<a name="line.156"></a>
-<span class="sourceLineNo">157</span>          schedWaitCond.await();<a name="line.157"></a>
-<span class="sourceLineNo">158</span>        } else {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>          schedWaitCond.awaitNanos(nanos);<a name="line.159"></a>
-<span class="sourceLineNo">160</span>        }<a name="line.160"></a>
-<span class="sourceLineNo">161</span>        if (!queueHasRunnables()) {<a name="line.161"></a>
-<span class="sourceLineNo">162</span>          nullPollCalls++;<a name="line.162"></a>
-<span class="sourceLineNo">163</span>          return null;<a name="line.163"></a>
-<span class="sourceLineNo">164</span>        }<a name="line.164"></a>
-<span class="sourceLineNo">165</span>      }<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      final Procedure pollResult = dequeue();<a name="line.166"></a>
-<span class="sourceLineNo">167</span><a name="line.167"></a>
-<span class="sourceLineNo">168</span>      pollCalls++;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      nullPollCalls += (pollResult == null) ? 1 : 0;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      return pollResult;<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    } catch (InterruptedException e) {<a name="line.171"></a>
-<span class="sourceLineNo">172</span>      Thread.currentThread().interrupt();<a name="line.172"></a>
-<span class="sourceLineNo">173</span>      nullPollCalls++;<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      return null;<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    } finally {<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      schedUnlock();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    }<a name="line.177"></a>
-<span class="sourceLineNo">178</span>  }<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>  //  Utils<a name="line.181"></a>
-<span class="sourceLineNo">182</span>  // ==========================================================================<a name="line.182"></a>
-<span class="sourceLineNo">183</span>  /**<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * Returns the number of elements in this queue.<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   * NOTE: this method is called with the sched lock held.<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   * @return the number of elements in this queue.<a name="line.186"></a>
-<span class="sourceLineNo">187</span>   */<a name="line.187"></a>
-<span class="sourceLineNo">188</span>  protected abstract int queueSize();<a name="line.188"></a>
+<span class="sourceLineNo">144</span>  @Override<a name="line.144"></a>
+<span class="sourceLineNo">145</span>  public Procedure poll() {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    return poll(-1);<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>  @Override<a name="line.149"></a>
+<span class="sourceLineNo">150</span>  public Procedure poll(long timeout, TimeUnit unit) {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    return poll(unit.toNanos(timeout));<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>  @edu.umd.cs.findbugs.annotations.SuppressWarnings("WA_AWAIT_NOT_IN_LOOP")<a name="line.154"></a>
+<span class="sourceLineNo">155</span>  public Procedure poll(final long nanos) {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    schedLock();<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    try {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      if (!running) {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        LOG.debug("the scheduler is not running");<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        return null;<a name="line.160"></a>
+<span class="sourceLineNo">161</span>      }<a name="line.161"></a>
+<span class="sourceLineNo">162</span><a name="line.162"></a>
+<span class="sourceLineNo">163</span>      if (!queueHasRunnables()) {<a name="line.163"></a>
+<span class="sourceLineNo">164</span>        // WA_AWAIT_NOT_IN_LOOP: we are not in a loop because we want the caller<a name="line.164"></a>
+<span class="sourceLineNo">165</span>        // to take decisions after a wake/interruption.<a name="line.165"></a>
+<span class="sourceLineNo">166</span>        if (nanos &lt; 0) {<a name="line.166"></a>
+<span class="sourceLineNo">167</span>          schedWaitCond.await();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>        } else {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>          schedWaitCond.awaitNanos(nanos);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>        }<a name="line.170"></a>
+<span class="sourceLineNo">171</span>        if (!queueHasRunnables()) {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>          nullPollCalls++;<a name="line.172"></a>
+<span class="sourceLineNo">173</span>          return null;<a name="line.173"></a>
+<span class="sourceLineNo">174</span>        }<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      }<a name="line.175"></a>
+<span class="sourceLineNo">176</span>      final Procedure pollResult = dequeue();<a name="line.176"></a>
+<span class="sourceLineNo">177</span><a name="line.177"></a>
+<span class="sourceLineNo">178</span>      pollCalls++;<a name="line.178"></a>
+<span class="sourceLineNo">179</span>      nullPollCalls += (pollResult == null) ? 1 : 0;<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      return pollResult;<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    } catch (InterruptedException e) {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      Thread.currentThread().interrupt();<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      nullPollCalls++;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>      return null;<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    } finally {<a name="line.185"></a>
+<span class="sourceLineNo">186</span>      schedUnlock();<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    }<a name="line.187"></a>
+<span class="sourceLineNo">188</span>  }<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>   * Returns true if there are procedures available to process.<a name="line.191"></a>
-<span class="sourceLineNo">192</span>   * NOTE: this method is called with the sched lock held.<a name="line.192"></a>
-<span class="sourceLineNo">193</span>   * @return true if there are procedures available to process, otherwise false.<a name="line.193"></a>
-<span class="sourceLineNo">194</span>   */<a name="line.194"></a>
-<span class="sourceLineNo">195</span>  protected abstract boolean queueHasRunnables();<a name="line.195"></a>
-<span class="sourceLineNo">196</span><a name="line.196"></a>
-<span class="sourceLineNo">197</span>  @Override<a name="line.197"></a>
-<span class="sourceLineNo">198</span>  public int size() {<a name="line.198"></a>
-<span class="sourceLineNo">199</span>    schedLock();<a name="line.199"></a>
-<span class="sourceLineNo">200</span>    try {<a name="line.200"></a>
-<span class="sourceLineNo">201</span>      return queueSize();<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    } finally {<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      schedUnlock();<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  }<a name="line.205"></a>
+<span class="sourceLineNo">190</span>  // ==========================================================================<a name="line.190"></a>
+<span class="sourceLineNo">191</span>  //  Utils<a name="line.191"></a>
+<span class="sourceLineNo">192</span>  // ==========================================================================<a name="line.192"></a>
+<span class="sourceLineNo">193</span>  /**<a name="line.193"></a>
+<span class="sourceLineNo">194</span>   * Returns the number of elements in this queue.<a name="line.194"></a>
+<span class="sourceLineNo">195</span>   * NOTE: this method is called with the sched lock held.<a name="line.195"></a>
+<span class="sourceLineNo">196</span>   * @return the number of elements in this queue.<a name="line.196"></a>
+<span class="sourceLineNo">197</span>   */<a name="line.197"></a>
+<span class="sourceLineNo">198</span>  protected abstract int queueSize();<a name="line.198"></a>
+<span class="sourceLineNo">199</span><a name="line.199"></a>
+<span class="sourceLineNo">200</span>  /**<a name="line.200"></a>
+<span class="sourceLineNo">201</span>   * Returns true if there are procedures available to process.<a name="line.201"></a>
+<span class="sourceLineNo">202</span>   * NOTE: this method is called with the sched lock held.<a name="line.202"></a>
+<span class="sourceLineNo">203</span>   * @return true if there are procedures available to process, otherwise false.<a name="line.203"></a>
+<span class="sourceLineNo">204</span>   */<a name="line.204"></a>
+<span class="sourceLineNo">205</span>  protected abstract boolean queueHasRunnables();<a name="line.205"></a>
 <span class="sourceLineNo">206</span><a name="line.206"></a>
 <span class="sourceLineNo">207</span>  @Override<a name="line.207"></a>
-<span class="sourceLineNo">208</span>  public boolean hasRunnables() {<a name="line.208"></a>
+<span class="sourceLineNo">208</span>  public int size() {<a name="line.208"></a>
 <span class="sourceLineNo">209</span>    schedLock();<a name="line.209"></a>
 <span class="sourceLineNo">210</span>    try {<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      return queueHasRunnables();<a name="line.211"></a>
+<span class="sourceLineNo">211</span>      return queueSize();<a name="line.211"></a>
 <span class="sourceLineNo">212</span>    } finally {<a name="line.212"></a>
 <span class="sourceLineNo">213</span>      schedUnlock();<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><a name="line.216"></a>
-<span class="sourceLineNo">217</span>  // ============================================================================<a name="line.217"></a>
-<span class="sourceLineNo">218</span>  //  TODO: Metrics<a name="line.218"></a>
-<span class="sourceLineNo">219</span>  // ============================================================================<a name="line.219"></a>
-<span class="sourceLineNo">220</span>  public long getPollCalls() {<a name="line.220"></a>
-<span class="sourceLineNo">221</span>    return pollCalls;<a name="line.221"></a>
-<span class="sourceLineNo">222</span>  }<a name="line.222"></a>
-<span class="sourceLineNo">223</span><a name="line.223"></a>
-<span class="sourceLineNo">224</span>  public long getNullPollCalls() {<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    return nullPollCalls;<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>  //  Procedure Events<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>  /**<a name="line.232"></a>
-<span class="sourceLineNo">233</span>   * Wake up all of the given events.<a name="line.233"></a>
-<span class="sourceLineNo">234</span>   * Note that we first take scheduler lock and then wakeInternal() synchronizes on the event.<a name="line.234"></a>
-<span class="sourceLineNo">235</span>   * Access should remain package-private. Use ProcedureEvent class to wake/suspend events.<a name="line.235"></a>
-<span class="sourceLineNo">236</span>   * @param events the list of events to wake<a name="line.236"></a>
-<span class="sourceLineNo">237</span>   */<a name="line.237"></a>
-<span class="sourceLineNo">238</span>  void wakeEvents(ProcedureEvent[] events) {<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    schedLock();<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    try {<a name="line.240"></a>
-<span class="sourceLineNo">241</span>      for (ProcedureEvent event : events) {<a name="line.241"></a>
-<span class="sourceLineNo">242</span>        if (event == null) {<a name="line.242"></a>
-<span class="sourceLineNo">243</span>          continue;<a name="line.243"></a>
-<span class="sourceLineNo">244</span>        }<a name="line.244"></a>
-<span class="sourceLineNo">245</span>        event.wakeInternal(this);<a name="line.245"></a>
-<span class="sourceLineNo">246</span>      }<a name="line.246"></a>
-<span class="sourceLineNo">247</span>    } finally {<a name="line.247"></a>
-<span class="sourceLineNo">248</span>      schedUnlock();<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    }<a name="line.249"></a>
-<span class="sourceLineNo">250</span>  }<a name="line.250"></a>
-<span class="sourceLineNo">251</span><a name="line.251"></a>
-<span class="sourceLineNo">252</span>  /**<a name="line.252"></a>
-<span class="sourceLineNo">253</span>   * Wakes up given waiting procedures by pushing them back into scheduler queues.<a name="line.253"></a>
-<span class="sourceLineNo">254</span>   * @return size of given {@code waitQueue}.<a name="line.254"></a>
-<span class="sourceLineNo">255</span>   */<a name="line.255"></a>
-<span class="sourceLineNo">256</span>  protected int wakeWaitingProcedures(LockAndQueue lockAndQueue) {<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    return lockAndQueue.wakeWaitingProcedures(this);<a name="line.257"></a>
-<span class="sourceLineNo">258</span>  }<a name="line.258"></a>
-<span class="sourceLineNo">259</span><a name="line.259"></a>
-<span class="sourceLineNo">260</span>  protected void waitProcedure(LockAndQueue lockAndQueue, final Procedure proc) {<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    lockAndQueue.addLast(proc);<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>  protected void wakeProcedure(final Procedure procedure) {<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    LOG.trace("Wake {}", procedure);<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    push(procedure, /* addFront= */ true, /* notify= */false);<a name="line.266"></a>
-<span class="sourceLineNo">267</span>  }<a name="line.267"></a>
-<span class="sourceLineNo">268</span><a name="line.268"></a>
+<span class="sourceLineNo">217</span>  @Override<a name="line.217"></a>
+<span class="sourceLineNo">218</span>  public boolean hasRunnables() {<a name="line.218"></a>
+<span class="sourceLineNo">219</span>    schedLock();<a name="line.219"></a>
+<span class="sourceLineNo">220</span>    try {<a name="line.220"></a>
+<span class="sourceLineNo">221</span>      return queueHasRunnables();<a name="line.221"></a>
+<span class="sourceLineNo">222</span>    } finally {<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      schedUnlock();<a name="line.223"></a>
+<span class="sourceLineNo">224</span>    }<a name="line.224"></a>
+<span class="sourceLineNo">225</span>  }<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>  //  TODO: Metrics<a name="line.228"></a>
+<span class="sourceLineNo">229</span>  // ============================================================================<a name="line.229"></a>
+<span class="sourceLineNo">230</span>  public long getPollCalls() {<a name="line.230"></a>
+<span class="sourceLineNo">231</span>    return pollCalls;<a name="line.231"></a>
+<span class="sourceLineNo">232</span>  }<a name="line.232"></a>
+<span class="sourceLineNo">233</span><a name="line.233"></a>
+<span class="sourceLineNo">234</span>  public long getNullPollCalls() {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>    return nullPollCalls;<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>  // ==========================================================================<a name="line.238"></a>
+<span class="sourceLineNo">239</span>  //  Procedure Events<a name="line.239"></a>
+<span class="sourceLineNo">240</span>  // ==========================================================================<a name="line.240"></a>
+<span class="sourceLineNo">241</span><a name="line.241"></a>
+<span class="sourceLineNo">242</span>  /**<a name="line.242"></a>
+<span class="sourceLineNo">243</span>   * Wake up all of the given events.<a name="line.243"></a>
+<span class="sourceLineNo">244</span>   * Note that we first take scheduler lock and then wakeInternal() synchronizes on the event.<a name="line.244"></a>
+<span class="sourceLineNo">245</span>   * Access should remain package-private. Use ProcedureEvent class to wake/suspend events.<a name="line.245"></a>
+<span class="sourceLineNo">246</span>   * @param events the list of events to wake<a name="line.246"></a>
+<span class="sourceLineNo">247</span>   */<a name="line.247"></a>
+<span class="sourceLineNo">248</span>  void wakeEvents(ProcedureEvent[] events) {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>    schedLock();<a name="line.249"></a>
+<span class="sourceLineNo">250</span>    try {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>      for (ProcedureEvent event : events) {<a name="line.251"></a>
+<span class="sourceLineNo">252</span>        if (event == null) {<a name="line.252"></a>
+<span class="sourceLineNo">253</span>          continue;<a name="line.253"></a>
+<span class="sourceLineNo">254</span>        }<a name="line.254"></a>
+<span class="sourceLineNo">255</span>        event.wakeInternal(this);<a name="line.255"></a>
+<span class="sourceLineNo">256</span>      }<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    } finally {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>      schedUnlock();<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    }<a name="line.259"></a>
+<span class="sourceLineNo">260</span>  }<a name="line.260"></a>
+<span class="sourceLineNo">261</span><a name="line.261"></a>
+<span class="sourceLineNo">262</span>  /**<a name="line.262"></a>
+<span class="sourceLineNo">263</span>   * Wakes up given waiting procedures by pushing them back into scheduler queues.<a name="line.263"></a>
+<span class="sourceLineNo">264</span>   * @return size of given {@code waitQueue}.<a name="line.264"></a>
+<span class="sourceLineNo">265</span>   */<a name="line.265"></a>
+<span class="sourceLineNo">266</span>  protected int wakeWaitingProcedures(LockAndQueue lockAndQueue) {<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    return lockAndQueue.wakeWaitingProcedures(this);<a name="line.267"></a>
+<span class="sourceLineNo">268</span>  }<a name="line.268"></a>
 <span class="sourceLineNo">269</span><a name="line.269"></a>
-<span class="sourceLineNo">270</span>  // ==========================================================================<a name="line.270"></a>
-<span class="sourceLineNo">271</span>  //  Internal helpers<a name="line.271"></a>
-<span class="sourceLineNo">272</span>  // ==========================================================================<a name="line.272"></a>
-<span class="sourceLineNo">273</span>  protected void schedLock() {<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    schedulerLock.lock();<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>  protected void schedUnlock() {<a name="line.277"></a>
-<span class="sourceLineNo">278</span>    schedulerLock.unlock();<a name="line.278"></a>
-<span class="sourceLineNo">279</span>  }<a name="line.279"></a>
-<span class="sourceLineNo">280</span><a name="line.280"></a>
-<span class="sourceLineNo">281</span>  protected void wakePollIfNeeded(final int waitingCount) {<a name="line.281"></a>
-<span class="sourceLineNo">282</span>    if (waitingCount &lt;= 0) {<a name="line.282"></a>
-<span class="sourceLineNo">283</span>      return;<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    }<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    if (waitingCount == 1) {<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      schedWaitCond.signal();<a name="line.286"></a>
-<span class="sourceLineNo">287</span>    } else {<a name="line.287"></a>
-<span class="sourceLineNo">288</span>      schedWaitCond.signalAll();<a name="line.288"></a>
-<span class="sourceLineNo">289</span>    }<a name="line.289"></a>
-<span class="sourceLineNo">290</span>  }<a name="line.290"></a>
-<span class="sourceLineNo">291</span>}<a name="line.291"></a>
+<span class="sourceLineNo">270</span>  protected void waitProcedure(LockAndQueue lockAndQueue, final Procedure proc) {<a name="line.270"></a>
+<span class="sourceLineNo">271</span>    lockAndQueue.addLast(proc);<a name="line.271"></a>
+<span class="sourceLineNo">272</span>  }<a name="line.272"></a>
+<span class="sourceLineNo">273</span><a name="line.273"></a>
+<span class="sourceLineNo">274</span>  protected void wakeProcedure(final Procedure procedure) {<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    LOG.trace("Wake {}", procedure);<a name="line.275"></a>
+<span class="sourceLineNo">276</span>    push(procedure, /* addFront= */ true, /* notify= */false);<a name="line.276"></a>
+<span class="sourceLineNo">277</span>  }<a name="line.277"></a>
+<span class="sourceLineNo">278</span><a name="line.278"></a>
+<span class="sourceLineNo">279</span><a name="line.279"></a>
+<span class="sourceLineNo">280</span>  // ==========================================================================<a name="line.280"></a>
+<span class="sourceLineNo">281</span>  //  Internal helpers<a name="line.281"></a>
+<span class="sourceLineNo">282</span>  // ==========================================================================<a name="line.282"></a>
+<span class="sourceLineNo">283</span>  protected void schedLock() {<a name="line.283"></a>
+<span class="sourceLineNo">284</span>    schedulerLock.lock();<a name="line.284"></a>
+<span class="sourceLineNo">285</span>  }<a name="line.285"></a>
+<span class="sourceLineNo">286</span><a name="line.286"></a>
+<span class="sourceLineNo">287</span>  protected void schedUnlock() {<a name="line.287"></a>
+<span class="sourceLineNo">288</span>    schedulerLock.unlock();<a name="line.288"></a>
+<span class="sourceLineNo">289</span>  }<a name="line.289"></a>
+<span class="sourceLineNo">290</span><a name="line.290"></a>
+<span class="sourceLineNo">291</span>  protected void wakePollIfNeeded(final int waitingCount) {<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    if (waitingCount &lt;= 0) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      return;<a name="line.293"></a>
+<span class="sourceLineNo">294</span>    }<a name="line.294"></a>
+<span class="sourceLineNo">295</span>    if (waitingCount == 1) {<a name="line.295"></a>
+<span class="sourceLineNo">296</span>      schedWaitCond.signal();<a name="line.296"></a>
+<span class="sourceLineNo">297</span>    } else {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>      schedWaitCond.signalAll();<a name="line.298"></a>
+<span class="sourceLineNo">299</span>    }<a name="line.299"></a>
+<span class="sourceLineNo">300</span>  }<a name="line.300"></a>
+<span class="sourceLineNo">301</span>}<a name="line.301"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/LockAndQueue.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/LockAndQueue.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/LockAndQueue.html
index 6df87bb..1c77e4e 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/LockAndQueue.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/LockAndQueue.html
@@ -81,123 +81,124 @@
 <span class="sourceLineNo">073</span><a name="line.73"></a>
 <span class="sourceLineNo">074</span>  @Override<a name="line.74"></a>
 <span class="sourceLineNo">075</span>  public boolean hasParentLock(Procedure&lt;?&gt; proc) {<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    // TODO: need to check all the ancestors<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    return proc.hasParent() &amp;&amp;<a name="line.77"></a>
-<span class="sourceLineNo">078</span>      (isLockOwner(proc.getParentProcId()) || isLockOwner(proc.getRootProcId()));<a name="line.78"></a>
-<span class="sourceLineNo">079</span>  }<a name="line.79"></a>
-<span class="sourceLineNo">080</span><a name="line.80"></a>
-<span class="sourceLineNo">081</span>  @Override<a name="line.81"></a>
-<span class="sourceLineNo">082</span>  public boolean hasLockAccess(Procedure&lt;?&gt; proc) {<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    return isLockOwner(proc.getProcId()) || hasParentLock(proc);<a name="line.83"></a>
-<span class="sourceLineNo">084</span>  }<a name="line.84"></a>
-<span class="sourceLineNo">085</span><a name="line.85"></a>
-<span class="sourceLineNo">086</span>  @Override<a name="line.86"></a>
-<span class="sourceLineNo">087</span>  public Procedure&lt;?&gt; getExclusiveLockOwnerProcedure() {<a name="line.87"></a>
-<span class="sourceLineNo">088</span>    return exclusiveLockOwnerProcedure;<a name="line.88"></a>
-<span class="sourceLineNo">089</span>  }<a name="line.89"></a>
-<span class="sourceLineNo">090</span><a name="line.90"></a>
-<span class="sourceLineNo">091</span>  @Override<a name="line.91"></a>
-<span class="sourceLineNo">092</span>  public long getExclusiveLockProcIdOwner() {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>    if (exclusiveLockOwnerProcedure == null) {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>      return Long.MIN_VALUE;<a name="line.94"></a>
-<span class="sourceLineNo">095</span>    } else {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>      return exclusiveLockOwnerProcedure.getProcId();<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    }<a name="line.97"></a>
-<span class="sourceLineNo">098</span>  }<a name="line.98"></a>
-<span class="sourceLineNo">099</span><a name="line.99"></a>
-<span class="sourceLineNo">100</span>  @Override<a name="line.100"></a>
-<span class="sourceLineNo">101</span>  public int getSharedLockCount() {<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    return sharedLock;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>  }<a name="line.103"></a>
-<span class="sourceLineNo">104</span><a name="line.104"></a>
-<span class="sourceLineNo">105</span>  // ======================================================================<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  //  try/release Shared/Exclusive lock<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  // ======================================================================<a name="line.107"></a>
-<span class="sourceLineNo">108</span><a name="line.108"></a>
-<span class="sourceLineNo">109</span>  /**<a name="line.109"></a>
-<span class="sourceLineNo">110</span>   * @return whether we have succesfully acquired the shared lock.<a name="line.110"></a>
-<span class="sourceLineNo">111</span>   */<a name="line.111"></a>
-<span class="sourceLineNo">112</span>  public boolean trySharedLock(Procedure&lt;?&gt; proc) {<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    if (hasExclusiveLock() &amp;&amp; !hasLockAccess(proc)) {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>      return false;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    }<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    // If no one holds the xlock, then we are free to hold the sharedLock<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    // If the parent proc or we have already held the xlock, then we return true here as<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    // xlock is more powerful then shared lock.<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    sharedLock++;<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    return true;<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>  /**<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   * @return whether we should wake the procedures waiting on the lock here.<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   */<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  public boolean releaseSharedLock() {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    // hasExclusiveLock could be true, it usually means we acquire shared lock while we or our<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    // parent have held the xlock. And since there is still an exclusive lock, we do not need to<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    // wake any procedures.<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    return --sharedLock == 0 &amp;&amp; !hasExclusiveLock();<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 boolean tryExclusiveLock(Procedure&lt;?&gt; proc) {<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    if (isLocked()) {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>      return hasLockAccess(proc);<a name="line.135"></a>
-<span class="sourceLineNo">136</span>    }<a name="line.136"></a>
-<span class="sourceLineNo">137</span>    exclusiveLockOwnerProcedure = proc;<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    return true;<a name="line.138"></a>
-<span class="sourceLineNo">139</span>  }<a name="line.139"></a>
-<span class="sourceLineNo">140</span><a name="line.140"></a>
-<span class="sourceLineNo">141</span>  /**<a name="line.141"></a>
-<span class="sourceLineNo">142</span>   * @return whether we should wake the procedures waiting on the lock here.<a name="line.142"></a>
-<span class="sourceLineNo">143</span>   */<a name="line.143"></a>
-<span class="sourceLineNo">144</span>  public boolean releaseExclusiveLock(Procedure&lt;?&gt; proc) {<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    if (!isLockOwner(proc.getProcId())) {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      // We are not the lock owner, it is probably inherited from the parent procedures.<a name="line.146"></a>
-<span class="sourceLineNo">147</span>      return false;<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    }<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    exclusiveLockOwnerProcedure = null;<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    // This maybe a bit strange so let me explain. We allow acquiring shared lock while the parent<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    // proc or we have already held the xlock, and also allow releasing the locks in any order, so<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    // it could happen that the xlock is released but there are still some procs holding the shared<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    // lock.<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    // In HBase, this could happen when a proc which holdLock is false and schedules sub procs which<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    // acquire the shared lock on the same lock. This is because we will schedule the sub proces<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    // before releasing the lock, so the sub procs could call acquire lock before we releasing the<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    // xlock.<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    return sharedLock == 0;<a name="line.158"></a>
-<span class="sourceLineNo">159</span>  }<a name="line.159"></a>
-<span class="sourceLineNo">160</span><a name="line.160"></a>
-<span class="sourceLineNo">161</span>  public boolean isWaitingQueueEmpty() {<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    return queue.isEmpty();<a name="line.162"></a>
-<span class="sourceLineNo">163</span>  }<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>  public Procedure&lt;?&gt; removeFirst() {<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    return queue.removeFirst();<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  }<a name="line.167"></a>
-<span class="sourceLineNo">168</span><a name="line.168"></a>
-<span class="sourceLineNo">169</span>  public void addLast(Procedure&lt;?&gt; proc) {<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    queue.addLast(proc);<a name="line.170"></a>
-<span class="sourceLineNo">171</span>  }<a name="line.171"></a>
-<span class="sourceLineNo">172</span><a name="line.172"></a>
-<span class="sourceLineNo">173</span>  public int wakeWaitingProcedures(ProcedureScheduler scheduler) {<a name="line.173"></a>
-<span class="sourceLineNo">174</span>    int count = queue.size();<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    // wakeProcedure adds to the front of queue, so we start from last in the waitQueue' queue, so<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    // that the procedure which was added first goes in the front for the scheduler queue.<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    scheduler.addFront(queue.descendingIterator());<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    queue.clear();<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    return count;<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>  @SuppressWarnings("rawtypes")<a name="line.182"></a>
-<span class="sourceLineNo">183</span>  public Stream&lt;Procedure&gt; filterWaitingQueue(Predicate&lt;Procedure&gt; predicate) {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    return queue.stream().filter(predicate);<a name="line.184"></a>
-<span class="sourceLineNo">185</span>  }<a name="line.185"></a>
-<span class="sourceLineNo">186</span><a name="line.186"></a>
-<span class="sourceLineNo">187</span>  @Override<a name="line.187"></a>
-<span class="sourceLineNo">188</span>  public String toString() {<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    return "exclusiveLockOwner=" + (hasExclusiveLock() ? getExclusiveLockProcIdOwner() : "NONE") +<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      ", sharedLockCount=" + getSharedLockCount() + ", waitingProcCount=" + queue.size();<a name="line.190"></a>
-<span class="sourceLineNo">191</span>  }<a name="line.191"></a>
-<span class="sourceLineNo">192</span>}<a name="line.192"></a>
+<span class="sourceLineNo">076</span>    // TODO: need to check all the ancestors. need to passed in the procedures<a name="line.76"></a>
+<span class="sourceLineNo">077</span>    // to find the ancestors.<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    return proc.hasParent() &amp;&amp;<a name="line.78"></a>
+<span class="sourceLineNo">079</span>      (isLockOwner(proc.getParentProcId()) || isLockOwner(proc.getRootProcId()));<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  }<a name="line.80"></a>
+<span class="sourceLineNo">081</span><a name="line.81"></a>
+<span class="sourceLineNo">082</span>  @Override<a name="line.82"></a>
+<span class="sourceLineNo">083</span>  public boolean hasLockAccess(Procedure&lt;?&gt; proc) {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    return isLockOwner(proc.getProcId()) || hasParentLock(proc);<a name="line.84"></a>
+<span class="sourceLineNo">085</span>  }<a name="line.85"></a>
+<span class="sourceLineNo">086</span><a name="line.86"></a>
+<span class="sourceLineNo">087</span>  @Override<a name="line.87"></a>
+<span class="sourceLineNo">088</span>  public Procedure&lt;?&gt; getExclusiveLockOwnerProcedure() {<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    return exclusiveLockOwnerProcedure;<a name="line.89"></a>
+<span class="sourceLineNo">090</span>  }<a name="line.90"></a>
+<span class="sourceLineNo">091</span><a name="line.91"></a>
+<span class="sourceLineNo">092</span>  @Override<a name="line.92"></a>
+<span class="sourceLineNo">093</span>  public long getExclusiveLockProcIdOwner() {<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    if (exclusiveLockOwnerProcedure == null) {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>      return Long.MIN_VALUE;<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    } else {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      return exclusiveLockOwnerProcedure.getProcId();<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    }<a name="line.98"></a>
+<span class="sourceLineNo">099</span>  }<a name="line.99"></a>
+<span class="sourceLineNo">100</span><a name="line.100"></a>
+<span class="sourceLineNo">101</span>  @Override<a name="line.101"></a>
+<span class="sourceLineNo">102</span>  public int getSharedLockCount() {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    return sharedLock;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>  }<a name="line.104"></a>
+<span class="sourceLineNo">105</span><a name="line.105"></a>
+<span class="sourceLineNo">106</span>  // ======================================================================<a name="line.106"></a>
+<span class="sourceLineNo">107</span>  //  try/release Shared/Exclusive lock<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  // ======================================================================<a name="line.108"></a>
+<span class="sourceLineNo">109</span><a name="line.109"></a>
+<span class="sourceLineNo">110</span>  /**<a name="line.110"></a>
+<span class="sourceLineNo">111</span>   * @return whether we have succesfully acquired the shared lock.<a name="line.111"></a>
+<span class="sourceLineNo">112</span>   */<a name="line.112"></a>
+<span class="sourceLineNo">113</span>  public boolean trySharedLock(Procedure&lt;?&gt; proc) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    if (hasExclusiveLock() &amp;&amp; !hasLockAccess(proc)) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      return false;<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    // If no one holds the xlock, then we are free to hold the sharedLock<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    // If the parent proc or we have already held the xlock, then we return true here as<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    // xlock is more powerful then shared lock.<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    sharedLock++;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    return true;<a name="line.121"></a>
+<span class="sourceLineNo">122</span>  }<a name="line.122"></a>
+<span class="sourceLineNo">123</span><a name="line.123"></a>
+<span class="sourceLineNo">124</span>  /**<a name="line.124"></a>
+<span class="sourceLineNo">125</span>   * @return whether we should wake the procedures waiting on the lock here.<a name="line.125"></a>
+<span class="sourceLineNo">126</span>   */<a name="line.126"></a>
+<span class="sourceLineNo">127</span>  public boolean releaseSharedLock() {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    // hasExclusiveLock could be true, it usually means we acquire shared lock while we or our<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    // parent have held the xlock. And since there is still an exclusive lock, we do not need to<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    // wake any procedures.<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    return --sharedLock == 0 &amp;&amp; !hasExclusiveLock();<a name="line.131"></a>
+<span class="sourceLineNo">132</span>  }<a name="line.132"></a>
+<span class="sourceLineNo">133</span><a name="line.133"></a>
+<span class="sourceLineNo">134</span>  public boolean tryExclusiveLock(Procedure&lt;?&gt; proc) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    if (isLocked()) {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>      return hasLockAccess(proc);<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    }<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    exclusiveLockOwnerProcedure = proc;<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    return true;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>  }<a name="line.140"></a>
+<span class="sourceLineNo">141</span><a name="line.141"></a>
+<span class="sourceLineNo">142</span>  /**<a name="line.142"></a>
+<span class="sourceLineNo">143</span>   * @return whether we should wake the procedures waiting on the lock here.<a name="line.143"></a>
+<span class="sourceLineNo">144</span>   */<a name="line.144"></a>
+<span class="sourceLineNo">145</span>  public boolean releaseExclusiveLock(Procedure&lt;?&gt; proc) {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    if (!isLockOwner(proc.getProcId())) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      // We are not the lock owner, it is probably inherited from the parent procedures.<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      return false;<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    }<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    exclusiveLockOwnerProcedure = null;<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    // This maybe a bit strange so let me explain. We allow acquiring shared lock while the parent<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    // proc or we have already held the xlock, and also allow releasing the locks in any order, so<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    // it could happen that the xlock is released but there are still some procs holding the shared<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    // lock.<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    // In HBase, this could happen when a proc which holdLock is false and schedules sub procs which<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    // acquire the shared lock on the same lock. This is because we will schedule the sub proces<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    // before releasing the lock, so the sub procs could call acquire lock before we releasing the<a name="line.157"></a>
+<span class="sourceLineNo">158</span>    // xlock.<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    return sharedLock == 0;<a name="line.159"></a>
+<span class="sourceLineNo">160</span>  }<a name="line.160"></a>
+<span class="sourceLineNo">161</span><a name="line.161"></a>
+<span class="sourceLineNo">162</span>  public boolean isWaitingQueueEmpty() {<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    return queue.isEmpty();<a name="line.163"></a>
+<span class="sourceLineNo">164</span>  }<a name="line.164"></a>
+<span class="sourceLineNo">165</span><a name="line.165"></a>
+<span class="sourceLineNo">166</span>  public Procedure&lt;?&gt; removeFirst() {<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    return queue.removeFirst();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>  }<a name="line.168"></a>
+<span class="sourceLineNo">169</span><a name="line.169"></a>
+<span class="sourceLineNo">170</span>  public void addLast(Procedure&lt;?&gt; proc) {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    queue.addLast(proc);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>  }<a name="line.172"></a>
+<span class="sourceLineNo">173</span><a name="line.173"></a>
+<span class="sourceLineNo">174</span>  public int wakeWaitingProcedures(ProcedureScheduler scheduler) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    int count = queue.size();<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    // wakeProcedure adds to the front of queue, so we start from last in the waitQueue' queue, so<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    // that the procedure which was added first goes in the front for the scheduler queue.<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    scheduler.addFront(queue.descendingIterator());<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    queue.clear();<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    return count;<a name="line.180"></a>
+<span class="sourceLineNo">181</span>  }<a name="line.181"></a>
+<span class="sourceLineNo">182</span><a name="line.182"></a>
+<span class="sourceLineNo">183</span>  @SuppressWarnings("rawtypes")<a name="line.183"></a>
+<span class="sourceLineNo">184</span>  public Stream&lt;Procedure&gt; filterWaitingQueue(Predicate&lt;Procedure&gt; predicate) {<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    return queue.stream().filter(predicate);<a name="line.185"></a>
+<span class="sourceLineNo">186</span>  }<a name="line.186"></a>
+<span class="sourceLineNo">187</span><a name="line.187"></a>
+<span class="sourceLineNo">188</span>  @Override<a name="line.188"></a>
+<span class="sourceLineNo">189</span>  public String toString() {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>    return "exclusiveLockOwner=" + (hasExclusiveLock() ? getExclusiveLockProcIdOwner() : "NONE") +<a name="line.190"></a>
+<span class="sourceLineNo">191</span>      ", sharedLockCount=" + getSharedLockCount() + ", waitingProcCount=" + queue.size();<a name="line.191"></a>
+<span class="sourceLineNo">192</span>  }<a name="line.192"></a>
+<span class="sourceLineNo">193</span>}<a name="line.193"></a>
 
 
 


Mime
View raw message