hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [14/30] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Mon, 19 Jun 2017 15:00:26 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/7f23ee04/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSource.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSource.html b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSource.html
index 5e9c67d..552ee2f 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSource.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSource.html
@@ -69,125 +69,136 @@
 <span class="sourceLineNo">061</span>  }<a name="line.61"></a>
 <span class="sourceLineNo">062</span><a name="line.62"></a>
 <span class="sourceLineNo">063</span>  @Override<a name="line.63"></a>
-<span class="sourceLineNo">064</span>  protected void tryStartNewShipperThread(String walGroupId, PriorityBlockingQueue&lt;Path&gt; queue) {<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    final RecoveredReplicationSourceShipperThread worker =<a name="line.65"></a>
-<span class="sourceLineNo">066</span>        new RecoveredReplicationSourceShipperThread(conf, walGroupId, queue, this,<a name="line.66"></a>
+<span class="sourceLineNo">064</span>  protected void tryStartNewShipper(String walGroupId, PriorityBlockingQueue&lt;Path&gt; queue) {<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    final RecoveredReplicationSourceShipper worker =<a name="line.65"></a>
+<span class="sourceLineNo">066</span>        new RecoveredReplicationSourceShipper(conf, walGroupId, queue, this,<a name="line.66"></a>
 <span class="sourceLineNo">067</span>            this.replicationQueues);<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    ReplicationSourceShipperThread extant = workerThreads.putIfAbsent(walGroupId, worker);<a name="line.68"></a>
+<span class="sourceLineNo">068</span>    ReplicationSourceShipper extant = workerThreads.putIfAbsent(walGroupId, worker);<a name="line.68"></a>
 <span class="sourceLineNo">069</span>    if (extant != null) {<a name="line.69"></a>
 <span class="sourceLineNo">070</span>      LOG.debug("Someone has beat us to start a worker thread for wal group " + walGroupId);<a name="line.70"></a>
 <span class="sourceLineNo">071</span>    } else {<a name="line.71"></a>
 <span class="sourceLineNo">072</span>      LOG.debug("Starting up worker for wal group " + walGroupId);<a name="line.72"></a>
 <span class="sourceLineNo">073</span>      worker.startup(getUncaughtExceptionHandler());<a name="line.73"></a>
 <span class="sourceLineNo">074</span>      worker.setWALReader(<a name="line.74"></a>
-<span class="sourceLineNo">075</span>        startNewWALReaderThread(worker.getName(), walGroupId, queue, worker.getStartPosition()));<a name="line.75"></a>
+<span class="sourceLineNo">075</span>        startNewWALReader(worker.getName(), walGroupId, queue, worker.getStartPosition()));<a name="line.75"></a>
 <span class="sourceLineNo">076</span>      workerThreads.put(walGroupId, worker);<a name="line.76"></a>
 <span class="sourceLineNo">077</span>    }<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 void locateRecoveredPaths(PriorityBlockingQueue&lt;Path&gt; queue) throws IOException {<a name="line.80"></a>
-<span class="sourceLineNo">081</span>    boolean hasPathChanged = false;<a name="line.81"></a>
-<span class="sourceLineNo">082</span>    PriorityBlockingQueue&lt;Path&gt; newPaths =<a name="line.82"></a>
-<span class="sourceLineNo">083</span>        new PriorityBlockingQueue&lt;Path&gt;(queueSizePerGroup, new LogsComparator());<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    pathsLoop: for (Path path : queue) {<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      if (fs.exists(path)) { // still in same location, don't need to do anything<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        newPaths.add(path);<a name="line.86"></a>
-<span class="sourceLineNo">087</span>        continue;<a name="line.87"></a>
-<span class="sourceLineNo">088</span>      }<a name="line.88"></a>
-<span class="sourceLineNo">089</span>      // Path changed - try to find the right path.<a name="line.89"></a>
-<span class="sourceLineNo">090</span>      hasPathChanged = true;<a name="line.90"></a>
-<span class="sourceLineNo">091</span>      if (stopper instanceof ReplicationSyncUp.DummyServer) {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>        // In the case of disaster/recovery, HMaster may be shutdown/crashed before flush data<a name="line.92"></a>
-<span class="sourceLineNo">093</span>        // from .logs to .oldlogs. Loop into .logs folders and check whether a match exists<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        Path newPath = getReplSyncUpPath(path);<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        newPaths.add(newPath);<a name="line.95"></a>
-<span class="sourceLineNo">096</span>        continue;<a name="line.96"></a>
-<span class="sourceLineNo">097</span>      } else {<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        // See if Path exists in the dead RS folder (there could be a chain of failures<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        // to look at)<a name="line.99"></a>
-<span class="sourceLineNo">100</span>        List&lt;String&gt; deadRegionServers = this.replicationQueueInfo.getDeadRegionServers();<a name="line.100"></a>
-<span class="sourceLineNo">101</span>        LOG.info("NB dead servers : " + deadRegionServers.size());<a name="line.101"></a>
-<span class="sourceLineNo">102</span>        final Path walDir = FSUtils.getWALRootDir(conf);<a name="line.102"></a>
-<span class="sourceLineNo">103</span>        for (String curDeadServerName : deadRegionServers) {<a name="line.103"></a>
-<span class="sourceLineNo">104</span>          final Path deadRsDirectory =<a name="line.104"></a>
-<span class="sourceLineNo">105</span>              new Path(walDir, AbstractFSWALProvider.getWALDirectoryName(curDeadServerName));<a name="line.105"></a>
-<span class="sourceLineNo">106</span>          Path[] locs = new Path[] { new Path(deadRsDirectory, path.getName()), new Path(<a name="line.106"></a>
-<span class="sourceLineNo">107</span>              deadRsDirectory.suffix(AbstractFSWALProvider.SPLITTING_EXT), path.getName()) };<a name="line.107"></a>
-<span class="sourceLineNo">108</span>          for (Path possibleLogLocation : locs) {<a name="line.108"></a>
-<span class="sourceLineNo">109</span>            LOG.info("Possible location " + possibleLogLocation.toUri().toString());<a name="line.109"></a>
-<span class="sourceLineNo">110</span>            if (manager.getFs().exists(possibleLogLocation)) {<a name="line.110"></a>
-<span class="sourceLineNo">111</span>              // We found the right new location<a name="line.111"></a>
-<span class="sourceLineNo">112</span>              LOG.info("Log " + path + " still exists at " + possibleLogLocation);<a name="line.112"></a>
-<span class="sourceLineNo">113</span>              newPaths.add(possibleLogLocation);<a name="line.113"></a>
-<span class="sourceLineNo">114</span>              continue pathsLoop;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>            }<a name="line.115"></a>
-<span class="sourceLineNo">116</span>          }<a name="line.116"></a>
-<span class="sourceLineNo">117</span>        }<a name="line.117"></a>
-<span class="sourceLineNo">118</span>        // didn't find a new location<a name="line.118"></a>
-<span class="sourceLineNo">119</span>        LOG.error(<a name="line.119"></a>
-<span class="sourceLineNo">120</span>          String.format("WAL Path %s doesn't exist and couldn't find its new location", path));<a name="line.120"></a>
-<span class="sourceLineNo">121</span>        newPaths.add(path);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>      }<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    }<a name="line.123"></a>
-<span class="sourceLineNo">124</span><a name="line.124"></a>
-<span class="sourceLineNo">125</span>    if (hasPathChanged) {<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      if (newPaths.size() != queue.size()) { // this shouldn't happen<a name="line.126"></a>
-<span class="sourceLineNo">127</span>        LOG.error("Recovery queue size is incorrect");<a name="line.127"></a>
-<span class="sourceLineNo">128</span>        throw new IOException("Recovery queue size error");<a name="line.128"></a>
-<span class="sourceLineNo">129</span>      }<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      // put the correct locations in the queue<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      // since this is a recovered queue with no new incoming logs,<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      // there shouldn't be any concurrency issues<a name="line.132"></a>
-<span class="sourceLineNo">133</span>      queue.clear();<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      for (Path path : newPaths) {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        queue.add(path);<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>  }<a name="line.138"></a>
-<span class="sourceLineNo">139</span><a name="line.139"></a>
-<span class="sourceLineNo">140</span>  // N.B. the ReplicationSyncUp tool sets the manager.getWALDir to the root of the wal<a name="line.140"></a>
-<span class="sourceLineNo">141</span>  // area rather than to the wal area for a particular region server.<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  private Path getReplSyncUpPath(Path path) throws IOException {<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    FileStatus[] rss = fs.listStatus(manager.getLogDir());<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    for (FileStatus rs : rss) {<a name="line.144"></a>
-<span class="sourceLineNo">145</span>      Path p = rs.getPath();<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      FileStatus[] logs = fs.listStatus(p);<a name="line.146"></a>
-<span class="sourceLineNo">147</span>      for (FileStatus log : logs) {<a name="line.147"></a>
-<span class="sourceLineNo">148</span>        p = new Path(p, log.getPath().getName());<a name="line.148"></a>
-<span class="sourceLineNo">149</span>        if (p.getName().equals(path.getName())) {<a name="line.149"></a>
-<span class="sourceLineNo">150</span>          LOG.info("Log " + p.getName() + " found at " + p);<a name="line.150"></a>
-<span class="sourceLineNo">151</span>          return p;<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>    LOG.error("Didn't find path for: " + path.getName());<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    return path;<a name="line.156"></a>
-<span class="sourceLineNo">157</span>  }<a name="line.157"></a>
-<span class="sourceLineNo">158</span><a name="line.158"></a>
-<span class="sourceLineNo">159</span>  public void tryFinish() {<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    // use synchronize to make sure one last thread will clean the queue<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    synchronized (workerThreads) {<a name="line.161"></a>
-<span class="sourceLineNo">162</span>      Threads.sleep(100);// wait a short while for other worker thread to fully exit<a name="line.162"></a>
-<span class="sourceLineNo">163</span>      boolean allTasksDone = true;<a name="line.163"></a>
-<span class="sourceLineNo">164</span>      for (ReplicationSourceShipperThread worker : workerThreads.values()) {<a name="line.164"></a>
-<span class="sourceLineNo">165</span>        if (!worker.isFinished()) {<a name="line.165"></a>
-<span class="sourceLineNo">166</span>          allTasksDone = false;<a name="line.166"></a>
-<span class="sourceLineNo">167</span>          break;<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>      if (allTasksDone) {<a name="line.170"></a>
-<span class="sourceLineNo">171</span>        manager.closeRecoveredQueue(this);<a name="line.171"></a>
-<span class="sourceLineNo">172</span>        LOG.info("Finished recovering queue " + peerClusterZnode + " with the following stats: "<a name="line.172"></a>
-<span class="sourceLineNo">173</span>            + getStats());<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>  }<a name="line.176"></a>
-<span class="sourceLineNo">177</span><a name="line.177"></a>
-<span class="sourceLineNo">178</span>  @Override<a name="line.178"></a>
-<span class="sourceLineNo">179</span>  public String getPeerId() {<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    return this.actualPeerId;<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">080</span>  @Override<a name="line.80"></a>
+<span class="sourceLineNo">081</span>  protected ReplicationSourceWALReader startNewWALReader(String threadName,<a name="line.81"></a>
+<span class="sourceLineNo">082</span>      String walGroupId, PriorityBlockingQueue&lt;Path&gt; queue, long startPosition) {<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    ReplicationSourceWALReader walReader = new RecoveredReplicationSourceWALReader(fs,<a name="line.83"></a>
+<span class="sourceLineNo">084</span>        conf, queue, startPosition, walEntryFilter, this);<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    Threads.setDaemonThreadRunning(walReader, threadName<a name="line.85"></a>
+<span class="sourceLineNo">086</span>        + ".replicationSource.replicationWALReaderThread." + walGroupId + "," + peerClusterZnode,<a name="line.86"></a>
+<span class="sourceLineNo">087</span>      getUncaughtExceptionHandler());<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    return walReader;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>  }<a name="line.89"></a>
+<span class="sourceLineNo">090</span><a name="line.90"></a>
+<span class="sourceLineNo">091</span>  public void locateRecoveredPaths(PriorityBlockingQueue&lt;Path&gt; queue) throws IOException {<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    boolean hasPathChanged = false;<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    PriorityBlockingQueue&lt;Path&gt; newPaths =<a name="line.93"></a>
+<span class="sourceLineNo">094</span>        new PriorityBlockingQueue&lt;Path&gt;(queueSizePerGroup, new LogsComparator());<a name="line.94"></a>
+<span class="sourceLineNo">095</span>    pathsLoop: for (Path path : queue) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>      if (fs.exists(path)) { // still in same location, don't need to do anything<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        newPaths.add(path);<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        continue;<a name="line.98"></a>
+<span class="sourceLineNo">099</span>      }<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      // Path changed - try to find the right path.<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      hasPathChanged = true;<a name="line.101"></a>
+<span class="sourceLineNo">102</span>      if (stopper instanceof ReplicationSyncUp.DummyServer) {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        // In the case of disaster/recovery, HMaster may be shutdown/crashed before flush data<a name="line.103"></a>
+<span class="sourceLineNo">104</span>        // from .logs to .oldlogs. Loop into .logs folders and check whether a match exists<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        Path newPath = getReplSyncUpPath(path);<a name="line.105"></a>
+<span class="sourceLineNo">106</span>        newPaths.add(newPath);<a name="line.106"></a>
+<span class="sourceLineNo">107</span>        continue;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      } else {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>        // See if Path exists in the dead RS folder (there could be a chain of failures<a name="line.109"></a>
+<span class="sourceLineNo">110</span>        // to look at)<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        List&lt;String&gt; deadRegionServers = this.replicationQueueInfo.getDeadRegionServers();<a name="line.111"></a>
+<span class="sourceLineNo">112</span>        LOG.info("NB dead servers : " + deadRegionServers.size());<a name="line.112"></a>
+<span class="sourceLineNo">113</span>        final Path walDir = FSUtils.getWALRootDir(conf);<a name="line.113"></a>
+<span class="sourceLineNo">114</span>        for (String curDeadServerName : deadRegionServers) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>          final Path deadRsDirectory =<a name="line.115"></a>
+<span class="sourceLineNo">116</span>              new Path(walDir, AbstractFSWALProvider.getWALDirectoryName(curDeadServerName));<a name="line.116"></a>
+<span class="sourceLineNo">117</span>          Path[] locs = new Path[] { new Path(deadRsDirectory, path.getName()), new Path(<a name="line.117"></a>
+<span class="sourceLineNo">118</span>              deadRsDirectory.suffix(AbstractFSWALProvider.SPLITTING_EXT), path.getName()) };<a name="line.118"></a>
+<span class="sourceLineNo">119</span>          for (Path possibleLogLocation : locs) {<a name="line.119"></a>
+<span class="sourceLineNo">120</span>            LOG.info("Possible location " + possibleLogLocation.toUri().toString());<a name="line.120"></a>
+<span class="sourceLineNo">121</span>            if (manager.getFs().exists(possibleLogLocation)) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>              // We found the right new location<a name="line.122"></a>
+<span class="sourceLineNo">123</span>              LOG.info("Log " + path + " still exists at " + possibleLogLocation);<a name="line.123"></a>
+<span class="sourceLineNo">124</span>              newPaths.add(possibleLogLocation);<a name="line.124"></a>
+<span class="sourceLineNo">125</span>              continue pathsLoop;<a name="line.125"></a>
+<span class="sourceLineNo">126</span>            }<a name="line.126"></a>
+<span class="sourceLineNo">127</span>          }<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        }<a name="line.128"></a>
+<span class="sourceLineNo">129</span>        // didn't find a new location<a name="line.129"></a>
+<span class="sourceLineNo">130</span>        LOG.error(<a name="line.130"></a>
+<span class="sourceLineNo">131</span>          String.format("WAL Path %s doesn't exist and couldn't find its new location", path));<a name="line.131"></a>
+<span class="sourceLineNo">132</span>        newPaths.add(path);<a name="line.132"></a>
+<span class="sourceLineNo">133</span>      }<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    }<a name="line.134"></a>
+<span class="sourceLineNo">135</span><a name="line.135"></a>
+<span class="sourceLineNo">136</span>    if (hasPathChanged) {<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      if (newPaths.size() != queue.size()) { // this shouldn't happen<a name="line.137"></a>
+<span class="sourceLineNo">138</span>        LOG.error("Recovery queue size is incorrect");<a name="line.138"></a>
+<span class="sourceLineNo">139</span>        throw new IOException("Recovery queue size error");<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      }<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      // put the correct locations in the queue<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      // since this is a recovered queue with no new incoming logs,<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      // there shouldn't be any concurrency issues<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      queue.clear();<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      for (Path path : newPaths) {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>        queue.add(path);<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><a name="line.150"></a>
+<span class="sourceLineNo">151</span>  // N.B. the ReplicationSyncUp tool sets the manager.getWALDir to the root of the wal<a name="line.151"></a>
+<span class="sourceLineNo">152</span>  // area rather than to the wal area for a particular region server.<a name="line.152"></a>
+<span class="sourceLineNo">153</span>  private Path getReplSyncUpPath(Path path) throws IOException {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    FileStatus[] rss = fs.listStatus(manager.getLogDir());<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    for (FileStatus rs : rss) {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      Path p = rs.getPath();<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      FileStatus[] logs = fs.listStatus(p);<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      for (FileStatus log : logs) {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        p = new Path(p, log.getPath().getName());<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        if (p.getName().equals(path.getName())) {<a name="line.160"></a>
+<span class="sourceLineNo">161</span>          LOG.info("Log " + p.getName() + " found at " + p);<a name="line.161"></a>
+<span class="sourceLineNo">162</span>          return p;<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>    }<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    LOG.error("Didn't find path for: " + path.getName());<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    return path;<a name="line.167"></a>
+<span class="sourceLineNo">168</span>  }<a name="line.168"></a>
+<span class="sourceLineNo">169</span><a name="line.169"></a>
+<span class="sourceLineNo">170</span>  public void tryFinish() {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    // use synchronize to make sure one last thread will clean the queue<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    synchronized (workerThreads) {<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      Threads.sleep(100);// wait a short while for other worker thread to fully exit<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      boolean allTasksDone = true;<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      for (ReplicationSourceShipper worker : workerThreads.values()) {<a name="line.175"></a>
+<span class="sourceLineNo">176</span>        if (!worker.isFinished()) {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>          allTasksDone = false;<a name="line.177"></a>
+<span class="sourceLineNo">178</span>          break;<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>      if (allTasksDone) {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>        manager.closeRecoveredQueue(this);<a name="line.182"></a>
+<span class="sourceLineNo">183</span>        LOG.info("Finished recovering queue " + peerClusterZnode + " with the following stats: "<a name="line.183"></a>
+<span class="sourceLineNo">184</span>            + getStats());<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><a name="line.188"></a>
+<span class="sourceLineNo">189</span>  @Override<a name="line.189"></a>
+<span class="sourceLineNo">190</span>  public String getPeerId() {<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    return this.actualPeerId;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>  }<a name="line.192"></a>
+<span class="sourceLineNo">193</span>}<a name="line.193"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/7f23ee04/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipper.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipper.html b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipper.html
new file mode 100644
index 0000000..1c1c800
--- /dev/null
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipper.html
@@ -0,0 +1,223 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
+<span class="sourceLineNo">002</span> *<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * or more contributor license agreements.  See the NOTICE file<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a>
+<span class="sourceLineNo">009</span> * with the License.  You may obtain a copy of the License at<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
+<span class="sourceLineNo">012</span> *<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a>
+<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a>
+<span class="sourceLineNo">018</span> */<a name="line.18"></a>
+<span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.replication.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.util.concurrent.PriorityBlockingQueue;<a name="line.22"></a>
+<span class="sourceLineNo">023</span><a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.commons.logging.Log;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import org.apache.commons.logging.LogFactory;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.conf.Configuration;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.fs.Path;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.replication.ReplicationException;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.replication.ReplicationQueues;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceWALReader.WALEntryBatch;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.util.Threads;<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> *  Used by a {@link RecoveredReplicationSource}.<a name="line.35"></a>
+<span class="sourceLineNo">036</span> */<a name="line.36"></a>
+<span class="sourceLineNo">037</span>@InterfaceAudience.Private<a name="line.37"></a>
+<span class="sourceLineNo">038</span>public class RecoveredReplicationSourceShipper extends ReplicationSourceShipper {<a name="line.38"></a>
+<span class="sourceLineNo">039</span><a name="line.39"></a>
+<span class="sourceLineNo">040</span>  private static final Log LOG = LogFactory.getLog(RecoveredReplicationSourceShipper.class);<a name="line.40"></a>
+<span class="sourceLineNo">041</span>  protected final RecoveredReplicationSource source;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>  private final ReplicationQueues replicationQueues;<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>  public RecoveredReplicationSourceShipper(Configuration conf, String walGroupId,<a name="line.44"></a>
+<span class="sourceLineNo">045</span>      PriorityBlockingQueue&lt;Path&gt; queue, RecoveredReplicationSource source,<a name="line.45"></a>
+<span class="sourceLineNo">046</span>      ReplicationQueues replicationQueues) {<a name="line.46"></a>
+<span class="sourceLineNo">047</span>    super(conf, walGroupId, queue, source);<a name="line.47"></a>
+<span class="sourceLineNo">048</span>    this.source = source;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    this.replicationQueues = replicationQueues;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>  }<a name="line.50"></a>
+<span class="sourceLineNo">051</span><a name="line.51"></a>
+<span class="sourceLineNo">052</span>  @Override<a name="line.52"></a>
+<span class="sourceLineNo">053</span>  public void run() {<a name="line.53"></a>
+<span class="sourceLineNo">054</span>    setWorkerState(WorkerState.RUNNING);<a name="line.54"></a>
+<span class="sourceLineNo">055</span>    // Loop until we close down<a name="line.55"></a>
+<span class="sourceLineNo">056</span>    while (isActive()) {<a name="line.56"></a>
+<span class="sourceLineNo">057</span>      int sleepMultiplier = 1;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>      // Sleep until replication is enabled again<a name="line.58"></a>
+<span class="sourceLineNo">059</span>      if (!source.isPeerEnabled()) {<a name="line.59"></a>
+<span class="sourceLineNo">060</span>        if (source.sleepForRetries("Replication is disabled", sleepMultiplier)) {<a name="line.60"></a>
+<span class="sourceLineNo">061</span>          sleepMultiplier++;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>        }<a name="line.62"></a>
+<span class="sourceLineNo">063</span>        continue;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>      }<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>      while (entryReader == null) {<a name="line.66"></a>
+<span class="sourceLineNo">067</span>        if (source.sleepForRetries("Replication WAL entry reader thread not initialized",<a name="line.67"></a>
+<span class="sourceLineNo">068</span>          sleepMultiplier)) {<a name="line.68"></a>
+<span class="sourceLineNo">069</span>          sleepMultiplier++;<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>      try {<a name="line.73"></a>
+<span class="sourceLineNo">074</span>        WALEntryBatch entryBatch = entryReader.take();<a name="line.74"></a>
+<span class="sourceLineNo">075</span>        shipEdits(entryBatch);<a name="line.75"></a>
+<span class="sourceLineNo">076</span>        if (entryBatch.getWalEntries().isEmpty()<a name="line.76"></a>
+<span class="sourceLineNo">077</span>            &amp;&amp; entryBatch.getLastSeqIds().isEmpty()) {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>          LOG.debug("Finished recovering queue for group " + walGroupId + " of peer "<a name="line.78"></a>
+<span class="sourceLineNo">079</span>              + source.getPeerClusterZnode());<a name="line.79"></a>
+<span class="sourceLineNo">080</span>          source.getSourceMetrics().incrCompletedRecoveryQueue();<a name="line.80"></a>
+<span class="sourceLineNo">081</span>          setWorkerState(WorkerState.FINISHED);<a name="line.81"></a>
+<span class="sourceLineNo">082</span>          continue;<a name="line.82"></a>
+<span class="sourceLineNo">083</span>        }<a name="line.83"></a>
+<span class="sourceLineNo">084</span>      } catch (InterruptedException e) {<a name="line.84"></a>
+<span class="sourceLineNo">085</span>        LOG.trace("Interrupted while waiting for next replication entry batch", e);<a name="line.85"></a>
+<span class="sourceLineNo">086</span>        Thread.currentThread().interrupt();<a name="line.86"></a>
+<span class="sourceLineNo">087</span>      }<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    }<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    source.tryFinish();<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    // If the worker exits run loop without finishing its task, mark it as stopped.<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    if (!isFinished()) {<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      setWorkerState(WorkerState.STOPPED);<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    }<a name="line.93"></a>
+<span class="sourceLineNo">094</span>  }<a name="line.94"></a>
+<span class="sourceLineNo">095</span><a name="line.95"></a>
+<span class="sourceLineNo">096</span>  @Override<a name="line.96"></a>
+<span class="sourceLineNo">097</span>  public long getStartPosition() {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>    long startPosition = getRecoveredQueueStartPos();<a name="line.98"></a>
+<span class="sourceLineNo">099</span>    int numRetries = 0;<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    while (numRetries &lt;= maxRetriesMultiplier) {<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      try {<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        source.locateRecoveredPaths(queue);<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        break;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>      } catch (IOException e) {<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        LOG.error("Error while locating recovered queue paths, attempt #" + numRetries);<a name="line.105"></a>
+<span class="sourceLineNo">106</span>        numRetries++;<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>    return startPosition;<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>  // If this is a recovered queue, the queue is already full and the first log<a name="line.112"></a>
+<span class="sourceLineNo">113</span>  // normally has a position (unless the RS failed between 2 logs)<a name="line.113"></a>
+<span class="sourceLineNo">114</span>  private long getRecoveredQueueStartPos() {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    long startPosition = 0;<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    String peerClusterZnode = source.getPeerClusterZnode();<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    try {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>      startPosition = this.replicationQueues.getLogPosition(peerClusterZnode,<a name="line.118"></a>
+<span class="sourceLineNo">119</span>        this.queue.peek().getName());<a name="line.119"></a>
+<span class="sourceLineNo">120</span>      if (LOG.isTraceEnabled()) {<a name="line.120"></a>
+<span class="sourceLineNo">121</span>        LOG.trace("Recovered queue started with log " + this.queue.peek() + " at position "<a name="line.121"></a>
+<span class="sourceLineNo">122</span>            + startPosition);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>      }<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    } catch (ReplicationException e) {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>      terminate("Couldn't get the position of this recovered queue " + peerClusterZnode, e);<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    }<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    return startPosition;<a name="line.127"></a>
+<span class="sourceLineNo">128</span>  }<a name="line.128"></a>
+<span class="sourceLineNo">129</span><a name="line.129"></a>
+<span class="sourceLineNo">130</span>  @Override<a name="line.130"></a>
+<span class="sourceLineNo">131</span>  protected void updateLogPosition(long lastReadPosition) {<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    source.getSourceManager().logPositionAndCleanOldLogs(currentPath, source.getPeerClusterZnode(),<a name="line.132"></a>
+<span class="sourceLineNo">133</span>      lastReadPosition, true, false);<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    lastLoggedPosition = lastReadPosition;<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
+<span class="sourceLineNo">136</span><a name="line.136"></a>
+<span class="sourceLineNo">137</span>  private void terminate(String reason, Exception cause) {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    if (cause == null) {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>      LOG.info("Closing worker for wal group " + this.walGroupId + " because: " + reason);<a name="line.139"></a>
+<span class="sourceLineNo">140</span><a name="line.140"></a>
+<span class="sourceLineNo">141</span>    } else {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      LOG.error("Closing worker for wal group " + this.walGroupId<a name="line.142"></a>
+<span class="sourceLineNo">143</span>          + " because an error occurred: " + reason, cause);<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    }<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    entryReader.interrupt();<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    Threads.shutdown(entryReader, sleepForRetries);<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    this.interrupt();<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    Threads.shutdown(this, sleepForRetries);<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    LOG.info("ReplicationSourceWorker " + this.getName() + " terminated");<a name="line.149"></a>
+<span class="sourceLineNo">150</span>  }<a name="line.150"></a>
+<span class="sourceLineNo">151</span>}<a name="line.151"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/7f23ee04/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipperThread.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipperThread.html b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipperThread.html
deleted file mode 100644
index 27886a9..0000000
--- a/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceShipperThread.html
+++ /dev/null
@@ -1,223 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html lang="en">
-<head>
-<title>Source code</title>
-<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
-</head>
-<body>
-<div class="sourceContainer">
-<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
-<span class="sourceLineNo">002</span> *<a name="line.2"></a>
-<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a>
-<span class="sourceLineNo">004</span> * or more contributor license agreements.  See the NOTICE file<a name="line.4"></a>
-<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a>
-<span class="sourceLineNo">006</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.6"></a>
-<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a>
-<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a>
-<span class="sourceLineNo">009</span> * with the License.  You may obtain a copy of the License at<a name="line.9"></a>
-<span class="sourceLineNo">010</span> *<a name="line.10"></a>
-<span class="sourceLineNo">011</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
-<span class="sourceLineNo">012</span> *<a name="line.12"></a>
-<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
-<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
-<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
-<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a>
-<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a>
-<span class="sourceLineNo">018</span> */<a name="line.18"></a>
-<span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.replication.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.util.concurrent.PriorityBlockingQueue;<a name="line.22"></a>
-<span class="sourceLineNo">023</span><a name="line.23"></a>
-<span class="sourceLineNo">024</span>import org.apache.commons.logging.Log;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.commons.logging.LogFactory;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.conf.Configuration;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.fs.Path;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.replication.ReplicationException;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.replication.ReplicationQueues;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceWALReaderThread.WALEntryBatch;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.util.Threads;<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> *  Used by a {@link RecoveredReplicationSource}.<a name="line.35"></a>
-<span class="sourceLineNo">036</span> */<a name="line.36"></a>
-<span class="sourceLineNo">037</span>@InterfaceAudience.Private<a name="line.37"></a>
-<span class="sourceLineNo">038</span>public class RecoveredReplicationSourceShipperThread extends ReplicationSourceShipperThread {<a name="line.38"></a>
-<span class="sourceLineNo">039</span><a name="line.39"></a>
-<span class="sourceLineNo">040</span>  private static final Log LOG = LogFactory.getLog(RecoveredReplicationSourceShipperThread.class);<a name="line.40"></a>
-<span class="sourceLineNo">041</span>  protected final RecoveredReplicationSource source;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  private final ReplicationQueues replicationQueues;<a name="line.42"></a>
-<span class="sourceLineNo">043</span><a name="line.43"></a>
-<span class="sourceLineNo">044</span>  public RecoveredReplicationSourceShipperThread(Configuration conf, String walGroupId,<a name="line.44"></a>
-<span class="sourceLineNo">045</span>      PriorityBlockingQueue&lt;Path&gt; queue, RecoveredReplicationSource source,<a name="line.45"></a>
-<span class="sourceLineNo">046</span>      ReplicationQueues replicationQueues) {<a name="line.46"></a>
-<span class="sourceLineNo">047</span>    super(conf, walGroupId, queue, source);<a name="line.47"></a>
-<span class="sourceLineNo">048</span>    this.source = source;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>    this.replicationQueues = replicationQueues;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>  }<a name="line.50"></a>
-<span class="sourceLineNo">051</span><a name="line.51"></a>
-<span class="sourceLineNo">052</span>  @Override<a name="line.52"></a>
-<span class="sourceLineNo">053</span>  public void run() {<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    setWorkerState(WorkerState.RUNNING);<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    // Loop until we close down<a name="line.55"></a>
-<span class="sourceLineNo">056</span>    while (isActive()) {<a name="line.56"></a>
-<span class="sourceLineNo">057</span>      int sleepMultiplier = 1;<a name="line.57"></a>
-<span class="sourceLineNo">058</span>      // Sleep until replication is enabled again<a name="line.58"></a>
-<span class="sourceLineNo">059</span>      if (!source.isPeerEnabled()) {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>        if (source.sleepForRetries("Replication is disabled", sleepMultiplier)) {<a name="line.60"></a>
-<span class="sourceLineNo">061</span>          sleepMultiplier++;<a name="line.61"></a>
-<span class="sourceLineNo">062</span>        }<a name="line.62"></a>
-<span class="sourceLineNo">063</span>        continue;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>      }<a name="line.64"></a>
-<span class="sourceLineNo">065</span><a name="line.65"></a>
-<span class="sourceLineNo">066</span>      while (entryReader == null) {<a name="line.66"></a>
-<span class="sourceLineNo">067</span>        if (source.sleepForRetries("Replication WAL entry reader thread not initialized",<a name="line.67"></a>
-<span class="sourceLineNo">068</span>          sleepMultiplier)) {<a name="line.68"></a>
-<span class="sourceLineNo">069</span>          sleepMultiplier++;<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>      try {<a name="line.73"></a>
-<span class="sourceLineNo">074</span>        WALEntryBatch entryBatch = entryReader.take();<a name="line.74"></a>
-<span class="sourceLineNo">075</span>        shipEdits(entryBatch);<a name="line.75"></a>
-<span class="sourceLineNo">076</span>        if (entryBatch.getWalEntries().isEmpty()<a name="line.76"></a>
-<span class="sourceLineNo">077</span>            &amp;&amp; entryBatch.getLastSeqIds().isEmpty()) {<a name="line.77"></a>
-<span class="sourceLineNo">078</span>          LOG.debug("Finished recovering queue for group " + walGroupId + " of peer "<a name="line.78"></a>
-<span class="sourceLineNo">079</span>              + source.getPeerClusterZnode());<a name="line.79"></a>
-<span class="sourceLineNo">080</span>          source.getSourceMetrics().incrCompletedRecoveryQueue();<a name="line.80"></a>
-<span class="sourceLineNo">081</span>          setWorkerState(WorkerState.FINISHED);<a name="line.81"></a>
-<span class="sourceLineNo">082</span>          continue;<a name="line.82"></a>
-<span class="sourceLineNo">083</span>        }<a name="line.83"></a>
-<span class="sourceLineNo">084</span>      } catch (InterruptedException e) {<a name="line.84"></a>
-<span class="sourceLineNo">085</span>        LOG.trace("Interrupted while waiting for next replication entry batch", e);<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        Thread.currentThread().interrupt();<a name="line.86"></a>
-<span class="sourceLineNo">087</span>      }<a name="line.87"></a>
-<span class="sourceLineNo">088</span>    }<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    source.tryFinish();<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    // If the worker exits run loop without finishing its task, mark it as stopped.<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    if (!isFinished()) {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>      setWorkerState(WorkerState.STOPPED);<a name="line.92"></a>
-<span class="sourceLineNo">093</span>    }<a name="line.93"></a>
-<span class="sourceLineNo">094</span>  }<a name="line.94"></a>
-<span class="sourceLineNo">095</span><a name="line.95"></a>
-<span class="sourceLineNo">096</span>  @Override<a name="line.96"></a>
-<span class="sourceLineNo">097</span>  public long getStartPosition() {<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    long startPosition = getRecoveredQueueStartPos();<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    int numRetries = 0;<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    while (numRetries &lt;= maxRetriesMultiplier) {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>      try {<a name="line.101"></a>
-<span class="sourceLineNo">102</span>        source.locateRecoveredPaths(queue);<a name="line.102"></a>
-<span class="sourceLineNo">103</span>        break;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>      } catch (IOException e) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>        LOG.error("Error while locating recovered queue paths, attempt #" + numRetries);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>        numRetries++;<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>    return startPosition;<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>  // If this is a recovered queue, the queue is already full and the first log<a name="line.112"></a>
-<span class="sourceLineNo">113</span>  // normally has a position (unless the RS failed between 2 logs)<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  private long getRecoveredQueueStartPos() {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    long startPosition = 0;<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    String peerClusterZnode = source.getPeerClusterZnode();<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    try {<a name="line.117"></a>
-<span class="sourceLineNo">118</span>      startPosition = this.replicationQueues.getLogPosition(peerClusterZnode,<a name="line.118"></a>
-<span class="sourceLineNo">119</span>        this.queue.peek().getName());<a name="line.119"></a>
-<span class="sourceLineNo">120</span>      if (LOG.isTraceEnabled()) {<a name="line.120"></a>
-<span class="sourceLineNo">121</span>        LOG.trace("Recovered queue started with log " + this.queue.peek() + " at position "<a name="line.121"></a>
-<span class="sourceLineNo">122</span>            + startPosition);<a name="line.122"></a>
-<span class="sourceLineNo">123</span>      }<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    } catch (ReplicationException e) {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      terminate("Couldn't get the position of this recovered queue " + peerClusterZnode, e);<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    }<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    return startPosition;<a name="line.127"></a>
-<span class="sourceLineNo">128</span>  }<a name="line.128"></a>
-<span class="sourceLineNo">129</span><a name="line.129"></a>
-<span class="sourceLineNo">130</span>  @Override<a name="line.130"></a>
-<span class="sourceLineNo">131</span>  protected void updateLogPosition(long lastReadPosition) {<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    source.getSourceManager().logPositionAndCleanOldLogs(currentPath, source.getPeerClusterZnode(),<a name="line.132"></a>
-<span class="sourceLineNo">133</span>      lastReadPosition, true, false);<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    lastLoggedPosition = lastReadPosition;<a name="line.134"></a>
-<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
-<span class="sourceLineNo">136</span><a name="line.136"></a>
-<span class="sourceLineNo">137</span>  private void terminate(String reason, Exception cause) {<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    if (cause == null) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      LOG.info("Closing worker for wal group " + this.walGroupId + " because: " + reason);<a name="line.139"></a>
-<span class="sourceLineNo">140</span><a name="line.140"></a>
-<span class="sourceLineNo">141</span>    } else {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      LOG.error("Closing worker for wal group " + this.walGroupId<a name="line.142"></a>
-<span class="sourceLineNo">143</span>          + " because an error occurred: " + reason, cause);<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    }<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    entryReader.interrupt();<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    Threads.shutdown(entryReader, sleepForRetries);<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    this.interrupt();<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    Threads.shutdown(this, sleepForRetries);<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    LOG.info("ReplicationSourceWorker " + this.getName() + " terminated");<a name="line.149"></a>
-<span class="sourceLineNo">150</span>  }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>}<a name="line.151"></a>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-</pre>
-</div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/7f23ee04/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceWALReader.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceWALReader.html b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceWALReader.html
new file mode 100644
index 0000000..b8a660c
--- /dev/null
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/replication/regionserver/RecoveredReplicationSourceWALReader.html
@@ -0,0 +1,127 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
+<span class="sourceLineNo">002</span> *<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * or more contributor license agreements.  See the NOTICE file<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a>
+<span class="sourceLineNo">009</span> * with the License.  You may obtain a copy of the License at<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
+<span class="sourceLineNo">012</span> *<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a>
+<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a>
+<span class="sourceLineNo">018</span> */<a name="line.18"></a>
+<span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.replication.regionserver;<a name="line.19"></a>
+<span class="sourceLineNo">020</span><a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.util.concurrent.PriorityBlockingQueue;<a name="line.21"></a>
+<span class="sourceLineNo">022</span><a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.commons.logging.Log;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.commons.logging.LogFactory;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import org.apache.hadoop.conf.Configuration;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.fs.FileSystem;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.fs.Path;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.classification.InterfaceStability;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.replication.WALEntryFilter;<a name="line.30"></a>
+<span class="sourceLineNo">031</span><a name="line.31"></a>
+<span class="sourceLineNo">032</span>/**<a name="line.32"></a>
+<span class="sourceLineNo">033</span> * Used by a {@link RecoveredReplicationSourceShipper}.<a name="line.33"></a>
+<span class="sourceLineNo">034</span> */<a name="line.34"></a>
+<span class="sourceLineNo">035</span>@InterfaceAudience.Private<a name="line.35"></a>
+<span class="sourceLineNo">036</span>@InterfaceStability.Evolving<a name="line.36"></a>
+<span class="sourceLineNo">037</span>public class RecoveredReplicationSourceWALReader extends ReplicationSourceWALReader {<a name="line.37"></a>
+<span class="sourceLineNo">038</span>  private static final Log LOG = LogFactory.getLog(RecoveredReplicationSourceWALReader.class);<a name="line.38"></a>
+<span class="sourceLineNo">039</span><a name="line.39"></a>
+<span class="sourceLineNo">040</span>  public RecoveredReplicationSourceWALReader(FileSystem fs, Configuration conf,<a name="line.40"></a>
+<span class="sourceLineNo">041</span>      PriorityBlockingQueue&lt;Path&gt; logQueue, long startPosition, WALEntryFilter filter,<a name="line.41"></a>
+<span class="sourceLineNo">042</span>      ReplicationSource source) {<a name="line.42"></a>
+<span class="sourceLineNo">043</span>    super(fs, conf, logQueue, startPosition, filter, source);<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>  protected void handleEmptyWALEntryBatch(WALEntryBatch batch, Path currentPath)<a name="line.46"></a>
+<span class="sourceLineNo">047</span>      throws InterruptedException {<a name="line.47"></a>
+<span class="sourceLineNo">048</span>    LOG.trace("Didn't read any new entries from WAL");<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    // we're done with queue recovery, shut ourself down<a name="line.49"></a>
+<span class="sourceLineNo">050</span>    setReaderRunning(false);<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    // shuts down shipper thread immediately<a name="line.51"></a>
+<span class="sourceLineNo">052</span>    entryBatchQueue.put(batch != null ? batch<a name="line.52"></a>
+<span class="sourceLineNo">053</span>        : new WALEntryBatch(replicationBatchCountCapacity, currentPath));<a name="line.53"></a>
+<span class="sourceLineNo">054</span>  }<a name="line.54"></a>
+<span class="sourceLineNo">055</span>}<a name="line.55"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>


Mime
View raw message