hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [04/14] hbase git commit: Published site at 55087ce8887b5be38b0fda0dda3fbf2f92c13778.
Date Mon, 23 Nov 2015 23:03:21 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/f843f57d/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestWALLockup.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestWALLockup.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestWALLockup.html
index 8dbf4f4..f9f2ab3 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestWALLockup.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestWALLockup.html
@@ -31,269 +31,274 @@
 <span class="sourceLineNo">023</span><a name="line.23"></a>
 <span class="sourceLineNo">024</span>import java.io.IOException;<a name="line.24"></a>
 <span class="sourceLineNo">025</span>import java.util.concurrent.CountDownLatch;<a name="line.25"></a>
-<span class="sourceLineNo">026</span><a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.commons.logging.Log;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.commons.logging.LogFactory;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.conf.Configuration;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.fs.FileSystem;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.Path;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.HConstants;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.HTableDescriptor;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.Server;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.TableName;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Durability;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.client.Put;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.regionserver.wal.FSHLog;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.regionserver.wal.WALEdit;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.43"></a>
-<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;<a name="line.44"></a>
-<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.util.Threads;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.wal.WAL;<a name="line.46"></a>
-<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.wal.WALKey;<a name="line.47"></a>
-<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.wal.WALProvider.Writer;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>import org.junit.After;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>import org.junit.Before;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>import org.junit.Rule;<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>import org.junit.rules.TestName;<a name="line.54"></a>
-<span class="sourceLineNo">055</span>import org.mockito.Mockito;<a name="line.55"></a>
-<span class="sourceLineNo">056</span><a name="line.56"></a>
-<span class="sourceLineNo">057</span>/**<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * Testing for lock up of WAL subsystem.<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * Copied from TestHRegion.<a name="line.59"></a>
-<span class="sourceLineNo">060</span> */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>@Category({MediumTests.class})<a name="line.61"></a>
-<span class="sourceLineNo">062</span>public class TestWALLockup {<a name="line.62"></a>
-<span class="sourceLineNo">063</span>  private static final Log LOG = LogFactory.getLog(TestWALLockup.class);<a name="line.63"></a>
-<span class="sourceLineNo">064</span>  @Rule public TestName name = new TestName();<a name="line.64"></a>
-<span class="sourceLineNo">065</span><a name="line.65"></a>
-<span class="sourceLineNo">066</span>  private static final String COLUMN_FAMILY = "MyCF";<a name="line.66"></a>
-<span class="sourceLineNo">067</span>  private static final byte [] COLUMN_FAMILY_BYTES = Bytes.toBytes(COLUMN_FAMILY);<a name="line.67"></a>
-<span class="sourceLineNo">068</span><a name="line.68"></a>
-<span class="sourceLineNo">069</span>  HRegion region = null;<a name="line.69"></a>
-<span class="sourceLineNo">070</span>  // Do not run unit tests in parallel (? Why not?  It don't work?  Why not?  St.Ack)<a name="line.70"></a>
-<span class="sourceLineNo">071</span>  private static HBaseTestingUtility TEST_UTIL;<a name="line.71"></a>
-<span class="sourceLineNo">072</span>  private static Configuration CONF ;<a name="line.72"></a>
-<span class="sourceLineNo">073</span>  private String dir;<a name="line.73"></a>
-<span class="sourceLineNo">074</span><a name="line.74"></a>
-<span class="sourceLineNo">075</span>  // Test names<a name="line.75"></a>
-<span class="sourceLineNo">076</span>  protected TableName tableName;<a name="line.76"></a>
-<span class="sourceLineNo">077</span><a name="line.77"></a>
-<span class="sourceLineNo">078</span>  @Before<a name="line.78"></a>
-<span class="sourceLineNo">079</span>  public void setup() throws IOException {<a name="line.79"></a>
-<span class="sourceLineNo">080</span>    TEST_UTIL = HBaseTestingUtility.createLocalHTU();<a name="line.80"></a>
-<span class="sourceLineNo">081</span>    CONF = TEST_UTIL.getConfiguration();<a name="line.81"></a>
-<span class="sourceLineNo">082</span>    // Disable block cache.<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    CONF.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f);<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    dir = TEST_UTIL.getDataTestDir("TestHRegion").toString();<a name="line.84"></a>
-<span class="sourceLineNo">085</span>    tableName = TableName.valueOf(name.getMethodName());<a name="line.85"></a>
-<span class="sourceLineNo">086</span>  }<a name="line.86"></a>
-<span class="sourceLineNo">087</span><a name="line.87"></a>
-<span class="sourceLineNo">088</span>  @After<a name="line.88"></a>
-<span class="sourceLineNo">089</span>  public void tearDown() throws Exception {<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    EnvironmentEdgeManagerTestHelper.reset();<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    LOG.info("Cleaning test directory: " + TEST_UTIL.getDataTestDir());<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    TEST_UTIL.cleanupTestDir();<a name="line.92"></a>
-<span class="sourceLineNo">093</span>  }<a name="line.93"></a>
-<span class="sourceLineNo">094</span><a name="line.94"></a>
-<span class="sourceLineNo">095</span>  String getName() {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    return name.getMethodName();<a name="line.96"></a>
-<span class="sourceLineNo">097</span>  }<a name="line.97"></a>
-<span class="sourceLineNo">098</span><a name="line.98"></a>
-<span class="sourceLineNo">099</span>  /**<a name="line.99"></a>
-<span class="sourceLineNo">100</span>   * Reproduce locking up that happens when we get an inopportune sync during setup for<a name="line.100"></a>
-<span class="sourceLineNo">101</span>   * zigzaglatch wait. See HBASE-14317. If below is broken, we will see this test timeout because<a name="line.101"></a>
-<span class="sourceLineNo">102</span>   * it is locked up.<a name="line.102"></a>
-<span class="sourceLineNo">103</span>   * &lt;p&gt;First I need to set up some mocks for Server and RegionServerServices. I also need to<a name="line.103"></a>
-<span class="sourceLineNo">104</span>   * set up a dodgy WAL that will throw an exception when we go to append to it.<a name="line.104"></a>
-<span class="sourceLineNo">105</span>   */<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  @Test (timeout=15000)<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  public void testLockupWhenSyncInMiddleOfZigZagSetup() throws IOException {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>    // A WAL that we can have throw exceptions when a flag is set.<a name="line.108"></a>
-<span class="sourceLineNo">109</span>    class DodgyFSLog extends FSHLog {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>      // Set this when want the WAL to start throwing exceptions.<a name="line.110"></a>
-<span class="sourceLineNo">111</span>      volatile boolean throwException = false;<a name="line.111"></a>
-<span class="sourceLineNo">112</span><a name="line.112"></a>
-<span class="sourceLineNo">113</span>      // Latch to hold up processing until after another operation has had time to run.<a name="line.113"></a>
-<span class="sourceLineNo">114</span>      CountDownLatch latch = new CountDownLatch(1);<a name="line.114"></a>
-<span class="sourceLineNo">115</span><a name="line.115"></a>
-<span class="sourceLineNo">116</span>      public DodgyFSLog(FileSystem fs, Path root, String logDir, Configuration conf)<a name="line.116"></a>
-<span class="sourceLineNo">117</span>      throws IOException {<a name="line.117"></a>
-<span class="sourceLineNo">118</span>        super(fs, root, logDir, conf);<a name="line.118"></a>
-<span class="sourceLineNo">119</span>      }<a name="line.119"></a>
-<span class="sourceLineNo">120</span><a name="line.120"></a>
-<span class="sourceLineNo">121</span>      @Override<a name="line.121"></a>
-<span class="sourceLineNo">122</span>      protected void afterCreatingZigZagLatch() {<a name="line.122"></a>
-<span class="sourceLineNo">123</span>        // If throwException set, then append will throw an exception causing the WAL to be<a name="line.123"></a>
-<span class="sourceLineNo">124</span>        // rolled. We'll come in here. Hold up processing until a sync can get in before<a name="line.124"></a>
-<span class="sourceLineNo">125</span>        // the zigzag has time to complete its setup and get its own sync in. This is what causes<a name="line.125"></a>
-<span class="sourceLineNo">126</span>        // the lock up we've seen in production.<a name="line.126"></a>
-<span class="sourceLineNo">127</span>        if (throwException) {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>          try {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>            LOG.info("LATCHED");<a name="line.129"></a>
-<span class="sourceLineNo">130</span>            this.latch.await();<a name="line.130"></a>
-<span class="sourceLineNo">131</span>          } catch (InterruptedException e) {<a name="line.131"></a>
-<span class="sourceLineNo">132</span>            // TODO Auto-generated catch block<a name="line.132"></a>
-<span class="sourceLineNo">133</span>            e.printStackTrace();<a name="line.133"></a>
-<span class="sourceLineNo">134</span>          }<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        }<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      }<a name="line.136"></a>
-<span class="sourceLineNo">137</span><a name="line.137"></a>
-<span class="sourceLineNo">138</span>      @Override<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      protected void beforeWaitOnSafePoint() {<a name="line.139"></a>
-<span class="sourceLineNo">140</span>        if (throwException) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>          LOG.info("COUNTDOWN");<a name="line.141"></a>
-<span class="sourceLineNo">142</span>          // Don't countdown latch until someone waiting on it otherwise, the above<a name="line.142"></a>
-<span class="sourceLineNo">143</span>          // afterCreatingZigZagLatch will get to the latch and no one will ever free it and we'll<a name="line.143"></a>
-<span class="sourceLineNo">144</span>          // be stuck; test won't go down<a name="line.144"></a>
-<span class="sourceLineNo">145</span>          while (this.latch.getCount() &lt;= 0) Threads.sleep(1);<a name="line.145"></a>
-<span class="sourceLineNo">146</span>          this.latch.countDown();<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        }<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      }<a name="line.148"></a>
-<span class="sourceLineNo">149</span><a name="line.149"></a>
-<span class="sourceLineNo">150</span>      @Override<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      protected Writer createWriterInstance(Path path) throws IOException {<a name="line.151"></a>
-<span class="sourceLineNo">152</span>        final Writer w = super.createWriterInstance(path);<a name="line.152"></a>
-<span class="sourceLineNo">153</span>        return new Writer() {<a name="line.153"></a>
-<span class="sourceLineNo">154</span>          @Override<a name="line.154"></a>
-<span class="sourceLineNo">155</span>          public void close() throws IOException {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>            w.close();<a name="line.156"></a>
-<span class="sourceLineNo">157</span>          }<a name="line.157"></a>
-<span class="sourceLineNo">158</span><a name="line.158"></a>
-<span class="sourceLineNo">159</span>          @Override<a name="line.159"></a>
-<span class="sourceLineNo">160</span>          public void sync() throws IOException {<a name="line.160"></a>
-<span class="sourceLineNo">161</span>            if (throwException) {<a name="line.161"></a>
-<span class="sourceLineNo">162</span>              throw new IOException("FAKE! Failed to replace a bad datanode...SYNC");<a name="line.162"></a>
-<span class="sourceLineNo">163</span>            }<a name="line.163"></a>
-<span class="sourceLineNo">164</span>            w.sync();<a name="line.164"></a>
-<span class="sourceLineNo">165</span>          }<a name="line.165"></a>
-<span class="sourceLineNo">166</span><a name="line.166"></a>
-<span class="sourceLineNo">167</span>          @Override<a name="line.167"></a>
-<span class="sourceLineNo">168</span>          public void append(Entry entry) throws IOException {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>            if (throwException) {<a name="line.169"></a>
-<span class="sourceLineNo">170</span>              throw new IOException("FAKE! Failed to replace a bad datanode...APPEND");<a name="line.170"></a>
-<span class="sourceLineNo">171</span>            }<a name="line.171"></a>
-<span class="sourceLineNo">172</span>            w.append(entry);<a name="line.172"></a>
-<span class="sourceLineNo">173</span>          }<a name="line.173"></a>
-<span class="sourceLineNo">174</span><a name="line.174"></a>
-<span class="sourceLineNo">175</span>          @Override<a name="line.175"></a>
-<span class="sourceLineNo">176</span>          public long getLength() throws IOException {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>            return w.getLength();<a name="line.177"></a>
-<span class="sourceLineNo">178</span>          }<a name="line.178"></a>
-<span class="sourceLineNo">179</span>        };<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      }<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    }<a name="line.181"></a>
-<span class="sourceLineNo">182</span><a name="line.182"></a>
-<span class="sourceLineNo">183</span>    // Mocked up server and regionserver services. Needed below.<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    Server server = Mockito.mock(Server.class);<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    Mockito.when(server.getConfiguration()).thenReturn(CONF);<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    Mockito.when(server.isStopped()).thenReturn(false);<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    Mockito.when(server.isAborted()).thenReturn(false);<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    RegionServerServices services = Mockito.mock(RegionServerServices.class);<a name="line.188"></a>
+<span class="sourceLineNo">026</span>import java.util.concurrent.TimeUnit;<a name="line.26"></a>
+<span class="sourceLineNo">027</span><a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.commons.logging.Log;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.commons.logging.LogFactory;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.conf.Configuration;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.FileSystem;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.fs.Path;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.HConstants;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.HTableDescriptor;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.Server;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.TableName;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.client.Durability;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.client.Put;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.regionserver.wal.FSHLog;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.regionserver.wal.WALEdit;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.testclassification.MediumTests;<a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.util.Threads;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.wal.WAL;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.wal.WALKey;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.wal.WALProvider.Writer;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>import org.junit.After;<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.Rule;<a name="line.52"></a>
+<span class="sourceLineNo">053</span>import org.junit.Test;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>import org.junit.experimental.categories.Category;<a name="line.54"></a>
+<span class="sourceLineNo">055</span>import org.junit.rules.TestName;<a name="line.55"></a>
+<span class="sourceLineNo">056</span>import org.mockito.Mockito;<a name="line.56"></a>
+<span class="sourceLineNo">057</span><a name="line.57"></a>
+<span class="sourceLineNo">058</span>/**<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * Testing for lock up of WAL subsystem.<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * Copied from TestHRegion.<a name="line.60"></a>
+<span class="sourceLineNo">061</span> */<a name="line.61"></a>
+<span class="sourceLineNo">062</span>@Category({MediumTests.class})<a name="line.62"></a>
+<span class="sourceLineNo">063</span>public class TestWALLockup {<a name="line.63"></a>
+<span class="sourceLineNo">064</span>  private static final Log LOG = LogFactory.getLog(TestWALLockup.class);<a name="line.64"></a>
+<span class="sourceLineNo">065</span>  @Rule public TestName name = new TestName();<a name="line.65"></a>
+<span class="sourceLineNo">066</span><a name="line.66"></a>
+<span class="sourceLineNo">067</span>  private static final String COLUMN_FAMILY = "MyCF";<a name="line.67"></a>
+<span class="sourceLineNo">068</span>  private static final byte [] COLUMN_FAMILY_BYTES = Bytes.toBytes(COLUMN_FAMILY);<a name="line.68"></a>
+<span class="sourceLineNo">069</span><a name="line.69"></a>
+<span class="sourceLineNo">070</span>  HRegion region = null;<a name="line.70"></a>
+<span class="sourceLineNo">071</span>  // Do not run unit tests in parallel (? Why not?  It don't work?  Why not?  St.Ack)<a name="line.71"></a>
+<span class="sourceLineNo">072</span>  private static HBaseTestingUtility TEST_UTIL;<a name="line.72"></a>
+<span class="sourceLineNo">073</span>  private static Configuration CONF ;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>  private String dir;<a name="line.74"></a>
+<span class="sourceLineNo">075</span><a name="line.75"></a>
+<span class="sourceLineNo">076</span>  // Test names<a name="line.76"></a>
+<span class="sourceLineNo">077</span>  protected TableName tableName;<a name="line.77"></a>
+<span class="sourceLineNo">078</span><a name="line.78"></a>
+<span class="sourceLineNo">079</span>  @Before<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  public void setup() throws IOException {<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    TEST_UTIL = HBaseTestingUtility.createLocalHTU();<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    CONF = TEST_UTIL.getConfiguration();<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    // Disable block cache.<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    CONF.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f);<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    dir = TEST_UTIL.getDataTestDir("TestHRegion").toString();<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    tableName = TableName.valueOf(name.getMethodName());<a name="line.86"></a>
+<span class="sourceLineNo">087</span>  }<a name="line.87"></a>
+<span class="sourceLineNo">088</span><a name="line.88"></a>
+<span class="sourceLineNo">089</span>  @After<a name="line.89"></a>
+<span class="sourceLineNo">090</span>  public void tearDown() throws Exception {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    EnvironmentEdgeManagerTestHelper.reset();<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    LOG.info("Cleaning test directory: " + TEST_UTIL.getDataTestDir());<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    TEST_UTIL.cleanupTestDir();<a name="line.93"></a>
+<span class="sourceLineNo">094</span>  }<a name="line.94"></a>
+<span class="sourceLineNo">095</span><a name="line.95"></a>
+<span class="sourceLineNo">096</span>  String getName() {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    return name.getMethodName();<a name="line.97"></a>
+<span class="sourceLineNo">098</span>  }<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>   * Reproduce locking up that happens when we get an inopportune sync during setup for<a name="line.101"></a>
+<span class="sourceLineNo">102</span>   * zigzaglatch wait. See HBASE-14317. If below is broken, we will see this test timeout because<a name="line.102"></a>
+<span class="sourceLineNo">103</span>   * it is locked up.<a name="line.103"></a>
+<span class="sourceLineNo">104</span>   * &lt;p&gt;First I need to set up some mocks for Server and RegionServerServices. I also need to<a name="line.104"></a>
+<span class="sourceLineNo">105</span>   * set up a dodgy WAL that will throw an exception when we go to append to it.<a name="line.105"></a>
+<span class="sourceLineNo">106</span>   */<a name="line.106"></a>
+<span class="sourceLineNo">107</span>  @Test (timeout=20000)<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  public void testLockupWhenSyncInMiddleOfZigZagSetup() throws IOException {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>    // A WAL that we can have throw exceptions when a flag is set.<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    class DodgyFSLog extends FSHLog {<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      // Set this when want the WAL to start throwing exceptions.<a name="line.111"></a>
+<span class="sourceLineNo">112</span>      volatile boolean throwException = false;<a name="line.112"></a>
+<span class="sourceLineNo">113</span><a name="line.113"></a>
+<span class="sourceLineNo">114</span>      // Latch to hold up processing until after another operation has had time to run.<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      CountDownLatch latch = new CountDownLatch(1);<a name="line.115"></a>
+<span class="sourceLineNo">116</span><a name="line.116"></a>
+<span class="sourceLineNo">117</span>      public DodgyFSLog(FileSystem fs, Path root, String logDir, Configuration conf)<a name="line.117"></a>
+<span class="sourceLineNo">118</span>      throws IOException {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>        super(fs, root, logDir, conf);<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>      @Override<a name="line.122"></a>
+<span class="sourceLineNo">123</span>      protected void afterCreatingZigZagLatch() {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>        // If throwException set, then append will throw an exception causing the WAL to be<a name="line.124"></a>
+<span class="sourceLineNo">125</span>        // rolled. We'll come in here. Hold up processing until a sync can get in before<a name="line.125"></a>
+<span class="sourceLineNo">126</span>        // the zigzag has time to complete its setup and get its own sync in. This is what causes<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        // the lock up we've seen in production.<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        if (throwException) {<a name="line.128"></a>
+<span class="sourceLineNo">129</span>          try {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>            LOG.info("LATCHED");<a name="line.130"></a>
+<span class="sourceLineNo">131</span>            // So, timing can have it that the test can run and the bad flush below happens<a name="line.131"></a>
+<span class="sourceLineNo">132</span>            // before we get here. In this case, we'll be stuck waiting on this latch but there<a name="line.132"></a>
+<span class="sourceLineNo">133</span>            // is nothing in the WAL pipeline to get us to the below beforeWaitOnSafePoint...<a name="line.133"></a>
+<span class="sourceLineNo">134</span>            // because all WALs have rolled. In this case, just give up on test.<a name="line.134"></a>
+<span class="sourceLineNo">135</span>            if (!this.latch.await(5, TimeUnit.SECONDS)) {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>              LOG.warn("GIVE UP! Failed waiting on latch...Test is ABORTED!");<a name="line.136"></a>
+<span class="sourceLineNo">137</span>            }<a name="line.137"></a>
+<span class="sourceLineNo">138</span>          } catch (InterruptedException e) {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>            // TODO Auto-generated catch block<a name="line.139"></a>
+<span class="sourceLineNo">140</span>            e.printStackTrace();<a name="line.140"></a>
+<span class="sourceLineNo">141</span>          }<a name="line.141"></a>
+<span class="sourceLineNo">142</span>        }<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      }<a name="line.143"></a>
+<span class="sourceLineNo">144</span><a name="line.144"></a>
+<span class="sourceLineNo">145</span>      @Override<a name="line.145"></a>
+<span class="sourceLineNo">146</span>      protected void beforeWaitOnSafePoint() {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>        if (throwException) {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>          LOG.info("COUNTDOWN");<a name="line.148"></a>
+<span class="sourceLineNo">149</span>          // Don't countdown latch until someone waiting on it otherwise, the above<a name="line.149"></a>
+<span class="sourceLineNo">150</span>          // afterCreatingZigZagLatch will get to the latch and no one will ever free it and we'll<a name="line.150"></a>
+<span class="sourceLineNo">151</span>          // be stuck; test won't go down<a name="line.151"></a>
+<span class="sourceLineNo">152</span>          while (this.latch.getCount() &lt;= 0) Threads.sleep(1);<a name="line.152"></a>
+<span class="sourceLineNo">153</span>          this.latch.countDown();<a name="line.153"></a>
+<span class="sourceLineNo">154</span>        }<a name="line.154"></a>
+<span class="sourceLineNo">155</span>      }<a name="line.155"></a>
+<span class="sourceLineNo">156</span><a name="line.156"></a>
+<span class="sourceLineNo">157</span>      @Override<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      protected Writer createWriterInstance(Path path) throws IOException {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        final Writer w = super.createWriterInstance(path);<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        return new Writer() {<a name="line.160"></a>
+<span class="sourceLineNo">161</span>          @Override<a name="line.161"></a>
+<span class="sourceLineNo">162</span>          public void close() throws IOException {<a name="line.162"></a>
+<span class="sourceLineNo">163</span>            w.close();<a name="line.163"></a>
+<span class="sourceLineNo">164</span>          }<a name="line.164"></a>
+<span class="sourceLineNo">165</span><a name="line.165"></a>
+<span class="sourceLineNo">166</span>          @Override<a name="line.166"></a>
+<span class="sourceLineNo">167</span>          public void sync() throws IOException {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>            if (throwException) {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>              throw new IOException("FAKE! Failed to replace a bad datanode...SYNC");<a name="line.169"></a>
+<span class="sourceLineNo">170</span>            }<a name="line.170"></a>
+<span class="sourceLineNo">171</span>            w.sync();<a name="line.171"></a>
+<span class="sourceLineNo">172</span>          }<a name="line.172"></a>
+<span class="sourceLineNo">173</span><a name="line.173"></a>
+<span class="sourceLineNo">174</span>          @Override<a name="line.174"></a>
+<span class="sourceLineNo">175</span>          public void append(Entry entry) throws IOException {<a name="line.175"></a>
+<span class="sourceLineNo">176</span>            if (throwException) {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>              throw new IOException("FAKE! Failed to replace a bad datanode...APPEND");<a name="line.177"></a>
+<span class="sourceLineNo">178</span>            }<a name="line.178"></a>
+<span class="sourceLineNo">179</span>            w.append(entry);<a name="line.179"></a>
+<span class="sourceLineNo">180</span>          }<a name="line.180"></a>
+<span class="sourceLineNo">181</span><a name="line.181"></a>
+<span class="sourceLineNo">182</span>          @Override<a name="line.182"></a>
+<span class="sourceLineNo">183</span>          public long getLength() throws IOException {<a name="line.183"></a>
+<span class="sourceLineNo">184</span>            return w.getLength();<a name="line.184"></a>
+<span class="sourceLineNo">185</span>          }<a name="line.185"></a>
+<span class="sourceLineNo">186</span>        };<a name="line.186"></a>
+<span class="sourceLineNo">187</span>      }<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    }<a name="line.188"></a>
 <span class="sourceLineNo">189</span><a name="line.189"></a>
-<span class="sourceLineNo">190</span>    // OK. Now I have my mocked up Server &amp; RegionServerServices and dodgy WAL, go ahead with test.<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    FileSystem fs = FileSystem.get(CONF);<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    Path rootDir = new Path(dir + getName());<a name="line.192"></a>
-<span class="sourceLineNo">193</span>    DodgyFSLog dodgyWAL = new DodgyFSLog(fs, rootDir, getName(), CONF);<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    Path originalWAL = dodgyWAL.getCurrentFileName();<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    // I need a log roller running.<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    LogRoller logRoller = new LogRoller(server, services);<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    logRoller.addWAL(dodgyWAL);<a name="line.197"></a>
-<span class="sourceLineNo">198</span>    // There is no 'stop' once a logRoller is running.. it just dies.<a name="line.198"></a>
-<span class="sourceLineNo">199</span>    logRoller.start();<a name="line.199"></a>
-<span class="sourceLineNo">200</span>    // Now get a region and start adding in edits.<a name="line.200"></a>
-<span class="sourceLineNo">201</span>    HTableDescriptor htd = new HTableDescriptor(TableName.META_TABLE_NAME);<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    final HRegion region = initHRegion(tableName, null, null, dodgyWAL);<a name="line.202"></a>
-<span class="sourceLineNo">203</span>    byte [] bytes = Bytes.toBytes(getName());<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    try {<a name="line.204"></a>
-<span class="sourceLineNo">205</span>      // First get something into memstore. Make a Put and then pull the Cell out of it. Will<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      // manage append and sync carefully in below to manufacture hang. We keep adding same<a name="line.206"></a>
-<span class="sourceLineNo">207</span>      // edit. WAL subsystem doesn't care.<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      Put put = new Put(bytes);<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("1"), bytes);<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      WALKey key = new WALKey(region.getRegionInfo().getEncodedNameAsBytes(), htd.getTableName());<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      WALEdit edit = new WALEdit();<a name="line.211"></a>
-<span class="sourceLineNo">212</span>      CellScanner CellScanner = put.cellScanner();<a name="line.212"></a>
-<span class="sourceLineNo">213</span>      assertTrue(CellScanner.advance());<a name="line.213"></a>
-<span class="sourceLineNo">214</span>      edit.add(CellScanner.current());<a name="line.214"></a>
-<span class="sourceLineNo">215</span>      // Put something in memstore and out in the WAL. Do a big number of appends so we push<a name="line.215"></a>
-<span class="sourceLineNo">216</span>      // out other side of the ringbuffer. If small numbers, stuff doesn't make it to WAL<a name="line.216"></a>
-<span class="sourceLineNo">217</span>      for (int i = 0; i &lt; 1000; i++) {<a name="line.217"></a>
-<span class="sourceLineNo">218</span>        region.put(put);<a name="line.218"></a>
-<span class="sourceLineNo">219</span>      }<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      // Set it so we start throwing exceptions.<a name="line.220"></a>
-<span class="sourceLineNo">221</span>      LOG.info("SET throwing of exception on append");<a name="line.221"></a>
-<span class="sourceLineNo">222</span>      dodgyWAL.throwException = true;<a name="line.222"></a>
-<span class="sourceLineNo">223</span>      // This append provokes a WAL roll request<a name="line.223"></a>
-<span class="sourceLineNo">224</span>      dodgyWAL.append(htd, region.getRegionInfo(), key, edit, true);<a name="line.224"></a>
-<span class="sourceLineNo">225</span>      // Now wait until the dodgy WAL is latched.<a name="line.225"></a>
-<span class="sourceLineNo">226</span>      while (dodgyWAL.latch.getCount() &lt;= 0) Threads.sleep(1);<a name="line.226"></a>
-<span class="sourceLineNo">227</span>      boolean exception = false;<a name="line.227"></a>
-<span class="sourceLineNo">228</span>      try {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>        dodgyWAL.sync();<a name="line.229"></a>
-<span class="sourceLineNo">230</span>      } catch (Exception e) {<a name="line.230"></a>
-<span class="sourceLineNo">231</span>        exception = true;<a name="line.231"></a>
-<span class="sourceLineNo">232</span>      }<a name="line.232"></a>
-<span class="sourceLineNo">233</span>      assertTrue("Did not get sync exception", exception);<a name="line.233"></a>
-<span class="sourceLineNo">234</span><a name="line.234"></a>
-<span class="sourceLineNo">235</span>      // Get a memstore flush going too so we have same hung profile as up in the issue over<a name="line.235"></a>
-<span class="sourceLineNo">236</span>      // in HBASE-14317. Flush hangs trying to get sequenceid because the ringbuffer is held up<a name="line.236"></a>
-<span class="sourceLineNo">237</span>      // by the zigzaglatch waiting on syncs to come home.<a name="line.237"></a>
-<span class="sourceLineNo">238</span>      Thread t = new Thread ("Flusher") {<a name="line.238"></a>
-<span class="sourceLineNo">239</span>        public void run() {<a name="line.239"></a>
-<span class="sourceLineNo">240</span>          try {<a name="line.240"></a>
-<span class="sourceLineNo">241</span>            if (region.getMemstoreSize() &lt;= 0) {<a name="line.241"></a>
-<span class="sourceLineNo">242</span>              throw new IOException("memstore size=" + region.getMemstoreSize());<a name="line.242"></a>
-<span class="sourceLineNo">243</span>            }<a name="line.243"></a>
-<span class="sourceLineNo">244</span>            region.flush(false);<a name="line.244"></a>
-<span class="sourceLineNo">245</span>          } catch (IOException e) {<a name="line.245"></a>
-<span class="sourceLineNo">246</span>            // Can fail trying to flush in middle of a roll. Not a failure. Will succeed later<a name="line.246"></a>
-<span class="sourceLineNo">247</span>            // when roll completes.<a name="line.247"></a>
-<span class="sourceLineNo">248</span>            LOG.info("In flush", e);<a name="line.248"></a>
-<span class="sourceLineNo">249</span>          }<a name="line.249"></a>
-<span class="sourceLineNo">250</span>          LOG.info("Exiting");<a name="line.250"></a>
-<span class="sourceLineNo">251</span>        };<a name="line.251"></a>
-<span class="sourceLineNo">252</span>      };<a name="line.252"></a>
-<span class="sourceLineNo">253</span>      t.setDaemon(true);<a name="line.253"></a>
-<span class="sourceLineNo">254</span>      t.start();<a name="line.254"></a>
-<span class="sourceLineNo">255</span>      // Wait until <a name="line.255"></a>
-<span class="sourceLineNo">256</span>      while (dodgyWAL.latch.getCount() &gt; 0) Threads.sleep(1);<a name="line.256"></a>
-<span class="sourceLineNo">257</span>      // Now assert I got a new WAL file put in place even though loads of errors above.<a name="line.257"></a>
-<span class="sourceLineNo">258</span>      assertTrue(originalWAL != dodgyWAL.getCurrentFileName());<a name="line.258"></a>
-<span class="sourceLineNo">259</span>      // Can I append to it?<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      dodgyWAL.throwException = false;<a name="line.260"></a>
-<span class="sourceLineNo">261</span>      try {<a name="line.261"></a>
-<span class="sourceLineNo">262</span>        region.put(put);<a name="line.262"></a>
-<span class="sourceLineNo">263</span>      } catch (Exception e) {<a name="line.263"></a>
-<span class="sourceLineNo">264</span>        LOG.info("In the put", e);<a name="line.264"></a>
-<span class="sourceLineNo">265</span>      }<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    } finally {<a name="line.266"></a>
-<span class="sourceLineNo">267</span>      // To stop logRoller, its server has to say it is stopped.<a name="line.267"></a>
-<span class="sourceLineNo">268</span>      Mockito.when(server.isStopped()).thenReturn(true);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>      if (logRoller != null) logRoller.interrupt();<a name="line.269"></a>
-<span class="sourceLineNo">270</span>      try {<a name="line.270"></a>
-<span class="sourceLineNo">271</span>        if (region != null) region.close();<a name="line.271"></a>
-<span class="sourceLineNo">272</span>        if (dodgyWAL != null) dodgyWAL.close();<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      } catch (Exception e) {<a name="line.273"></a>
-<span class="sourceLineNo">274</span>        LOG.info("On way out", e);<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><a name="line.278"></a>
-<span class="sourceLineNo">279</span>  /**<a name="line.279"></a>
-<span class="sourceLineNo">280</span>   * @return A region on which you must call<a name="line.280"></a>
-<span class="sourceLineNo">281</span>   *         {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.<a name="line.281"></a>
-<span class="sourceLineNo">282</span>   */<a name="line.282"></a>
-<span class="sourceLineNo">283</span>  public static HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, WAL wal)<a name="line.283"></a>
-<span class="sourceLineNo">284</span>  throws IOException {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, false, Durability.SYNC_WAL,<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      wal, COLUMN_FAMILY_BYTES);<a name="line.286"></a>
-<span class="sourceLineNo">287</span>  }<a name="line.287"></a>
-<span class="sourceLineNo">288</span>}<a name="line.288"></a>
+<span class="sourceLineNo">190</span>    // Mocked up server and regionserver services. Needed below.<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    Server server = Mockito.mock(Server.class);<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    Mockito.when(server.getConfiguration()).thenReturn(CONF);<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    Mockito.when(server.isStopped()).thenReturn(false);<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    Mockito.when(server.isAborted()).thenReturn(false);<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    RegionServerServices services = Mockito.mock(RegionServerServices.class);<a name="line.195"></a>
+<span class="sourceLineNo">196</span><a name="line.196"></a>
+<span class="sourceLineNo">197</span>    // OK. Now I have my mocked up Server &amp; RegionServerServices and dodgy WAL, go ahead with test.<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    FileSystem fs = FileSystem.get(CONF);<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    Path rootDir = new Path(dir + getName());<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    DodgyFSLog dodgyWAL = new DodgyFSLog(fs, rootDir, getName(), CONF);<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    Path originalWAL = dodgyWAL.getCurrentFileName();<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    // I need a log roller running.<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    LogRoller logRoller = new LogRoller(server, services);<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    logRoller.addWAL(dodgyWAL);<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    // There is no 'stop' once a logRoller is running.. it just dies.<a name="line.205"></a>
+<span class="sourceLineNo">206</span>    logRoller.start();<a name="line.206"></a>
+<span class="sourceLineNo">207</span>    // Now get a region and start adding in edits.<a name="line.207"></a>
+<span class="sourceLineNo">208</span>    HTableDescriptor htd = new HTableDescriptor(TableName.META_TABLE_NAME);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>    final HRegion region = initHRegion(tableName, null, null, dodgyWAL);<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    byte [] bytes = Bytes.toBytes(getName());<a name="line.210"></a>
+<span class="sourceLineNo">211</span>    try {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>      // First get something into memstore. Make a Put and then pull the Cell out of it. Will<a name="line.212"></a>
+<span class="sourceLineNo">213</span>      // manage append and sync carefully in below to manufacture hang. We keep adding same<a name="line.213"></a>
+<span class="sourceLineNo">214</span>      // edit. WAL subsystem doesn't care.<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      Put put = new Put(bytes);<a name="line.215"></a>
+<span class="sourceLineNo">216</span>      put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("1"), bytes);<a name="line.216"></a>
+<span class="sourceLineNo">217</span>      WALKey key = new WALKey(region.getRegionInfo().getEncodedNameAsBytes(), htd.getTableName());<a name="line.217"></a>
+<span class="sourceLineNo">218</span>      WALEdit edit = new WALEdit();<a name="line.218"></a>
+<span class="sourceLineNo">219</span>      CellScanner CellScanner = put.cellScanner();<a name="line.219"></a>
+<span class="sourceLineNo">220</span>      assertTrue(CellScanner.advance());<a name="line.220"></a>
+<span class="sourceLineNo">221</span>      edit.add(CellScanner.current());<a name="line.221"></a>
+<span class="sourceLineNo">222</span>      // Put something in memstore and out in the WAL. Do a big number of appends so we push<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      // out other side of the ringbuffer. If small numbers, stuff doesn't make it to WAL<a name="line.223"></a>
+<span class="sourceLineNo">224</span>      for (int i = 0; i &lt; 1000; i++) {<a name="line.224"></a>
+<span class="sourceLineNo">225</span>        region.put(put);<a name="line.225"></a>
+<span class="sourceLineNo">226</span>      }<a name="line.226"></a>
+<span class="sourceLineNo">227</span>      // Set it so we start throwing exceptions.<a name="line.227"></a>
+<span class="sourceLineNo">228</span>      LOG.info("SET throwing of exception on append");<a name="line.228"></a>
+<span class="sourceLineNo">229</span>      dodgyWAL.throwException = true;<a name="line.229"></a>
+<span class="sourceLineNo">230</span>      // This append provokes a WAL roll request<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      dodgyWAL.append(htd, region.getRegionInfo(), key, edit, true);<a name="line.231"></a>
+<span class="sourceLineNo">232</span>      boolean exception = false;<a name="line.232"></a>
+<span class="sourceLineNo">233</span>      try {<a name="line.233"></a>
+<span class="sourceLineNo">234</span>        dodgyWAL.sync();<a name="line.234"></a>
+<span class="sourceLineNo">235</span>      } catch (Exception e) {<a name="line.235"></a>
+<span class="sourceLineNo">236</span>        exception = true;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      }<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      assertTrue("Did not get sync exception", exception);<a name="line.238"></a>
+<span class="sourceLineNo">239</span><a name="line.239"></a>
+<span class="sourceLineNo">240</span>      // Get a memstore flush going too so we have same hung profile as up in the issue over<a name="line.240"></a>
+<span class="sourceLineNo">241</span>      // in HBASE-14317. Flush hangs trying to get sequenceid because the ringbuffer is held up<a name="line.241"></a>
+<span class="sourceLineNo">242</span>      // by the zigzaglatch waiting on syncs to come home.<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      Thread t = new Thread ("Flusher") {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>        public void run() {<a name="line.244"></a>
+<span class="sourceLineNo">245</span>          try {<a name="line.245"></a>
+<span class="sourceLineNo">246</span>            if (region.getMemstoreSize() &lt;= 0) {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>              throw new IOException("memstore size=" + region.getMemstoreSize());<a name="line.247"></a>
+<span class="sourceLineNo">248</span>            }<a name="line.248"></a>
+<span class="sourceLineNo">249</span>            region.flush(false);<a name="line.249"></a>
+<span class="sourceLineNo">250</span>          } catch (IOException e) {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>            // Can fail trying to flush in middle of a roll. Not a failure. Will succeed later<a name="line.251"></a>
+<span class="sourceLineNo">252</span>            // when roll completes.<a name="line.252"></a>
+<span class="sourceLineNo">253</span>            LOG.info("In flush", e);<a name="line.253"></a>
+<span class="sourceLineNo">254</span>          }<a name="line.254"></a>
+<span class="sourceLineNo">255</span>          LOG.info("Exiting");<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>      t.setDaemon(true);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>      t.start();<a name="line.259"></a>
+<span class="sourceLineNo">260</span>      // Wait until <a name="line.260"></a>
+<span class="sourceLineNo">261</span>      while (dodgyWAL.latch.getCount() &gt; 0) Threads.sleep(1);<a name="line.261"></a>
+<span class="sourceLineNo">262</span>      // Now assert I got a new WAL file put in place even though loads of errors above.<a name="line.262"></a>
+<span class="sourceLineNo">263</span>      assertTrue(originalWAL != dodgyWAL.getCurrentFileName());<a name="line.263"></a>
+<span class="sourceLineNo">264</span>      // Can I append to it?<a name="line.264"></a>
+<span class="sourceLineNo">265</span>      dodgyWAL.throwException = false;<a name="line.265"></a>
+<span class="sourceLineNo">266</span>      try {<a name="line.266"></a>
+<span class="sourceLineNo">267</span>        region.put(put);<a name="line.267"></a>
+<span class="sourceLineNo">268</span>      } catch (Exception e) {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>        LOG.info("In the put", e);<a name="line.269"></a>
+<span class="sourceLineNo">270</span>      }<a name="line.270"></a>
+<span class="sourceLineNo">271</span>    } finally {<a name="line.271"></a>
+<span class="sourceLineNo">272</span>      // To stop logRoller, its server has to say it is stopped.<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      Mockito.when(server.isStopped()).thenReturn(true);<a name="line.273"></a>
+<span class="sourceLineNo">274</span>      if (logRoller != null) logRoller.interrupt();<a name="line.274"></a>
+<span class="sourceLineNo">275</span>      try {<a name="line.275"></a>
+<span class="sourceLineNo">276</span>        if (region != null) region.close();<a name="line.276"></a>
+<span class="sourceLineNo">277</span>        if (dodgyWAL != null) dodgyWAL.close();<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      } catch (Exception e) {<a name="line.278"></a>
+<span class="sourceLineNo">279</span>        LOG.info("On way out", e);<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      }<a name="line.280"></a>
+<span class="sourceLineNo">281</span>    }<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>  /**<a name="line.284"></a>
+<span class="sourceLineNo">285</span>   * @return A region on which you must call<a name="line.285"></a>
+<span class="sourceLineNo">286</span>   *         {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.<a name="line.286"></a>
+<span class="sourceLineNo">287</span>   */<a name="line.287"></a>
+<span class="sourceLineNo">288</span>  public static HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, WAL wal)<a name="line.288"></a>
+<span class="sourceLineNo">289</span>  throws IOException {<a name="line.289"></a>
+<span class="sourceLineNo">290</span>    return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, false, Durability.SYNC_WAL,<a name="line.290"></a>
+<span class="sourceLineNo">291</span>      wal, COLUMN_FAMILY_BYTES);<a name="line.291"></a>
+<span class="sourceLineNo">292</span>  }<a name="line.292"></a>
+<span class="sourceLineNo">293</span>}<a name="line.293"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/f843f57d/xref-test/org/apache/hadoop/hbase/io/TestBoundedByteBufferPool.html
----------------------------------------------------------------------
diff --git a/xref-test/org/apache/hadoop/hbase/io/TestBoundedByteBufferPool.html b/xref-test/org/apache/hadoop/hbase/io/TestBoundedByteBufferPool.html
index 05e0b38..be7970c 100644
--- a/xref-test/org/apache/hadoop/hbase/io/TestBoundedByteBufferPool.html
+++ b/xref-test/org/apache/hadoop/hbase/io/TestBoundedByteBufferPool.html
@@ -63,38 +63,38 @@
 <a class="jxr_linenumber" name="53" href="#53">53</a>      <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(bb);
 <a class="jxr_linenumber" name="54" href="#54">54</a>      <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(bb);
 <a class="jxr_linenumber" name="55" href="#55">55</a>      <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(bb);
-<a class="jxr_linenumber" name="56" href="#56">56</a>      assertEquals(3, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="56" href="#56">56</a>      assertEquals(3, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="57" href="#57">57</a>    }
 <a class="jxr_linenumber" name="58" href="#58">58</a>  
 <a class="jxr_linenumber" name="59" href="#59">59</a>    @Test
 <a class="jxr_linenumber" name="60" href="#60">60</a>    <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testGetPut() {
 <a class="jxr_linenumber" name="61" href="#61">61</a>      ByteBuffer bb = <strong class="jxr_keyword">this</strong>.reservoir.getBuffer();
 <a class="jxr_linenumber" name="62" href="#62">62</a>      assertEquals(initialByteBufferSize, bb.capacity());
-<a class="jxr_linenumber" name="63" href="#63">63</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="63" href="#63">63</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="64" href="#64">64</a>      <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(bb);
-<a class="jxr_linenumber" name="65" href="#65">65</a>      assertEquals(1, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="65" href="#65">65</a>      assertEquals(1, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="66" href="#66">66</a>      <em class="jxr_comment">// Now remove a buffer and don't put it back so reservoir is empty.</em>
 <a class="jxr_linenumber" name="67" href="#67">67</a>      <strong class="jxr_keyword">this</strong>.reservoir.getBuffer();
-<a class="jxr_linenumber" name="68" href="#68">68</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="68" href="#68">68</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="69" href="#69">69</a>      <em class="jxr_comment">// Try adding in a buffer with a bigger-than-initial size and see if our runningAverage works.</em>
 <a class="jxr_linenumber" name="70" href="#70">70</a>      <em class="jxr_comment">// Need to add then remove, then get a new bytebuffer so reservoir internally is doing</em>
 <a class="jxr_linenumber" name="71" href="#71">71</a>      <em class="jxr_comment">// allocation</em>
 <a class="jxr_linenumber" name="72" href="#72">72</a>      <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> newCapacity = 2;
 <a class="jxr_linenumber" name="73" href="#73">73</a>      <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(ByteBuffer.allocate(newCapacity));
-<a class="jxr_linenumber" name="74" href="#74">74</a>      assertEquals(1, reservoir.buffers.size());
+<a class="jxr_linenumber" name="74" href="#74">74</a>      assertEquals(1, reservoir.getQueueSize());
 <a class="jxr_linenumber" name="75" href="#75">75</a>      <strong class="jxr_keyword">this</strong>.reservoir.getBuffer();
-<a class="jxr_linenumber" name="76" href="#76">76</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="76" href="#76">76</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="77" href="#77">77</a>      bb = <strong class="jxr_keyword">this</strong>.reservoir.getBuffer();
 <a class="jxr_linenumber" name="78" href="#78">78</a>      assertEquals(newCapacity, bb.capacity());
 <a class="jxr_linenumber" name="79" href="#79">79</a>      <em class="jxr_comment">// Assert that adding a too-big buffer won't happen</em>
-<a class="jxr_linenumber" name="80" href="#80">80</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="80" href="#80">80</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="81" href="#81">81</a>      <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(ByteBuffer.allocate(maxByteBufferSizeToCache * 2));
-<a class="jxr_linenumber" name="82" href="#82">82</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="82" href="#82">82</a>      assertEquals(0, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="83" href="#83">83</a>      <em class="jxr_comment">// Assert we can't add more than max allowed instances.</em>
 <a class="jxr_linenumber" name="84" href="#84">84</a>      <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; maxToCache; i++) {
 <a class="jxr_linenumber" name="85" href="#85">85</a>        <strong class="jxr_keyword">this</strong>.reservoir.putBuffer(ByteBuffer.allocate(initialByteBufferSize));
 <a class="jxr_linenumber" name="86" href="#86">86</a>      }
-<a class="jxr_linenumber" name="87" href="#87">87</a>      assertEquals(maxToCache, <strong class="jxr_keyword">this</strong>.reservoir.buffers.size());
+<a class="jxr_linenumber" name="87" href="#87">87</a>      assertEquals(maxToCache, <strong class="jxr_keyword">this</strong>.reservoir.getQueueSize());
 <a class="jxr_linenumber" name="88" href="#88">88</a>    }
 <a class="jxr_linenumber" name="89" href="#89">89</a>  
 <a class="jxr_linenumber" name="90" href="#90">90</a>    @Test
@@ -154,7 +154,7 @@
 <a class="jxr_linenumber" name="144" href="#144">144</a>     }
 <a class="jxr_linenumber" name="145" href="#145">145</a>     <em class="jxr_comment">// None of the BBs we got from pool is growing while in use. So we should not change the</em>
 <a class="jxr_linenumber" name="146" href="#146">146</a>     <em class="jxr_comment">// runningAverage in pool</em>
-<a class="jxr_linenumber" name="147" href="#147">147</a>     assertEquals(initialByteBufferSize, <strong class="jxr_keyword">this</strong>.reservoir.runningAverage);
+<a class="jxr_linenumber" name="147" href="#147">147</a>     assertEquals(initialByteBufferSize, <strong class="jxr_keyword">this</strong>.reservoir.getRunningAverage());
 <a class="jxr_linenumber" name="148" href="#148">148</a>   }
 <a class="jxr_linenumber" name="149" href="#149">149</a> }
 </pre>


Mime
View raw message