hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [11/51] [partial] hbase-site git commit: Published site at .
Date Sun, 28 Jan 2018 15:13:15 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/aa7ffc92/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.html b/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.html
index 75e3c2b..6c25207 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.html
@@ -80,7 +80,7 @@
 <span class="sourceLineNo">072</span>  }<a name="line.72"></a>
 <span class="sourceLineNo">073</span><a name="line.73"></a>
 <span class="sourceLineNo">074</span>  protected List&lt;String&gt; filterMissingFiles(List&lt;String&gt; incrBackupFileList) throws IOException {<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    List&lt;String&gt; list = new ArrayList&lt;String&gt;();<a name="line.75"></a>
+<span class="sourceLineNo">075</span>    List&lt;String&gt; list = new ArrayList&lt;&gt;();<a name="line.75"></a>
 <span class="sourceLineNo">076</span>    for (String file : incrBackupFileList) {<a name="line.76"></a>
 <span class="sourceLineNo">077</span>      Path p = new Path(file);<a name="line.77"></a>
 <span class="sourceLineNo">078</span>      if (fs.exists(p) || isActiveWalPath(p)) {<a name="line.78"></a>
@@ -102,201 +102,201 @@
 <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>  protected static int getIndex(TableName tbl, List&lt;TableName&gt; sTableList) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    if (sTableList == null) return 0;<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    for (int i = 0; i &lt; sTableList.size(); i++) {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>      if (tbl.equals(sTableList.get(i))) {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>        return i;<a name="line.100"></a>
-<span class="sourceLineNo">101</span>      }<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    }<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    return -1;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>  }<a name="line.104"></a>
-<span class="sourceLineNo">105</span><a name="line.105"></a>
-<span class="sourceLineNo">106</span>  /*<a name="line.106"></a>
-<span class="sourceLineNo">107</span>   * Reads bulk load records from backup table, iterates through the records and forms the paths<a name="line.107"></a>
-<span class="sourceLineNo">108</span>   * for bulk loaded hfiles. Copies the bulk loaded hfiles to backup destination<a name="line.108"></a>
-<span class="sourceLineNo">109</span>   * @param sTableList list of tables to be backed up<a name="line.109"></a>
-<span class="sourceLineNo">110</span>   * @return map of table to List of files<a name="line.110"></a>
-<span class="sourceLineNo">111</span>   */<a name="line.111"></a>
-<span class="sourceLineNo">112</span>  @SuppressWarnings("unchecked")<a name="line.112"></a>
-<span class="sourceLineNo">113</span>  protected Map&lt;byte[], List&lt;Path&gt;&gt;[] handleBulkLoad(List&lt;TableName&gt; sTableList) throws IOException {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    Map&lt;byte[], List&lt;Path&gt;&gt;[] mapForSrc = new Map[sTableList.size()];<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    List&lt;String&gt; activeFiles = new ArrayList&lt;String&gt;();<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    List&lt;String&gt; archiveFiles = new ArrayList&lt;String&gt;();<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    Pair&lt;Map&lt;TableName, Map&lt;String, Map&lt;String, List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt;&gt;, List&lt;byte[]&gt;&gt; pair =<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    backupManager.readBulkloadRows(sTableList);<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    Map&lt;TableName, Map&lt;String, Map&lt;String, List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt;&gt; map = pair.getFirst();<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    FileSystem tgtFs;<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    try {<a name="line.121"></a>
-<span class="sourceLineNo">122</span>      tgtFs = FileSystem.get(new URI(backupInfo.getBackupRootDir()), conf);<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    } catch (URISyntaxException use) {<a name="line.123"></a>
-<span class="sourceLineNo">124</span>      throw new IOException("Unable to get FileSystem", use);<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    }<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    Path rootdir = FSUtils.getRootDir(conf);<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    Path tgtRoot = new Path(new Path(backupInfo.getBackupRootDir()), backupId);<a name="line.127"></a>
-<span class="sourceLineNo">128</span><a name="line.128"></a>
-<span class="sourceLineNo">129</span>    for (Map.Entry&lt;TableName, Map&lt;String, Map&lt;String, List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt;&gt; tblEntry :<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      map.entrySet()) {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      TableName srcTable = tblEntry.getKey();<a name="line.131"></a>
+<span class="sourceLineNo">097</span>    if (sTableList == null) {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      return 0;<a name="line.98"></a>
+<span class="sourceLineNo">099</span>    }<a name="line.99"></a>
+<span class="sourceLineNo">100</span><a name="line.100"></a>
+<span class="sourceLineNo">101</span>    for (int i = 0; i &lt; sTableList.size(); i++) {<a name="line.101"></a>
+<span class="sourceLineNo">102</span>      if (tbl.equals(sTableList.get(i))) {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        return i;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>      }<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    }<a name="line.105"></a>
+<span class="sourceLineNo">106</span>    return -1;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>  }<a name="line.107"></a>
+<span class="sourceLineNo">108</span><a name="line.108"></a>
+<span class="sourceLineNo">109</span>  /*<a name="line.109"></a>
+<span class="sourceLineNo">110</span>   * Reads bulk load records from backup table, iterates through the records and forms the paths<a name="line.110"></a>
+<span class="sourceLineNo">111</span>   * for bulk loaded hfiles. Copies the bulk loaded hfiles to backup destination<a name="line.111"></a>
+<span class="sourceLineNo">112</span>   * @param sTableList list of tables to be backed up<a name="line.112"></a>
+<span class="sourceLineNo">113</span>   * @return map of table to List of files<a name="line.113"></a>
+<span class="sourceLineNo">114</span>   */<a name="line.114"></a>
+<span class="sourceLineNo">115</span>  @SuppressWarnings("unchecked")<a name="line.115"></a>
+<span class="sourceLineNo">116</span>  protected Map&lt;byte[], List&lt;Path&gt;&gt;[] handleBulkLoad(List&lt;TableName&gt; sTableList)<a name="line.116"></a>
+<span class="sourceLineNo">117</span>          throws IOException {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    Map&lt;byte[], List&lt;Path&gt;&gt;[] mapForSrc = new Map[sTableList.size()];<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    List&lt;String&gt; activeFiles = new ArrayList&lt;&gt;();<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    List&lt;String&gt; archiveFiles = new ArrayList&lt;&gt;();<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    Pair&lt;Map&lt;TableName, Map&lt;String, Map&lt;String, List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt;&gt;, List&lt;byte[]&gt;&gt; pair =<a name="line.121"></a>
+<span class="sourceLineNo">122</span>            backupManager.readBulkloadRows(sTableList);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    Map&lt;TableName, Map&lt;String, Map&lt;String, List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt;&gt; map = pair.getFirst();<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    FileSystem tgtFs;<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    try {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      tgtFs = FileSystem.get(new URI(backupInfo.getBackupRootDir()), conf);<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    } catch (URISyntaxException use) {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      throw new IOException("Unable to get FileSystem", use);<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    Path rootdir = FSUtils.getRootDir(conf);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    Path tgtRoot = new Path(new Path(backupInfo.getBackupRootDir()), backupId);<a name="line.131"></a>
 <span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>      int srcIdx = getIndex(srcTable, sTableList);<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      if (srcIdx &lt; 0) {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        LOG.warn("Couldn't find " + srcTable + " in source table List");<a name="line.135"></a>
-<span class="sourceLineNo">136</span>        continue;<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      }<a name="line.137"></a>
-<span class="sourceLineNo">138</span>      if (mapForSrc[srcIdx] == null) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>        mapForSrc[srcIdx] = new TreeMap&lt;byte[], List&lt;Path&gt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      }<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      Path tblDir = FSUtils.getTableDir(rootdir, srcTable);<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      Path tgtTable = new Path(new Path(tgtRoot, srcTable.getNamespaceAsString()),<a name="line.142"></a>
-<span class="sourceLineNo">143</span>          srcTable.getQualifierAsString());<a name="line.143"></a>
-<span class="sourceLineNo">144</span>      for (Map.Entry&lt;String,Map&lt;String,List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt; regionEntry :<a name="line.144"></a>
-<span class="sourceLineNo">145</span>        tblEntry.getValue().entrySet()){<a name="line.145"></a>
-<span class="sourceLineNo">146</span>        String regionName = regionEntry.getKey();<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        Path regionDir = new Path(tblDir, regionName);<a name="line.147"></a>
-<span class="sourceLineNo">148</span>        // map from family to List of hfiles<a name="line.148"></a>
-<span class="sourceLineNo">149</span>        for (Map.Entry&lt;String,List&lt;Pair&lt;String, Boolean&gt;&gt;&gt; famEntry :<a name="line.149"></a>
-<span class="sourceLineNo">150</span>          regionEntry.getValue().entrySet()) {<a name="line.150"></a>
-<span class="sourceLineNo">151</span>          String fam = famEntry.getKey();<a name="line.151"></a>
-<span class="sourceLineNo">152</span>          Path famDir = new Path(regionDir, fam);<a name="line.152"></a>
-<span class="sourceLineNo">153</span>          List&lt;Path&gt; files;<a name="line.153"></a>
-<span class="sourceLineNo">154</span>          if (!mapForSrc[srcIdx].containsKey(fam.getBytes())) {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>            files = new ArrayList&lt;Path&gt;();<a name="line.155"></a>
-<span class="sourceLineNo">156</span>            mapForSrc[srcIdx].put(fam.getBytes(), files);<a name="line.156"></a>
-<span class="sourceLineNo">157</span>          } else {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>            files = mapForSrc[srcIdx].get(fam.getBytes());<a name="line.158"></a>
-<span class="sourceLineNo">159</span>          }<a name="line.159"></a>
-<span class="sourceLineNo">160</span>          Path archiveDir = HFileArchiveUtil.getStoreArchivePath(conf, srcTable, regionName, fam);<a name="line.160"></a>
-<span class="sourceLineNo">161</span>          String tblName = srcTable.getQualifierAsString();<a name="line.161"></a>
-<span class="sourceLineNo">162</span>          Path tgtFam = new Path(new Path(tgtTable, regionName), fam);<a name="line.162"></a>
-<span class="sourceLineNo">163</span>          if (!tgtFs.mkdirs(tgtFam)) {<a name="line.163"></a>
-<span class="sourceLineNo">164</span>            throw new IOException("couldn't create " + tgtFam);<a name="line.164"></a>
-<span class="sourceLineNo">165</span>          }<a name="line.165"></a>
-<span class="sourceLineNo">166</span>          for (Pair&lt;String, Boolean&gt; fileWithState : famEntry.getValue()) {<a name="line.166"></a>
-<span class="sourceLineNo">167</span>            String file = fileWithState.getFirst();<a name="line.167"></a>
-<span class="sourceLineNo">168</span>            int idx = file.lastIndexOf("/");<a name="line.168"></a>
-<span class="sourceLineNo">169</span>            String filename = file;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>            if (idx &gt; 0) {<a name="line.170"></a>
-<span class="sourceLineNo">171</span>              filename = file.substring(idx+1);<a name="line.171"></a>
-<span class="sourceLineNo">172</span>            }<a name="line.172"></a>
-<span class="sourceLineNo">173</span>            Path p = new Path(famDir, filename);<a name="line.173"></a>
-<span class="sourceLineNo">174</span>            Path tgt = new Path(tgtFam, filename);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>            Path archive = new Path(archiveDir, filename);<a name="line.175"></a>
-<span class="sourceLineNo">176</span>            if (fs.exists(p)) {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>              if (LOG.isTraceEnabled()) {<a name="line.177"></a>
-<span class="sourceLineNo">178</span>                LOG.trace("found bulk hfile " + file + " in " + famDir + " for " + tblName);<a name="line.178"></a>
-<span class="sourceLineNo">179</span>              }<a name="line.179"></a>
-<span class="sourceLineNo">180</span>                if (LOG.isTraceEnabled()) {<a name="line.180"></a>
-<span class="sourceLineNo">181</span>                  LOG.trace("copying " + p + " to " + tgt);<a name="line.181"></a>
-<span class="sourceLineNo">182</span>                }<a name="line.182"></a>
-<span class="sourceLineNo">183</span>                activeFiles.add(p.toString());<a name="line.183"></a>
-<span class="sourceLineNo">184</span>            } else if (fs.exists(archive)){<a name="line.184"></a>
-<span class="sourceLineNo">185</span>              LOG.debug("copying archive " + archive + " to " + tgt);<a name="line.185"></a>
-<span class="sourceLineNo">186</span>                archiveFiles.add(archive.toString());<a name="line.186"></a>
-<span class="sourceLineNo">187</span>            }<a name="line.187"></a>
-<span class="sourceLineNo">188</span>            files.add(tgt);<a name="line.188"></a>
-<span class="sourceLineNo">189</span>          }<a name="line.189"></a>
-<span class="sourceLineNo">190</span>        }<a name="line.190"></a>
-<span class="sourceLineNo">191</span>      }<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    }<a name="line.192"></a>
-<span class="sourceLineNo">193</span><a name="line.193"></a>
-<span class="sourceLineNo">194</span>    copyBulkLoadedFiles(activeFiles, archiveFiles);<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    backupManager.deleteBulkLoadedRows(pair.getSecond());<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    return mapForSrc;<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>  private void copyBulkLoadedFiles(List&lt;String&gt; activeFiles, List&lt;String&gt; archiveFiles)<a name="line.199"></a>
-<span class="sourceLineNo">200</span>      throws IOException {<a name="line.200"></a>
-<span class="sourceLineNo">201</span><a name="line.201"></a>
-<span class="sourceLineNo">202</span>    try {<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      // Enable special mode of BackupDistCp<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      conf.setInt(MapReduceBackupCopyJob.NUMBER_OF_LEVELS_TO_PRESERVE_KEY, 5);<a name="line.204"></a>
-<span class="sourceLineNo">205</span>      // Copy active files<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      String tgtDest = backupInfo.getBackupRootDir() + Path.SEPARATOR + backupInfo.getBackupId();<a name="line.206"></a>
-<span class="sourceLineNo">207</span>      int attempt = 1;<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      while (activeFiles.size() &gt; 0) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>        LOG.info("Copy "+ activeFiles.size() +<a name="line.209"></a>
-<span class="sourceLineNo">210</span>          " active bulk loaded files. Attempt ="+ (attempt++));<a name="line.210"></a>
-<span class="sourceLineNo">211</span>        String[] toCopy = new String[activeFiles.size()];<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        activeFiles.toArray(toCopy);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>        // Active file can be archived during copy operation,<a name="line.213"></a>
-<span class="sourceLineNo">214</span>        // we need to handle this properly<a name="line.214"></a>
-<span class="sourceLineNo">215</span>        try {<a name="line.215"></a>
-<span class="sourceLineNo">216</span>          incrementalCopyHFiles(toCopy, tgtDest);<a name="line.216"></a>
-<span class="sourceLineNo">217</span>          break;<a name="line.217"></a>
-<span class="sourceLineNo">218</span>        } catch (IOException e) {<a name="line.218"></a>
-<span class="sourceLineNo">219</span>          // Check if some files got archived<a name="line.219"></a>
-<span class="sourceLineNo">220</span>          // Update active and archived lists<a name="line.220"></a>
-<span class="sourceLineNo">221</span>          // When file is being moved from active to archive<a name="line.221"></a>
-<span class="sourceLineNo">222</span>          // directory, the number of active files decreases<a name="line.222"></a>
-<span class="sourceLineNo">223</span><a name="line.223"></a>
-<span class="sourceLineNo">224</span>          int numOfActive = activeFiles.size();<a name="line.224"></a>
-<span class="sourceLineNo">225</span>          updateFileLists(activeFiles, archiveFiles);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>          if (activeFiles.size() &lt; numOfActive) {<a name="line.226"></a>
-<span class="sourceLineNo">227</span>            continue;<a name="line.227"></a>
-<span class="sourceLineNo">228</span>          }<a name="line.228"></a>
-<span class="sourceLineNo">229</span>          // if not - throw exception<a name="line.229"></a>
-<span class="sourceLineNo">230</span>          throw e;<a name="line.230"></a>
-<span class="sourceLineNo">231</span>        }<a name="line.231"></a>
-<span class="sourceLineNo">232</span>      }<a name="line.232"></a>
-<span class="sourceLineNo">233</span>      // If incremental copy will fail for archived files<a name="line.233"></a>
-<span class="sourceLineNo">234</span>      // we will have partially loaded files in backup destination (only files from active data<a name="line.234"></a>
-<span class="sourceLineNo">235</span>      // directory). It is OK, because the backup will marked as FAILED and data will be cleaned up<a name="line.235"></a>
-<span class="sourceLineNo">236</span>      if (archiveFiles.size() &gt; 0) {<a name="line.236"></a>
-<span class="sourceLineNo">237</span>        String[] toCopy = new String[archiveFiles.size()];<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        archiveFiles.toArray(toCopy);<a name="line.238"></a>
-<span class="sourceLineNo">239</span>        incrementalCopyHFiles(toCopy, tgtDest);<a name="line.239"></a>
-<span class="sourceLineNo">240</span>      }<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    } finally {<a name="line.241"></a>
-<span class="sourceLineNo">242</span>      // Disable special mode of BackupDistCp<a name="line.242"></a>
-<span class="sourceLineNo">243</span>      conf.unset(MapReduceBackupCopyJob.NUMBER_OF_LEVELS_TO_PRESERVE_KEY);<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    }<a name="line.244"></a>
-<span class="sourceLineNo">245</span><a name="line.245"></a>
-<span class="sourceLineNo">246</span>  }<a name="line.246"></a>
-<span class="sourceLineNo">247</span><a name="line.247"></a>
-<span class="sourceLineNo">248</span>  private void updateFileLists(List&lt;String&gt; activeFiles, List&lt;String&gt; archiveFiles)<a name="line.248"></a>
-<span class="sourceLineNo">249</span>      throws IOException {<a name="line.249"></a>
-<span class="sourceLineNo">250</span>    List&lt;String&gt; newlyArchived = new ArrayList&lt;String&gt;();<a name="line.250"></a>
-<span class="sourceLineNo">251</span><a name="line.251"></a>
-<span class="sourceLineNo">252</span>    for (String spath : activeFiles) {<a name="line.252"></a>
-<span class="sourceLineNo">253</span>      if (!fs.exists(new Path(spath))) {<a name="line.253"></a>
-<span class="sourceLineNo">254</span>        newlyArchived.add(spath);<a name="line.254"></a>
-<span class="sourceLineNo">255</span>      }<a name="line.255"></a>
-<span class="sourceLineNo">256</span>    }<a name="line.256"></a>
-<span class="sourceLineNo">257</span><a name="line.257"></a>
-<span class="sourceLineNo">258</span>    if (newlyArchived.size() &gt; 0) {<a name="line.258"></a>
-<span class="sourceLineNo">259</span>      activeFiles.removeAll(newlyArchived);<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      archiveFiles.addAll(newlyArchived);<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    }<a name="line.261"></a>
-<span class="sourceLineNo">262</span><a name="line.262"></a>
-<span class="sourceLineNo">263</span>    LOG.debug(newlyArchived.size() + " files have been archived.");<a name="line.263"></a>
-<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">133</span>    for (Map.Entry&lt;TableName, Map&lt;String, Map&lt;String, List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt;&gt; tblEntry :<a name="line.133"></a>
+<span class="sourceLineNo">134</span>      map.entrySet()) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      TableName srcTable = tblEntry.getKey();<a name="line.135"></a>
+<span class="sourceLineNo">136</span><a name="line.136"></a>
+<span class="sourceLineNo">137</span>      int srcIdx = getIndex(srcTable, sTableList);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      if (srcIdx &lt; 0) {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>        LOG.warn("Couldn't find " + srcTable + " in source table List");<a name="line.139"></a>
+<span class="sourceLineNo">140</span>        continue;<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      }<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      if (mapForSrc[srcIdx] == null) {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>        mapForSrc[srcIdx] = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      }<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      Path tblDir = FSUtils.getTableDir(rootdir, srcTable);<a name="line.145"></a>
+<span class="sourceLineNo">146</span>      Path tgtTable = new Path(new Path(tgtRoot, srcTable.getNamespaceAsString()),<a name="line.146"></a>
+<span class="sourceLineNo">147</span>          srcTable.getQualifierAsString());<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      for (Map.Entry&lt;String,Map&lt;String,List&lt;Pair&lt;String, Boolean&gt;&gt;&gt;&gt; regionEntry :<a name="line.148"></a>
+<span class="sourceLineNo">149</span>        tblEntry.getValue().entrySet()){<a name="line.149"></a>
+<span class="sourceLineNo">150</span>        String regionName = regionEntry.getKey();<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        Path regionDir = new Path(tblDir, regionName);<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        // map from family to List of hfiles<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        for (Map.Entry&lt;String,List&lt;Pair&lt;String, Boolean&gt;&gt;&gt; famEntry :<a name="line.153"></a>
+<span class="sourceLineNo">154</span>          regionEntry.getValue().entrySet()) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>          String fam = famEntry.getKey();<a name="line.155"></a>
+<span class="sourceLineNo">156</span>          Path famDir = new Path(regionDir, fam);<a name="line.156"></a>
+<span class="sourceLineNo">157</span>          List&lt;Path&gt; files;<a name="line.157"></a>
+<span class="sourceLineNo">158</span>          if (!mapForSrc[srcIdx].containsKey(fam.getBytes())) {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>            files = new ArrayList&lt;&gt;();<a name="line.159"></a>
+<span class="sourceLineNo">160</span>            mapForSrc[srcIdx].put(fam.getBytes(), files);<a name="line.160"></a>
+<span class="sourceLineNo">161</span>          } else {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>            files = mapForSrc[srcIdx].get(fam.getBytes());<a name="line.162"></a>
+<span class="sourceLineNo">163</span>          }<a name="line.163"></a>
+<span class="sourceLineNo">164</span>          Path archiveDir = HFileArchiveUtil.getStoreArchivePath(conf, srcTable, regionName, fam);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>          String tblName = srcTable.getQualifierAsString();<a name="line.165"></a>
+<span class="sourceLineNo">166</span>          Path tgtFam = new Path(new Path(tgtTable, regionName), fam);<a name="line.166"></a>
+<span class="sourceLineNo">167</span>          if (!tgtFs.mkdirs(tgtFam)) {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>            throw new IOException("couldn't create " + tgtFam);<a name="line.168"></a>
+<span class="sourceLineNo">169</span>          }<a name="line.169"></a>
+<span class="sourceLineNo">170</span>          for (Pair&lt;String, Boolean&gt; fileWithState : famEntry.getValue()) {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>            String file = fileWithState.getFirst();<a name="line.171"></a>
+<span class="sourceLineNo">172</span>            int idx = file.lastIndexOf("/");<a name="line.172"></a>
+<span class="sourceLineNo">173</span>            String filename = file;<a name="line.173"></a>
+<span class="sourceLineNo">174</span>            if (idx &gt; 0) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>              filename = file.substring(idx+1);<a name="line.175"></a>
+<span class="sourceLineNo">176</span>            }<a name="line.176"></a>
+<span class="sourceLineNo">177</span>            Path p = new Path(famDir, filename);<a name="line.177"></a>
+<span class="sourceLineNo">178</span>            Path tgt = new Path(tgtFam, filename);<a name="line.178"></a>
+<span class="sourceLineNo">179</span>            Path archive = new Path(archiveDir, filename);<a name="line.179"></a>
+<span class="sourceLineNo">180</span>            if (fs.exists(p)) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>              if (LOG.isTraceEnabled()) {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>                LOG.trace("found bulk hfile " + file + " in " + famDir + " for " + tblName);<a name="line.182"></a>
+<span class="sourceLineNo">183</span>              }<a name="line.183"></a>
+<span class="sourceLineNo">184</span>              if (LOG.isTraceEnabled()) {<a name="line.184"></a>
+<span class="sourceLineNo">185</span>                LOG.trace("copying " + p + " to " + tgt);<a name="line.185"></a>
+<span class="sourceLineNo">186</span>              }<a name="line.186"></a>
+<span class="sourceLineNo">187</span>              activeFiles.add(p.toString());<a name="line.187"></a>
+<span class="sourceLineNo">188</span>            } else if (fs.exists(archive)){<a name="line.188"></a>
+<span class="sourceLineNo">189</span>              LOG.debug("copying archive " + archive + " to " + tgt);<a name="line.189"></a>
+<span class="sourceLineNo">190</span>              archiveFiles.add(archive.toString());<a name="line.190"></a>
+<span class="sourceLineNo">191</span>            }<a name="line.191"></a>
+<span class="sourceLineNo">192</span>            files.add(tgt);<a name="line.192"></a>
+<span class="sourceLineNo">193</span>          }<a name="line.193"></a>
+<span class="sourceLineNo">194</span>        }<a name="line.194"></a>
+<span class="sourceLineNo">195</span>      }<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>    copyBulkLoadedFiles(activeFiles, archiveFiles);<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    backupManager.deleteBulkLoadedRows(pair.getSecond());<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    return mapForSrc;<a name="line.200"></a>
+<span class="sourceLineNo">201</span>  }<a name="line.201"></a>
+<span class="sourceLineNo">202</span><a name="line.202"></a>
+<span class="sourceLineNo">203</span>  private void copyBulkLoadedFiles(List&lt;String&gt; activeFiles, List&lt;String&gt; archiveFiles)<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      throws IOException {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    try {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      // Enable special mode of BackupDistCp<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      conf.setInt(MapReduceBackupCopyJob.NUMBER_OF_LEVELS_TO_PRESERVE_KEY, 5);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      // Copy active files<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      String tgtDest = backupInfo.getBackupRootDir() + Path.SEPARATOR + backupInfo.getBackupId();<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      int attempt = 1;<a name="line.210"></a>
+<span class="sourceLineNo">211</span>      while (activeFiles.size() &gt; 0) {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>        LOG.info("Copy "+ activeFiles.size() +<a name="line.212"></a>
+<span class="sourceLineNo">213</span>          " active bulk loaded files. Attempt ="+ (attempt++));<a name="line.213"></a>
+<span class="sourceLineNo">214</span>        String[] toCopy = new String[activeFiles.size()];<a name="line.214"></a>
+<span class="sourceLineNo">215</span>        activeFiles.toArray(toCopy);<a name="line.215"></a>
+<span class="sourceLineNo">216</span>        // Active file can be archived during copy operation,<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        // we need to handle this properly<a name="line.217"></a>
+<span class="sourceLineNo">218</span>        try {<a name="line.218"></a>
+<span class="sourceLineNo">219</span>          incrementalCopyHFiles(toCopy, tgtDest);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>          break;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        } catch (IOException e) {<a name="line.221"></a>
+<span class="sourceLineNo">222</span>          // Check if some files got archived<a name="line.222"></a>
+<span class="sourceLineNo">223</span>          // Update active and archived lists<a name="line.223"></a>
+<span class="sourceLineNo">224</span>          // When file is being moved from active to archive<a name="line.224"></a>
+<span class="sourceLineNo">225</span>          // directory, the number of active files decreases<a name="line.225"></a>
+<span class="sourceLineNo">226</span>          int numOfActive = activeFiles.size();<a name="line.226"></a>
+<span class="sourceLineNo">227</span>          updateFileLists(activeFiles, archiveFiles);<a name="line.227"></a>
+<span class="sourceLineNo">228</span>          if (activeFiles.size() &lt; numOfActive) {<a name="line.228"></a>
+<span class="sourceLineNo">229</span>            continue;<a name="line.229"></a>
+<span class="sourceLineNo">230</span>          }<a name="line.230"></a>
+<span class="sourceLineNo">231</span>          // if not - throw exception<a name="line.231"></a>
+<span class="sourceLineNo">232</span>          throw e;<a name="line.232"></a>
+<span class="sourceLineNo">233</span>        }<a name="line.233"></a>
+<span class="sourceLineNo">234</span>      }<a name="line.234"></a>
+<span class="sourceLineNo">235</span>      // If incremental copy will fail for archived files<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      // we will have partially loaded files in backup destination (only files from active data<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      // directory). It is OK, because the backup will marked as FAILED and data will be cleaned up<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      if (archiveFiles.size() &gt; 0) {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>        String[] toCopy = new String[archiveFiles.size()];<a name="line.239"></a>
+<span class="sourceLineNo">240</span>        archiveFiles.toArray(toCopy);<a name="line.240"></a>
+<span class="sourceLineNo">241</span>        incrementalCopyHFiles(toCopy, tgtDest);<a name="line.241"></a>
+<span class="sourceLineNo">242</span>      }<a name="line.242"></a>
+<span class="sourceLineNo">243</span>    } finally {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      // Disable special mode of BackupDistCp<a name="line.244"></a>
+<span class="sourceLineNo">245</span>      conf.unset(MapReduceBackupCopyJob.NUMBER_OF_LEVELS_TO_PRESERVE_KEY);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    }<a name="line.246"></a>
+<span class="sourceLineNo">247</span>  }<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>  private void updateFileLists(List&lt;String&gt; activeFiles, List&lt;String&gt; archiveFiles)<a name="line.249"></a>
+<span class="sourceLineNo">250</span>      throws IOException {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    List&lt;String&gt; newlyArchived = new ArrayList&lt;&gt;();<a name="line.251"></a>
+<span class="sourceLineNo">252</span><a name="line.252"></a>
+<span class="sourceLineNo">253</span>    for (String spath : activeFiles) {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>      if (!fs.exists(new Path(spath))) {<a name="line.254"></a>
+<span class="sourceLineNo">255</span>        newlyArchived.add(spath);<a name="line.255"></a>
+<span class="sourceLineNo">256</span>      }<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    }<a name="line.257"></a>
+<span class="sourceLineNo">258</span><a name="line.258"></a>
+<span class="sourceLineNo">259</span>    if (newlyArchived.size() &gt; 0) {<a name="line.259"></a>
+<span class="sourceLineNo">260</span>      activeFiles.removeAll(newlyArchived);<a name="line.260"></a>
+<span class="sourceLineNo">261</span>      archiveFiles.addAll(newlyArchived);<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    }<a name="line.262"></a>
+<span class="sourceLineNo">263</span><a name="line.263"></a>
+<span class="sourceLineNo">264</span>    LOG.debug(newlyArchived.size() + " files have been archived.");<a name="line.264"></a>
 <span class="sourceLineNo">265</span>  }<a name="line.265"></a>
 <span class="sourceLineNo">266</span><a name="line.266"></a>
 <span class="sourceLineNo">267</span>  @Override<a name="line.267"></a>
 <span class="sourceLineNo">268</span>  public void execute() throws IOException {<a name="line.268"></a>
-<span class="sourceLineNo">269</span><a name="line.269"></a>
-<span class="sourceLineNo">270</span>    try {<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      // case PREPARE_INCREMENTAL:<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      beginBackup(backupManager, backupInfo);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      backupInfo.setPhase(BackupPhase.PREPARE_INCREMENTAL);<a name="line.273"></a>
-<span class="sourceLineNo">274</span>      LOG.debug("For incremental backup, current table set is "<a name="line.274"></a>
-<span class="sourceLineNo">275</span>          + backupManager.getIncrementalBackupTableSet());<a name="line.275"></a>
-<span class="sourceLineNo">276</span>      newTimestamps =<a name="line.276"></a>
-<span class="sourceLineNo">277</span>          ((IncrementalBackupManager) backupManager).getIncrBackupLogFileMap();<a name="line.277"></a>
-<span class="sourceLineNo">278</span>    } catch (Exception e) {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>      // fail the overall backup and return<a name="line.279"></a>
-<span class="sourceLineNo">280</span>      failBackup(conn, backupInfo, backupManager, e, "Unexpected Exception : ",<a name="line.280"></a>
-<span class="sourceLineNo">281</span>        BackupType.INCREMENTAL, conf);<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      throw new IOException(e);<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    }<a name="line.283"></a>
-<span class="sourceLineNo">284</span><a name="line.284"></a>
-<span class="sourceLineNo">285</span>    // case INCREMENTAL_COPY:<a name="line.285"></a>
-<span class="sourceLineNo">286</span>    try {<a name="line.286"></a>
-<span class="sourceLineNo">287</span>      // copy out the table and region info files for each table<a name="line.287"></a>
-<span class="sourceLineNo">288</span>      BackupUtils.copyTableRegionInfo(conn, backupInfo, conf);<a name="line.288"></a>
-<span class="sourceLineNo">289</span>      // convert WAL to HFiles and copy them to .tmp under BACKUP_ROOT<a name="line.289"></a>
-<span class="sourceLineNo">290</span>      convertWALsToHFiles();<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      incrementalCopyHFiles(new String[] {getBulkOutputDir().toString()}, backupInfo.getBackupRootDir());<a name="line.291"></a>
+<span class="sourceLineNo">269</span>    try {<a name="line.269"></a>
+<span class="sourceLineNo">270</span>      // case PREPARE_INCREMENTAL:<a name="line.270"></a>
+<span class="sourceLineNo">271</span>      beginBackup(backupManager, backupInfo);<a name="line.271"></a>
+<span class="sourceLineNo">272</span>      backupInfo.setPhase(BackupPhase.PREPARE_INCREMENTAL);<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      LOG.debug("For incremental backup, current table set is "<a name="line.273"></a>
+<span class="sourceLineNo">274</span>          + backupManager.getIncrementalBackupTableSet());<a name="line.274"></a>
+<span class="sourceLineNo">275</span>      newTimestamps =<a name="line.275"></a>
+<span class="sourceLineNo">276</span>          ((IncrementalBackupManager) backupManager).getIncrBackupLogFileMap();<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    } catch (Exception e) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      // fail the overall backup and return<a name="line.278"></a>
+<span class="sourceLineNo">279</span>      failBackup(conn, backupInfo, backupManager, e, "Unexpected Exception : ",<a name="line.279"></a>
+<span class="sourceLineNo">280</span>        BackupType.INCREMENTAL, conf);<a name="line.280"></a>
+<span class="sourceLineNo">281</span>      throw new IOException(e);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>    }<a name="line.282"></a>
+<span class="sourceLineNo">283</span><a name="line.283"></a>
+<span class="sourceLineNo">284</span>    // case INCREMENTAL_COPY:<a name="line.284"></a>
+<span class="sourceLineNo">285</span>    try {<a name="line.285"></a>
+<span class="sourceLineNo">286</span>      // copy out the table and region info files for each table<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      BackupUtils.copyTableRegionInfo(conn, backupInfo, conf);<a name="line.287"></a>
+<span class="sourceLineNo">288</span>      // convert WAL to HFiles and copy them to .tmp under BACKUP_ROOT<a name="line.288"></a>
+<span class="sourceLineNo">289</span>      convertWALsToHFiles();<a name="line.289"></a>
+<span class="sourceLineNo">290</span>      incrementalCopyHFiles(new String[] {getBulkOutputDir().toString()},<a name="line.290"></a>
+<span class="sourceLineNo">291</span>              backupInfo.getBackupRootDir());<a name="line.291"></a>
 <span class="sourceLineNo">292</span>      // Save list of WAL files copied<a name="line.292"></a>
 <span class="sourceLineNo">293</span>      backupManager.recordWALFiles(backupInfo.getIncrBackupFileList());<a name="line.293"></a>
 <span class="sourceLineNo">294</span>    } catch (Exception e) {<a name="line.294"></a>
@@ -337,118 +337,113 @@
 <span class="sourceLineNo">329</span>  }<a name="line.329"></a>
 <span class="sourceLineNo">330</span><a name="line.330"></a>
 <span class="sourceLineNo">331</span>  protected void incrementalCopyHFiles(String[] files, String backupDest) throws IOException {<a name="line.331"></a>
-<span class="sourceLineNo">332</span><a name="line.332"></a>
-<span class="sourceLineNo">333</span>    try {<a name="line.333"></a>
-<span class="sourceLineNo">334</span>      LOG.debug("Incremental copy HFiles is starting. dest="+backupDest);<a name="line.334"></a>
-<span class="sourceLineNo">335</span>      // set overall backup phase: incremental_copy<a name="line.335"></a>
-<span class="sourceLineNo">336</span>      backupInfo.setPhase(BackupPhase.INCREMENTAL_COPY);<a name="line.336"></a>
-<span class="sourceLineNo">337</span>      // get incremental backup file list and prepare parms for DistCp<a name="line.337"></a>
-<span class="sourceLineNo">338</span>      String[] strArr = new String[files.length + 1];<a name="line.338"></a>
-<span class="sourceLineNo">339</span>      System.arraycopy(files, 0, strArr, 0, files.length);<a name="line.339"></a>
-<span class="sourceLineNo">340</span>      strArr[strArr.length - 1] = backupDest;<a name="line.340"></a>
-<span class="sourceLineNo">341</span><a name="line.341"></a>
-<span class="sourceLineNo">342</span>      String jobname = "Incremental_Backup-HFileCopy-" + backupInfo.getBackupId();<a name="line.342"></a>
-<span class="sourceLineNo">343</span>      if (LOG.isDebugEnabled()) {<a name="line.343"></a>
-<span class="sourceLineNo">344</span>        LOG.debug("Setting incremental copy HFiles job name to : " + jobname);<a name="line.344"></a>
-<span class="sourceLineNo">345</span>      }<a name="line.345"></a>
-<span class="sourceLineNo">346</span>      conf.set(JOB_NAME_CONF_KEY, jobname);<a name="line.346"></a>
-<span class="sourceLineNo">347</span><a name="line.347"></a>
-<span class="sourceLineNo">348</span>      BackupCopyJob copyService = BackupRestoreFactory.getBackupCopyJob(conf);<a name="line.348"></a>
-<span class="sourceLineNo">349</span>      int res = copyService.copy(backupInfo, backupManager, conf, BackupType.INCREMENTAL, strArr);<a name="line.349"></a>
-<span class="sourceLineNo">350</span>      if (res != 0) {<a name="line.350"></a>
-<span class="sourceLineNo">351</span>        LOG.error("Copy incremental HFile files failed with return code: " + res + ".");<a name="line.351"></a>
-<span class="sourceLineNo">352</span>        throw new IOException("Failed copy from " + StringUtils.join(files, ',')<a name="line.352"></a>
-<span class="sourceLineNo">353</span>            + " to " + backupDest);<a name="line.353"></a>
-<span class="sourceLineNo">354</span>      }<a name="line.354"></a>
-<span class="sourceLineNo">355</span>      LOG.debug("Incremental copy HFiles from " + StringUtils.join(files, ',')<a name="line.355"></a>
-<span class="sourceLineNo">356</span>          + " to " + backupDest + " finished.");<a name="line.356"></a>
-<span class="sourceLineNo">357</span>    } finally {<a name="line.357"></a>
-<span class="sourceLineNo">358</span>      deleteBulkLoadDirectory();<a name="line.358"></a>
-<span class="sourceLineNo">359</span>    }<a name="line.359"></a>
-<span class="sourceLineNo">360</span>  }<a name="line.360"></a>
-<span class="sourceLineNo">361</span><a name="line.361"></a>
-<span class="sourceLineNo">362</span>  protected void deleteBulkLoadDirectory() throws IOException {<a name="line.362"></a>
-<span class="sourceLineNo">363</span>    // delete original bulk load directory on method exit<a name="line.363"></a>
-<span class="sourceLineNo">364</span>    Path path = getBulkOutputDir();<a name="line.364"></a>
-<span class="sourceLineNo">365</span>    boolean result = fs.delete(path, true);<a name="line.365"></a>
-<span class="sourceLineNo">366</span>    if (!result) {<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      LOG.warn("Could not delete " + path);<a name="line.367"></a>
-<span class="sourceLineNo">368</span>    }<a name="line.368"></a>
+<span class="sourceLineNo">332</span>    try {<a name="line.332"></a>
+<span class="sourceLineNo">333</span>      LOG.debug("Incremental copy HFiles is starting. dest=" + backupDest);<a name="line.333"></a>
+<span class="sourceLineNo">334</span>      // set overall backup phase: incremental_copy<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      backupInfo.setPhase(BackupPhase.INCREMENTAL_COPY);<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      // get incremental backup file list and prepare parms for DistCp<a name="line.336"></a>
+<span class="sourceLineNo">337</span>      String[] strArr = new String[files.length + 1];<a name="line.337"></a>
+<span class="sourceLineNo">338</span>      System.arraycopy(files, 0, strArr, 0, files.length);<a name="line.338"></a>
+<span class="sourceLineNo">339</span>      strArr[strArr.length - 1] = backupDest;<a name="line.339"></a>
+<span class="sourceLineNo">340</span><a name="line.340"></a>
+<span class="sourceLineNo">341</span>      String jobname = "Incremental_Backup-HFileCopy-" + backupInfo.getBackupId();<a name="line.341"></a>
+<span class="sourceLineNo">342</span>      if (LOG.isDebugEnabled()) {<a name="line.342"></a>
+<span class="sourceLineNo">343</span>        LOG.debug("Setting incremental copy HFiles job name to : " + jobname);<a name="line.343"></a>
+<span class="sourceLineNo">344</span>      }<a name="line.344"></a>
+<span class="sourceLineNo">345</span>      conf.set(JOB_NAME_CONF_KEY, jobname);<a name="line.345"></a>
+<span class="sourceLineNo">346</span><a name="line.346"></a>
+<span class="sourceLineNo">347</span>      BackupCopyJob copyService = BackupRestoreFactory.getBackupCopyJob(conf);<a name="line.347"></a>
+<span class="sourceLineNo">348</span>      int res = copyService.copy(backupInfo, backupManager, conf, BackupType.INCREMENTAL, strArr);<a name="line.348"></a>
+<span class="sourceLineNo">349</span>      if (res != 0) {<a name="line.349"></a>
+<span class="sourceLineNo">350</span>        LOG.error("Copy incremental HFile files failed with return code: " + res + ".");<a name="line.350"></a>
+<span class="sourceLineNo">351</span>        throw new IOException("Failed copy from " + StringUtils.join(files, ',')<a name="line.351"></a>
+<span class="sourceLineNo">352</span>            + " to " + backupDest);<a name="line.352"></a>
+<span class="sourceLineNo">353</span>      }<a name="line.353"></a>
+<span class="sourceLineNo">354</span>      LOG.debug("Incremental copy HFiles from " + StringUtils.join(files, ',')<a name="line.354"></a>
+<span class="sourceLineNo">355</span>          + " to " + backupDest + " finished.");<a name="line.355"></a>
+<span class="sourceLineNo">356</span>    } finally {<a name="line.356"></a>
+<span class="sourceLineNo">357</span>      deleteBulkLoadDirectory();<a name="line.357"></a>
+<span class="sourceLineNo">358</span>    }<a name="line.358"></a>
+<span class="sourceLineNo">359</span>  }<a name="line.359"></a>
+<span class="sourceLineNo">360</span><a name="line.360"></a>
+<span class="sourceLineNo">361</span>  protected void deleteBulkLoadDirectory() throws IOException {<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    // delete original bulk load directory on method exit<a name="line.362"></a>
+<span class="sourceLineNo">363</span>    Path path = getBulkOutputDir();<a name="line.363"></a>
+<span class="sourceLineNo">364</span>    boolean result = fs.delete(path, true);<a name="line.364"></a>
+<span class="sourceLineNo">365</span>    if (!result) {<a name="line.365"></a>
+<span class="sourceLineNo">366</span>      LOG.warn("Could not delete " + path);<a name="line.366"></a>
+<span class="sourceLineNo">367</span>    }<a name="line.367"></a>
+<span class="sourceLineNo">368</span>  }<a name="line.368"></a>
 <span class="sourceLineNo">369</span><a name="line.369"></a>
-<span class="sourceLineNo">370</span>  }<a name="line.370"></a>
-<span class="sourceLineNo">371</span><a name="line.371"></a>
-<span class="sourceLineNo">372</span>  protected void convertWALsToHFiles() throws IOException {<a name="line.372"></a>
-<span class="sourceLineNo">373</span>    // get incremental backup file list and prepare parameters for DistCp<a name="line.373"></a>
-<span class="sourceLineNo">374</span>    List&lt;String&gt; incrBackupFileList = backupInfo.getIncrBackupFileList();<a name="line.374"></a>
-<span class="sourceLineNo">375</span>    // Get list of tables in incremental backup set<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    Set&lt;TableName&gt; tableSet = backupManager.getIncrementalBackupTableSet();<a name="line.376"></a>
-<span class="sourceLineNo">377</span>    // filter missing files out (they have been copied by previous backups)<a name="line.377"></a>
-<span class="sourceLineNo">378</span>    incrBackupFileList = filterMissingFiles(incrBackupFileList);<a name="line.378"></a>
-<span class="sourceLineNo">379</span>    for (TableName table : tableSet) {<a name="line.379"></a>
-<span class="sourceLineNo">380</span>      // Check if table exists<a name="line.380"></a>
-<span class="sourceLineNo">381</span>      if (tableExists(table, conn)) {<a name="line.381"></a>
-<span class="sourceLineNo">382</span>        walToHFiles(incrBackupFileList, table);<a name="line.382"></a>
-<span class="sourceLineNo">383</span>      } else {<a name="line.383"></a>
-<span class="sourceLineNo">384</span>        LOG.warn("Table " + table + " does not exists. Skipping in WAL converter");<a name="line.384"></a>
-<span class="sourceLineNo">385</span>      }<a name="line.385"></a>
-<span class="sourceLineNo">386</span>    }<a name="line.386"></a>
-<span class="sourceLineNo">387</span>  }<a name="line.387"></a>
-<span class="sourceLineNo">388</span><a name="line.388"></a>
-<span class="sourceLineNo">389</span><a name="line.389"></a>
-<span class="sourceLineNo">390</span>  protected boolean tableExists(TableName table, Connection conn) throws IOException {<a name="line.390"></a>
-<span class="sourceLineNo">391</span>    try (Admin admin = conn.getAdmin()) {<a name="line.391"></a>
-<span class="sourceLineNo">392</span>      return admin.tableExists(table);<a name="line.392"></a>
-<span class="sourceLineNo">393</span>    }<a name="line.393"></a>
-<span class="sourceLineNo">394</span>  }<a name="line.394"></a>
+<span class="sourceLineNo">370</span>  protected void convertWALsToHFiles() throws IOException {<a name="line.370"></a>
+<span class="sourceLineNo">371</span>    // get incremental backup file list and prepare parameters for DistCp<a name="line.371"></a>
+<span class="sourceLineNo">372</span>    List&lt;String&gt; incrBackupFileList = backupInfo.getIncrBackupFileList();<a name="line.372"></a>
+<span class="sourceLineNo">373</span>    // Get list of tables in incremental backup set<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    Set&lt;TableName&gt; tableSet = backupManager.getIncrementalBackupTableSet();<a name="line.374"></a>
+<span class="sourceLineNo">375</span>    // filter missing files out (they have been copied by previous backups)<a name="line.375"></a>
+<span class="sourceLineNo">376</span>    incrBackupFileList = filterMissingFiles(incrBackupFileList);<a name="line.376"></a>
+<span class="sourceLineNo">377</span>    for (TableName table : tableSet) {<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      // Check if table exists<a name="line.378"></a>
+<span class="sourceLineNo">379</span>      if (tableExists(table, conn)) {<a name="line.379"></a>
+<span class="sourceLineNo">380</span>        walToHFiles(incrBackupFileList, table);<a name="line.380"></a>
+<span class="sourceLineNo">381</span>      } else {<a name="line.381"></a>
+<span class="sourceLineNo">382</span>        LOG.warn("Table " + table + " does not exists. Skipping in WAL converter");<a name="line.382"></a>
+<span class="sourceLineNo">383</span>      }<a name="line.383"></a>
+<span class="sourceLineNo">384</span>    }<a name="line.384"></a>
+<span class="sourceLineNo">385</span>  }<a name="line.385"></a>
+<span class="sourceLineNo">386</span><a name="line.386"></a>
+<span class="sourceLineNo">387</span>  protected boolean tableExists(TableName table, Connection conn) throws IOException {<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    try (Admin admin = conn.getAdmin()) {<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      return admin.tableExists(table);<a name="line.389"></a>
+<span class="sourceLineNo">390</span>    }<a name="line.390"></a>
+<span class="sourceLineNo">391</span>  }<a name="line.391"></a>
+<span class="sourceLineNo">392</span><a name="line.392"></a>
+<span class="sourceLineNo">393</span>  protected void walToHFiles(List&lt;String&gt; dirPaths, TableName tableName) throws IOException {<a name="line.393"></a>
+<span class="sourceLineNo">394</span>    Tool player = new WALPlayer();<a name="line.394"></a>
 <span class="sourceLineNo">395</span><a name="line.395"></a>
-<span class="sourceLineNo">396</span>  protected void walToHFiles(List&lt;String&gt; dirPaths, TableName tableName) throws IOException {<a name="line.396"></a>
-<span class="sourceLineNo">397</span><a name="line.397"></a>
-<span class="sourceLineNo">398</span>    Tool player = new WALPlayer();<a name="line.398"></a>
-<span class="sourceLineNo">399</span><a name="line.399"></a>
-<span class="sourceLineNo">400</span>    // Player reads all files in arbitrary directory structure and creates<a name="line.400"></a>
-<span class="sourceLineNo">401</span>    // a Map task for each file. We use ';' as separator<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    // because WAL file names contains ','<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    String dirs = StringUtils.join(dirPaths, ';');<a name="line.403"></a>
-<span class="sourceLineNo">404</span>    String jobname = "Incremental_Backup-" + backupId + "-" + tableName.getNameAsString();<a name="line.404"></a>
-<span class="sourceLineNo">405</span><a name="line.405"></a>
-<span class="sourceLineNo">406</span>    Path bulkOutputPath = getBulkOutputDirForTable(tableName);<a name="line.406"></a>
-<span class="sourceLineNo">407</span>    conf.set(WALPlayer.BULK_OUTPUT_CONF_KEY, bulkOutputPath.toString());<a name="line.407"></a>
-<span class="sourceLineNo">408</span>    conf.set(WALPlayer.INPUT_FILES_SEPARATOR_KEY, ";");<a name="line.408"></a>
-<span class="sourceLineNo">409</span>    conf.set(JOB_NAME_CONF_KEY, jobname);<a name="line.409"></a>
-<span class="sourceLineNo">410</span>    String[] playerArgs = { dirs, tableName.getNameAsString() };<a name="line.410"></a>
-<span class="sourceLineNo">411</span><a name="line.411"></a>
-<span class="sourceLineNo">412</span>    try {<a name="line.412"></a>
-<span class="sourceLineNo">413</span>      player.setConf(conf);<a name="line.413"></a>
-<span class="sourceLineNo">414</span>      int result = player.run(playerArgs);<a name="line.414"></a>
-<span class="sourceLineNo">415</span>      if(result != 0) {<a name="line.415"></a>
-<span class="sourceLineNo">416</span>        throw new IOException("WAL Player failed");<a name="line.416"></a>
-<span class="sourceLineNo">417</span>      }<a name="line.417"></a>
-<span class="sourceLineNo">418</span>      conf.unset(WALPlayer.INPUT_FILES_SEPARATOR_KEY);<a name="line.418"></a>
-<span class="sourceLineNo">419</span>      conf.unset(JOB_NAME_CONF_KEY);<a name="line.419"></a>
-<span class="sourceLineNo">420</span>    } catch (IOException e) {<a name="line.420"></a>
-<span class="sourceLineNo">421</span>      throw e;<a name="line.421"></a>
-<span class="sourceLineNo">422</span>    } catch (Exception ee) {<a name="line.422"></a>
-<span class="sourceLineNo">423</span>      throw new IOException("Can not convert from directory " + dirs<a name="line.423"></a>
-<span class="sourceLineNo">424</span>          + " (check Hadoop, HBase and WALPlayer M/R job logs) ", ee);<a name="line.424"></a>
-<span class="sourceLineNo">425</span>    }<a name="line.425"></a>
-<span class="sourceLineNo">426</span>  }<a name="line.426"></a>
-<span class="sourceLineNo">427</span><a name="line.427"></a>
-<span class="sourceLineNo">428</span>  protected Path getBulkOutputDirForTable(TableName table) {<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    Path tablePath = getBulkOutputDir();<a name="line.429"></a>
-<span class="sourceLineNo">430</span>    tablePath = new Path(tablePath, table.getNamespaceAsString());<a name="line.430"></a>
-<span class="sourceLineNo">431</span>    tablePath = new Path(tablePath, table.getQualifierAsString());<a name="line.431"></a>
-<span class="sourceLineNo">432</span>    return new Path(tablePath, "data");<a name="line.432"></a>
-<span class="sourceLineNo">433</span>  }<a name="line.433"></a>
-<span class="sourceLineNo">434</span><a name="line.434"></a>
-<span class="sourceLineNo">435</span>  protected Path getBulkOutputDir() {<a name="line.435"></a>
-<span class="sourceLineNo">436</span>    String backupId = backupInfo.getBackupId();<a name="line.436"></a>
-<span class="sourceLineNo">437</span>    Path path = new Path(backupInfo.getBackupRootDir());<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    path = new Path(path, ".tmp");<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    path = new Path(path, backupId);<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    return path;<a name="line.440"></a>
-<span class="sourceLineNo">441</span>  }<a name="line.441"></a>
-<span class="sourceLineNo">442</span><a name="line.442"></a>
-<span class="sourceLineNo">443</span>}<a name="line.443"></a>
+<span class="sourceLineNo">396</span>    // Player reads all files in arbitrary directory structure and creates<a name="line.396"></a>
+<span class="sourceLineNo">397</span>    // a Map task for each file. We use ';' as separator<a name="line.397"></a>
+<span class="sourceLineNo">398</span>    // because WAL file names contains ','<a name="line.398"></a>
+<span class="sourceLineNo">399</span>    String dirs = StringUtils.join(dirPaths, ';');<a name="line.399"></a>
+<span class="sourceLineNo">400</span>    String jobname = "Incremental_Backup-" + backupId + "-" + tableName.getNameAsString();<a name="line.400"></a>
+<span class="sourceLineNo">401</span><a name="line.401"></a>
+<span class="sourceLineNo">402</span>    Path bulkOutputPath = getBulkOutputDirForTable(tableName);<a name="line.402"></a>
+<span class="sourceLineNo">403</span>    conf.set(WALPlayer.BULK_OUTPUT_CONF_KEY, bulkOutputPath.toString());<a name="line.403"></a>
+<span class="sourceLineNo">404</span>    conf.set(WALPlayer.INPUT_FILES_SEPARATOR_KEY, ";");<a name="line.404"></a>
+<span class="sourceLineNo">405</span>    conf.set(JOB_NAME_CONF_KEY, jobname);<a name="line.405"></a>
+<span class="sourceLineNo">406</span>    String[] playerArgs = { dirs, tableName.getNameAsString() };<a name="line.406"></a>
+<span class="sourceLineNo">407</span><a name="line.407"></a>
+<span class="sourceLineNo">408</span>    try {<a name="line.408"></a>
+<span class="sourceLineNo">409</span>      player.setConf(conf);<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      int result = player.run(playerArgs);<a name="line.410"></a>
+<span class="sourceLineNo">411</span>      if(result != 0) {<a name="line.411"></a>
+<span class="sourceLineNo">412</span>        throw new IOException("WAL Player failed");<a name="line.412"></a>
+<span class="sourceLineNo">413</span>      }<a name="line.413"></a>
+<span class="sourceLineNo">414</span>      conf.unset(WALPlayer.INPUT_FILES_SEPARATOR_KEY);<a name="line.414"></a>
+<span class="sourceLineNo">415</span>      conf.unset(JOB_NAME_CONF_KEY);<a name="line.415"></a>
+<span class="sourceLineNo">416</span>    } catch (IOException e) {<a name="line.416"></a>
+<span class="sourceLineNo">417</span>      throw e;<a name="line.417"></a>
+<span class="sourceLineNo">418</span>    } catch (Exception ee) {<a name="line.418"></a>
+<span class="sourceLineNo">419</span>      throw new IOException("Can not convert from directory " + dirs<a name="line.419"></a>
+<span class="sourceLineNo">420</span>          + " (check Hadoop, HBase and WALPlayer M/R job logs) ", ee);<a name="line.420"></a>
+<span class="sourceLineNo">421</span>    }<a name="line.421"></a>
+<span class="sourceLineNo">422</span>  }<a name="line.422"></a>
+<span class="sourceLineNo">423</span><a name="line.423"></a>
+<span class="sourceLineNo">424</span>  protected Path getBulkOutputDirForTable(TableName table) {<a name="line.424"></a>
+<span class="sourceLineNo">425</span>    Path tablePath = getBulkOutputDir();<a name="line.425"></a>
+<span class="sourceLineNo">426</span>    tablePath = new Path(tablePath, table.getNamespaceAsString());<a name="line.426"></a>
+<span class="sourceLineNo">427</span>    tablePath = new Path(tablePath, table.getQualifierAsString());<a name="line.427"></a>
+<span class="sourceLineNo">428</span>    return new Path(tablePath, "data");<a name="line.428"></a>
+<span class="sourceLineNo">429</span>  }<a name="line.429"></a>
+<span class="sourceLineNo">430</span><a name="line.430"></a>
+<span class="sourceLineNo">431</span>  protected Path getBulkOutputDir() {<a name="line.431"></a>
+<span class="sourceLineNo">432</span>    String backupId = backupInfo.getBackupId();<a name="line.432"></a>
+<span class="sourceLineNo">433</span>    Path path = new Path(backupInfo.getBackupRootDir());<a name="line.433"></a>
+<span class="sourceLineNo">434</span>    path = new Path(path, ".tmp");<a name="line.434"></a>
+<span class="sourceLineNo">435</span>    path = new Path(path, backupId);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>    return path;<a name="line.436"></a>
+<span class="sourceLineNo">437</span>  }<a name="line.437"></a>
+<span class="sourceLineNo">438</span>}<a name="line.438"></a>
 
 
 


Mime
View raw message