hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [01/43] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Fri, 05 May 2017 14:58:38 GMT
Repository: hbase-site
Updated Branches:
  refs/heads/asf-site 02b335089 -> e2c783b2d


http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e2c783b2/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestFSUtils.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestFSUtils.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestFSUtils.html
index 77e9b6c..fdf7de6 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestFSUtils.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/util/TestFSUtils.html
@@ -45,18 +45,18 @@
 <span class="sourceLineNo">037</span>import org.apache.hadoop.fs.FileSystem;<a name="line.37"></a>
 <span class="sourceLineNo">038</span>import org.apache.hadoop.fs.Path;<a name="line.38"></a>
 <span class="sourceLineNo">039</span>import org.apache.hadoop.fs.permission.FsPermission;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.HConstants;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.HDFSBlocksDistribution;<a name="line.43"></a>
-<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.exceptions.DeserializationException;<a name="line.44"></a>
-<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.fs.HFileSystem;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.46"></a>
-<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.testclassification.MiscTests;<a name="line.47"></a>
-<span class="sourceLineNo">048</span>import org.apache.hadoop.hdfs.DFSConfigKeys;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>import org.apache.hadoop.hdfs.DFSHedgedReadMetrics;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>import org.apache.hadoop.hdfs.DFSTestUtil;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>import org.apache.hadoop.hdfs.MiniDFSCluster;<a name="line.51"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.HConstants;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.HDFSBlocksDistribution;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.exceptions.DeserializationException;<a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.fs.HFileSystem;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.testclassification.MiscTests;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>import org.apache.hadoop.hdfs.DFSConfigKeys;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>import org.apache.hadoop.hdfs.DFSHedgedReadMetrics;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>import org.apache.hadoop.hdfs.DFSTestUtil;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>import org.apache.hadoop.hdfs.MiniDFSCluster;<a name="line.50"></a>
+<span class="sourceLineNo">051</span>import org.junit.Before;<a name="line.51"></a>
 <span class="sourceLineNo">052</span>import org.junit.Test;<a name="line.52"></a>
 <span class="sourceLineNo">053</span>import org.junit.experimental.categories.Category;<a name="line.53"></a>
 <span class="sourceLineNo">054</span><a name="line.54"></a>
@@ -65,531 +65,515 @@
 <span class="sourceLineNo">057</span> */<a name="line.57"></a>
 <span class="sourceLineNo">058</span>@Category({MiscTests.class, MediumTests.class})<a name="line.58"></a>
 <span class="sourceLineNo">059</span>public class TestFSUtils {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>  /**<a name="line.60"></a>
-<span class="sourceLineNo">061</span>   * Test path compare and prefix checking.<a name="line.61"></a>
-<span class="sourceLineNo">062</span>   * @throws IOException<a name="line.62"></a>
-<span class="sourceLineNo">063</span>   */<a name="line.63"></a>
-<span class="sourceLineNo">064</span>  @Test<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  public void testMatchingTail() throws IOException {<a name="line.65"></a>
-<span class="sourceLineNo">066</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    final FileSystem fs = htu.getTestFileSystem();<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    Path rootdir = htu.getDataTestDir();<a name="line.68"></a>
-<span class="sourceLineNo">069</span>    assertTrue(rootdir.depth() &gt; 1);<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    Path partPath = new Path("a", "b");<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    Path fullPath = new Path(rootdir, partPath);<a name="line.71"></a>
-<span class="sourceLineNo">072</span>    Path fullyQualifiedPath = fs.makeQualified(fullPath);<a name="line.72"></a>
-<span class="sourceLineNo">073</span>    assertFalse(FSUtils.isMatchingTail(fullPath, partPath));<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    assertFalse(FSUtils.isMatchingTail(fullPath, partPath.toString()));<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    assertTrue(FSUtils.isStartingWithPath(rootdir, fullPath.toString()));<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    assertTrue(FSUtils.isStartingWithPath(fullyQualifiedPath, fullPath.toString()));<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    assertFalse(FSUtils.isStartingWithPath(rootdir, partPath.toString()));<a name="line.77"></a>
-<span class="sourceLineNo">078</span>    assertFalse(FSUtils.isMatchingTail(fullyQualifiedPath, partPath));<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    assertTrue(FSUtils.isMatchingTail(fullyQualifiedPath, fullPath));<a name="line.79"></a>
-<span class="sourceLineNo">080</span>    assertTrue(FSUtils.isMatchingTail(fullyQualifiedPath, fullPath.toString()));<a name="line.80"></a>
-<span class="sourceLineNo">081</span>    assertTrue(FSUtils.isMatchingTail(fullyQualifiedPath, fs.makeQualified(fullPath)));<a name="line.81"></a>
-<span class="sourceLineNo">082</span>    assertTrue(FSUtils.isStartingWithPath(rootdir, fullyQualifiedPath.toString()));<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    assertFalse(FSUtils.isMatchingTail(fullPath, new Path("x")));<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    assertFalse(FSUtils.isMatchingTail(new Path("x"), fullPath));<a name="line.84"></a>
-<span class="sourceLineNo">085</span>  }<a name="line.85"></a>
-<span class="sourceLineNo">086</span><a name="line.86"></a>
-<span class="sourceLineNo">087</span>  @Test<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  public void testVersion() throws DeserializationException, IOException {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    final FileSystem fs = htu.getTestFileSystem();<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    final Path rootdir = htu.getDataTestDir();<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    assertNull(FSUtils.getVersion(fs, rootdir));<a name="line.92"></a>
-<span class="sourceLineNo">093</span>    // Write out old format version file.  See if we can read it in and convert.<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME);<a name="line.94"></a>
-<span class="sourceLineNo">095</span>    FSDataOutputStream s = fs.create(versionFile);<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    final String version = HConstants.FILE_SYSTEM_VERSION;<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    s.writeUTF(version);<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    s.close();<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    assertTrue(fs.exists(versionFile));<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    FileStatus [] status = fs.listStatus(versionFile);<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    assertNotNull(status);<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    assertTrue(status.length &gt; 0);<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    String newVersion = FSUtils.getVersion(fs, rootdir);<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    assertEquals(version.length(), newVersion.length());<a name="line.104"></a>
-<span class="sourceLineNo">105</span>    assertEquals(version, newVersion);<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    // File will have been converted. Exercise the pb format<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    assertEquals(version, FSUtils.getVersion(fs, rootdir));<a name="line.107"></a>
-<span class="sourceLineNo">108</span>    FSUtils.checkVersion(fs, rootdir, true);<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  }<a name="line.109"></a>
-<span class="sourceLineNo">110</span><a name="line.110"></a>
-<span class="sourceLineNo">111</span>  @Test public void testIsHDFS() throws Exception {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    assertFalse(FSUtils.isHDFS(htu.getConfiguration()));<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    MiniDFSCluster cluster = null;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    try {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>      cluster = htu.startMiniDFSCluster(1);<a name="line.116"></a>
-<span class="sourceLineNo">117</span>      assertTrue(FSUtils.isHDFS(htu.getConfiguration()));<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    } finally {<a name="line.118"></a>
-<span class="sourceLineNo">119</span>      if (cluster != null) cluster.shutdown();<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    }<a name="line.120"></a>
-<span class="sourceLineNo">121</span>  }<a name="line.121"></a>
-<span class="sourceLineNo">122</span><a name="line.122"></a>
-<span class="sourceLineNo">123</span>  private void WriteDataToHDFS(FileSystem fs, Path file, int dataSize)<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    throws Exception {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    FSDataOutputStream out = fs.create(file);<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    byte [] data = new byte[dataSize];<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    out.write(data, 0, dataSize);<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    out.close();<a name="line.128"></a>
-<span class="sourceLineNo">129</span>  }<a name="line.129"></a>
-<span class="sourceLineNo">130</span><a name="line.130"></a>
-<span class="sourceLineNo">131</span>  @Test public void testcomputeHDFSBlocksDistribution() throws Exception {<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    final int DEFAULT_BLOCK_SIZE = 1024;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    htu.getConfiguration().setLong("dfs.blocksize", DEFAULT_BLOCK_SIZE);<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    MiniDFSCluster cluster = null;<a name="line.135"></a>
-<span class="sourceLineNo">136</span>    Path testFile = null;<a name="line.136"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>  private HBaseTestingUtility htu;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>  private FileSystem fs;<a name="line.62"></a>
+<span class="sourceLineNo">063</span>  private Configuration conf;<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>  @Before<a name="line.65"></a>
+<span class="sourceLineNo">066</span>  public void setUp() throws IOException {<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    htu = new HBaseTestingUtility();<a name="line.67"></a>
+<span class="sourceLineNo">068</span>    fs = htu.getTestFileSystem();<a name="line.68"></a>
+<span class="sourceLineNo">069</span>    conf = htu.getConfiguration();<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>   * Test path compare and prefix checking.<a name="line.73"></a>
+<span class="sourceLineNo">074</span>   * @throws IOException<a name="line.74"></a>
+<span class="sourceLineNo">075</span>   */<a name="line.75"></a>
+<span class="sourceLineNo">076</span>  @Test<a name="line.76"></a>
+<span class="sourceLineNo">077</span>  public void testMatchingTail() throws IOException {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    Path rootdir = htu.getDataTestDir();<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    assertTrue(rootdir.depth() &gt; 1);<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    Path partPath = new Path("a", "b");<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    Path fullPath = new Path(rootdir, partPath);<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    Path fullyQualifiedPath = fs.makeQualified(fullPath);<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    assertFalse(FSUtils.isMatchingTail(fullPath, partPath));<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    assertFalse(FSUtils.isMatchingTail(fullPath, partPath.toString()));<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    assertTrue(FSUtils.isStartingWithPath(rootdir, fullPath.toString()));<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    assertTrue(FSUtils.isStartingWithPath(fullyQualifiedPath, fullPath.toString()));<a name="line.86"></a>
+<span class="sourceLineNo">087</span>    assertFalse(FSUtils.isStartingWithPath(rootdir, partPath.toString()));<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    assertFalse(FSUtils.isMatchingTail(fullyQualifiedPath, partPath));<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    assertTrue(FSUtils.isMatchingTail(fullyQualifiedPath, fullPath));<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    assertTrue(FSUtils.isMatchingTail(fullyQualifiedPath, fullPath.toString()));<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    assertTrue(FSUtils.isMatchingTail(fullyQualifiedPath, fs.makeQualified(fullPath)));<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    assertTrue(FSUtils.isStartingWithPath(rootdir, fullyQualifiedPath.toString()));<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    assertFalse(FSUtils.isMatchingTail(fullPath, new Path("x")));<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    assertFalse(FSUtils.isMatchingTail(new Path("x"), fullPath));<a name="line.94"></a>
+<span class="sourceLineNo">095</span>  }<a name="line.95"></a>
+<span class="sourceLineNo">096</span><a name="line.96"></a>
+<span class="sourceLineNo">097</span>  @Test<a name="line.97"></a>
+<span class="sourceLineNo">098</span>  public void testVersion() throws DeserializationException, IOException {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>    final Path rootdir = htu.getDataTestDir();<a name="line.99"></a>
+<span class="sourceLineNo">100</span>    assertNull(FSUtils.getVersion(fs, rootdir));<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    // Write out old format version file.  See if we can read it in and convert.<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME);<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    FSDataOutputStream s = fs.create(versionFile);<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    final String version = HConstants.FILE_SYSTEM_VERSION;<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    s.writeUTF(version);<a name="line.105"></a>
+<span class="sourceLineNo">106</span>    s.close();<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    assertTrue(fs.exists(versionFile));<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    FileStatus [] status = fs.listStatus(versionFile);<a name="line.108"></a>
+<span class="sourceLineNo">109</span>    assertNotNull(status);<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    assertTrue(status.length &gt; 0);<a name="line.110"></a>
+<span class="sourceLineNo">111</span>    String newVersion = FSUtils.getVersion(fs, rootdir);<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    assertEquals(version.length(), newVersion.length());<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    assertEquals(version, newVersion);<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    // File will have been converted. Exercise the pb format<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    assertEquals(version, FSUtils.getVersion(fs, rootdir));<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    FSUtils.checkVersion(fs, rootdir, true);<a name="line.116"></a>
+<span class="sourceLineNo">117</span>  }<a name="line.117"></a>
+<span class="sourceLineNo">118</span><a name="line.118"></a>
+<span class="sourceLineNo">119</span>  @Test public void testIsHDFS() throws Exception {<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    assertFalse(FSUtils.isHDFS(conf));<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    MiniDFSCluster cluster = null;<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    try {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>      cluster = htu.startMiniDFSCluster(1);<a name="line.123"></a>
+<span class="sourceLineNo">124</span>      assertTrue(FSUtils.isHDFS(conf));<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    } finally {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      if (cluster != null) cluster.shutdown();<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><a name="line.129"></a>
+<span class="sourceLineNo">130</span>  private void WriteDataToHDFS(FileSystem fs, Path file, int dataSize)<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    throws Exception {<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    FSDataOutputStream out = fs.create(file);<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    byte [] data = new byte[dataSize];<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    out.write(data, 0, dataSize);<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    out.close();<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>    try {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      // set up a cluster with 3 nodes<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      String hosts[] = new String[] { "host1", "host2", "host3" };<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      cluster = htu.startMiniDFSCluster(hosts);<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      cluster.waitActive();<a name="line.142"></a>
-<span class="sourceLineNo">143</span>      FileSystem fs = cluster.getFileSystem();<a name="line.143"></a>
-<span class="sourceLineNo">144</span><a name="line.144"></a>
-<span class="sourceLineNo">145</span>      // create a file with two blocks<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      testFile = new Path("/test1.txt");<a name="line.146"></a>
-<span class="sourceLineNo">147</span>      WriteDataToHDFS(fs, testFile, 2*DEFAULT_BLOCK_SIZE);<a name="line.147"></a>
-<span class="sourceLineNo">148</span><a name="line.148"></a>
-<span class="sourceLineNo">149</span>      // given the default replication factor is 3, the same as the number of<a name="line.149"></a>
-<span class="sourceLineNo">150</span>      // datanodes; the locality index for each host should be 100%,<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      // or getWeight for each host should be the same as getUniqueBlocksWeights<a name="line.151"></a>
-<span class="sourceLineNo">152</span>      final long maxTime = System.currentTimeMillis() + 2000;<a name="line.152"></a>
-<span class="sourceLineNo">153</span>      boolean ok;<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      do {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>        ok = true;<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        FileStatus status = fs.getFileStatus(testFile);<a name="line.156"></a>
-<span class="sourceLineNo">157</span>        HDFSBlocksDistribution blocksDistribution =<a name="line.157"></a>
-<span class="sourceLineNo">158</span>          FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());<a name="line.158"></a>
-<span class="sourceLineNo">159</span>        long uniqueBlocksTotalWeight =<a name="line.159"></a>
-<span class="sourceLineNo">160</span>          blocksDistribution.getUniqueBlocksTotalWeight();<a name="line.160"></a>
-<span class="sourceLineNo">161</span>        for (String host : hosts) {<a name="line.161"></a>
-<span class="sourceLineNo">162</span>          long weight = blocksDistribution.getWeight(host);<a name="line.162"></a>
-<span class="sourceLineNo">163</span>          ok = (ok &amp;&amp; uniqueBlocksTotalWeight == weight);<a name="line.163"></a>
-<span class="sourceLineNo">164</span>        }<a name="line.164"></a>
-<span class="sourceLineNo">165</span>      } while (!ok &amp;&amp; System.currentTimeMillis() &lt; maxTime);<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      assertTrue(ok);<a name="line.166"></a>
-<span class="sourceLineNo">167</span>      } finally {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      htu.shutdownMiniDFSCluster();<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    }<a name="line.169"></a>
-<span class="sourceLineNo">170</span><a name="line.170"></a>
-<span class="sourceLineNo">171</span><a name="line.171"></a>
-<span class="sourceLineNo">172</span>    try {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>      // set up a cluster with 4 nodes<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      String hosts[] = new String[] { "host1", "host2", "host3", "host4" };<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      cluster = htu.startMiniDFSCluster(hosts);<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      cluster.waitActive();<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      FileSystem fs = cluster.getFileSystem();<a name="line.177"></a>
-<span class="sourceLineNo">178</span><a name="line.178"></a>
-<span class="sourceLineNo">179</span>      // create a file with three blocks<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      testFile = new Path("/test2.txt");<a name="line.180"></a>
-<span class="sourceLineNo">181</span>      WriteDataToHDFS(fs, testFile, 3*DEFAULT_BLOCK_SIZE);<a name="line.181"></a>
-<span class="sourceLineNo">182</span><a name="line.182"></a>
-<span class="sourceLineNo">183</span>      // given the default replication factor is 3, we will have total of 9<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      // replica of blocks; thus the host with the highest weight should have<a name="line.184"></a>
-<span class="sourceLineNo">185</span>      // weight == 3 * DEFAULT_BLOCK_SIZE<a name="line.185"></a>
-<span class="sourceLineNo">186</span>      final long maxTime = System.currentTimeMillis() + 2000;<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      long weight;<a name="line.187"></a>
-<span class="sourceLineNo">188</span>      long uniqueBlocksTotalWeight;<a name="line.188"></a>
-<span class="sourceLineNo">189</span>      do {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>        FileStatus status = fs.getFileStatus(testFile);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>        HDFSBlocksDistribution blocksDistribution =<a name="line.191"></a>
-<span class="sourceLineNo">192</span>          FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());<a name="line.192"></a>
-<span class="sourceLineNo">193</span>        uniqueBlocksTotalWeight = blocksDistribution.getUniqueBlocksTotalWeight();<a name="line.193"></a>
-<span class="sourceLineNo">194</span><a name="line.194"></a>
-<span class="sourceLineNo">195</span>        String tophost = blocksDistribution.getTopHosts().get(0);<a name="line.195"></a>
-<span class="sourceLineNo">196</span>        weight = blocksDistribution.getWeight(tophost);<a name="line.196"></a>
-<span class="sourceLineNo">197</span><a name="line.197"></a>
-<span class="sourceLineNo">198</span>        // NameNode is informed asynchronously, so we may have a delay. See HBASE-6175<a name="line.198"></a>
-<span class="sourceLineNo">199</span>      } while (uniqueBlocksTotalWeight != weight &amp;&amp; System.currentTimeMillis() &lt; maxTime);<a name="line.199"></a>
-<span class="sourceLineNo">200</span>      assertTrue(uniqueBlocksTotalWeight == weight);<a name="line.200"></a>
-<span class="sourceLineNo">201</span><a name="line.201"></a>
-<span class="sourceLineNo">202</span>    } finally {<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      htu.shutdownMiniDFSCluster();<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
-<span class="sourceLineNo">205</span><a name="line.205"></a>
-<span class="sourceLineNo">206</span><a name="line.206"></a>
-<span class="sourceLineNo">207</span>    try {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      // set up a cluster with 4 nodes<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      String hosts[] = new String[] { "host1", "host2", "host3", "host4" };<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      cluster = htu.startMiniDFSCluster(hosts);<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      cluster.waitActive();<a name="line.211"></a>
-<span class="sourceLineNo">212</span>      FileSystem fs = cluster.getFileSystem();<a name="line.212"></a>
-<span class="sourceLineNo">213</span><a name="line.213"></a>
-<span class="sourceLineNo">214</span>      // create a file with one block<a name="line.214"></a>
-<span class="sourceLineNo">215</span>      testFile = new Path("/test3.txt");<a name="line.215"></a>
-<span class="sourceLineNo">216</span>      WriteDataToHDFS(fs, testFile, DEFAULT_BLOCK_SIZE);<a name="line.216"></a>
-<span class="sourceLineNo">217</span><a name="line.217"></a>
-<span class="sourceLineNo">218</span>      // given the default replication factor is 3, we will have total of 3<a name="line.218"></a>
-<span class="sourceLineNo">219</span>      // replica of blocks; thus there is one host without weight<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      final long maxTime = System.currentTimeMillis() + 2000;<a name="line.220"></a>
-<span class="sourceLineNo">221</span>      HDFSBlocksDistribution blocksDistribution;<a name="line.221"></a>
-<span class="sourceLineNo">222</span>      do {<a name="line.222"></a>
-<span class="sourceLineNo">223</span>        FileStatus status = fs.getFileStatus(testFile);<a name="line.223"></a>
-<span class="sourceLineNo">224</span>        blocksDistribution = FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());<a name="line.224"></a>
-<span class="sourceLineNo">225</span>        // NameNode is informed asynchronously, so we may have a delay. See HBASE-6175<a name="line.225"></a>
-<span class="sourceLineNo">226</span>      }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>      while (blocksDistribution.getTopHosts().size() != 3 &amp;&amp; System.currentTimeMillis() &lt; maxTime);<a name="line.227"></a>
-<span class="sourceLineNo">228</span>      assertEquals("Wrong number of hosts distributing blocks.", 3,<a name="line.228"></a>
-<span class="sourceLineNo">229</span>        blocksDistribution.getTopHosts().size());<a name="line.229"></a>
-<span class="sourceLineNo">230</span>    } finally {<a name="line.230"></a>
-<span class="sourceLineNo">231</span>      htu.shutdownMiniDFSCluster();<a name="line.231"></a>
-<span class="sourceLineNo">232</span>    }<a name="line.232"></a>
-<span class="sourceLineNo">233</span>  }<a name="line.233"></a>
-<span class="sourceLineNo">234</span><a name="line.234"></a>
-<span class="sourceLineNo">235</span>  @Test<a name="line.235"></a>
-<span class="sourceLineNo">236</span>  public void testPermMask() throws Exception {<a name="line.236"></a>
-<span class="sourceLineNo">237</span><a name="line.237"></a>
-<span class="sourceLineNo">238</span>    Configuration conf = HBaseConfiguration.create();<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    FileSystem fs = FileSystem.get(conf);<a name="line.239"></a>
+<span class="sourceLineNo">138</span>  @Test public void testcomputeHDFSBlocksDistribution() throws Exception {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    final int DEFAULT_BLOCK_SIZE = 1024;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>    conf.setLong("dfs.blocksize", DEFAULT_BLOCK_SIZE);<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    MiniDFSCluster cluster = null;<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    Path testFile = null;<a name="line.142"></a>
+<span class="sourceLineNo">143</span><a name="line.143"></a>
+<span class="sourceLineNo">144</span>    try {<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      // set up a cluster with 3 nodes<a name="line.145"></a>
+<span class="sourceLineNo">146</span>      String hosts[] = new String[] { "host1", "host2", "host3" };<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      cluster = htu.startMiniDFSCluster(hosts);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      cluster.waitActive();<a name="line.148"></a>
+<span class="sourceLineNo">149</span>      FileSystem fs = cluster.getFileSystem();<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>      // create a file with two blocks<a name="line.151"></a>
+<span class="sourceLineNo">152</span>      testFile = new Path("/test1.txt");<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      WriteDataToHDFS(fs, testFile, 2*DEFAULT_BLOCK_SIZE);<a name="line.153"></a>
+<span class="sourceLineNo">154</span><a name="line.154"></a>
+<span class="sourceLineNo">155</span>      // given the default replication factor is 3, the same as the number of<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      // datanodes; the locality index for each host should be 100%,<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      // or getWeight for each host should be the same as getUniqueBlocksWeights<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      final long maxTime = System.currentTimeMillis() + 2000;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>      boolean ok;<a name="line.159"></a>
+<span class="sourceLineNo">160</span>      do {<a name="line.160"></a>
+<span class="sourceLineNo">161</span>        ok = true;<a name="line.161"></a>
+<span class="sourceLineNo">162</span>        FileStatus status = fs.getFileStatus(testFile);<a name="line.162"></a>
+<span class="sourceLineNo">163</span>        HDFSBlocksDistribution blocksDistribution =<a name="line.163"></a>
+<span class="sourceLineNo">164</span>          FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());<a name="line.164"></a>
+<span class="sourceLineNo">165</span>        long uniqueBlocksTotalWeight =<a name="line.165"></a>
+<span class="sourceLineNo">166</span>          blocksDistribution.getUniqueBlocksTotalWeight();<a name="line.166"></a>
+<span class="sourceLineNo">167</span>        for (String host : hosts) {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>          long weight = blocksDistribution.getWeight(host);<a name="line.168"></a>
+<span class="sourceLineNo">169</span>          ok = (ok &amp;&amp; uniqueBlocksTotalWeight == weight);<a name="line.169"></a>
+<span class="sourceLineNo">170</span>        }<a name="line.170"></a>
+<span class="sourceLineNo">171</span>      } while (!ok &amp;&amp; System.currentTimeMillis() &lt; maxTime);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      assertTrue(ok);<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      } finally {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      htu.shutdownMiniDFSCluster();<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>    try {<a name="line.178"></a>
+<span class="sourceLineNo">179</span>      // set up a cluster with 4 nodes<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      String hosts[] = new String[] { "host1", "host2", "host3", "host4" };<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      cluster = htu.startMiniDFSCluster(hosts);<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      cluster.waitActive();<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      FileSystem fs = cluster.getFileSystem();<a name="line.183"></a>
+<span class="sourceLineNo">184</span><a name="line.184"></a>
+<span class="sourceLineNo">185</span>      // create a file with three blocks<a name="line.185"></a>
+<span class="sourceLineNo">186</span>      testFile = new Path("/test2.txt");<a name="line.186"></a>
+<span class="sourceLineNo">187</span>      WriteDataToHDFS(fs, testFile, 3*DEFAULT_BLOCK_SIZE);<a name="line.187"></a>
+<span class="sourceLineNo">188</span><a name="line.188"></a>
+<span class="sourceLineNo">189</span>      // given the default replication factor is 3, we will have total of 9<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      // replica of blocks; thus the host with the highest weight should have<a name="line.190"></a>
+<span class="sourceLineNo">191</span>      // weight == 3 * DEFAULT_BLOCK_SIZE<a name="line.191"></a>
+<span class="sourceLineNo">192</span>      final long maxTime = System.currentTimeMillis() + 2000;<a name="line.192"></a>
+<span class="sourceLineNo">193</span>      long weight;<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      long uniqueBlocksTotalWeight;<a name="line.194"></a>
+<span class="sourceLineNo">195</span>      do {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>        FileStatus status = fs.getFileStatus(testFile);<a name="line.196"></a>
+<span class="sourceLineNo">197</span>        HDFSBlocksDistribution blocksDistribution =<a name="line.197"></a>
+<span class="sourceLineNo">198</span>          FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());<a name="line.198"></a>
+<span class="sourceLineNo">199</span>        uniqueBlocksTotalWeight = blocksDistribution.getUniqueBlocksTotalWeight();<a name="line.199"></a>
+<span class="sourceLineNo">200</span><a name="line.200"></a>
+<span class="sourceLineNo">201</span>        String tophost = blocksDistribution.getTopHosts().get(0);<a name="line.201"></a>
+<span class="sourceLineNo">202</span>        weight = blocksDistribution.getWeight(tophost);<a name="line.202"></a>
+<span class="sourceLineNo">203</span><a name="line.203"></a>
+<span class="sourceLineNo">204</span>        // NameNode is informed asynchronously, so we may have a delay. See HBASE-6175<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      } while (uniqueBlocksTotalWeight != weight &amp;&amp; System.currentTimeMillis() &lt; maxTime);<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      assertTrue(uniqueBlocksTotalWeight == weight);<a name="line.206"></a>
+<span class="sourceLineNo">207</span><a name="line.207"></a>
+<span class="sourceLineNo">208</span>    } finally {<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      htu.shutdownMiniDFSCluster();<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
+<span class="sourceLineNo">211</span><a name="line.211"></a>
+<span class="sourceLineNo">212</span><a name="line.212"></a>
+<span class="sourceLineNo">213</span>    try {<a name="line.213"></a>
+<span class="sourceLineNo">214</span>      // set up a cluster with 4 nodes<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      String hosts[] = new String[] { "host1", "host2", "host3", "host4" };<a name="line.215"></a>
+<span class="sourceLineNo">216</span>      cluster = htu.startMiniDFSCluster(hosts);<a name="line.216"></a>
+<span class="sourceLineNo">217</span>      cluster.waitActive();<a name="line.217"></a>
+<span class="sourceLineNo">218</span>      FileSystem fs = cluster.getFileSystem();<a name="line.218"></a>
+<span class="sourceLineNo">219</span><a name="line.219"></a>
+<span class="sourceLineNo">220</span>      // create a file with one block<a name="line.220"></a>
+<span class="sourceLineNo">221</span>      testFile = new Path("/test3.txt");<a name="line.221"></a>
+<span class="sourceLineNo">222</span>      WriteDataToHDFS(fs, testFile, DEFAULT_BLOCK_SIZE);<a name="line.222"></a>
+<span class="sourceLineNo">223</span><a name="line.223"></a>
+<span class="sourceLineNo">224</span>      // given the default replication factor is 3, we will have total of 3<a name="line.224"></a>
+<span class="sourceLineNo">225</span>      // replica of blocks; thus there is one host without weight<a name="line.225"></a>
+<span class="sourceLineNo">226</span>      final long maxTime = System.currentTimeMillis() + 2000;<a name="line.226"></a>
+<span class="sourceLineNo">227</span>      HDFSBlocksDistribution blocksDistribution;<a name="line.227"></a>
+<span class="sourceLineNo">228</span>      do {<a name="line.228"></a>
+<span class="sourceLineNo">229</span>        FileStatus status = fs.getFileStatus(testFile);<a name="line.229"></a>
+<span class="sourceLineNo">230</span>        blocksDistribution = FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());<a name="line.230"></a>
+<span class="sourceLineNo">231</span>        // NameNode is informed asynchronously, so we may have a delay. See HBASE-6175<a name="line.231"></a>
+<span class="sourceLineNo">232</span>      }<a name="line.232"></a>
+<span class="sourceLineNo">233</span>      while (blocksDistribution.getTopHosts().size() != 3 &amp;&amp; System.currentTimeMillis() &lt; maxTime);<a name="line.233"></a>
+<span class="sourceLineNo">234</span>      assertEquals("Wrong number of hosts distributing blocks.", 3,<a name="line.234"></a>
+<span class="sourceLineNo">235</span>        blocksDistribution.getTopHosts().size());<a name="line.235"></a>
+<span class="sourceLineNo">236</span>    } finally {<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      htu.shutdownMiniDFSCluster();<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    }<a name="line.238"></a>
+<span class="sourceLineNo">239</span>  }<a name="line.239"></a>
 <span class="sourceLineNo">240</span><a name="line.240"></a>
-<span class="sourceLineNo">241</span>    // default fs permission<a name="line.241"></a>
-<span class="sourceLineNo">242</span>    FsPermission defaultFsPerm = FSUtils.getFilePermissions(fs, conf,<a name="line.242"></a>
-<span class="sourceLineNo">243</span>        HConstants.DATA_FILE_UMASK_KEY);<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    // 'hbase.data.umask.enable' is false. We will get default fs permission.<a name="line.244"></a>
-<span class="sourceLineNo">245</span>    assertEquals(FsPermission.getFileDefault(), defaultFsPerm);<a name="line.245"></a>
-<span class="sourceLineNo">246</span><a name="line.246"></a>
-<span class="sourceLineNo">247</span>    conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);<a name="line.247"></a>
-<span class="sourceLineNo">248</span>    // first check that we don't crash if we don't have perms set<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    FsPermission defaultStartPerm = FSUtils.getFilePermissions(fs, conf,<a name="line.249"></a>
-<span class="sourceLineNo">250</span>        HConstants.DATA_FILE_UMASK_KEY);<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    // default 'hbase.data.umask'is 000, and this umask will be used when<a name="line.251"></a>
-<span class="sourceLineNo">252</span>    // 'hbase.data.umask.enable' is true.<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    // Therefore we will not get the real fs default in this case.<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    // Instead we will get the starting point FULL_RWX_PERMISSIONS<a name="line.254"></a>
-<span class="sourceLineNo">255</span>    assertEquals(new FsPermission(FSUtils.FULL_RWX_PERMISSIONS), defaultStartPerm);<a name="line.255"></a>
-<span class="sourceLineNo">256</span><a name="line.256"></a>
-<span class="sourceLineNo">257</span>    conf.setStrings(HConstants.DATA_FILE_UMASK_KEY, "077");<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    // now check that we get the right perms<a name="line.258"></a>
-<span class="sourceLineNo">259</span>    FsPermission filePerm = FSUtils.getFilePermissions(fs, conf,<a name="line.259"></a>
-<span class="sourceLineNo">260</span>        HConstants.DATA_FILE_UMASK_KEY);<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    assertEquals(new FsPermission("700"), filePerm);<a name="line.261"></a>
-<span class="sourceLineNo">262</span><a name="line.262"></a>
-<span class="sourceLineNo">263</span>    // then that the correct file is created<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    Path p = new Path("target" + File.separator + UUID.randomUUID().toString());<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    try {<a name="line.265"></a>
-<span class="sourceLineNo">266</span>      FSDataOutputStream out = FSUtils.create(conf, fs, p, filePerm, null);<a name="line.266"></a>
-<span class="sourceLineNo">267</span>      out.close();<a name="line.267"></a>
-<span class="sourceLineNo">268</span>      FileStatus stat = fs.getFileStatus(p);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>      assertEquals(new FsPermission("700"), stat.getPermission());<a name="line.269"></a>
-<span class="sourceLineNo">270</span>      // and then cleanup<a name="line.270"></a>
-<span class="sourceLineNo">271</span>    } finally {<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      fs.delete(p, true);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    }<a name="line.273"></a>
-<span class="sourceLineNo">274</span>  }<a name="line.274"></a>
-<span class="sourceLineNo">275</span><a name="line.275"></a>
-<span class="sourceLineNo">276</span>  @Test<a name="line.276"></a>
-<span class="sourceLineNo">277</span>  public void testDeleteAndExists() throws Exception {<a name="line.277"></a>
-<span class="sourceLineNo">278</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.278"></a>
-<span class="sourceLineNo">279</span>    Configuration conf = htu.getConfiguration();<a name="line.279"></a>
+<span class="sourceLineNo">241</span>  @Test<a name="line.241"></a>
+<span class="sourceLineNo">242</span>  public void testPermMask() throws Exception {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>    // default fs permission<a name="line.243"></a>
+<span class="sourceLineNo">244</span>    FsPermission defaultFsPerm = FSUtils.getFilePermissions(fs, conf,<a name="line.244"></a>
+<span class="sourceLineNo">245</span>        HConstants.DATA_FILE_UMASK_KEY);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    // 'hbase.data.umask.enable' is false. We will get default fs permission.<a name="line.246"></a>
+<span class="sourceLineNo">247</span>    assertEquals(FsPermission.getFileDefault(), defaultFsPerm);<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>    conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);<a name="line.249"></a>
+<span class="sourceLineNo">250</span>    // first check that we don't crash if we don't have perms set<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    FsPermission defaultStartPerm = FSUtils.getFilePermissions(fs, conf,<a name="line.251"></a>
+<span class="sourceLineNo">252</span>        HConstants.DATA_FILE_UMASK_KEY);<a name="line.252"></a>
+<span class="sourceLineNo">253</span>    // default 'hbase.data.umask'is 000, and this umask will be used when<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    // 'hbase.data.umask.enable' is true.<a name="line.254"></a>
+<span class="sourceLineNo">255</span>    // Therefore we will not get the real fs default in this case.<a name="line.255"></a>
+<span class="sourceLineNo">256</span>    // Instead we will get the starting point FULL_RWX_PERMISSIONS<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    assertEquals(new FsPermission(FSUtils.FULL_RWX_PERMISSIONS), defaultStartPerm);<a name="line.257"></a>
+<span class="sourceLineNo">258</span><a name="line.258"></a>
+<span class="sourceLineNo">259</span>    conf.setStrings(HConstants.DATA_FILE_UMASK_KEY, "077");<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    // now check that we get the right perms<a name="line.260"></a>
+<span class="sourceLineNo">261</span>    FsPermission filePerm = FSUtils.getFilePermissions(fs, conf,<a name="line.261"></a>
+<span class="sourceLineNo">262</span>        HConstants.DATA_FILE_UMASK_KEY);<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    assertEquals(new FsPermission("700"), filePerm);<a name="line.263"></a>
+<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">265</span>    // then that the correct file is created<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    Path p = new Path("target" + File.separator + UUID.randomUUID().toString());<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    try {<a name="line.267"></a>
+<span class="sourceLineNo">268</span>      FSDataOutputStream out = FSUtils.create(conf, fs, p, filePerm, null);<a name="line.268"></a>
+<span class="sourceLineNo">269</span>      out.close();<a name="line.269"></a>
+<span class="sourceLineNo">270</span>      FileStatus stat = fs.getFileStatus(p);<a name="line.270"></a>
+<span class="sourceLineNo">271</span>      assertEquals(new FsPermission("700"), stat.getPermission());<a name="line.271"></a>
+<span class="sourceLineNo">272</span>      // and then cleanup<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    } finally {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>      fs.delete(p, true);<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    }<a name="line.275"></a>
+<span class="sourceLineNo">276</span>  }<a name="line.276"></a>
+<span class="sourceLineNo">277</span><a name="line.277"></a>
+<span class="sourceLineNo">278</span>  @Test<a name="line.278"></a>
+<span class="sourceLineNo">279</span>  public void testDeleteAndExists() throws Exception {<a name="line.279"></a>
 <span class="sourceLineNo">280</span>    conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);<a name="line.280"></a>
-<span class="sourceLineNo">281</span>    FileSystem fs = FileSystem.get(conf);<a name="line.281"></a>
-<span class="sourceLineNo">282</span>    FsPermission perms = FSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    // then that the correct file is created<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    String file = UUID.randomUUID().toString();<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    Path p = new Path(htu.getDataTestDir(), "temptarget" + File.separator + file);<a name="line.285"></a>
-<span class="sourceLineNo">286</span>    Path p1 = new Path(htu.getDataTestDir(), "temppath" + File.separator + file);<a name="line.286"></a>
-<span class="sourceLineNo">287</span>    try {<a name="line.287"></a>
-<span class="sourceLineNo">288</span>      FSDataOutputStream out = FSUtils.create(conf, fs, p, perms, null);<a name="line.288"></a>
-<span class="sourceLineNo">289</span>      out.close();<a name="line.289"></a>
-<span class="sourceLineNo">290</span>      assertTrue("The created file should be present", FSUtils.isExists(fs, p));<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      // delete the file with recursion as false. Only the file will be deleted.<a name="line.291"></a>
-<span class="sourceLineNo">292</span>      FSUtils.delete(fs, p, false);<a name="line.292"></a>
-<span class="sourceLineNo">293</span>      // Create another file<a name="line.293"></a>
-<span class="sourceLineNo">294</span>      FSDataOutputStream out1 = FSUtils.create(conf, fs, p1, perms, null);<a name="line.294"></a>
-<span class="sourceLineNo">295</span>      out1.close();<a name="line.295"></a>
-<span class="sourceLineNo">296</span>      // delete the file with recursion as false. Still the file only will be deleted<a name="line.296"></a>
-<span class="sourceLineNo">297</span>      FSUtils.delete(fs, p1, true);<a name="line.297"></a>
-<span class="sourceLineNo">298</span>      assertFalse("The created file should be present", FSUtils.isExists(fs, p1));<a name="line.298"></a>
-<span class="sourceLineNo">299</span>      // and then cleanup<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    } finally {<a name="line.300"></a>
-<span class="sourceLineNo">301</span>      FSUtils.delete(fs, p, true);<a name="line.301"></a>
-<span class="sourceLineNo">302</span>      FSUtils.delete(fs, p1, true);<a name="line.302"></a>
-<span class="sourceLineNo">303</span>    }<a name="line.303"></a>
-<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
-<span class="sourceLineNo">305</span><a name="line.305"></a>
-<span class="sourceLineNo">306</span>  @Test<a name="line.306"></a>
-<span class="sourceLineNo">307</span>  public void testRenameAndSetModifyTime() throws Exception {<a name="line.307"></a>
-<span class="sourceLineNo">308</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.308"></a>
-<span class="sourceLineNo">309</span>    Configuration conf = htu.getConfiguration();<a name="line.309"></a>
-<span class="sourceLineNo">310</span><a name="line.310"></a>
-<span class="sourceLineNo">311</span>    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);<a name="line.311"></a>
-<span class="sourceLineNo">312</span>    assertTrue(FSUtils.isHDFS(conf));<a name="line.312"></a>
-<span class="sourceLineNo">313</span><a name="line.313"></a>
-<span class="sourceLineNo">314</span>    FileSystem fs = FileSystem.get(conf);<a name="line.314"></a>
-<span class="sourceLineNo">315</span>    Path testDir = htu.getDataTestDirOnTestFS("testArchiveFile");<a name="line.315"></a>
-<span class="sourceLineNo">316</span><a name="line.316"></a>
-<span class="sourceLineNo">317</span>    String file = UUID.randomUUID().toString();<a name="line.317"></a>
-<span class="sourceLineNo">318</span>    Path p = new Path(testDir, file);<a name="line.318"></a>
+<span class="sourceLineNo">281</span>    FsPermission perms = FSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>    // then that the correct file is created<a name="line.282"></a>
+<span class="sourceLineNo">283</span>    String file = UUID.randomUUID().toString();<a name="line.283"></a>
+<span class="sourceLineNo">284</span>    Path p = new Path(htu.getDataTestDir(), "temptarget" + File.separator + file);<a name="line.284"></a>
+<span class="sourceLineNo">285</span>    Path p1 = new Path(htu.getDataTestDir(), "temppath" + File.separator + file);<a name="line.285"></a>
+<span class="sourceLineNo">286</span>    try {<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      FSDataOutputStream out = FSUtils.create(conf, fs, p, perms, null);<a name="line.287"></a>
+<span class="sourceLineNo">288</span>      out.close();<a name="line.288"></a>
+<span class="sourceLineNo">289</span>      assertTrue("The created file should be present", FSUtils.isExists(fs, p));<a name="line.289"></a>
+<span class="sourceLineNo">290</span>      // delete the file with recursion as false. Only the file will be deleted.<a name="line.290"></a>
+<span class="sourceLineNo">291</span>      FSUtils.delete(fs, p, false);<a name="line.291"></a>
+<span class="sourceLineNo">292</span>      // Create another file<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      FSDataOutputStream out1 = FSUtils.create(conf, fs, p1, perms, null);<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      out1.close();<a name="line.294"></a>
+<span class="sourceLineNo">295</span>      // delete the file with recursion as false. Still the file only will be deleted<a name="line.295"></a>
+<span class="sourceLineNo">296</span>      FSUtils.delete(fs, p1, true);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      assertFalse("The created file should be present", FSUtils.isExists(fs, p1));<a name="line.297"></a>
+<span class="sourceLineNo">298</span>      // and then cleanup<a name="line.298"></a>
+<span class="sourceLineNo">299</span>    } finally {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>      FSUtils.delete(fs, p, true);<a name="line.300"></a>
+<span class="sourceLineNo">301</span>      FSUtils.delete(fs, p1, true);<a name="line.301"></a>
+<span class="sourceLineNo">302</span>    }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>  }<a name="line.303"></a>
+<span class="sourceLineNo">304</span><a name="line.304"></a>
+<span class="sourceLineNo">305</span>  @Test<a name="line.305"></a>
+<span class="sourceLineNo">306</span>  public void testRenameAndSetModifyTime() throws Exception {<a name="line.306"></a>
+<span class="sourceLineNo">307</span>    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    assertTrue(FSUtils.isHDFS(conf));<a name="line.308"></a>
+<span class="sourceLineNo">309</span><a name="line.309"></a>
+<span class="sourceLineNo">310</span>    FileSystem fs = FileSystem.get(conf);<a name="line.310"></a>
+<span class="sourceLineNo">311</span>    Path testDir = htu.getDataTestDirOnTestFS("testArchiveFile");<a name="line.311"></a>
+<span class="sourceLineNo">312</span><a name="line.312"></a>
+<span class="sourceLineNo">313</span>    String file = UUID.randomUUID().toString();<a name="line.313"></a>
+<span class="sourceLineNo">314</span>    Path p = new Path(testDir, file);<a name="line.314"></a>
+<span class="sourceLineNo">315</span><a name="line.315"></a>
+<span class="sourceLineNo">316</span>    FSDataOutputStream out = fs.create(p);<a name="line.316"></a>
+<span class="sourceLineNo">317</span>    out.close();<a name="line.317"></a>
+<span class="sourceLineNo">318</span>    assertTrue("The created file should be present", FSUtils.isExists(fs, p));<a name="line.318"></a>
 <span class="sourceLineNo">319</span><a name="line.319"></a>
-<span class="sourceLineNo">320</span>    FSDataOutputStream out = fs.create(p);<a name="line.320"></a>
-<span class="sourceLineNo">321</span>    out.close();<a name="line.321"></a>
-<span class="sourceLineNo">322</span>    assertTrue("The created file should be present", FSUtils.isExists(fs, p));<a name="line.322"></a>
-<span class="sourceLineNo">323</span><a name="line.323"></a>
-<span class="sourceLineNo">324</span>    long expect = System.currentTimeMillis() + 1000;<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    assertNotEquals(expect, fs.getFileStatus(p).getModificationTime());<a name="line.325"></a>
-<span class="sourceLineNo">326</span><a name="line.326"></a>
-<span class="sourceLineNo">327</span>    ManualEnvironmentEdge mockEnv = new ManualEnvironmentEdge();<a name="line.327"></a>
-<span class="sourceLineNo">328</span>    mockEnv.setValue(expect);<a name="line.328"></a>
-<span class="sourceLineNo">329</span>    EnvironmentEdgeManager.injectEdge(mockEnv);<a name="line.329"></a>
-<span class="sourceLineNo">330</span>    try {<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      String dstFile = UUID.randomUUID().toString();<a name="line.331"></a>
-<span class="sourceLineNo">332</span>      Path dst = new Path(testDir , dstFile);<a name="line.332"></a>
+<span class="sourceLineNo">320</span>    long expect = System.currentTimeMillis() + 1000;<a name="line.320"></a>
+<span class="sourceLineNo">321</span>    assertNotEquals(expect, fs.getFileStatus(p).getModificationTime());<a name="line.321"></a>
+<span class="sourceLineNo">322</span><a name="line.322"></a>
+<span class="sourceLineNo">323</span>    ManualEnvironmentEdge mockEnv = new ManualEnvironmentEdge();<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    mockEnv.setValue(expect);<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    EnvironmentEdgeManager.injectEdge(mockEnv);<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    try {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>      String dstFile = UUID.randomUUID().toString();<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      Path dst = new Path(testDir , dstFile);<a name="line.328"></a>
+<span class="sourceLineNo">329</span><a name="line.329"></a>
+<span class="sourceLineNo">330</span>      assertTrue(FSUtils.renameAndSetModifyTime(fs, p, dst));<a name="line.330"></a>
+<span class="sourceLineNo">331</span>      assertFalse("The moved file should not be present", FSUtils.isExists(fs, p));<a name="line.331"></a>
+<span class="sourceLineNo">332</span>      assertTrue("The dst file should be present", FSUtils.isExists(fs, dst));<a name="line.332"></a>
 <span class="sourceLineNo">333</span><a name="line.333"></a>
-<span class="sourceLineNo">334</span>      assertTrue(FSUtils.renameAndSetModifyTime(fs, p, dst));<a name="line.334"></a>
-<span class="sourceLineNo">335</span>      assertFalse("The moved file should not be present", FSUtils.isExists(fs, p));<a name="line.335"></a>
-<span class="sourceLineNo">336</span>      assertTrue("The dst file should be present", FSUtils.isExists(fs, dst));<a name="line.336"></a>
-<span class="sourceLineNo">337</span><a name="line.337"></a>
-<span class="sourceLineNo">338</span>      assertEquals(expect, fs.getFileStatus(dst).getModificationTime());<a name="line.338"></a>
-<span class="sourceLineNo">339</span>      cluster.shutdown();<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    } finally {<a name="line.340"></a>
-<span class="sourceLineNo">341</span>      EnvironmentEdgeManager.reset();<a name="line.341"></a>
-<span class="sourceLineNo">342</span>    }<a name="line.342"></a>
-<span class="sourceLineNo">343</span>  }<a name="line.343"></a>
-<span class="sourceLineNo">344</span><a name="line.344"></a>
-<span class="sourceLineNo">345</span>  private void verifyFileInDirWithStoragePolicy(final String policy) throws Exception {<a name="line.345"></a>
-<span class="sourceLineNo">346</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.346"></a>
-<span class="sourceLineNo">347</span>    Configuration conf = htu.getConfiguration();<a name="line.347"></a>
-<span class="sourceLineNo">348</span>    conf.set(HConstants.WAL_STORAGE_POLICY, policy);<a name="line.348"></a>
-<span class="sourceLineNo">349</span><a name="line.349"></a>
-<span class="sourceLineNo">350</span>    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);<a name="line.350"></a>
-<span class="sourceLineNo">351</span>    try {<a name="line.351"></a>
-<span class="sourceLineNo">352</span>      assertTrue(FSUtils.isHDFS(conf));<a name="line.352"></a>
-<span class="sourceLineNo">353</span><a name="line.353"></a>
-<span class="sourceLineNo">354</span>      FileSystem fs = FileSystem.get(conf);<a name="line.354"></a>
-<span class="sourceLineNo">355</span>      Path testDir = htu.getDataTestDirOnTestFS("testArchiveFile");<a name="line.355"></a>
-<span class="sourceLineNo">356</span>      fs.mkdirs(testDir);<a name="line.356"></a>
-<span class="sourceLineNo">357</span><a name="line.357"></a>
-<span class="sourceLineNo">358</span>      FSUtils.setStoragePolicy(fs, conf, testDir, HConstants.WAL_STORAGE_POLICY,<a name="line.358"></a>
-<span class="sourceLineNo">359</span>          HConstants.DEFAULT_WAL_STORAGE_POLICY);<a name="line.359"></a>
-<span class="sourceLineNo">360</span><a name="line.360"></a>
-<span class="sourceLineNo">361</span>      String file = UUID.randomUUID().toString();<a name="line.361"></a>
-<span class="sourceLineNo">362</span>      Path p = new Path(testDir, file);<a name="line.362"></a>
-<span class="sourceLineNo">363</span>      WriteDataToHDFS(fs, p, 4096);<a name="line.363"></a>
-<span class="sourceLineNo">364</span>      // will assert existance before deleting.<a name="line.364"></a>
-<span class="sourceLineNo">365</span>      cleanupFile(fs, testDir);<a name="line.365"></a>
-<span class="sourceLineNo">366</span>    } finally {<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      cluster.shutdown();<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">334</span>      assertEquals(expect, fs.getFileStatus(dst).getModificationTime());<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      cluster.shutdown();<a name="line.335"></a>
+<span class="sourceLineNo">336</span>    } finally {<a name="line.336"></a>
+<span class="sourceLineNo">337</span>      EnvironmentEdgeManager.reset();<a name="line.337"></a>
+<span class="sourceLineNo">338</span>    }<a name="line.338"></a>
+<span class="sourceLineNo">339</span>  }<a name="line.339"></a>
+<span class="sourceLineNo">340</span><a name="line.340"></a>
+<span class="sourceLineNo">341</span>  private void verifyFileInDirWithStoragePolicy(final String policy) throws Exception {<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    conf.set(HConstants.WAL_STORAGE_POLICY, policy);<a name="line.342"></a>
+<span class="sourceLineNo">343</span><a name="line.343"></a>
+<span class="sourceLineNo">344</span>    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    try {<a name="line.345"></a>
+<span class="sourceLineNo">346</span>      assertTrue(FSUtils.isHDFS(conf));<a name="line.346"></a>
+<span class="sourceLineNo">347</span><a name="line.347"></a>
+<span class="sourceLineNo">348</span>      FileSystem fs = FileSystem.get(conf);<a name="line.348"></a>
+<span class="sourceLineNo">349</span>      Path testDir = htu.getDataTestDirOnTestFS("testArchiveFile");<a name="line.349"></a>
+<span class="sourceLineNo">350</span>      fs.mkdirs(testDir);<a name="line.350"></a>
+<span class="sourceLineNo">351</span><a name="line.351"></a>
+<span class="sourceLineNo">352</span>      FSUtils.setStoragePolicy(fs, conf, testDir, HConstants.WAL_STORAGE_POLICY,<a name="line.352"></a>
+<span class="sourceLineNo">353</span>          HConstants.DEFAULT_WAL_STORAGE_POLICY);<a name="line.353"></a>
+<span class="sourceLineNo">354</span><a name="line.354"></a>
+<span class="sourceLineNo">355</span>      String file = UUID.randomUUID().toString();<a name="line.355"></a>
+<span class="sourceLineNo">356</span>      Path p = new Path(testDir, file);<a name="line.356"></a>
+<span class="sourceLineNo">357</span>      WriteDataToHDFS(fs, p, 4096);<a name="line.357"></a>
+<span class="sourceLineNo">358</span>      // will assert existance before deleting.<a name="line.358"></a>
+<span class="sourceLineNo">359</span>      cleanupFile(fs, testDir);<a name="line.359"></a>
+<span class="sourceLineNo">360</span>    } finally {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      cluster.shutdown();<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    }<a name="line.362"></a>
+<span class="sourceLineNo">363</span>  }<a name="line.363"></a>
+<span class="sourceLineNo">364</span><a name="line.364"></a>
+<span class="sourceLineNo">365</span>  @Test<a name="line.365"></a>
+<span class="sourceLineNo">366</span>  public void testSetStoragePolicyDefault() throws Exception {<a name="line.366"></a>
+<span class="sourceLineNo">367</span>    verifyFileInDirWithStoragePolicy(HConstants.DEFAULT_WAL_STORAGE_POLICY);<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>  /* might log a warning, but still work. (always warning on Hadoop &lt; 2.6.0) */<a name="line.370"></a>
 <span class="sourceLineNo">371</span>  @Test<a name="line.371"></a>
-<span class="sourceLineNo">372</span>  public void testSetStoragePolicyDefault() throws Exception {<a name="line.372"></a>
-<span class="sourceLineNo">373</span>    verifyFileInDirWithStoragePolicy(HConstants.DEFAULT_WAL_STORAGE_POLICY);<a name="line.373"></a>
+<span class="sourceLineNo">372</span>  public void testSetStoragePolicyValidButMaybeNotPresent() throws Exception {<a name="line.372"></a>
+<span class="sourceLineNo">373</span>    verifyFileInDirWithStoragePolicy("ALL_SSD");<a name="line.373"></a>
 <span class="sourceLineNo">374</span>  }<a name="line.374"></a>
 <span class="sourceLineNo">375</span><a name="line.375"></a>
-<span class="sourceLineNo">376</span>  /* might log a warning, but still work. (always warning on Hadoop &lt; 2.6.0) */<a name="line.376"></a>
+<span class="sourceLineNo">376</span>  /* should log a warning, but still work. (different warning on Hadoop &lt; 2.6.0) */<a name="line.376"></a>
 <span class="sourceLineNo">377</span>  @Test<a name="line.377"></a>
-<span class="sourceLineNo">378</span>  public void testSetStoragePolicyValidButMaybeNotPresent() throws Exception {<a name="line.378"></a>
-<span class="sourceLineNo">379</span>    verifyFileInDirWithStoragePolicy("ALL_SSD");<a name="line.379"></a>
+<span class="sourceLineNo">378</span>  public void testSetStoragePolicyInvalid() throws Exception {<a name="line.378"></a>
+<span class="sourceLineNo">379</span>    verifyFileInDirWithStoragePolicy("1772");<a name="line.379"></a>
 <span class="sourceLineNo">380</span>  }<a name="line.380"></a>
 <span class="sourceLineNo">381</span><a name="line.381"></a>
-<span class="sourceLineNo">382</span>  /* should log a warning, but still work. (different warning on Hadoop &lt; 2.6.0) */<a name="line.382"></a>
-<span class="sourceLineNo">383</span>  @Test<a name="line.383"></a>
-<span class="sourceLineNo">384</span>  public void testSetStoragePolicyInvalid() throws Exception {<a name="line.384"></a>
-<span class="sourceLineNo">385</span>    verifyFileInDirWithStoragePolicy("1772");<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>  @Test<a name="line.388"></a>
-<span class="sourceLineNo">389</span>  public void testSetWALRootDir() throws Exception {<a name="line.389"></a>
-<span class="sourceLineNo">390</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.390"></a>
-<span class="sourceLineNo">391</span>    Configuration conf = htu.getConfiguration();<a name="line.391"></a>
-<span class="sourceLineNo">392</span>    Path p = new Path("file:///hbase/root");<a name="line.392"></a>
-<span class="sourceLineNo">393</span>    FSUtils.setWALRootDir(conf, p);<a name="line.393"></a>
-<span class="sourceLineNo">394</span>    assertEquals(p.toString(), conf.get(HFileSystem.HBASE_WAL_DIR));<a name="line.394"></a>
-<span class="sourceLineNo">395</span>  }<a name="line.395"></a>
-<span class="sourceLineNo">396</span><a name="line.396"></a>
-<span class="sourceLineNo">397</span>  @Test<a name="line.397"></a>
-<span class="sourceLineNo">398</span>  public void testGetWALRootDir() throws IOException {<a name="line.398"></a>
-<span class="sourceLineNo">399</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.399"></a>
-<span class="sourceLineNo">400</span>    Configuration conf = htu.getConfiguration();<a name="line.400"></a>
-<span class="sourceLineNo">401</span>    Path root = new Path("file:///hbase/root");<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    Path walRoot = new Path("file:///hbase/logroot");<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    FSUtils.setRootDir(conf, root);<a name="line.403"></a>
-<span class="sourceLineNo">404</span>    assertEquals(FSUtils.getRootDir(conf), root);<a name="line.404"></a>
-<span class="sourceLineNo">405</span>    assertEquals(FSUtils.getWALRootDir(conf), root);<a name="line.405"></a>
-<span class="sourceLineNo">406</span>    FSUtils.setWALRootDir(conf, walRoot);<a name="line.406"></a>
-<span class="sourceLineNo">407</span>    assertEquals(FSUtils.getWALRootDir(conf), walRoot);<a name="line.407"></a>
-<span class="sourceLineNo">408</span>  }<a name="line.408"></a>
-<span class="sourceLineNo">409</span><a name="line.409"></a>
-<span class="sourceLineNo">410</span>  @Test(expected=IllegalStateException.class)<a name="line.410"></a>
-<span class="sourceLineNo">411</span>  public void testGetWALRootDirIllegalWALDir() throws IOException {<a name="line.411"></a>
-<span class="sourceLineNo">412</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.412"></a>
-<span class="sourceLineNo">413</span>    Configuration conf = htu.getConfiguration();<a name="line.413"></a>
-<span class="sourceLineNo">414</span>    Path root = new Path("file:///hbase/root");<a name="line.414"></a>
-<span class="sourceLineNo">415</span>    Path invalidWALDir = new Path("file:///hbase/root/logroot");<a name="line.415"></a>
-<span class="sourceLineNo">416</span>    FSUtils.setRootDir(conf, root);<a name="line.416"></a>
-<span class="sourceLineNo">417</span>    FSUtils.setWALRootDir(conf, invalidWALDir);<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    FSUtils.getWALRootDir(conf);<a name="line.418"></a>
-<span class="sourceLineNo">419</span>  }<a name="line.419"></a>
-<span class="sourceLineNo">420</span><a name="line.420"></a>
-<span class="sourceLineNo">421</span>  @Test<a name="line.421"></a>
-<span class="sourceLineNo">422</span>  public void testRemoveWALRootPath() throws Exception {<a name="line.422"></a>
-<span class="sourceLineNo">423</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    Configuration conf = htu.getConfiguration();<a name="line.424"></a>
-<span class="sourceLineNo">425</span>    FSUtils.setRootDir(conf, new Path("file:///user/hbase"));<a name="line.425"></a>
-<span class="sourceLineNo">426</span>    Path testFile = new Path(FSUtils.getRootDir(conf), "test/testfile");<a name="line.426"></a>
-<span class="sourceLineNo">427</span>    Path tmpFile = new Path("file:///test/testfile");<a name="line.427"></a>
-<span class="sourceLineNo">428</span>    assertEquals(FSUtils.removeWALRootPath(testFile, conf), "test/testfile");<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    assertEquals(FSUtils.removeWALRootPath(tmpFile, conf), tmpFile.toString());<a name="line.429"></a>
-<span class="sourceLineNo">430</span>    FSUtils.setWALRootDir(conf, new Path("file:///user/hbaseLogDir"));<a name="line.430"></a>
-<span class="sourceLineNo">431</span>    assertEquals(FSUtils.removeWALRootPath(testFile, conf), testFile.toString());<a name="line.431"></a>
-<span class="sourceLineNo">432</span>    Path logFile = new Path(FSUtils.getWALRootDir(conf), "test/testlog");<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    assertEquals(FSUtils.removeWALRootPath(logFile, conf), "test/testlog");<a name="line.433"></a>
-<span class="sourceLineNo">434</span>  }<a name="line.434"></a>
-<span class="sourceLineNo">435</span><a name="line.435"></a>
-<span class="sourceLineNo">436</span>  /**<a name="line.436"></a>
-<span class="sourceLineNo">437</span>   * Ugly test that ensures we can get at the hedged read counters in dfsclient.<a name="line.437"></a>
-<span class="sourceLineNo">438</span>   * Does a bit of preading with hedged reads enabled using code taken from hdfs TestPread.<a name="line.438"></a>
-<span class="sourceLineNo">439</span>   * @throws Exception<a name="line.439"></a>
-<span class="sourceLineNo">440</span>   */<a name="line.440"></a>
-<span class="sourceLineNo">441</span>  @Test public void testDFSHedgedReadMetrics() throws Exception {<a name="line.441"></a>
-<span class="sourceLineNo">442</span>    HBaseTestingUtility htu = new HBaseTestingUtility();<a name="line.442"></a>
-<span class="sourceLineNo">443</span>    // Enable hedged reads and set it so the threshold is really low.<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    // Most of this test is taken from HDFS, from TestPread.<a name="line.444"></a>
-<span class="sourceLineNo">445</span>    Configuration conf = htu.getConfiguration();<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    conf.setInt(DFSConfigKeys.DFS_DFSCLIENT_HEDGED_READ_THREADPOOL_SIZE, 5);<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    conf.setLong(DFSConfigKeys.DFS_DFSCLIENT_HEDGED_READ_THRESHOLD_MILLIS, 0);<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 4096);<a name="line.448"></a>
-<span class="sourceLineNo">449</span>    conf.setLong(DFSConfigKeys.DFS_CLIENT_READ_PREFETCH_SIZE_KEY, 4096);<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    // Set short retry timeouts so this test runs faster<a name="line.450"></a>
-<span class="sourceLineNo">451</span>    conf.setInt(DFSConfigKeys.DFS_CLIENT_RETRY_WINDOW_BASE, 0);<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    conf.setBoolean("dfs.datanode.transferTo.allowed", false);<a name="line.452"></a>
-<span class="sourceLineNo">453</span>    MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();<a name="line.453"></a>
-<span class="sourceLineNo">454</span>    // Get the metrics.  Should be empty.<a name="line.454"></a>
-<span class="sourceLineNo">455</span>    DFSHedgedReadMetrics metrics = FSUtils.getDFSHedgedReadMetrics(conf);<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    assertEquals(0, metrics.getHedgedReadOps());<a name="line.456"></a>
-<span class="sourceLineNo">457</span>    FileSystem fileSys = cluster.getFileSystem();<a name="line.457"></a>
-<span class="sourceLineNo">458</span>    try {<a name="line.458"></a>
-<span class="sourceLineNo">459</span>      Path p = new Path("preadtest.dat");<a name="line.459"></a>
-<span class="sourceLineNo">460</span>      // We need &gt; 1 blocks to test out the hedged reads.<a name="line.460"></a>
-<span class="sourceLineNo">461</span>      DFSTestUtil.createFile(fileSys, p, 12 * blockSize, 12 * blockSize,<a name="line.461"></a>
-<span class="sourceLineNo">462</span>        blockSize, (short) 3, seed);<a name="line.462"></a>
-<span class="sourceLineNo">463</span>      pReadFile(fileSys, p);<a name="line.463"></a>
-<span class="sourceLineNo">464</span>      cleanupFile(fileSys, p);<a name="line.464"></a>
-<span class="sourceLineNo">465</span>      assertTrue(metrics.getHedgedReadOps() &gt; 0);<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    } finally {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>      fileSys.close();<a name="line.467"></a>
-<span class="sourceLineNo">468</span>      cluster.shutdown();<a name="line.468"></a>
-<span class="sourceLineNo">469</span>    }<a name="line.469"></a>
-<span class="sourceLineNo">470</span>  }<a name="line.470"></a>
-<span class="sourceLineNo">471</span><a name="line.471"></a>
-<span class="sourceLineNo">472</span>  // Below is taken from TestPread over in HDFS.<a name="line.472"></a>
-<span class="sourceLineNo">473</span>  static final int blockSize = 4096;<a name="line.473"></a>
-<span class="sourceLineNo">474</span>  static final long seed = 0xDEADBEEFL;<a name="line.474"></a>
-<span class="sourceLineNo">475</span><a name="line.475"></a>
-<span class="sourceLineNo">476</span>  private void pReadFile(FileSystem fileSys, Path name) throws IOException {<a name="line.476"></a>
-<span class="sourceLineNo">477</span>    FSDataInputStream stm = fileSys.open(name);<a name="line.477"></a>
-<span class="sourceLineNo">478</span>    byte[] expected = new byte[12 * blockSize];<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    Random rand = new Random(seed);<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    rand.nextBytes(expected);<a name="line.480"></a>
-<span class="sourceLineNo">481</span>    // do a sanity check. Read first 4K bytes<a name="line.481"></a>
-<span class="sourceLineNo">482</span>    byte[] actual = new byte[4096];<a name="line.482"></a>
-<span class="sourceLineNo">483</span>    stm.readFully(actual);<a name="line.483"></a>
-<span class="sourceLineNo">484</span>    checkAndEraseData(actual, 0, expected, "Read Sanity Test");<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    // now do a pread for the first 8K bytes<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    actual = new byte[8192];<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    doPread(stm, 0L, actual, 0, 8192);<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    checkAndEraseData(actual, 0, expected, "Pread Test 1");<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    // Now check to see if the normal read returns 4K-8K byte range<a name="line.489"></a>
-<span class="sourceLineNo">490</span>    actual = new byte[4096];<a name="line.490"></a>
-<span class="sourceLineNo">491</span>    stm.readFully(actual);<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    checkAndEraseData(actual, 4096, expected, "Pread Test 2");<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    // Now see if we can cross a single block boundary successfully<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    // read 4K bytes from blockSize - 2K offset<a name="line.494"></a>
-<span class="sourceLineNo">495</span>    stm.readFully(blockSize - 2048, actual, 0, 4096);<a name="line.495"></a>
-<span class="sourceLineNo">496</span>    checkAndEraseData(actual, (blockSize - 2048), expected, "Pread Test 3");<a name="line.496"></a>
-<span class="sourceLineNo">497</span>    // now see if we can cross two block boundaries successfully<a name="line.497"></a>
-<span class="sourceLineNo">498</span>    // read blockSize + 4K bytes from blockSize - 2K offset<a name="line.498"></a>
-<span class="sourceLineNo">499</span>    actual = new byte[blockSize + 4096];<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    stm.readFully(blockSize - 2048, actual);<a name="line.500"></a>
-<span class="sourceLineNo">501</span>    checkAndEraseData(actual, (blockSize - 2048), expected, "Pread Test 4");<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    // now see if we can cross two block boundaries that are not cached<a name="line.502"></a>
-<span class="sourceLineNo">503</span>    // read blockSize + 4K bytes from 10*blockSize - 2K offset<a name="line.503"></a>
-<span class="sourceLineNo">504</span>    actual = new byte[blockSize + 4096];<a name="line.504"></a>
-<span class="sourceLineNo">505</span>    stm.readFully(10 * blockSize - 2048, actual);<a name="line.505"></a>
-<span class="sourceLineNo">506</span>    checkAndEraseData(actual, (10 * blockSize - 2048), expected, "Pread Test 5");<a name="line.506"></a>
-<span class="sourceLineNo">507</span>    // now check that even after all these preads, we can still read<a name="line.507"></a>
-<span class="sourceLineNo">508</span>    // bytes 8K-12K<a name="line.508"></a>
-<span class="sourceLineNo">509</span>    actual = new byte[4096];<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    stm.readFully(actual);<a name="line.510"></a>
-<span class="sourceLineNo">511</span>    checkAndEraseData(actual, 8192, expected, "Pread Test 6");<a name="line.511"></a>
-<span class="sourceLineNo">512</span>    // done<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    stm.close();<a name="line.513"></a>
-<span class="sourceLineNo">514</span>    // check block location caching<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    stm = fileSys.open(name);<a name="line.515"></a>
-<span class="sourceLineNo">516</span>    stm.readFully(1, actual, 0, 4096);<a name="line.516"></a>
-<span class="sourceLineNo">517</span>    stm.readFully(4*blockSize, actual, 0, 4096);<a name="line.517"></a>
-<span class="sourceLineNo">518</span>    stm.readFully(7*blockSize, actual, 0, 4096);<a name="line.518"></a>
-<span class="sourceLineNo">519</span>    actual = new byte[3*4096];<a name="line.519"></a>
-<span class="sourceLineNo">520</span>    stm.readFully(0*blockSize, actual, 0, 3*4096);<a name="line.520"></a>
-<span class="sourceLineNo">521</span>    checkAndEraseData(actual, 0, expected, "Pread Test 7");<a name="line.521"></a>
-<span class="sourceLineNo">522</span>    actual = new byte[8*4096];<a name="line.522"></a>
-<span class="sourceLineNo">523</span>    stm.readFully(3*blockSize, actual, 0, 8*4096);<a name="line.523"></a>
-<span class="sourceLineNo">524</span>    checkAndEraseData(actual, 3*blockSize, expected, "Pread Test 8");<a name="line.524"></a>
-<span class="sourceLineNo">525</span>    // read the tail<a name="line.525"></a>
-<span class="sourceLineNo">526</span>    stm.readFully(11*blockSize+blockSize/2, actual, 0, blockSize/2);<a name="line.526"></a>
-<span class="sourceLineNo">527</span>    IOException res = null;<a name="line.527"></a>
-<span class="sourceLineNo">528</span>    try { // read beyond the end of the file<a name="line.528"></a>
-<span class="sourceLineNo">529</span>      stm.readFully(11*blockSize+blockSize/2, actual, 0, blockSize);<a name="line.529"></a>
-<span class="sourceLineNo">530</span>    } catch (IOException e) {<a name="line.530"></a>
-<span class="sourceLineNo">531</span>      // should throw an exception<a name="line.531"></a>
-<span class="sourceLineNo">532</span>      res = e;<a name="line.532"></a>
-<span class="sourceLineNo">533</span>    }<a name="line.533"></a>
-<span class="sourceLineNo">534</span>    assertTrue("Error reading beyond file boundary.", res != null);<a name="line.534"></a>
-<span class="sourceLineNo">535</span><a name="line.535"></a>
-<span class="sourceLineNo">536</span>    stm.close();<a name="line.536"></a>
-<span class="sourceLineNo">537</span>  }<a name="line.537"></a>
-<span class="sourceLineNo">538</span><a name="line.538"></a>
-<span class="sourceLineNo">539</span>  private void checkAndEraseData(byte[] actual, int from, byte[] expected, String message) {<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    for (int idx = 0; idx &lt; actual.length; idx++) {<a name="line.540"></a>
-<span class="sourceLineNo">541</span>      assertEquals(message+" byte "+(from+idx)+" differs. expected "+<a name="line.541"></a>
-<span class="sourceLineNo">542</span>                        expected[from+idx]+" actual "+actual[idx],<a name="line.542"></a>
-<span class="sourceLineNo">543</span>                        actual[idx], expected[from+idx]);<a name="line.543"></a>
-<span class="sourceLineNo">544</span>      actual[idx] = 0;<a name="line.544"></a>
-<span class="sourceLineNo">545</span>    }<a name="line.545"></a>
-<span class="sourceLineNo">546</span>  }<a name="line.546"></a>
-<span class="sourceLineNo">547</span><a name="line.547"></a>
-<span class="sourceLineNo">548</span>  private void doPread(FSDataInputStream stm, long position, byte[] buffer,<a name="line.548"></a>
-<span class="sourceLineNo">549</span>      int offset, int length) throws IOException {<a name="line.549"></a>
-<span class="sourceLineNo">550</span>    int nread = 0;<a name="line.550"></a>
-<span class="sourceLineNo">551</span>    // long totalRead = 0;<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    // DFSInputStream dfstm = null;<a name="line.552"></a>
-<span class="sourceLineNo">553</span><a name="line.553"></a>
-<span class="sourceLineNo">554</span>    /* Disable. This counts do not add up. Some issue in original hdfs tests?<a name="line.554"></a>
-<span class="sourceLineNo">555</span>    if (stm.getWrappedStream() instanceof DFSInputStream) {<a name="line.555"></a>
-<span class="sourceLineNo">556</span>      dfstm = (DFSInputStream) (stm.getWrappedStream());<a name="line.556"></a>
-<span class="sourceLineNo">557</span>      totalRead = dfstm.getReadStatistics().getTotalBytesRead();<a name="line.557"></a>
-<span class="sourceLineNo">558</span>    } */<a name="line.558"></a>
-<span class="sourceLineNo">559</span><a name="line.559"></a>
-<span class="sourceLineNo">560</span>    while (nread &lt; length) {<a name="line.560"></a>
-<span class="sourceLineNo">561</span>      int nbytes =<a name="line.561"></a>
-<span class="sourceLineNo">562</span>          stm.read(position + nread, buffer, offset + nread, length - nread);<a name="line.562"></a>
-<span class="sourceLineNo">563</span>      assertTrue("Error in pread", nbytes &gt; 0);<a name="line.563"></a>
-<span class="sourceLineNo">564</span>      nread += nbytes;<a name="line.564"></a>
-<span class="sourceLineNo">565</span>    }<a name="line.565"></a>
-<span class="sourceLineNo">566</span><a name="line.566"></a>
-<span class="sourceLineNo">567</span>    /* Disable. This counts do not add up. Some issue in original hdfs tests?<a name="line.567"></a>
-<span class="sourceLineNo">568</span>    if (dfstm != null) {<a name="line.568"></a>
-<span class="sourceLineNo">569</span>      if (isHedgedRead) {<a name="line.569"></a>
-<span class="sourceLineNo">570</span>        assertTrue("Expected read statistic to be incremented",<a name="line.570"></a>
-<span class="sourceLineNo">571</span>          length &lt;= dfstm.getReadStatistics().getTotalBytesRead() - totalRead);<a name="line.571"></a>
-<span class="sourceLineNo">572</span>      } else {<a name="line.572"></a>
-<span class="sourceLineNo">573</span>        assertEquals("Expected read statistic to be incremented", length, dfstm<a name="line.573"></a>
-<span class="sourceLineNo">574</span>            .getReadStatistics().getTotalBytesRead() - totalRead);<a name="line.574"></a>
-<span class="sourceLineNo">575</span>      }<a name="line.575"></a>
-<span class="sourceLineNo">576</span>    }*/<a name="line.576"></a>
-<span class="sourceLineNo">577</span>  }<a name="line.577"></a>
-<span class="sourceLineNo">578</span><a name="line.578"></a>
-<span class="sourceLineNo">579</span>  private void cleanupFile(FileSystem fileSys, Path name) throws IOException {<a name="line.579"></a>
-<span class="sourceLineNo">580</span>    assertTrue(fileSys.exists(name));<a name="line.580"></a>
-<span class="sourceLineNo">581</span>    assertTrue(fileSys.delete(name, true));<a name="line.581"></a>
-<span class="sourceLineNo">582</span>    assertTrue(!fileSys.exists(name));<a name="line.582"></a>
-<span class="sourceLineNo">583</span>  }<a name="line.583"></a>
-<span class="sourceLineNo">584</span>}<a name="line.584"></a>
+<span class="sourceLineNo">382</span>  @Test<a name="line.382"></a>
+<span class="sourceLineNo">383</span>  public void testSetWALRootDir() throws Exception {<a name="line.383"></a>
+<span class="sourceLineNo">384</span>    Path p = new Path("file:

<TRUNCATED>

Mime
View raw message