hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [22/29] hbase-site git commit: Published site at c9f8c3436f6e38b5c7807677c5c3e7fc3e19e071.
Date Fri, 18 May 2018 14:48:05 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ead846d7/devapidocs/org/apache/hadoop/hbase/util/package-tree.html
----------------------------------------------------------------------
diff --git a/devapidocs/org/apache/hadoop/hbase/util/package-tree.html b/devapidocs/org/apache/hadoop/hbase/util/package-tree.html
index 6c464c1..845224b 100644
--- a/devapidocs/org/apache/hadoop/hbase/util/package-tree.html
+++ b/devapidocs/org/apache/hadoop/hbase/util/package-tree.html
@@ -532,14 +532,14 @@
 <ul>
 <li type="circle">java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html?is-external=true" title="class or interface in java.lang"><span class="typeNameLink">Enum</span></a>&lt;E&gt; (implements java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a>&lt;T&gt;, java.io.<a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>)
 <ul>
+<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">Bytes.LexicographicalComparerHolder.UnsafeComparer</span></a> (implements org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Bytes.Comparer.html" title="interface in org.apache.hadoop.hbase.util">Bytes.Comparer</a>&lt;T&gt;)</li>
+<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/ChecksumType.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">ChecksumType</span></a></li>
 <li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.PureJavaComparer.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">Bytes.LexicographicalComparerHolder.PureJavaComparer</span></a> (implements org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Bytes.Comparer.html" title="interface in org.apache.hadoop.hbase.util">Bytes.Comparer</a>&lt;T&gt;)</li>
+<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Order.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">Order</span></a></li>
 <li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/HBaseFsck.ErrorReporter.ERROR_CODE.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">HBaseFsck.ErrorReporter.ERROR_CODE</span></a></li>
-<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/PoolMap.PoolType.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">PoolMap.PoolType</span></a></li>
 <li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/PrettyPrinter.Unit.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">PrettyPrinter.Unit</span></a></li>
-<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">Bytes.LexicographicalComparerHolder.UnsafeComparer</span></a> (implements org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Bytes.Comparer.html" title="interface in org.apache.hadoop.hbase.util">Bytes.Comparer</a>&lt;T&gt;)</li>
+<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/PoolMap.PoolType.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">PoolMap.PoolType</span></a></li>
 <li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/IdReadWriteLock.ReferenceType.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">IdReadWriteLock.ReferenceType</span></a></li>
-<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/Order.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">Order</span></a></li>
-<li type="circle">org.apache.hadoop.hbase.util.<a href="../../../../../org/apache/hadoop/hbase/util/ChecksumType.html" title="enum in org.apache.hadoop.hbase.util"><span class="typeNameLink">ChecksumType</span></a></li>
 </ul>
 </li>
 </ul>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ead846d7/devapidocs/org/apache/hadoop/hbase/wal/package-tree.html
----------------------------------------------------------------------
diff --git a/devapidocs/org/apache/hadoop/hbase/wal/package-tree.html b/devapidocs/org/apache/hadoop/hbase/wal/package-tree.html
index 9ec5b35..c0e28b4 100644
--- a/devapidocs/org/apache/hadoop/hbase/wal/package-tree.html
+++ b/devapidocs/org/apache/hadoop/hbase/wal/package-tree.html
@@ -189,8 +189,8 @@
 <ul>
 <li type="circle">java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html?is-external=true" title="class or interface in java.lang"><span class="typeNameLink">Enum</span></a>&lt;E&gt; (implements java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a>&lt;T&gt;, java.io.<a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>)
 <ul>
-<li type="circle">org.apache.hadoop.hbase.wal.<a href="../../../../../org/apache/hadoop/hbase/wal/WALFactory.Providers.html" title="enum in org.apache.hadoop.hbase.wal"><span class="typeNameLink">WALFactory.Providers</span></a></li>
 <li type="circle">org.apache.hadoop.hbase.wal.<a href="../../../../../org/apache/hadoop/hbase/wal/RegionGroupingProvider.Strategies.html" title="enum in org.apache.hadoop.hbase.wal"><span class="typeNameLink">RegionGroupingProvider.Strategies</span></a></li>
+<li type="circle">org.apache.hadoop.hbase.wal.<a href="../../../../../org/apache/hadoop/hbase/wal/WALFactory.Providers.html" title="enum in org.apache.hadoop.hbase.wal"><span class="typeNameLink">WALFactory.Providers</span></a></li>
 </ul>
 </li>
 </ul>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ead846d7/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
index f05b00d..9bc07e3 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
@@ -16,11 +16,11 @@
 <span class="sourceLineNo">008</span>@InterfaceAudience.Private<a name="line.8"></a>
 <span class="sourceLineNo">009</span>public class Version {<a name="line.9"></a>
 <span class="sourceLineNo">010</span>  public static final String version = "3.0.0-SNAPSHOT";<a name="line.10"></a>
-<span class="sourceLineNo">011</span>  public static final String revision = "cf529f18a9959589fa635f78df4840472526ea2c";<a name="line.11"></a>
+<span class="sourceLineNo">011</span>  public static final String revision = "c9f8c3436f6e38b5c7807677c5c3e7fc3e19e071";<a name="line.11"></a>
 <span class="sourceLineNo">012</span>  public static final String user = "jenkins";<a name="line.12"></a>
-<span class="sourceLineNo">013</span>  public static final String date = "Thu May 17 14:39:20 UTC 2018";<a name="line.13"></a>
+<span class="sourceLineNo">013</span>  public static final String date = "Fri May 18 14:39:13 UTC 2018";<a name="line.13"></a>
 <span class="sourceLineNo">014</span>  public static final String url = "git://jenkins-websites1.apache.org/home/jenkins/jenkins-slave/workspace/hbase_generate_website/hbase";<a name="line.14"></a>
-<span class="sourceLineNo">015</span>  public static final String srcChecksum = "5e1af00298043edb8a0644db5a2c28dc";<a name="line.15"></a>
+<span class="sourceLineNo">015</span>  public static final String srcChecksum = "b02d3f1d4a3395e22f561b8280caf974";<a name="line.15"></a>
 <span class="sourceLineNo">016</span>}<a name="line.16"></a>
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ead846d7/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.Status.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.Status.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.Status.html
index 02dbc37..2547651 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.Status.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.Status.html
@@ -26,192 +26,198 @@
 <span class="sourceLineNo">018</span> */<a name="line.18"></a>
 <span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.regionserver;<a name="line.19"></a>
 <span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.io.IOException;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.io.InterruptedIOException;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.net.ConnectException;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.net.SocketTimeoutException;<a name="line.24"></a>
-<span class="sourceLineNo">025</span><a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.slf4j.Logger;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.slf4j.LoggerFactory;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.conf.Configuration;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.fs.FileSystem;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.Path;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.Server;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.RetriesExhaustedException;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.coordination.SplitLogWorkerCoordination;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.wal.WALFactory;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.wal.WALSplitter;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.util.CancelableProgressable;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.util.ExceptionUtil;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.util.FSUtils;<a name="line.40"></a>
-<span class="sourceLineNo">041</span><a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<a name="line.42"></a>
-<span class="sourceLineNo">043</span><a name="line.43"></a>
-<span class="sourceLineNo">044</span>/**<a name="line.44"></a>
-<span class="sourceLineNo">045</span> * This worker is spawned in every regionserver, including master. The Worker waits for log<a name="line.45"></a>
-<span class="sourceLineNo">046</span> * splitting tasks to be put up by the {@link org.apache.hadoop.hbase.master.SplitLogManager}<a name="line.46"></a>
-<span class="sourceLineNo">047</span> * running in the master and races with other workers in other serves to acquire those tasks.<a name="line.47"></a>
-<span class="sourceLineNo">048</span> * The coordination is done via coordination engine.<a name="line.48"></a>
-<span class="sourceLineNo">049</span> * &lt;p&gt;<a name="line.49"></a>
-<span class="sourceLineNo">050</span> * If a worker has successfully moved the task from state UNASSIGNED to OWNED then it owns the task.<a name="line.50"></a>
-<span class="sourceLineNo">051</span> * It keeps heart beating the manager by periodically moving the task from UNASSIGNED to OWNED<a name="line.51"></a>
-<span class="sourceLineNo">052</span> * state. On success it moves the task to TASK_DONE. On unrecoverable error it moves task state to<a name="line.52"></a>
-<span class="sourceLineNo">053</span> * ERR. If it cannot continue but wants the master to retry the task then it moves the task state to<a name="line.53"></a>
-<span class="sourceLineNo">054</span> * RESIGNED.<a name="line.54"></a>
-<span class="sourceLineNo">055</span> * &lt;p&gt;<a name="line.55"></a>
-<span class="sourceLineNo">056</span> * The manager can take a task away from a worker by moving the task from OWNED to UNASSIGNED. In<a name="line.56"></a>
-<span class="sourceLineNo">057</span> * the absence of a global lock there is a unavoidable race here - a worker might have just finished<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * its task when it is stripped of its ownership. Here we rely on the idempotency of the log<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * splitting task for correctness<a name="line.59"></a>
-<span class="sourceLineNo">060</span> */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>@InterfaceAudience.Private<a name="line.61"></a>
-<span class="sourceLineNo">062</span>public class SplitLogWorker implements Runnable {<a name="line.62"></a>
-<span class="sourceLineNo">063</span><a name="line.63"></a>
-<span class="sourceLineNo">064</span>  private static final Logger LOG = LoggerFactory.getLogger(SplitLogWorker.class);<a name="line.64"></a>
-<span class="sourceLineNo">065</span><a name="line.65"></a>
-<span class="sourceLineNo">066</span>  Thread worker;<a name="line.66"></a>
-<span class="sourceLineNo">067</span>  // thread pool which executes recovery work<a name="line.67"></a>
-<span class="sourceLineNo">068</span>  private SplitLogWorkerCoordination coordination;<a name="line.68"></a>
-<span class="sourceLineNo">069</span>  private Configuration conf;<a name="line.69"></a>
-<span class="sourceLineNo">070</span>  private RegionServerServices server;<a name="line.70"></a>
-<span class="sourceLineNo">071</span><a name="line.71"></a>
-<span class="sourceLineNo">072</span>  public SplitLogWorker(Server hserver, Configuration conf, RegionServerServices server,<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      TaskExecutor splitTaskExecutor) {<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    this.server = server;<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    this.conf = conf;<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    this.coordination = hserver.getCoordinatedStateManager().getSplitLogWorkerCoordination();<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    coordination.init(server, conf, splitTaskExecutor, this);<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>  public SplitLogWorker(final Server hserver, final Configuration conf,<a name="line.80"></a>
-<span class="sourceLineNo">081</span>      final RegionServerServices server, final LastSequenceId sequenceIdChecker,<a name="line.81"></a>
-<span class="sourceLineNo">082</span>      final WALFactory factory) {<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    this(hserver, conf, server, new TaskExecutor() {<a name="line.83"></a>
-<span class="sourceLineNo">084</span>      @Override<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      public Status exec(String filename, CancelableProgressable p) {<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        Path walDir;<a name="line.86"></a>
-<span class="sourceLineNo">087</span>        FileSystem fs;<a name="line.87"></a>
-<span class="sourceLineNo">088</span>        try {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>          walDir = FSUtils.getWALRootDir(conf);<a name="line.89"></a>
-<span class="sourceLineNo">090</span>          fs = walDir.getFileSystem(conf);<a name="line.90"></a>
-<span class="sourceLineNo">091</span>        } catch (IOException e) {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>          LOG.warn("could not find root dir or fs", e);<a name="line.92"></a>
-<span class="sourceLineNo">093</span>          return Status.RESIGNED;<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        }<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        // TODO have to correctly figure out when log splitting has been<a name="line.95"></a>
-<span class="sourceLineNo">096</span>        // interrupted or has encountered a transient error and when it has<a name="line.96"></a>
-<span class="sourceLineNo">097</span>        // encountered a bad non-retry-able persistent error.<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        try {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>          if (!WALSplitter.splitLogFile(walDir, fs.getFileStatus(new Path(walDir, filename)),<a name="line.99"></a>
-<span class="sourceLineNo">100</span>            fs, conf, p, sequenceIdChecker,<a name="line.100"></a>
-<span class="sourceLineNo">101</span>              server.getCoordinatedStateManager().getSplitLogWorkerCoordination(), factory)) {<a name="line.101"></a>
-<span class="sourceLineNo">102</span>            return Status.PREEMPTED;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>          }<a name="line.103"></a>
-<span class="sourceLineNo">104</span>        } catch (InterruptedIOException iioe) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>          LOG.warn("log splitting of " + filename + " interrupted, resigning", iioe);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>          return Status.RESIGNED;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>        } catch (IOException e) {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>          Throwable cause = e.getCause();<a name="line.108"></a>
-<span class="sourceLineNo">109</span>          if (e instanceof RetriesExhaustedException &amp;&amp; (cause instanceof NotServingRegionException<a name="line.109"></a>
-<span class="sourceLineNo">110</span>                  || cause instanceof ConnectException<a name="line.110"></a>
-<span class="sourceLineNo">111</span>                  || cause instanceof SocketTimeoutException)) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>            LOG.warn("log replaying of " + filename + " can't connect to the target regionserver, "<a name="line.112"></a>
-<span class="sourceLineNo">113</span>                + "resigning", e);<a name="line.113"></a>
-<span class="sourceLineNo">114</span>            return Status.RESIGNED;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>          } else if (cause instanceof InterruptedException) {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>            LOG.warn("log splitting of " + filename + " interrupted, resigning", e);<a name="line.116"></a>
-<span class="sourceLineNo">117</span>            return Status.RESIGNED;<a name="line.117"></a>
-<span class="sourceLineNo">118</span>          }<a name="line.118"></a>
-<span class="sourceLineNo">119</span>          LOG.warn("log splitting of " + filename + " failed, returning error", e);<a name="line.119"></a>
-<span class="sourceLineNo">120</span>          return Status.ERR;<a name="line.120"></a>
-<span class="sourceLineNo">121</span>        }<a name="line.121"></a>
-<span class="sourceLineNo">122</span>        return Status.DONE;<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>  }<a name="line.125"></a>
-<span class="sourceLineNo">126</span><a name="line.126"></a>
-<span class="sourceLineNo">127</span>  @Override<a name="line.127"></a>
-<span class="sourceLineNo">128</span>  public void run() {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    try {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      LOG.info("SplitLogWorker " + server.getServerName() + " starting");<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      coordination.registerListener();<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      // wait for Coordination Engine is ready<a name="line.132"></a>
-<span class="sourceLineNo">133</span>      boolean res = false;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      while (!res &amp;&amp; !coordination.isStop()) {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        res = coordination.isReady();<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      }<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      if (!coordination.isStop()) {<a name="line.137"></a>
-<span class="sourceLineNo">138</span>        coordination.taskLoop();<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      }<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    } catch (Throwable t) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      if (ExceptionUtil.isInterrupt(t)) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>        LOG.info("SplitLogWorker interrupted. Exiting. " + (coordination.isStop() ? "" :<a name="line.142"></a>
-<span class="sourceLineNo">143</span>            " (ERROR: exitWorker is not set, exiting anyway)"));<a name="line.143"></a>
-<span class="sourceLineNo">144</span>      } else {<a name="line.144"></a>
-<span class="sourceLineNo">145</span>        // only a logical error can cause here. Printing it out<a name="line.145"></a>
-<span class="sourceLineNo">146</span>        // to make debugging easier<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        LOG.error("unexpected error ", t);<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      }<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    } finally {<a name="line.149"></a>
-<span class="sourceLineNo">150</span>      coordination.removeListener();<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      LOG.info("SplitLogWorker " + server.getServerName() + " exiting");<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    }<a name="line.152"></a>
-<span class="sourceLineNo">153</span>  }<a name="line.153"></a>
-<span class="sourceLineNo">154</span><a name="line.154"></a>
-<span class="sourceLineNo">155</span>  /**<a name="line.155"></a>
-<span class="sourceLineNo">156</span>   * If the worker is doing a task i.e. splitting a log file then stop the task.<a name="line.156"></a>
-<span class="sourceLineNo">157</span>   * It doesn't exit the worker thread.<a name="line.157"></a>
-<span class="sourceLineNo">158</span>   */<a name="line.158"></a>
-<span class="sourceLineNo">159</span>  public void stopTask() {<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    LOG.info("Sending interrupt to stop the worker thread");<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    worker.interrupt(); // TODO interrupt often gets swallowed, do what else?<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>   * start the SplitLogWorker thread<a name="line.165"></a>
-<span class="sourceLineNo">166</span>   */<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  public void start() {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    worker = new Thread(null, this, "SplitLogWorker-" + server.getServerName().toShortString());<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    worker.start();<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>  /**<a name="line.172"></a>
-<span class="sourceLineNo">173</span>   * stop the SplitLogWorker thread<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   */<a name="line.174"></a>
-<span class="sourceLineNo">175</span>  public void stop() {<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    coordination.stopProcessingTasks();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    stopTask();<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>   * Objects implementing this interface actually do the task that has been<a name="line.181"></a>
-<span class="sourceLineNo">182</span>   * acquired by a {@link SplitLogWorker}. Since there isn't a water-tight<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   * guarantee that two workers will not be executing the same task therefore it<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * is better to have workers prepare the task and then have the<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   * {@link org.apache.hadoop.hbase.master.SplitLogManager} commit the work in<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   * SplitLogManager.TaskFinisher<a name="line.186"></a>
-<span class="sourceLineNo">187</span>   */<a name="line.187"></a>
-<span class="sourceLineNo">188</span>  public interface TaskExecutor {<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    enum Status {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      DONE(),<a name="line.190"></a>
-<span class="sourceLineNo">191</span>      ERR(),<a name="line.191"></a>
-<span class="sourceLineNo">192</span>      RESIGNED(),<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      PREEMPTED()<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    }<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    Status exec(String name, CancelableProgressable p);<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>   * Returns the number of tasks processed by coordination.<a name="line.199"></a>
-<span class="sourceLineNo">200</span>   * This method is used by tests only<a name="line.200"></a>
-<span class="sourceLineNo">201</span>   */<a name="line.201"></a>
-<span class="sourceLineNo">202</span>  @VisibleForTesting<a name="line.202"></a>
-<span class="sourceLineNo">203</span>  public int getTaskReadySeq() {<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    return coordination.getTaskReadySeq();<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>}<a name="line.206"></a>
+<span class="sourceLineNo">021</span>import java.io.FileNotFoundException;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.InterruptedIOException;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.net.ConnectException;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.net.SocketTimeoutException;<a name="line.25"></a>
+<span class="sourceLineNo">026</span><a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.slf4j.Logger;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.slf4j.LoggerFactory;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.conf.Configuration;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.FileSystem;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.fs.Path;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.Server;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.RetriesExhaustedException;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.coordination.SplitLogWorkerCoordination;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.wal.WALFactory;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.wal.WALSplitter;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.util.CancelableProgressable;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.util.ExceptionUtil;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.util.FSUtils;<a name="line.41"></a>
+<span class="sourceLineNo">042</span><a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<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> * This worker is spawned in every regionserver, including master. The Worker waits for log<a name="line.46"></a>
+<span class="sourceLineNo">047</span> * splitting tasks to be put up by the {@link org.apache.hadoop.hbase.master.SplitLogManager}<a name="line.47"></a>
+<span class="sourceLineNo">048</span> * running in the master and races with other workers in other serves to acquire those tasks.<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * The coordination is done via coordination engine.<a name="line.49"></a>
+<span class="sourceLineNo">050</span> * &lt;p&gt;<a name="line.50"></a>
+<span class="sourceLineNo">051</span> * If a worker has successfully moved the task from state UNASSIGNED to OWNED then it owns the task.<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * It keeps heart beating the manager by periodically moving the task from UNASSIGNED to OWNED<a name="line.52"></a>
+<span class="sourceLineNo">053</span> * state. On success it moves the task to TASK_DONE. On unrecoverable error it moves task state to<a name="line.53"></a>
+<span class="sourceLineNo">054</span> * ERR. If it cannot continue but wants the master to retry the task then it moves the task state to<a name="line.54"></a>
+<span class="sourceLineNo">055</span> * RESIGNED.<a name="line.55"></a>
+<span class="sourceLineNo">056</span> * &lt;p&gt;<a name="line.56"></a>
+<span class="sourceLineNo">057</span> * The manager can take a task away from a worker by moving the task from OWNED to UNASSIGNED. In<a name="line.57"></a>
+<span class="sourceLineNo">058</span> * the absence of a global lock there is a unavoidable race here - a worker might have just finished<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * its task when it is stripped of its ownership. Here we rely on the idempotency of the log<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * splitting task for correctness<a name="line.60"></a>
+<span class="sourceLineNo">061</span> */<a name="line.61"></a>
+<span class="sourceLineNo">062</span>@InterfaceAudience.Private<a name="line.62"></a>
+<span class="sourceLineNo">063</span>public class SplitLogWorker implements Runnable {<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>  private static final Logger LOG = LoggerFactory.getLogger(SplitLogWorker.class);<a name="line.65"></a>
+<span class="sourceLineNo">066</span><a name="line.66"></a>
+<span class="sourceLineNo">067</span>  Thread worker;<a name="line.67"></a>
+<span class="sourceLineNo">068</span>  // thread pool which executes recovery work<a name="line.68"></a>
+<span class="sourceLineNo">069</span>  private SplitLogWorkerCoordination coordination;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  private Configuration conf;<a name="line.70"></a>
+<span class="sourceLineNo">071</span>  private RegionServerServices server;<a name="line.71"></a>
+<span class="sourceLineNo">072</span><a name="line.72"></a>
+<span class="sourceLineNo">073</span>  public SplitLogWorker(Server hserver, Configuration conf, RegionServerServices server,<a name="line.73"></a>
+<span class="sourceLineNo">074</span>      TaskExecutor splitTaskExecutor) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    this.server = server;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>    this.conf = conf;<a name="line.76"></a>
+<span class="sourceLineNo">077</span>    this.coordination = hserver.getCoordinatedStateManager().getSplitLogWorkerCoordination();<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    coordination.init(server, conf, splitTaskExecutor, this);<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>  public SplitLogWorker(final Server hserver, final Configuration conf,<a name="line.81"></a>
+<span class="sourceLineNo">082</span>      final RegionServerServices server, final LastSequenceId sequenceIdChecker,<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      final WALFactory factory) {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    this(hserver, conf, server, new TaskExecutor() {<a name="line.84"></a>
+<span class="sourceLineNo">085</span>      @Override<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      public Status exec(String filename, CancelableProgressable p) {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        Path walDir;<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        FileSystem fs;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        try {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>          walDir = FSUtils.getWALRootDir(conf);<a name="line.90"></a>
+<span class="sourceLineNo">091</span>          fs = walDir.getFileSystem(conf);<a name="line.91"></a>
+<span class="sourceLineNo">092</span>        } catch (IOException e) {<a name="line.92"></a>
+<span class="sourceLineNo">093</span>          LOG.warn("could not find root dir or fs", e);<a name="line.93"></a>
+<span class="sourceLineNo">094</span>          return Status.RESIGNED;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        }<a name="line.95"></a>
+<span class="sourceLineNo">096</span>        // TODO have to correctly figure out when log splitting has been<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        // interrupted or has encountered a transient error and when it has<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        // encountered a bad non-retry-able persistent error.<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        try {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>          if (!WALSplitter.splitLogFile(walDir, fs.getFileStatus(new Path(walDir, filename)),<a name="line.100"></a>
+<span class="sourceLineNo">101</span>            fs, conf, p, sequenceIdChecker,<a name="line.101"></a>
+<span class="sourceLineNo">102</span>              server.getCoordinatedStateManager().getSplitLogWorkerCoordination(), factory)) {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>            return Status.PREEMPTED;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>          }<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        } catch (InterruptedIOException iioe) {<a name="line.105"></a>
+<span class="sourceLineNo">106</span>          LOG.warn("log splitting of " + filename + " interrupted, resigning", iioe);<a name="line.106"></a>
+<span class="sourceLineNo">107</span>          return Status.RESIGNED;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>        } catch (IOException e) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>          if (e instanceof FileNotFoundException) {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>            // A wal file may not exist anymore. Nothing can be recovered so move on<a name="line.110"></a>
+<span class="sourceLineNo">111</span>            LOG.warn("WAL {} does not exist anymore", filename, e);<a name="line.111"></a>
+<span class="sourceLineNo">112</span>            return Status.DONE;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>          }<a name="line.113"></a>
+<span class="sourceLineNo">114</span>          Throwable cause = e.getCause();<a name="line.114"></a>
+<span class="sourceLineNo">115</span>          if (e instanceof RetriesExhaustedException &amp;&amp; (cause instanceof NotServingRegionException<a name="line.115"></a>
+<span class="sourceLineNo">116</span>                  || cause instanceof ConnectException<a name="line.116"></a>
+<span class="sourceLineNo">117</span>                  || cause instanceof SocketTimeoutException)) {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>            LOG.warn("log replaying of " + filename + " can't connect to the target regionserver, "<a name="line.118"></a>
+<span class="sourceLineNo">119</span>                + "resigning", e);<a name="line.119"></a>
+<span class="sourceLineNo">120</span>            return Status.RESIGNED;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>          } else if (cause instanceof InterruptedException) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>            LOG.warn("log splitting of " + filename + " interrupted, resigning", e);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>            return Status.RESIGNED;<a name="line.123"></a>
+<span class="sourceLineNo">124</span>          }<a name="line.124"></a>
+<span class="sourceLineNo">125</span>          LOG.warn("log splitting of " + filename + " failed, returning error", e);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>          return Status.ERR;<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        }<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        return Status.DONE;<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    });<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>  @Override<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  public void run() {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    try {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>      LOG.info("SplitLogWorker " + server.getServerName() + " starting");<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      coordination.registerListener();<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      // wait for Coordination Engine is ready<a name="line.138"></a>
+<span class="sourceLineNo">139</span>      boolean res = false;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      while (!res &amp;&amp; !coordination.isStop()) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>        res = coordination.isReady();<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      }<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      if (!coordination.isStop()) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>        coordination.taskLoop();<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      }<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    } catch (Throwable t) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      if (ExceptionUtil.isInterrupt(t)) {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        LOG.info("SplitLogWorker interrupted. Exiting. " + (coordination.isStop() ? "" :<a name="line.148"></a>
+<span class="sourceLineNo">149</span>            " (ERROR: exitWorker is not set, exiting anyway)"));<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      } else {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        // only a logical error can cause here. Printing it out<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        // to make debugging easier<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        LOG.error("unexpected error ", t);<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      }<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    } finally {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      coordination.removeListener();<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      LOG.info("SplitLogWorker " + server.getServerName() + " exiting");<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><a name="line.160"></a>
+<span class="sourceLineNo">161</span>  /**<a name="line.161"></a>
+<span class="sourceLineNo">162</span>   * If the worker is doing a task i.e. splitting a log file then stop the task.<a name="line.162"></a>
+<span class="sourceLineNo">163</span>   * It doesn't exit the worker thread.<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   */<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  public void stopTask() {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    LOG.info("Sending interrupt to stop the worker thread");<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    worker.interrupt(); // TODO interrupt often gets swallowed, do what else?<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>  /**<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   * start the SplitLogWorker thread<a name="line.171"></a>
+<span class="sourceLineNo">172</span>   */<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  public void start() {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    worker = new Thread(null, this, "SplitLogWorker-" + server.getServerName().toShortString());<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    worker.start();<a name="line.175"></a>
+<span class="sourceLineNo">176</span>  }<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>   * stop the SplitLogWorker thread<a name="line.179"></a>
+<span class="sourceLineNo">180</span>   */<a name="line.180"></a>
+<span class="sourceLineNo">181</span>  public void stop() {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    coordination.stopProcessingTasks();<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    stopTask();<a name="line.183"></a>
+<span class="sourceLineNo">184</span>  }<a name="line.184"></a>
+<span class="sourceLineNo">185</span><a name="line.185"></a>
+<span class="sourceLineNo">186</span>  /**<a name="line.186"></a>
+<span class="sourceLineNo">187</span>   * Objects implementing this interface actually do the task that has been<a name="line.187"></a>
+<span class="sourceLineNo">188</span>   * acquired by a {@link SplitLogWorker}. Since there isn't a water-tight<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   * guarantee that two workers will not be executing the same task therefore it<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * is better to have workers prepare the task and then have the<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * {@link org.apache.hadoop.hbase.master.SplitLogManager} commit the work in<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * SplitLogManager.TaskFinisher<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   */<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  public interface TaskExecutor {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    enum Status {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      DONE(),<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      ERR(),<a name="line.197"></a>
+<span class="sourceLineNo">198</span>      RESIGNED(),<a name="line.198"></a>
+<span class="sourceLineNo">199</span>      PREEMPTED()<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    }<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    Status exec(String name, CancelableProgressable p);<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>  /**<a name="line.204"></a>
+<span class="sourceLineNo">205</span>   * Returns the number of tasks processed by coordination.<a name="line.205"></a>
+<span class="sourceLineNo">206</span>   * This method is used by tests only<a name="line.206"></a>
+<span class="sourceLineNo">207</span>   */<a name="line.207"></a>
+<span class="sourceLineNo">208</span>  @VisibleForTesting<a name="line.208"></a>
+<span class="sourceLineNo">209</span>  public int getTaskReadySeq() {<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    return coordination.getTaskReadySeq();<a name="line.210"></a>
+<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
+<span class="sourceLineNo">212</span>}<a name="line.212"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ead846d7/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.html
index 02dbc37..2547651 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/SplitLogWorker.TaskExecutor.html
@@ -26,192 +26,198 @@
 <span class="sourceLineNo">018</span> */<a name="line.18"></a>
 <span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.regionserver;<a name="line.19"></a>
 <span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.io.IOException;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.io.InterruptedIOException;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.net.ConnectException;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.net.SocketTimeoutException;<a name="line.24"></a>
-<span class="sourceLineNo">025</span><a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.slf4j.Logger;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.slf4j.LoggerFactory;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.conf.Configuration;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.fs.FileSystem;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.Path;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.Server;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.RetriesExhaustedException;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.coordination.SplitLogWorkerCoordination;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.wal.WALFactory;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.wal.WALSplitter;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.util.CancelableProgressable;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.util.ExceptionUtil;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.util.FSUtils;<a name="line.40"></a>
-<span class="sourceLineNo">041</span><a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<a name="line.42"></a>
-<span class="sourceLineNo">043</span><a name="line.43"></a>
-<span class="sourceLineNo">044</span>/**<a name="line.44"></a>
-<span class="sourceLineNo">045</span> * This worker is spawned in every regionserver, including master. The Worker waits for log<a name="line.45"></a>
-<span class="sourceLineNo">046</span> * splitting tasks to be put up by the {@link org.apache.hadoop.hbase.master.SplitLogManager}<a name="line.46"></a>
-<span class="sourceLineNo">047</span> * running in the master and races with other workers in other serves to acquire those tasks.<a name="line.47"></a>
-<span class="sourceLineNo">048</span> * The coordination is done via coordination engine.<a name="line.48"></a>
-<span class="sourceLineNo">049</span> * &lt;p&gt;<a name="line.49"></a>
-<span class="sourceLineNo">050</span> * If a worker has successfully moved the task from state UNASSIGNED to OWNED then it owns the task.<a name="line.50"></a>
-<span class="sourceLineNo">051</span> * It keeps heart beating the manager by periodically moving the task from UNASSIGNED to OWNED<a name="line.51"></a>
-<span class="sourceLineNo">052</span> * state. On success it moves the task to TASK_DONE. On unrecoverable error it moves task state to<a name="line.52"></a>
-<span class="sourceLineNo">053</span> * ERR. If it cannot continue but wants the master to retry the task then it moves the task state to<a name="line.53"></a>
-<span class="sourceLineNo">054</span> * RESIGNED.<a name="line.54"></a>
-<span class="sourceLineNo">055</span> * &lt;p&gt;<a name="line.55"></a>
-<span class="sourceLineNo">056</span> * The manager can take a task away from a worker by moving the task from OWNED to UNASSIGNED. In<a name="line.56"></a>
-<span class="sourceLineNo">057</span> * the absence of a global lock there is a unavoidable race here - a worker might have just finished<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * its task when it is stripped of its ownership. Here we rely on the idempotency of the log<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * splitting task for correctness<a name="line.59"></a>
-<span class="sourceLineNo">060</span> */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>@InterfaceAudience.Private<a name="line.61"></a>
-<span class="sourceLineNo">062</span>public class SplitLogWorker implements Runnable {<a name="line.62"></a>
-<span class="sourceLineNo">063</span><a name="line.63"></a>
-<span class="sourceLineNo">064</span>  private static final Logger LOG = LoggerFactory.getLogger(SplitLogWorker.class);<a name="line.64"></a>
-<span class="sourceLineNo">065</span><a name="line.65"></a>
-<span class="sourceLineNo">066</span>  Thread worker;<a name="line.66"></a>
-<span class="sourceLineNo">067</span>  // thread pool which executes recovery work<a name="line.67"></a>
-<span class="sourceLineNo">068</span>  private SplitLogWorkerCoordination coordination;<a name="line.68"></a>
-<span class="sourceLineNo">069</span>  private Configuration conf;<a name="line.69"></a>
-<span class="sourceLineNo">070</span>  private RegionServerServices server;<a name="line.70"></a>
-<span class="sourceLineNo">071</span><a name="line.71"></a>
-<span class="sourceLineNo">072</span>  public SplitLogWorker(Server hserver, Configuration conf, RegionServerServices server,<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      TaskExecutor splitTaskExecutor) {<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    this.server = server;<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    this.conf = conf;<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    this.coordination = hserver.getCoordinatedStateManager().getSplitLogWorkerCoordination();<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    coordination.init(server, conf, splitTaskExecutor, this);<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>  public SplitLogWorker(final Server hserver, final Configuration conf,<a name="line.80"></a>
-<span class="sourceLineNo">081</span>      final RegionServerServices server, final LastSequenceId sequenceIdChecker,<a name="line.81"></a>
-<span class="sourceLineNo">082</span>      final WALFactory factory) {<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    this(hserver, conf, server, new TaskExecutor() {<a name="line.83"></a>
-<span class="sourceLineNo">084</span>      @Override<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      public Status exec(String filename, CancelableProgressable p) {<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        Path walDir;<a name="line.86"></a>
-<span class="sourceLineNo">087</span>        FileSystem fs;<a name="line.87"></a>
-<span class="sourceLineNo">088</span>        try {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>          walDir = FSUtils.getWALRootDir(conf);<a name="line.89"></a>
-<span class="sourceLineNo">090</span>          fs = walDir.getFileSystem(conf);<a name="line.90"></a>
-<span class="sourceLineNo">091</span>        } catch (IOException e) {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>          LOG.warn("could not find root dir or fs", e);<a name="line.92"></a>
-<span class="sourceLineNo">093</span>          return Status.RESIGNED;<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        }<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        // TODO have to correctly figure out when log splitting has been<a name="line.95"></a>
-<span class="sourceLineNo">096</span>        // interrupted or has encountered a transient error and when it has<a name="line.96"></a>
-<span class="sourceLineNo">097</span>        // encountered a bad non-retry-able persistent error.<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        try {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>          if (!WALSplitter.splitLogFile(walDir, fs.getFileStatus(new Path(walDir, filename)),<a name="line.99"></a>
-<span class="sourceLineNo">100</span>            fs, conf, p, sequenceIdChecker,<a name="line.100"></a>
-<span class="sourceLineNo">101</span>              server.getCoordinatedStateManager().getSplitLogWorkerCoordination(), factory)) {<a name="line.101"></a>
-<span class="sourceLineNo">102</span>            return Status.PREEMPTED;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>          }<a name="line.103"></a>
-<span class="sourceLineNo">104</span>        } catch (InterruptedIOException iioe) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>          LOG.warn("log splitting of " + filename + " interrupted, resigning", iioe);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>          return Status.RESIGNED;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>        } catch (IOException e) {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>          Throwable cause = e.getCause();<a name="line.108"></a>
-<span class="sourceLineNo">109</span>          if (e instanceof RetriesExhaustedException &amp;&amp; (cause instanceof NotServingRegionException<a name="line.109"></a>
-<span class="sourceLineNo">110</span>                  || cause instanceof ConnectException<a name="line.110"></a>
-<span class="sourceLineNo">111</span>                  || cause instanceof SocketTimeoutException)) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>            LOG.warn("log replaying of " + filename + " can't connect to the target regionserver, "<a name="line.112"></a>
-<span class="sourceLineNo">113</span>                + "resigning", e);<a name="line.113"></a>
-<span class="sourceLineNo">114</span>            return Status.RESIGNED;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>          } else if (cause instanceof InterruptedException) {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>            LOG.warn("log splitting of " + filename + " interrupted, resigning", e);<a name="line.116"></a>
-<span class="sourceLineNo">117</span>            return Status.RESIGNED;<a name="line.117"></a>
-<span class="sourceLineNo">118</span>          }<a name="line.118"></a>
-<span class="sourceLineNo">119</span>          LOG.warn("log splitting of " + filename + " failed, returning error", e);<a name="line.119"></a>
-<span class="sourceLineNo">120</span>          return Status.ERR;<a name="line.120"></a>
-<span class="sourceLineNo">121</span>        }<a name="line.121"></a>
-<span class="sourceLineNo">122</span>        return Status.DONE;<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>  }<a name="line.125"></a>
-<span class="sourceLineNo">126</span><a name="line.126"></a>
-<span class="sourceLineNo">127</span>  @Override<a name="line.127"></a>
-<span class="sourceLineNo">128</span>  public void run() {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    try {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      LOG.info("SplitLogWorker " + server.getServerName() + " starting");<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      coordination.registerListener();<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      // wait for Coordination Engine is ready<a name="line.132"></a>
-<span class="sourceLineNo">133</span>      boolean res = false;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      while (!res &amp;&amp; !coordination.isStop()) {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        res = coordination.isReady();<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      }<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      if (!coordination.isStop()) {<a name="line.137"></a>
-<span class="sourceLineNo">138</span>        coordination.taskLoop();<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      }<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    } catch (Throwable t) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      if (ExceptionUtil.isInterrupt(t)) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>        LOG.info("SplitLogWorker interrupted. Exiting. " + (coordination.isStop() ? "" :<a name="line.142"></a>
-<span class="sourceLineNo">143</span>            " (ERROR: exitWorker is not set, exiting anyway)"));<a name="line.143"></a>
-<span class="sourceLineNo">144</span>      } else {<a name="line.144"></a>
-<span class="sourceLineNo">145</span>        // only a logical error can cause here. Printing it out<a name="line.145"></a>
-<span class="sourceLineNo">146</span>        // to make debugging easier<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        LOG.error("unexpected error ", t);<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      }<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    } finally {<a name="line.149"></a>
-<span class="sourceLineNo">150</span>      coordination.removeListener();<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      LOG.info("SplitLogWorker " + server.getServerName() + " exiting");<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    }<a name="line.152"></a>
-<span class="sourceLineNo">153</span>  }<a name="line.153"></a>
-<span class="sourceLineNo">154</span><a name="line.154"></a>
-<span class="sourceLineNo">155</span>  /**<a name="line.155"></a>
-<span class="sourceLineNo">156</span>   * If the worker is doing a task i.e. splitting a log file then stop the task.<a name="line.156"></a>
-<span class="sourceLineNo">157</span>   * It doesn't exit the worker thread.<a name="line.157"></a>
-<span class="sourceLineNo">158</span>   */<a name="line.158"></a>
-<span class="sourceLineNo">159</span>  public void stopTask() {<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    LOG.info("Sending interrupt to stop the worker thread");<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    worker.interrupt(); // TODO interrupt often gets swallowed, do what else?<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>   * start the SplitLogWorker thread<a name="line.165"></a>
-<span class="sourceLineNo">166</span>   */<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  public void start() {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    worker = new Thread(null, this, "SplitLogWorker-" + server.getServerName().toShortString());<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    worker.start();<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>  /**<a name="line.172"></a>
-<span class="sourceLineNo">173</span>   * stop the SplitLogWorker thread<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   */<a name="line.174"></a>
-<span class="sourceLineNo">175</span>  public void stop() {<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    coordination.stopProcessingTasks();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    stopTask();<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>   * Objects implementing this interface actually do the task that has been<a name="line.181"></a>
-<span class="sourceLineNo">182</span>   * acquired by a {@link SplitLogWorker}. Since there isn't a water-tight<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   * guarantee that two workers will not be executing the same task therefore it<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * is better to have workers prepare the task and then have the<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   * {@link org.apache.hadoop.hbase.master.SplitLogManager} commit the work in<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   * SplitLogManager.TaskFinisher<a name="line.186"></a>
-<span class="sourceLineNo">187</span>   */<a name="line.187"></a>
-<span class="sourceLineNo">188</span>  public interface TaskExecutor {<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    enum Status {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      DONE(),<a name="line.190"></a>
-<span class="sourceLineNo">191</span>      ERR(),<a name="line.191"></a>
-<span class="sourceLineNo">192</span>      RESIGNED(),<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      PREEMPTED()<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    }<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    Status exec(String name, CancelableProgressable p);<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>   * Returns the number of tasks processed by coordination.<a name="line.199"></a>
-<span class="sourceLineNo">200</span>   * This method is used by tests only<a name="line.200"></a>
-<span class="sourceLineNo">201</span>   */<a name="line.201"></a>
-<span class="sourceLineNo">202</span>  @VisibleForTesting<a name="line.202"></a>
-<span class="sourceLineNo">203</span>  public int getTaskReadySeq() {<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    return coordination.getTaskReadySeq();<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>}<a name="line.206"></a>
+<span class="sourceLineNo">021</span>import java.io.FileNotFoundException;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.InterruptedIOException;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.net.ConnectException;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.net.SocketTimeoutException;<a name="line.25"></a>
+<span class="sourceLineNo">026</span><a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.slf4j.Logger;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.slf4j.LoggerFactory;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.conf.Configuration;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.FileSystem;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.fs.Path;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.Server;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.RetriesExhaustedException;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.coordination.SplitLogWorkerCoordination;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.wal.WALFactory;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.wal.WALSplitter;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.util.CancelableProgressable;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.util.ExceptionUtil;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.util.FSUtils;<a name="line.41"></a>
+<span class="sourceLineNo">042</span><a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<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> * This worker is spawned in every regionserver, including master. The Worker waits for log<a name="line.46"></a>
+<span class="sourceLineNo">047</span> * splitting tasks to be put up by the {@link org.apache.hadoop.hbase.master.SplitLogManager}<a name="line.47"></a>
+<span class="sourceLineNo">048</span> * running in the master and races with other workers in other serves to acquire those tasks.<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * The coordination is done via coordination engine.<a name="line.49"></a>
+<span class="sourceLineNo">050</span> * &lt;p&gt;<a name="line.50"></a>
+<span class="sourceLineNo">051</span> * If a worker has successfully moved the task from state UNASSIGNED to OWNED then it owns the task.<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * It keeps heart beating the manager by periodically moving the task from UNASSIGNED to OWNED<a name="line.52"></a>
+<span class="sourceLineNo">053</span> * state. On success it moves the task to TASK_DONE. On unrecoverable error it moves task state to<a name="line.53"></a>
+<span class="sourceLineNo">054</span> * ERR. If it cannot continue but wants the master to retry the task then it moves the task state to<a name="line.54"></a>
+<span class="sourceLineNo">055</span> * RESIGNED.<a name="line.55"></a>
+<span class="sourceLineNo">056</span> * &lt;p&gt;<a name="line.56"></a>
+<span class="sourceLineNo">057</span> * The manager can take a task away from a worker by moving the task from OWNED to UNASSIGNED. In<a name="line.57"></a>
+<span class="sourceLineNo">058</span> * the absence of a global lock there is a unavoidable race here - a worker might have just finished<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * its task when it is stripped of its ownership. Here we rely on the idempotency of the log<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * splitting task for correctness<a name="line.60"></a>
+<span class="sourceLineNo">061</span> */<a name="line.61"></a>
+<span class="sourceLineNo">062</span>@InterfaceAudience.Private<a name="line.62"></a>
+<span class="sourceLineNo">063</span>public class SplitLogWorker implements Runnable {<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>  private static final Logger LOG = LoggerFactory.getLogger(SplitLogWorker.class);<a name="line.65"></a>
+<span class="sourceLineNo">066</span><a name="line.66"></a>
+<span class="sourceLineNo">067</span>  Thread worker;<a name="line.67"></a>
+<span class="sourceLineNo">068</span>  // thread pool which executes recovery work<a name="line.68"></a>
+<span class="sourceLineNo">069</span>  private SplitLogWorkerCoordination coordination;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  private Configuration conf;<a name="line.70"></a>
+<span class="sourceLineNo">071</span>  private RegionServerServices server;<a name="line.71"></a>
+<span class="sourceLineNo">072</span><a name="line.72"></a>
+<span class="sourceLineNo">073</span>  public SplitLogWorker(Server hserver, Configuration conf, RegionServerServices server,<a name="line.73"></a>
+<span class="sourceLineNo">074</span>      TaskExecutor splitTaskExecutor) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    this.server = server;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>    this.conf = conf;<a name="line.76"></a>
+<span class="sourceLineNo">077</span>    this.coordination = hserver.getCoordinatedStateManager().getSplitLogWorkerCoordination();<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    coordination.init(server, conf, splitTaskExecutor, this);<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>  public SplitLogWorker(final Server hserver, final Configuration conf,<a name="line.81"></a>
+<span class="sourceLineNo">082</span>      final RegionServerServices server, final LastSequenceId sequenceIdChecker,<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      final WALFactory factory) {<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    this(hserver, conf, server, new TaskExecutor() {<a name="line.84"></a>
+<span class="sourceLineNo">085</span>      @Override<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      public Status exec(String filename, CancelableProgressable p) {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        Path walDir;<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        FileSystem fs;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        try {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>          walDir = FSUtils.getWALRootDir(conf);<a name="line.90"></a>
+<span class="sourceLineNo">091</span>          fs = walDir.getFileSystem(conf);<a name="line.91"></a>
+<span class="sourceLineNo">092</span>        } catch (IOException e) {<a name="line.92"></a>
+<span class="sourceLineNo">093</span>          LOG.warn("could not find root dir or fs", e);<a name="line.93"></a>
+<span class="sourceLineNo">094</span>          return Status.RESIGNED;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        }<a name="line.95"></a>
+<span class="sourceLineNo">096</span>        // TODO have to correctly figure out when log splitting has been<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        // interrupted or has encountered a transient error and when it has<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        // encountered a bad non-retry-able persistent error.<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        try {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>          if (!WALSplitter.splitLogFile(walDir, fs.getFileStatus(new Path(walDir, filename)),<a name="line.100"></a>
+<span class="sourceLineNo">101</span>            fs, conf, p, sequenceIdChecker,<a name="line.101"></a>
+<span class="sourceLineNo">102</span>              server.getCoordinatedStateManager().getSplitLogWorkerCoordination(), factory)) {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>            return Status.PREEMPTED;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>          }<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        } catch (InterruptedIOException iioe) {<a name="line.105"></a>
+<span class="sourceLineNo">106</span>          LOG.warn("log splitting of " + filename + " interrupted, resigning", iioe);<a name="line.106"></a>
+<span class="sourceLineNo">107</span>          return Status.RESIGNED;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>        } catch (IOException e) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>          if (e instanceof FileNotFoundException) {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>            // A wal file may not exist anymore. Nothing can be recovered so move on<a name="line.110"></a>
+<span class="sourceLineNo">111</span>            LOG.warn("WAL {} does not exist anymore", filename, e);<a name="line.111"></a>
+<span class="sourceLineNo">112</span>            return Status.DONE;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>          }<a name="line.113"></a>
+<span class="sourceLineNo">114</span>          Throwable cause = e.getCause();<a name="line.114"></a>
+<span class="sourceLineNo">115</span>          if (e instanceof RetriesExhaustedException &amp;&amp; (cause instanceof NotServingRegionException<a name="line.115"></a>
+<span class="sourceLineNo">116</span>                  || cause instanceof ConnectException<a name="line.116"></a>
+<span class="sourceLineNo">117</span>                  || cause instanceof SocketTimeoutException)) {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>            LOG.warn("log replaying of " + filename + " can't connect to the target regionserver, "<a name="line.118"></a>
+<span class="sourceLineNo">119</span>                + "resigning", e);<a name="line.119"></a>
+<span class="sourceLineNo">120</span>            return Status.RESIGNED;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>          } else if (cause instanceof InterruptedException) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>            LOG.warn("log splitting of " + filename + " interrupted, resigning", e);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>            return Status.RESIGNED;<a name="line.123"></a>
+<span class="sourceLineNo">124</span>          }<a name="line.124"></a>
+<span class="sourceLineNo">125</span>          LOG.warn("log splitting of " + filename + " failed, returning error", e);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>          return Status.ERR;<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        }<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        return Status.DONE;<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    });<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>  @Override<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  public void run() {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    try {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>      LOG.info("SplitLogWorker " + server.getServerName() + " starting");<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      coordination.registerListener();<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      // wait for Coordination Engine is ready<a name="line.138"></a>
+<span class="sourceLineNo">139</span>      boolean res = false;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      while (!res &amp;&amp; !coordination.isStop()) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>        res = coordination.isReady();<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      }<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      if (!coordination.isStop()) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>        coordination.taskLoop();<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      }<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    } catch (Throwable t) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      if (ExceptionUtil.isInterrupt(t)) {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        LOG.info("SplitLogWorker interrupted. Exiting. " + (coordination.isStop() ? "" :<a name="line.148"></a>
+<span class="sourceLineNo">149</span>            " (ERROR: exitWorker is not set, exiting anyway)"));<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      } else {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        // only a logical error can cause here. Printing it out<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        // to make debugging easier<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        LOG.error("unexpected error ", t);<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      }<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    } finally {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      coordination.removeListener();<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      LOG.info("SplitLogWorker " + server.getServerName() + " exiting");<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><a name="line.160"></a>
+<span class="sourceLineNo">161</span>  /**<a name="line.161"></a>
+<span class="sourceLineNo">162</span>   * If the worker is doing a task i.e. splitting a log file then stop the task.<a name="line.162"></a>
+<span class="sourceLineNo">163</span>   * It doesn't exit the worker thread.<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   */<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  public void stopTask() {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    LOG.info("Sending interrupt to stop the worker thread");<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    worker.interrupt(); // TODO interrupt often gets swallowed, do what else?<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>  /**<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   * start the SplitLogWorker thread<a name="line.171"></a>
+<span class="sourceLineNo">172</span>   */<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  public void start() {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    worker = new Thread(null, this, "SplitLogWorker-" + server.getServerName().toShortString());<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    worker.start();<a name="line.175"></a>
+<span class="sourceLineNo">176</span>  }<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>   * stop the SplitLogWorker thread<a name="line.179"></a>
+<span class="sourceLineNo">180</span>   */<a name="line.180"></a>
+<span class="sourceLineNo">181</span>  public void stop() {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    coordination.stopProcessingTasks();<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    stopTask();<a name="line.183"></a>
+<span class="sourceLineNo">184</span>  }<a name="line.184"></a>
+<span class="sourceLineNo">185</span><a name="line.185"></a>
+<span class="sourceLineNo">186</span>  /**<a name="line.186"></a>
+<span class="sourceLineNo">187</span>   * Objects implementing this interface actually do the task that has been<a name="line.187"></a>
+<span class="sourceLineNo">188</span>   * acquired by a {@link SplitLogWorker}. Since there isn't a water-tight<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   * guarantee that two workers will not be executing the same task therefore it<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * is better to have workers prepare the task and then have the<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * {@link org.apache.hadoop.hbase.master.SplitLogManager} commit the work in<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * SplitLogManager.TaskFinisher<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   */<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  public interface TaskExecutor {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    enum Status {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      DONE(),<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      ERR(),<a name="line.197"></a>
+<span class="sourceLineNo">198</span>      RESIGNED(),<a name="line.198"></a>
+<span class="sourceLineNo">199</span>      PREEMPTED()<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    }<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    Status exec(String name, CancelableProgressable p);<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>  /**<a name="line.204"></a>
+<span class="sourceLineNo">205</span>   * Returns the number of tasks processed by coordination.<a name="line.205"></a>
+<span class="sourceLineNo">206</span>   * This method is used by tests only<a name="line.206"></a>
+<span class="sourceLineNo">207</span>   */<a name="line.207"></a>
+<span class="sourceLineNo">208</span>  @VisibleForTesting<a name="line.208"></a>
+<span class="sourceLineNo">209</span>  public int getTaskReadySeq() {<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    return coordination.getTaskReadySeq();<a name="line.210"></a>
+<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
+<span class="sourceLineNo">212</span>}<a name="line.212"></a>
 
 
 


Mime
View raw message