hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [10/51] [partial] hbase-site git commit: Published site at 3fe8649b2c9ba1271c25e8f476548907e4c7a90d.
Date Wed, 24 Oct 2018 14:54:44 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/8f09a71d/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
index 1579eab..dc5908e 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.DeleteState.html
@@ -31,221 +31,221 @@
 <span class="sourceLineNo">023</span>import java.util.Iterator;<a name="line.23"></a>
 <span class="sourceLineNo">024</span>import java.util.Map;<a name="line.24"></a>
 <span class="sourceLineNo">025</span>import java.util.TreeMap;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import java.util.stream.LongStream;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.procedure2.Procedure;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.29"></a>
-<span class="sourceLineNo">030</span><a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;<a name="line.31"></a>
-<span class="sourceLineNo">032</span><a name="line.32"></a>
-<span class="sourceLineNo">033</span>/**<a name="line.33"></a>
-<span class="sourceLineNo">034</span> * Keeps track of live procedures.<a name="line.34"></a>
-<span class="sourceLineNo">035</span> *<a name="line.35"></a>
-<span class="sourceLineNo">036</span> * It can be used by the ProcedureStore to identify which procedures are already<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * deleted/completed to avoid the deserialization step on restart<a name="line.37"></a>
-<span class="sourceLineNo">038</span> */<a name="line.38"></a>
-<span class="sourceLineNo">039</span>@InterfaceAudience.Private<a name="line.39"></a>
-<span class="sourceLineNo">040</span>@InterfaceStability.Evolving<a name="line.40"></a>
-<span class="sourceLineNo">041</span>public class ProcedureStoreTracker {<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  // Key is procedure id corresponding to first bit of the bitmap.<a name="line.42"></a>
-<span class="sourceLineNo">043</span>  private final TreeMap&lt;Long, BitSetNode&gt; map = new TreeMap&lt;&gt;();<a name="line.43"></a>
-<span class="sourceLineNo">044</span><a name="line.44"></a>
-<span class="sourceLineNo">045</span>  /**<a name="line.45"></a>
-<span class="sourceLineNo">046</span>   * If true, do not remove bits corresponding to deleted procedures. Note that this can result<a name="line.46"></a>
-<span class="sourceLineNo">047</span>   * in huge bitmaps overtime.<a name="line.47"></a>
-<span class="sourceLineNo">048</span>   * Currently, it's set to true only when building tracker state from logs during recovery. During<a name="line.48"></a>
-<span class="sourceLineNo">049</span>   * recovery, if we are sure that a procedure has been deleted, reading its old update entries<a name="line.49"></a>
-<span class="sourceLineNo">050</span>   * can be skipped.<a name="line.50"></a>
-<span class="sourceLineNo">051</span>   */<a name="line.51"></a>
-<span class="sourceLineNo">052</span>  private boolean keepDeletes = false;<a name="line.52"></a>
-<span class="sourceLineNo">053</span>  /**<a name="line.53"></a>
-<span class="sourceLineNo">054</span>   * If true, it means tracker has incomplete information about the active/deleted procedures.<a name="line.54"></a>
-<span class="sourceLineNo">055</span>   * It's set to true only when recovering from old logs. See {@link #isDeleted(long)} docs to<a name="line.55"></a>
-<span class="sourceLineNo">056</span>   * understand it's real use.<a name="line.56"></a>
-<span class="sourceLineNo">057</span>   */<a name="line.57"></a>
-<span class="sourceLineNo">058</span>  boolean partial = false;<a name="line.58"></a>
-<span class="sourceLineNo">059</span><a name="line.59"></a>
-<span class="sourceLineNo">060</span>  private long minModifiedProcId = Long.MAX_VALUE;<a name="line.60"></a>
-<span class="sourceLineNo">061</span>  private long maxModifiedProcId = Long.MIN_VALUE;<a name="line.61"></a>
-<span class="sourceLineNo">062</span><a name="line.62"></a>
-<span class="sourceLineNo">063</span>  public enum DeleteState { YES, NO, MAYBE }<a name="line.63"></a>
-<span class="sourceLineNo">064</span><a name="line.64"></a>
-<span class="sourceLineNo">065</span>  public void resetToProto(ProcedureProtos.ProcedureStoreTracker trackerProtoBuf) {<a name="line.65"></a>
-<span class="sourceLineNo">066</span>    reset();<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: trackerProtoBuf.getNodeList()) {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>      final BitSetNode node = new BitSetNode(protoNode);<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      map.put(node.getStart(), node);<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>  /**<a name="line.73"></a>
-<span class="sourceLineNo">074</span>   * Resets internal state to same as given {@code tracker}. Does deep copy of the bitmap.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>   */<a name="line.75"></a>
-<span class="sourceLineNo">076</span>  public void resetTo(ProcedureStoreTracker tracker) {<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    resetTo(tracker, false);<a name="line.77"></a>
-<span class="sourceLineNo">078</span>  }<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>   * Resets internal state to same as given {@code tracker}, and change the deleted flag according<a name="line.81"></a>
-<span class="sourceLineNo">082</span>   * to the modified flag if {@code resetDelete} is true. Does deep copy of the bitmap.<a name="line.82"></a>
-<span class="sourceLineNo">083</span>   * &lt;p/&gt;<a name="line.83"></a>
-<span class="sourceLineNo">084</span>   * The {@code resetDelete} will be set to true when building cleanup tracker, please see the<a name="line.84"></a>
-<span class="sourceLineNo">085</span>   * comments in {@link BitSetNode#BitSetNode(BitSetNode, boolean)} to learn how we change the<a name="line.85"></a>
-<span class="sourceLineNo">086</span>   * deleted flag if {@code resetDelete} is true.<a name="line.86"></a>
-<span class="sourceLineNo">087</span>   */<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  public void resetTo(ProcedureStoreTracker tracker, boolean resetDelete) {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    reset();<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    this.partial = tracker.partial;<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    this.minModifiedProcId = tracker.minModifiedProcId;<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    this.maxModifiedProcId = tracker.maxModifiedProcId;<a name="line.92"></a>
-<span class="sourceLineNo">093</span>    this.keepDeletes = tracker.keepDeletes;<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : tracker.map.entrySet()) {<a name="line.94"></a>
-<span class="sourceLineNo">095</span>      map.put(entry.getKey(), new BitSetNode(entry.getValue(), resetDelete));<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><a name="line.98"></a>
-<span class="sourceLineNo">099</span>  public void insert(long procId) {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    insert(null, procId);<a name="line.100"></a>
+<span class="sourceLineNo">026</span>import java.util.function.BiFunction;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import java.util.stream.LongStream;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.procedure2.Procedure;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.30"></a>
+<span class="sourceLineNo">031</span><a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;<a name="line.32"></a>
+<span class="sourceLineNo">033</span><a name="line.33"></a>
+<span class="sourceLineNo">034</span>/**<a name="line.34"></a>
+<span class="sourceLineNo">035</span> * Keeps track of live procedures.<a name="line.35"></a>
+<span class="sourceLineNo">036</span> *<a name="line.36"></a>
+<span class="sourceLineNo">037</span> * It can be used by the ProcedureStore to identify which procedures are already<a name="line.37"></a>
+<span class="sourceLineNo">038</span> * deleted/completed to avoid the deserialization step on restart<a name="line.38"></a>
+<span class="sourceLineNo">039</span> */<a name="line.39"></a>
+<span class="sourceLineNo">040</span>@InterfaceAudience.Private<a name="line.40"></a>
+<span class="sourceLineNo">041</span>@InterfaceStability.Evolving<a name="line.41"></a>
+<span class="sourceLineNo">042</span>public class ProcedureStoreTracker {<a name="line.42"></a>
+<span class="sourceLineNo">043</span>  // Key is procedure id corresponding to first bit of the bitmap.<a name="line.43"></a>
+<span class="sourceLineNo">044</span>  private final TreeMap&lt;Long, BitSetNode&gt; map = new TreeMap&lt;&gt;();<a name="line.44"></a>
+<span class="sourceLineNo">045</span><a name="line.45"></a>
+<span class="sourceLineNo">046</span>  /**<a name="line.46"></a>
+<span class="sourceLineNo">047</span>   * If true, do not remove bits corresponding to deleted procedures. Note that this can result<a name="line.47"></a>
+<span class="sourceLineNo">048</span>   * in huge bitmaps overtime.<a name="line.48"></a>
+<span class="sourceLineNo">049</span>   * Currently, it's set to true only when building tracker state from logs during recovery. During<a name="line.49"></a>
+<span class="sourceLineNo">050</span>   * recovery, if we are sure that a procedure has been deleted, reading its old update entries<a name="line.50"></a>
+<span class="sourceLineNo">051</span>   * can be skipped.<a name="line.51"></a>
+<span class="sourceLineNo">052</span>   */<a name="line.52"></a>
+<span class="sourceLineNo">053</span>  private boolean keepDeletes = false;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>  /**<a name="line.54"></a>
+<span class="sourceLineNo">055</span>   * If true, it means tracker has incomplete information about the active/deleted procedures.<a name="line.55"></a>
+<span class="sourceLineNo">056</span>   * It's set to true only when recovering from old logs. See {@link #isDeleted(long)} docs to<a name="line.56"></a>
+<span class="sourceLineNo">057</span>   * understand it's real use.<a name="line.57"></a>
+<span class="sourceLineNo">058</span>   */<a name="line.58"></a>
+<span class="sourceLineNo">059</span>  boolean partial = false;<a name="line.59"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>  private long minModifiedProcId = Long.MAX_VALUE;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>  private long maxModifiedProcId = Long.MIN_VALUE;<a name="line.62"></a>
+<span class="sourceLineNo">063</span><a name="line.63"></a>
+<span class="sourceLineNo">064</span>  public enum DeleteState { YES, NO, MAYBE }<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>  public void resetToProto(ProcedureProtos.ProcedureStoreTracker trackerProtoBuf) {<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    reset();<a name="line.67"></a>
+<span class="sourceLineNo">068</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: trackerProtoBuf.getNodeList()) {<a name="line.68"></a>
+<span class="sourceLineNo">069</span>      final BitSetNode node = new BitSetNode(protoNode);<a name="line.69"></a>
+<span class="sourceLineNo">070</span>      map.put(node.getStart(), node);<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><a name="line.73"></a>
+<span class="sourceLineNo">074</span>  /**<a name="line.74"></a>
+<span class="sourceLineNo">075</span>   * Resets internal state to same as given {@code tracker}. Does deep copy of the bitmap.<a name="line.75"></a>
+<span class="sourceLineNo">076</span>   */<a name="line.76"></a>
+<span class="sourceLineNo">077</span>  public void resetTo(ProcedureStoreTracker tracker) {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    resetTo(tracker, false);<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>  /**<a name="line.81"></a>
+<span class="sourceLineNo">082</span>   * Resets internal state to same as given {@code tracker}, and change the deleted flag according<a name="line.82"></a>
+<span class="sourceLineNo">083</span>   * to the modified flag if {@code resetDelete} is true. Does deep copy of the bitmap.<a name="line.83"></a>
+<span class="sourceLineNo">084</span>   * &lt;p/&gt;<a name="line.84"></a>
+<span class="sourceLineNo">085</span>   * The {@code resetDelete} will be set to true when building cleanup tracker, please see the<a name="line.85"></a>
+<span class="sourceLineNo">086</span>   * comments in {@link BitSetNode#BitSetNode(BitSetNode, boolean)} to learn how we change the<a name="line.86"></a>
+<span class="sourceLineNo">087</span>   * deleted flag if {@code resetDelete} is true.<a name="line.87"></a>
+<span class="sourceLineNo">088</span>   */<a name="line.88"></a>
+<span class="sourceLineNo">089</span>  public void resetTo(ProcedureStoreTracker tracker, boolean resetDelete) {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    reset();<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    // resetDelete will true if we are building the cleanup tracker, as we will reset deleted flags<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    // for all the unmodified bits to 1, the partial flag is useless so set it to false for not<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    // confusing the developers when debugging.<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    this.partial = resetDelete ? false : tracker.partial;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>    this.minModifiedProcId = tracker.minModifiedProcId;<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    this.maxModifiedProcId = tracker.maxModifiedProcId;<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    this.keepDeletes = tracker.keepDeletes;<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : tracker.map.entrySet()) {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>      map.put(entry.getKey(), new BitSetNode(entry.getValue(), resetDelete));<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    }<a name="line.100"></a>
 <span class="sourceLineNo">101</span>  }<a name="line.101"></a>
 <span class="sourceLineNo">102</span><a name="line.102"></a>
-<span class="sourceLineNo">103</span>  public void insert(long[] procIds) {<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      insert(procIds[i]);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    }<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>  public void insert(long procId, long[] subProcIds) {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    BitSetNode node = update(null, procId);<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    for (int i = 0; i &lt; subProcIds.length; ++i) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      node = insert(node, subProcIds[i]);<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    }<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  }<a name="line.114"></a>
-<span class="sourceLineNo">115</span><a name="line.115"></a>
-<span class="sourceLineNo">116</span>  private BitSetNode insert(BitSetNode node, long procId) {<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    if (node == null || !node.contains(procId)) {<a name="line.117"></a>
-<span class="sourceLineNo">118</span>      node = getOrCreateNode(procId);<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    }<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    node.insertOrUpdate(procId);<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    trackProcIds(procId);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    return node;<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>  public void update(long procId) {<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    update(null, procId);<a name="line.126"></a>
+<span class="sourceLineNo">103</span>  public void insert(long procId) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    insert(null, procId);<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>  public void insert(long[] procIds) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      insert(procIds[i]);<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><a name="line.112"></a>
+<span class="sourceLineNo">113</span>  public void insert(long procId, long[] subProcIds) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    BitSetNode node = update(null, procId);<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    for (int i = 0; i &lt; subProcIds.length; ++i) {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>      node = insert(node, subProcIds[i]);<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    }<a name="line.117"></a>
+<span class="sourceLineNo">118</span>  }<a name="line.118"></a>
+<span class="sourceLineNo">119</span><a name="line.119"></a>
+<span class="sourceLineNo">120</span>  private BitSetNode insert(BitSetNode node, long procId) {<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    if (node == null || !node.contains(procId)) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>      node = getOrCreateNode(procId);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    }<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    node.insertOrUpdate(procId);<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    trackProcIds(procId);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    return node;<a name="line.126"></a>
 <span class="sourceLineNo">127</span>  }<a name="line.127"></a>
 <span class="sourceLineNo">128</span><a name="line.128"></a>
-<span class="sourceLineNo">129</span>  private BitSetNode update(BitSetNode node, long procId) {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    node = lookupClosestNode(node, procId);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    assert node != null : "expected node to update procId=" + procId;<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    node.insertOrUpdate(procId);<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    trackProcIds(procId);<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    return node;<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>  public void delete(long procId) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    delete(null, procId);<a name="line.139"></a>
+<span class="sourceLineNo">129</span>  public void update(long procId) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    update(null, procId);<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>  private BitSetNode update(BitSetNode node, long procId) {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    node = lookupClosestNode(node, procId);<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    assert node != null : "expected node to update procId=" + procId;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    node.insertOrUpdate(procId);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    trackProcIds(procId);<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    return node;<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>  public void delete(final long[] procIds) {<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    Arrays.sort(procIds);<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    BitSetNode node = null;<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      node = delete(node, procIds[i]);<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>  private BitSetNode delete(BitSetNode node, long procId) {<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    node = lookupClosestNode(node, procId);<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    assert node != null : "expected node to delete procId=" + procId;<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    node.delete(procId);<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    if (!keepDeletes &amp;&amp; node.isEmpty()) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>      // TODO: RESET if (map.size() == 1)<a name="line.156"></a>
-<span class="sourceLineNo">157</span>      map.remove(node.getStart());<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    }<a name="line.158"></a>
-<span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>    trackProcIds(procId);<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    return node;<a name="line.161"></a>
-<span class="sourceLineNo">162</span>  }<a name="line.162"></a>
+<span class="sourceLineNo">142</span>  public void delete(long procId) {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    delete(null, procId);<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 void delete(final long[] procIds) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    Arrays.sort(procIds);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    BitSetNode node = null;<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      node = delete(node, procIds[i]);<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><a name="line.153"></a>
+<span class="sourceLineNo">154</span>  private BitSetNode delete(BitSetNode node, long procId) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    node = lookupClosestNode(node, procId);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    assert node != null : "expected node to delete procId=" + procId;<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.157"></a>
+<span class="sourceLineNo">158</span>    node.delete(procId);<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    if (!keepDeletes &amp;&amp; node.isEmpty()) {<a name="line.159"></a>
+<span class="sourceLineNo">160</span>      // TODO: RESET if (map.size() == 1)<a name="line.160"></a>
+<span class="sourceLineNo">161</span>      map.remove(node.getStart());<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    }<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>   * Will be called when restarting where we need to rebuild the ProcedureStoreTracker.<a name="line.165"></a>
-<span class="sourceLineNo">166</span>   */<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  public void setMinMaxModifiedProcIds(long min, long max) {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    this.minModifiedProcId = min;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    this.maxModifiedProcId = max;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>  }<a name="line.170"></a>
-<span class="sourceLineNo">171</span>  /**<a name="line.171"></a>
-<span class="sourceLineNo">172</span>   * This method is used when restarting where we need to rebuild the ProcedureStoreTracker. The<a name="line.172"></a>
-<span class="sourceLineNo">173</span>   * {@link #delete(long)} method above assume that the {@link BitSetNode} exists, but when restart<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   * this is not true, as we will read the wal files in reverse order so a delete may come first.<a name="line.174"></a>
-<span class="sourceLineNo">175</span>   */<a name="line.175"></a>
-<span class="sourceLineNo">176</span>  public void setDeleted(long procId, boolean isDeleted) {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    BitSetNode node = getOrCreateNode(procId);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node=" + node;<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    node.updateState(procId, isDeleted);<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    trackProcIds(procId);<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>  /**<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * Set the given bit for the procId to delete if it was modified before.<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   * &lt;p/&gt;<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   * This method is used to test whether a procedure wal file can be safely deleted, as if all the<a name="line.186"></a>
-<span class="sourceLineNo">187</span>   * procedures in the given procedure wal file has been modified in the new procedure wal files,<a name="line.187"></a>
-<span class="sourceLineNo">188</span>   * then we can delete it.<a name="line.188"></a>
-<span class="sourceLineNo">189</span>   */<a name="line.189"></a>
-<span class="sourceLineNo">190</span>  public void setDeletedIfModified(long... procId) {<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    BitSetNode node = null;<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    for (int i = 0; i &lt; procId.length; ++i) {<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      node = lookupClosestNode(node, procId[i]);<a name="line.193"></a>
-<span class="sourceLineNo">194</span>      if (node != null &amp;&amp; node.isModified(procId[i])) {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>        node.delete(procId[i]);<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      }<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><a name="line.199"></a>
-<span class="sourceLineNo">200</span>  /**<a name="line.200"></a>
-<span class="sourceLineNo">201</span>   * Similar with {@link #setDeletedIfModified(long...)}, but here the {@code procId} are given by<a name="line.201"></a>
-<span class="sourceLineNo">202</span>   * the {@code tracker}. If a procedure is modified by us, and also by the given {@code tracker},<a name="line.202"></a>
-<span class="sourceLineNo">203</span>   * then we mark it as deleted.<a name="line.203"></a>
-<span class="sourceLineNo">204</span>   * @see #setDeletedIfModified(long...)<a name="line.204"></a>
-<span class="sourceLineNo">205</span>   */<a name="line.205"></a>
-<span class="sourceLineNo">206</span>  public void setDeletedIfModifiedInBoth(ProcedureStoreTracker tracker, boolean globalTracker) {<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    BitSetNode trackerNode = null;<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    for (BitSetNode node : map.values()) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      final long minProcId = node.getStart();<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      final long maxProcId = node.getEnd();<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      for (long procId = minProcId; procId &lt;= maxProcId; ++procId) {<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        if (!node.isModified(procId)) {<a name="line.212"></a>
-<span class="sourceLineNo">213</span>          continue;<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>        trackerNode = tracker.lookupClosestNode(trackerNode, procId);<a name="line.216"></a>
-<span class="sourceLineNo">217</span>        if (trackerNode == null || !trackerNode.contains(procId)) {<a name="line.217"></a>
-<span class="sourceLineNo">218</span>          // the procId is not exist in the track, we can only delete the proc<a name="line.218"></a>
-<span class="sourceLineNo">219</span>          // if globalTracker set to true.<a name="line.219"></a>
-<span class="sourceLineNo">220</span>          // Only if the procedure is not in the global tracker we can delete the<a name="line.220"></a>
-<span class="sourceLineNo">221</span>          // the procedure. In other cases, the procedure may not update in a single<a name="line.221"></a>
-<span class="sourceLineNo">222</span>          // log, we cannot delete it just because the log's track doesn't have<a name="line.222"></a>
-<span class="sourceLineNo">223</span>          // any info for the procedure.<a name="line.223"></a>
-<span class="sourceLineNo">224</span>          if (globalTracker) {<a name="line.224"></a>
-<span class="sourceLineNo">225</span>            node.delete(procId);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>          }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>          continue;<a name="line.227"></a>
-<span class="sourceLineNo">228</span>        }<a name="line.228"></a>
-<span class="sourceLineNo">229</span>        // Only check delete in the global tracker, only global tracker has the<a name="line.229"></a>
-<span class="sourceLineNo">230</span>        // whole picture<a name="line.230"></a>
-<span class="sourceLineNo">231</span>        if (globalTracker &amp;&amp; trackerNode.isDeleted(procId) == DeleteState.YES) {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>          node.delete(procId);<a name="line.232"></a>
-<span class="sourceLineNo">233</span>          continue;<a name="line.233"></a>
-<span class="sourceLineNo">234</span>        }<a name="line.234"></a>
-<span class="sourceLineNo">235</span>        if (trackerNode.isModified(procId)) {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>          // the procedure was modified<a name="line.236"></a>
-<span class="sourceLineNo">237</span>          node.delete(procId);<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        }<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">164</span>    trackProcIds(procId);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    return node;<a name="line.165"></a>
+<span class="sourceLineNo">166</span>  }<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>   * Will be called when restarting where we need to rebuild the ProcedureStoreTracker.<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   */<a name="line.170"></a>
+<span class="sourceLineNo">171</span>  public void setMinMaxModifiedProcIds(long min, long max) {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    this.minModifiedProcId = min;<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    this.maxModifiedProcId = max;<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>   * This method is used when restarting where we need to rebuild the ProcedureStoreTracker. The<a name="line.176"></a>
+<span class="sourceLineNo">177</span>   * {@link #delete(long)} method above assume that the {@link BitSetNode} exists, but when restart<a name="line.177"></a>
+<span class="sourceLineNo">178</span>   * this is not true, as we will read the wal files in reverse order so a delete may come first.<a name="line.178"></a>
+<span class="sourceLineNo">179</span>   */<a name="line.179"></a>
+<span class="sourceLineNo">180</span>  public void setDeleted(long procId, boolean isDeleted) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    BitSetNode node = getOrCreateNode(procId);<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node=" + node;<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    node.updateState(procId, isDeleted);<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    trackProcIds(procId);<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>  /**<a name="line.187"></a>
+<span class="sourceLineNo">188</span>   * Set the given bit for the procId to delete if it was modified before.<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   * &lt;p/&gt;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * This method is used to test whether a procedure wal file can be safely deleted, as if all the<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * procedures in the given procedure wal file has been modified in the new procedure wal files,<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * then we can delete it.<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   */<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  public void setDeletedIfModified(long... procId) {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    BitSetNode node = null;<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    for (int i = 0; i &lt; procId.length; ++i) {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      node = lookupClosestNode(node, procId[i]);<a name="line.197"></a>
+<span class="sourceLineNo">198</span>      if (node != null &amp;&amp; node.isModified(procId[i])) {<a name="line.198"></a>
+<span class="sourceLineNo">199</span>        node.delete(procId[i]);<a name="line.199"></a>
+<span class="sourceLineNo">200</span>      }<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    }<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>  private void setDeleteIf(ProcedureStoreTracker tracker,<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      BiFunction&lt;BitSetNode, Long, Boolean&gt; func) {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>    BitSetNode trackerNode = null;<a name="line.206"></a>
+<span class="sourceLineNo">207</span>    for (BitSetNode node : map.values()) {<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      long minProcId = node.getStart();<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      long maxProcId = node.getEnd();<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      for (long procId = minProcId; procId &lt;= maxProcId; ++procId) {<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        if (!node.isModified(procId)) {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>          continue;<a name="line.212"></a>
+<span class="sourceLineNo">213</span>        }<a name="line.213"></a>
+<span class="sourceLineNo">214</span><a name="line.214"></a>
+<span class="sourceLineNo">215</span>        trackerNode = tracker.lookupClosestNode(trackerNode, procId);<a name="line.215"></a>
+<span class="sourceLineNo">216</span>        if (func.apply(trackerNode, procId)) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>          node.delete(procId);<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 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>   * For the global tracker, we will use this method to build the holdingCleanupTracker, as the<a name="line.224"></a>
+<span class="sourceLineNo">225</span>   * modified flags will be cleared after rolling so we only need to test the deleted flags.<a name="line.225"></a>
+<span class="sourceLineNo">226</span>   * @see #setDeletedIfModifiedInBoth(ProcedureStoreTracker)<a name="line.226"></a>
+<span class="sourceLineNo">227</span>   */<a name="line.227"></a>
+<span class="sourceLineNo">228</span>  public void setDeletedIfDeletedByThem(ProcedureStoreTracker tracker) {<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    setDeleteIf(tracker, (node, procId) -&gt; node == null || !node.contains(procId) ||<a name="line.229"></a>
+<span class="sourceLineNo">230</span>      node.isDeleted(procId) == DeleteState.YES);<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>  /**<a name="line.233"></a>
+<span class="sourceLineNo">234</span>   * Similar with {@link #setDeletedIfModified(long...)}, but here the {@code procId} are given by<a name="line.234"></a>
+<span class="sourceLineNo">235</span>   * the {@code tracker}. If a procedure is modified by us, and also by the given {@code tracker},<a name="line.235"></a>
+<span class="sourceLineNo">236</span>   * then we mark it as deleted.<a name="line.236"></a>
+<span class="sourceLineNo">237</span>   * @see #setDeletedIfModified(long...)<a name="line.237"></a>
+<span class="sourceLineNo">238</span>   */<a name="line.238"></a>
+<span class="sourceLineNo">239</span>  public void setDeletedIfModifiedInBoth(ProcedureStoreTracker tracker) {<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    setDeleteIf(tracker, (node, procId) -&gt; node != null &amp;&amp; node.isModified(procId));<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>  /**<a name="line.243"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/8f09a71d/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
index 1579eab..dc5908e 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/store/ProcedureStoreTracker.html
@@ -31,221 +31,221 @@
 <span class="sourceLineNo">023</span>import java.util.Iterator;<a name="line.23"></a>
 <span class="sourceLineNo">024</span>import java.util.Map;<a name="line.24"></a>
 <span class="sourceLineNo">025</span>import java.util.TreeMap;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import java.util.stream.LongStream;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.procedure2.Procedure;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.29"></a>
-<span class="sourceLineNo">030</span><a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;<a name="line.31"></a>
-<span class="sourceLineNo">032</span><a name="line.32"></a>
-<span class="sourceLineNo">033</span>/**<a name="line.33"></a>
-<span class="sourceLineNo">034</span> * Keeps track of live procedures.<a name="line.34"></a>
-<span class="sourceLineNo">035</span> *<a name="line.35"></a>
-<span class="sourceLineNo">036</span> * It can be used by the ProcedureStore to identify which procedures are already<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * deleted/completed to avoid the deserialization step on restart<a name="line.37"></a>
-<span class="sourceLineNo">038</span> */<a name="line.38"></a>
-<span class="sourceLineNo">039</span>@InterfaceAudience.Private<a name="line.39"></a>
-<span class="sourceLineNo">040</span>@InterfaceStability.Evolving<a name="line.40"></a>
-<span class="sourceLineNo">041</span>public class ProcedureStoreTracker {<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  // Key is procedure id corresponding to first bit of the bitmap.<a name="line.42"></a>
-<span class="sourceLineNo">043</span>  private final TreeMap&lt;Long, BitSetNode&gt; map = new TreeMap&lt;&gt;();<a name="line.43"></a>
-<span class="sourceLineNo">044</span><a name="line.44"></a>
-<span class="sourceLineNo">045</span>  /**<a name="line.45"></a>
-<span class="sourceLineNo">046</span>   * If true, do not remove bits corresponding to deleted procedures. Note that this can result<a name="line.46"></a>
-<span class="sourceLineNo">047</span>   * in huge bitmaps overtime.<a name="line.47"></a>
-<span class="sourceLineNo">048</span>   * Currently, it's set to true only when building tracker state from logs during recovery. During<a name="line.48"></a>
-<span class="sourceLineNo">049</span>   * recovery, if we are sure that a procedure has been deleted, reading its old update entries<a name="line.49"></a>
-<span class="sourceLineNo">050</span>   * can be skipped.<a name="line.50"></a>
-<span class="sourceLineNo">051</span>   */<a name="line.51"></a>
-<span class="sourceLineNo">052</span>  private boolean keepDeletes = false;<a name="line.52"></a>
-<span class="sourceLineNo">053</span>  /**<a name="line.53"></a>
-<span class="sourceLineNo">054</span>   * If true, it means tracker has incomplete information about the active/deleted procedures.<a name="line.54"></a>
-<span class="sourceLineNo">055</span>   * It's set to true only when recovering from old logs. See {@link #isDeleted(long)} docs to<a name="line.55"></a>
-<span class="sourceLineNo">056</span>   * understand it's real use.<a name="line.56"></a>
-<span class="sourceLineNo">057</span>   */<a name="line.57"></a>
-<span class="sourceLineNo">058</span>  boolean partial = false;<a name="line.58"></a>
-<span class="sourceLineNo">059</span><a name="line.59"></a>
-<span class="sourceLineNo">060</span>  private long minModifiedProcId = Long.MAX_VALUE;<a name="line.60"></a>
-<span class="sourceLineNo">061</span>  private long maxModifiedProcId = Long.MIN_VALUE;<a name="line.61"></a>
-<span class="sourceLineNo">062</span><a name="line.62"></a>
-<span class="sourceLineNo">063</span>  public enum DeleteState { YES, NO, MAYBE }<a name="line.63"></a>
-<span class="sourceLineNo">064</span><a name="line.64"></a>
-<span class="sourceLineNo">065</span>  public void resetToProto(ProcedureProtos.ProcedureStoreTracker trackerProtoBuf) {<a name="line.65"></a>
-<span class="sourceLineNo">066</span>    reset();<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: trackerProtoBuf.getNodeList()) {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>      final BitSetNode node = new BitSetNode(protoNode);<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      map.put(node.getStart(), node);<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>  /**<a name="line.73"></a>
-<span class="sourceLineNo">074</span>   * Resets internal state to same as given {@code tracker}. Does deep copy of the bitmap.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>   */<a name="line.75"></a>
-<span class="sourceLineNo">076</span>  public void resetTo(ProcedureStoreTracker tracker) {<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    resetTo(tracker, false);<a name="line.77"></a>
-<span class="sourceLineNo">078</span>  }<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>   * Resets internal state to same as given {@code tracker}, and change the deleted flag according<a name="line.81"></a>
-<span class="sourceLineNo">082</span>   * to the modified flag if {@code resetDelete} is true. Does deep copy of the bitmap.<a name="line.82"></a>
-<span class="sourceLineNo">083</span>   * &lt;p/&gt;<a name="line.83"></a>
-<span class="sourceLineNo">084</span>   * The {@code resetDelete} will be set to true when building cleanup tracker, please see the<a name="line.84"></a>
-<span class="sourceLineNo">085</span>   * comments in {@link BitSetNode#BitSetNode(BitSetNode, boolean)} to learn how we change the<a name="line.85"></a>
-<span class="sourceLineNo">086</span>   * deleted flag if {@code resetDelete} is true.<a name="line.86"></a>
-<span class="sourceLineNo">087</span>   */<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  public void resetTo(ProcedureStoreTracker tracker, boolean resetDelete) {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    reset();<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    this.partial = tracker.partial;<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    this.minModifiedProcId = tracker.minModifiedProcId;<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    this.maxModifiedProcId = tracker.maxModifiedProcId;<a name="line.92"></a>
-<span class="sourceLineNo">093</span>    this.keepDeletes = tracker.keepDeletes;<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : tracker.map.entrySet()) {<a name="line.94"></a>
-<span class="sourceLineNo">095</span>      map.put(entry.getKey(), new BitSetNode(entry.getValue(), resetDelete));<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><a name="line.98"></a>
-<span class="sourceLineNo">099</span>  public void insert(long procId) {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    insert(null, procId);<a name="line.100"></a>
+<span class="sourceLineNo">026</span>import java.util.function.BiFunction;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import java.util.stream.LongStream;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.procedure2.Procedure;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.30"></a>
+<span class="sourceLineNo">031</span><a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;<a name="line.32"></a>
+<span class="sourceLineNo">033</span><a name="line.33"></a>
+<span class="sourceLineNo">034</span>/**<a name="line.34"></a>
+<span class="sourceLineNo">035</span> * Keeps track of live procedures.<a name="line.35"></a>
+<span class="sourceLineNo">036</span> *<a name="line.36"></a>
+<span class="sourceLineNo">037</span> * It can be used by the ProcedureStore to identify which procedures are already<a name="line.37"></a>
+<span class="sourceLineNo">038</span> * deleted/completed to avoid the deserialization step on restart<a name="line.38"></a>
+<span class="sourceLineNo">039</span> */<a name="line.39"></a>
+<span class="sourceLineNo">040</span>@InterfaceAudience.Private<a name="line.40"></a>
+<span class="sourceLineNo">041</span>@InterfaceStability.Evolving<a name="line.41"></a>
+<span class="sourceLineNo">042</span>public class ProcedureStoreTracker {<a name="line.42"></a>
+<span class="sourceLineNo">043</span>  // Key is procedure id corresponding to first bit of the bitmap.<a name="line.43"></a>
+<span class="sourceLineNo">044</span>  private final TreeMap&lt;Long, BitSetNode&gt; map = new TreeMap&lt;&gt;();<a name="line.44"></a>
+<span class="sourceLineNo">045</span><a name="line.45"></a>
+<span class="sourceLineNo">046</span>  /**<a name="line.46"></a>
+<span class="sourceLineNo">047</span>   * If true, do not remove bits corresponding to deleted procedures. Note that this can result<a name="line.47"></a>
+<span class="sourceLineNo">048</span>   * in huge bitmaps overtime.<a name="line.48"></a>
+<span class="sourceLineNo">049</span>   * Currently, it's set to true only when building tracker state from logs during recovery. During<a name="line.49"></a>
+<span class="sourceLineNo">050</span>   * recovery, if we are sure that a procedure has been deleted, reading its old update entries<a name="line.50"></a>
+<span class="sourceLineNo">051</span>   * can be skipped.<a name="line.51"></a>
+<span class="sourceLineNo">052</span>   */<a name="line.52"></a>
+<span class="sourceLineNo">053</span>  private boolean keepDeletes = false;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>  /**<a name="line.54"></a>
+<span class="sourceLineNo">055</span>   * If true, it means tracker has incomplete information about the active/deleted procedures.<a name="line.55"></a>
+<span class="sourceLineNo">056</span>   * It's set to true only when recovering from old logs. See {@link #isDeleted(long)} docs to<a name="line.56"></a>
+<span class="sourceLineNo">057</span>   * understand it's real use.<a name="line.57"></a>
+<span class="sourceLineNo">058</span>   */<a name="line.58"></a>
+<span class="sourceLineNo">059</span>  boolean partial = false;<a name="line.59"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>  private long minModifiedProcId = Long.MAX_VALUE;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>  private long maxModifiedProcId = Long.MIN_VALUE;<a name="line.62"></a>
+<span class="sourceLineNo">063</span><a name="line.63"></a>
+<span class="sourceLineNo">064</span>  public enum DeleteState { YES, NO, MAYBE }<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>  public void resetToProto(ProcedureProtos.ProcedureStoreTracker trackerProtoBuf) {<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    reset();<a name="line.67"></a>
+<span class="sourceLineNo">068</span>    for (ProcedureProtos.ProcedureStoreTracker.TrackerNode protoNode: trackerProtoBuf.getNodeList()) {<a name="line.68"></a>
+<span class="sourceLineNo">069</span>      final BitSetNode node = new BitSetNode(protoNode);<a name="line.69"></a>
+<span class="sourceLineNo">070</span>      map.put(node.getStart(), node);<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><a name="line.73"></a>
+<span class="sourceLineNo">074</span>  /**<a name="line.74"></a>
+<span class="sourceLineNo">075</span>   * Resets internal state to same as given {@code tracker}. Does deep copy of the bitmap.<a name="line.75"></a>
+<span class="sourceLineNo">076</span>   */<a name="line.76"></a>
+<span class="sourceLineNo">077</span>  public void resetTo(ProcedureStoreTracker tracker) {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    resetTo(tracker, false);<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>  /**<a name="line.81"></a>
+<span class="sourceLineNo">082</span>   * Resets internal state to same as given {@code tracker}, and change the deleted flag according<a name="line.82"></a>
+<span class="sourceLineNo">083</span>   * to the modified flag if {@code resetDelete} is true. Does deep copy of the bitmap.<a name="line.83"></a>
+<span class="sourceLineNo">084</span>   * &lt;p/&gt;<a name="line.84"></a>
+<span class="sourceLineNo">085</span>   * The {@code resetDelete} will be set to true when building cleanup tracker, please see the<a name="line.85"></a>
+<span class="sourceLineNo">086</span>   * comments in {@link BitSetNode#BitSetNode(BitSetNode, boolean)} to learn how we change the<a name="line.86"></a>
+<span class="sourceLineNo">087</span>   * deleted flag if {@code resetDelete} is true.<a name="line.87"></a>
+<span class="sourceLineNo">088</span>   */<a name="line.88"></a>
+<span class="sourceLineNo">089</span>  public void resetTo(ProcedureStoreTracker tracker, boolean resetDelete) {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    reset();<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    // resetDelete will true if we are building the cleanup tracker, as we will reset deleted flags<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    // for all the unmodified bits to 1, the partial flag is useless so set it to false for not<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    // confusing the developers when debugging.<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    this.partial = resetDelete ? false : tracker.partial;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>    this.minModifiedProcId = tracker.minModifiedProcId;<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    this.maxModifiedProcId = tracker.maxModifiedProcId;<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    this.keepDeletes = tracker.keepDeletes;<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    for (Map.Entry&lt;Long, BitSetNode&gt; entry : tracker.map.entrySet()) {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>      map.put(entry.getKey(), new BitSetNode(entry.getValue(), resetDelete));<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    }<a name="line.100"></a>
 <span class="sourceLineNo">101</span>  }<a name="line.101"></a>
 <span class="sourceLineNo">102</span><a name="line.102"></a>
-<span class="sourceLineNo">103</span>  public void insert(long[] procIds) {<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      insert(procIds[i]);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    }<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>  public void insert(long procId, long[] subProcIds) {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    BitSetNode node = update(null, procId);<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    for (int i = 0; i &lt; subProcIds.length; ++i) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      node = insert(node, subProcIds[i]);<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    }<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  }<a name="line.114"></a>
-<span class="sourceLineNo">115</span><a name="line.115"></a>
-<span class="sourceLineNo">116</span>  private BitSetNode insert(BitSetNode node, long procId) {<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    if (node == null || !node.contains(procId)) {<a name="line.117"></a>
-<span class="sourceLineNo">118</span>      node = getOrCreateNode(procId);<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    }<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    node.insertOrUpdate(procId);<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    trackProcIds(procId);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    return node;<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>  public void update(long procId) {<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    update(null, procId);<a name="line.126"></a>
+<span class="sourceLineNo">103</span>  public void insert(long procId) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    insert(null, procId);<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>  public void insert(long[] procIds) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      insert(procIds[i]);<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><a name="line.112"></a>
+<span class="sourceLineNo">113</span>  public void insert(long procId, long[] subProcIds) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    BitSetNode node = update(null, procId);<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    for (int i = 0; i &lt; subProcIds.length; ++i) {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>      node = insert(node, subProcIds[i]);<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    }<a name="line.117"></a>
+<span class="sourceLineNo">118</span>  }<a name="line.118"></a>
+<span class="sourceLineNo">119</span><a name="line.119"></a>
+<span class="sourceLineNo">120</span>  private BitSetNode insert(BitSetNode node, long procId) {<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    if (node == null || !node.contains(procId)) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>      node = getOrCreateNode(procId);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    }<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    node.insertOrUpdate(procId);<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    trackProcIds(procId);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    return node;<a name="line.126"></a>
 <span class="sourceLineNo">127</span>  }<a name="line.127"></a>
 <span class="sourceLineNo">128</span><a name="line.128"></a>
-<span class="sourceLineNo">129</span>  private BitSetNode update(BitSetNode node, long procId) {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    node = lookupClosestNode(node, procId);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    assert node != null : "expected node to update procId=" + procId;<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    node.insertOrUpdate(procId);<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    trackProcIds(procId);<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    return node;<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>  public void delete(long procId) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    delete(null, procId);<a name="line.139"></a>
+<span class="sourceLineNo">129</span>  public void update(long procId) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    update(null, procId);<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>  private BitSetNode update(BitSetNode node, long procId) {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    node = lookupClosestNode(node, procId);<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    assert node != null : "expected node to update procId=" + procId;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    node.insertOrUpdate(procId);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    trackProcIds(procId);<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    return node;<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>  public void delete(final long[] procIds) {<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    Arrays.sort(procIds);<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    BitSetNode node = null;<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      node = delete(node, procIds[i]);<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>  private BitSetNode delete(BitSetNode node, long procId) {<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    node = lookupClosestNode(node, procId);<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    assert node != null : "expected node to delete procId=" + procId;<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    node.delete(procId);<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    if (!keepDeletes &amp;&amp; node.isEmpty()) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>      // TODO: RESET if (map.size() == 1)<a name="line.156"></a>
-<span class="sourceLineNo">157</span>      map.remove(node.getStart());<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    }<a name="line.158"></a>
-<span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>    trackProcIds(procId);<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    return node;<a name="line.161"></a>
-<span class="sourceLineNo">162</span>  }<a name="line.162"></a>
+<span class="sourceLineNo">142</span>  public void delete(long procId) {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    delete(null, procId);<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 void delete(final long[] procIds) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    Arrays.sort(procIds);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    BitSetNode node = null;<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    for (int i = 0; i &lt; procIds.length; ++i) {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      node = delete(node, procIds[i]);<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><a name="line.153"></a>
+<span class="sourceLineNo">154</span>  private BitSetNode delete(BitSetNode node, long procId) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    node = lookupClosestNode(node, procId);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    assert node != null : "expected node to delete procId=" + procId;<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node";<a name="line.157"></a>
+<span class="sourceLineNo">158</span>    node.delete(procId);<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    if (!keepDeletes &amp;&amp; node.isEmpty()) {<a name="line.159"></a>
+<span class="sourceLineNo">160</span>      // TODO: RESET if (map.size() == 1)<a name="line.160"></a>
+<span class="sourceLineNo">161</span>      map.remove(node.getStart());<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    }<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>   * Will be called when restarting where we need to rebuild the ProcedureStoreTracker.<a name="line.165"></a>
-<span class="sourceLineNo">166</span>   */<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  public void setMinMaxModifiedProcIds(long min, long max) {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    this.minModifiedProcId = min;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    this.maxModifiedProcId = max;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>  }<a name="line.170"></a>
-<span class="sourceLineNo">171</span>  /**<a name="line.171"></a>
-<span class="sourceLineNo">172</span>   * This method is used when restarting where we need to rebuild the ProcedureStoreTracker. The<a name="line.172"></a>
-<span class="sourceLineNo">173</span>   * {@link #delete(long)} method above assume that the {@link BitSetNode} exists, but when restart<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   * this is not true, as we will read the wal files in reverse order so a delete may come first.<a name="line.174"></a>
-<span class="sourceLineNo">175</span>   */<a name="line.175"></a>
-<span class="sourceLineNo">176</span>  public void setDeleted(long procId, boolean isDeleted) {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    BitSetNode node = getOrCreateNode(procId);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node=" + node;<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    node.updateState(procId, isDeleted);<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    trackProcIds(procId);<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>  /**<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * Set the given bit for the procId to delete if it was modified before.<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   * &lt;p/&gt;<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   * This method is used to test whether a procedure wal file can be safely deleted, as if all the<a name="line.186"></a>
-<span class="sourceLineNo">187</span>   * procedures in the given procedure wal file has been modified in the new procedure wal files,<a name="line.187"></a>
-<span class="sourceLineNo">188</span>   * then we can delete it.<a name="line.188"></a>
-<span class="sourceLineNo">189</span>   */<a name="line.189"></a>
-<span class="sourceLineNo">190</span>  public void setDeletedIfModified(long... procId) {<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    BitSetNode node = null;<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    for (int i = 0; i &lt; procId.length; ++i) {<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      node = lookupClosestNode(node, procId[i]);<a name="line.193"></a>
-<span class="sourceLineNo">194</span>      if (node != null &amp;&amp; node.isModified(procId[i])) {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>        node.delete(procId[i]);<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      }<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><a name="line.199"></a>
-<span class="sourceLineNo">200</span>  /**<a name="line.200"></a>
-<span class="sourceLineNo">201</span>   * Similar with {@link #setDeletedIfModified(long...)}, but here the {@code procId} are given by<a name="line.201"></a>
-<span class="sourceLineNo">202</span>   * the {@code tracker}. If a procedure is modified by us, and also by the given {@code tracker},<a name="line.202"></a>
-<span class="sourceLineNo">203</span>   * then we mark it as deleted.<a name="line.203"></a>
-<span class="sourceLineNo">204</span>   * @see #setDeletedIfModified(long...)<a name="line.204"></a>
-<span class="sourceLineNo">205</span>   */<a name="line.205"></a>
-<span class="sourceLineNo">206</span>  public void setDeletedIfModifiedInBoth(ProcedureStoreTracker tracker, boolean globalTracker) {<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    BitSetNode trackerNode = null;<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    for (BitSetNode node : map.values()) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      final long minProcId = node.getStart();<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      final long maxProcId = node.getEnd();<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      for (long procId = minProcId; procId &lt;= maxProcId; ++procId) {<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        if (!node.isModified(procId)) {<a name="line.212"></a>
-<span class="sourceLineNo">213</span>          continue;<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>        trackerNode = tracker.lookupClosestNode(trackerNode, procId);<a name="line.216"></a>
-<span class="sourceLineNo">217</span>        if (trackerNode == null || !trackerNode.contains(procId)) {<a name="line.217"></a>
-<span class="sourceLineNo">218</span>          // the procId is not exist in the track, we can only delete the proc<a name="line.218"></a>
-<span class="sourceLineNo">219</span>          // if globalTracker set to true.<a name="line.219"></a>
-<span class="sourceLineNo">220</span>          // Only if the procedure is not in the global tracker we can delete the<a name="line.220"></a>
-<span class="sourceLineNo">221</span>          // the procedure. In other cases, the procedure may not update in a single<a name="line.221"></a>
-<span class="sourceLineNo">222</span>          // log, we cannot delete it just because the log's track doesn't have<a name="line.222"></a>
-<span class="sourceLineNo">223</span>          // any info for the procedure.<a name="line.223"></a>
-<span class="sourceLineNo">224</span>          if (globalTracker) {<a name="line.224"></a>
-<span class="sourceLineNo">225</span>            node.delete(procId);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>          }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>          continue;<a name="line.227"></a>
-<span class="sourceLineNo">228</span>        }<a name="line.228"></a>
-<span class="sourceLineNo">229</span>        // Only check delete in the global tracker, only global tracker has the<a name="line.229"></a>
-<span class="sourceLineNo">230</span>        // whole picture<a name="line.230"></a>
-<span class="sourceLineNo">231</span>        if (globalTracker &amp;&amp; trackerNode.isDeleted(procId) == DeleteState.YES) {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>          node.delete(procId);<a name="line.232"></a>
-<span class="sourceLineNo">233</span>          continue;<a name="line.233"></a>
-<span class="sourceLineNo">234</span>        }<a name="line.234"></a>
-<span class="sourceLineNo">235</span>        if (trackerNode.isModified(procId)) {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>          // the procedure was modified<a name="line.236"></a>
-<span class="sourceLineNo">237</span>          node.delete(procId);<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        }<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">164</span>    trackProcIds(procId);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    return node;<a name="line.165"></a>
+<span class="sourceLineNo">166</span>  }<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>   * Will be called when restarting where we need to rebuild the ProcedureStoreTracker.<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   */<a name="line.170"></a>
+<span class="sourceLineNo">171</span>  public void setMinMaxModifiedProcIds(long min, long max) {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    this.minModifiedProcId = min;<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    this.maxModifiedProcId = max;<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>   * This method is used when restarting where we need to rebuild the ProcedureStoreTracker. The<a name="line.176"></a>
+<span class="sourceLineNo">177</span>   * {@link #delete(long)} method above assume that the {@link BitSetNode} exists, but when restart<a name="line.177"></a>
+<span class="sourceLineNo">178</span>   * this is not true, as we will read the wal files in reverse order so a delete may come first.<a name="line.178"></a>
+<span class="sourceLineNo">179</span>   */<a name="line.179"></a>
+<span class="sourceLineNo">180</span>  public void setDeleted(long procId, boolean isDeleted) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    BitSetNode node = getOrCreateNode(procId);<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    assert node.contains(procId) : "expected procId=" + procId + " in the node=" + node;<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    node.updateState(procId, isDeleted);<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    trackProcIds(procId);<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>  /**<a name="line.187"></a>
+<span class="sourceLineNo">188</span>   * Set the given bit for the procId to delete if it was modified before.<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   * &lt;p/&gt;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * This method is used to test whether a procedure wal file can be safely deleted, as if all the<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * procedures in the given procedure wal file has been modified in the new procedure wal files,<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * then we can delete it.<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   */<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  public void setDeletedIfModified(long... procId) {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    BitSetNode node = null;<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    for (int i = 0; i &lt; procId.length; ++i) {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      node = lookupClosestNode(node, procId[i]);<a name="line.197"></a>
+<span class="sourceLineNo">198</span>      if (node != null &amp;&amp; node.isModified(procId[i])) {<a name="line.198"></a>
+<span class="sourceLineNo">199</span>        node.delete(procId[i]);<a name="line.199"></a>
+<span class="sourceLineNo">200</span>      }<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    }<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>  private void setDeleteIf(ProcedureStoreTracker tracker,<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      BiFunction&lt;BitSetNode, Long, Boolean&gt; func) {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>    BitSetNode trackerNode = null;<a name="line.206"></a>
+<span class="sourceLineNo">207</span>    for (BitSetNode node : map.values()) {<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      long minProcId = node.getStart();<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      long maxProcId = node.getEnd();<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      for (long procId = minProcId; procId &lt;= maxProcId; ++procId) {<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        if (!node.isModified(procId)) {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>          continue;<a name="line.212"></a>
+<span class="sourceLineNo">213</span>        }<a name="line.213"></a>
+<span class="sourceLineNo">214</span><a name="line.214"></a>
+<span class="sourceLineNo">215</span>        trackerNode = tracker.lookupClosestNode(trackerNode, procId);<a name="line.215"></a>
+<span class="sourceLineNo">216</span>        if (func.apply(trackerNode, procId)) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>          node.delete(procId);<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 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>   * For the global tracker, we will use this method to build the holdingCleanupTracker, as the<a name="line.224"></a>
+<span class="sourceLineNo">225</span>   * modified flags will be cleared after rolling so we only need to test the deleted flags.<a name="line.225"></a>
+<span class="sourceLineNo">226</span>   * @see #setDeletedIfModifiedInBoth(ProcedureStoreTracker)<a name="line.226"></a>
+<span class="sourceLineNo">227</span>   */<a name="line.227"></a>
+<span class="sourceLineNo">228</span>  public void setDeletedIfDeletedByThem(ProcedureStoreTracker tracker) {<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    setDeleteIf(tracker, (node, procId) -&gt; node == null || !node.contains(procId) ||<a name="line.229"></a>
+<span class="sourceLineNo">230</span>      node.isDeleted(procId) == DeleteState.YES);<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>  /**<a name="line.233"></a>
+<span class="sourceLineNo">234</span>   * Similar with {@link #setDeletedIfModified(long...)}, but here the {@code procId} are given by<a name="line.234"></a>
+<span class="sourceLineNo">235</span>   * the {@code tracker}. If a procedure is modified by us, and also by the given {@code tracker},<a name="line.235"></a>
+<span class="sourceLineNo">236</span>   * then we mark it as deleted.<a name="line.236"></a>
+<span class="sourceLineNo">237</span>   * @see #setDeletedIfModified(long...)<a name="line.237"></a>
+<span class="sourceLineNo">238</span>   */<a name="line.238"></a>
+<span class="sourceLineNo">239</span>  public void setDeletedIfModifiedInBoth(ProcedureStoreTracker tracker) {<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    setDeleteIf(tracker, (node, procId) -&gt; node != null &amp;&amp; node.isModified(procId));<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>  /**<a name="line.243"></a>


Mime
View raw message