hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [04/20] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Wed, 17 May 2017 14:58:12 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/986c93ca/testdevapidocs/src-html/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.html
index d262284..25f3605 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.html
@@ -38,247 +38,258 @@
 <span class="sourceLineNo">030</span><a name="line.30"></a>
 <span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.HBaseTestingUtility;<a name="line.31"></a>
 <span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.TableName;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.util.Pair;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.junit.AfterClass;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.junit.BeforeClass;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.junit.Test;<a name="line.37"></a>
-<span class="sourceLineNo">038</span><a name="line.38"></a>
-<span class="sourceLineNo">039</span>public abstract class AbstractTestAsyncTableScan {<a name="line.39"></a>
-<span class="sourceLineNo">040</span><a name="line.40"></a>
-<span class="sourceLineNo">041</span>  protected static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();<a name="line.41"></a>
-<span class="sourceLineNo">042</span><a name="line.42"></a>
-<span class="sourceLineNo">043</span>  protected static TableName TABLE_NAME = TableName.valueOf("async");<a name="line.43"></a>
-<span class="sourceLineNo">044</span><a name="line.44"></a>
-<span class="sourceLineNo">045</span>  protected static byte[] FAMILY = Bytes.toBytes("cf");<a name="line.45"></a>
-<span class="sourceLineNo">046</span><a name="line.46"></a>
-<span class="sourceLineNo">047</span>  protected static byte[] CQ1 = Bytes.toBytes("cq1");<a name="line.47"></a>
-<span class="sourceLineNo">048</span><a name="line.48"></a>
-<span class="sourceLineNo">049</span>  protected static byte[] CQ2 = Bytes.toBytes("cq2");<a name="line.49"></a>
-<span class="sourceLineNo">050</span><a name="line.50"></a>
-<span class="sourceLineNo">051</span>  protected static int COUNT = 1000;<a name="line.51"></a>
-<span class="sourceLineNo">052</span><a name="line.52"></a>
-<span class="sourceLineNo">053</span>  protected static AsyncConnection ASYNC_CONN;<a name="line.53"></a>
-<span class="sourceLineNo">054</span><a name="line.54"></a>
-<span class="sourceLineNo">055</span>  @BeforeClass<a name="line.55"></a>
-<span class="sourceLineNo">056</span>  public static void setUp() throws Exception {<a name="line.56"></a>
-<span class="sourceLineNo">057</span>    TEST_UTIL.startMiniCluster(3);<a name="line.57"></a>
-<span class="sourceLineNo">058</span>    byte[][] splitKeys = new byte[8][];<a name="line.58"></a>
-<span class="sourceLineNo">059</span>    for (int i = 111; i &lt; 999; i += 111) {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>      splitKeys[i / 111 - 1] = Bytes.toBytes(String.format("%03d", i));<a name="line.60"></a>
-<span class="sourceLineNo">061</span>    }<a name="line.61"></a>
-<span class="sourceLineNo">062</span>    TEST_UTIL.createTable(TABLE_NAME, FAMILY, splitKeys);<a name="line.62"></a>
-<span class="sourceLineNo">063</span>    TEST_UTIL.waitTableAvailable(TABLE_NAME);<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    ASYNC_CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    ASYNC_CONN.getRawTable(TABLE_NAME).putAll(IntStream.range(0, COUNT)<a name="line.65"></a>
-<span class="sourceLineNo">066</span>        .mapToObj(i -&gt; new Put(Bytes.toBytes(String.format("%03d", i)))<a name="line.66"></a>
-<span class="sourceLineNo">067</span>            .addColumn(FAMILY, CQ1, Bytes.toBytes(i)).addColumn(FAMILY, CQ2, Bytes.toBytes(i * i)))<a name="line.67"></a>
-<span class="sourceLineNo">068</span>        .collect(Collectors.toList())).get();<a name="line.68"></a>
-<span class="sourceLineNo">069</span>  }<a name="line.69"></a>
-<span class="sourceLineNo">070</span><a name="line.70"></a>
-<span class="sourceLineNo">071</span>  @AfterClass<a name="line.71"></a>
-<span class="sourceLineNo">072</span>  public static void tearDown() throws Exception {<a name="line.72"></a>
-<span class="sourceLineNo">073</span>    ASYNC_CONN.close();<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    TEST_UTIL.shutdownMiniCluster();<a name="line.74"></a>
-<span class="sourceLineNo">075</span>  }<a name="line.75"></a>
-<span class="sourceLineNo">076</span><a name="line.76"></a>
-<span class="sourceLineNo">077</span>  protected static Scan createNormalScan() {<a name="line.77"></a>
-<span class="sourceLineNo">078</span>    return new Scan();<a name="line.78"></a>
-<span class="sourceLineNo">079</span>  }<a name="line.79"></a>
-<span class="sourceLineNo">080</span><a name="line.80"></a>
-<span class="sourceLineNo">081</span>  protected static Scan createBatchScan() {<a name="line.81"></a>
-<span class="sourceLineNo">082</span>    return new Scan().setBatch(1);<a name="line.82"></a>
-<span class="sourceLineNo">083</span>  }<a name="line.83"></a>
-<span class="sourceLineNo">084</span><a name="line.84"></a>
-<span class="sourceLineNo">085</span>  // set a small result size for testing flow control<a name="line.85"></a>
-<span class="sourceLineNo">086</span>  protected static Scan createSmallResultSizeScan() {<a name="line.86"></a>
-<span class="sourceLineNo">087</span>    return new Scan().setMaxResultSize(1);<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  }<a name="line.88"></a>
-<span class="sourceLineNo">089</span><a name="line.89"></a>
-<span class="sourceLineNo">090</span>  protected static Scan createBatchSmallResultSizeScan() {<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    return new Scan().setBatch(1).setMaxResultSize(1);<a name="line.91"></a>
-<span class="sourceLineNo">092</span>  }<a name="line.92"></a>
-<span class="sourceLineNo">093</span><a name="line.93"></a>
-<span class="sourceLineNo">094</span>  protected static List&lt;Pair&lt;String, Supplier&lt;Scan&gt;&gt;&gt; getScanCreater() {<a name="line.94"></a>
-<span class="sourceLineNo">095</span>    return Arrays.asList(Pair.newPair("normal", AbstractTestAsyncTableScan::createNormalScan),<a name="line.95"></a>
-<span class="sourceLineNo">096</span>      Pair.newPair("batch", AbstractTestAsyncTableScan::createBatchScan),<a name="line.96"></a>
-<span class="sourceLineNo">097</span>      Pair.newPair("smallResultSize", AbstractTestAsyncTableScan::createSmallResultSizeScan),<a name="line.97"></a>
-<span class="sourceLineNo">098</span>      Pair.newPair("batchSmallResultSize",<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        AbstractTestAsyncTableScan::createBatchSmallResultSizeScan));<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  }<a name="line.100"></a>
-<span class="sourceLineNo">101</span><a name="line.101"></a>
-<span class="sourceLineNo">102</span>  protected abstract Scan createScan();<a name="line.102"></a>
-<span class="sourceLineNo">103</span><a name="line.103"></a>
-<span class="sourceLineNo">104</span>  protected abstract List&lt;Result&gt; doScan(Scan scan) throws Exception;<a name="line.104"></a>
-<span class="sourceLineNo">105</span><a name="line.105"></a>
-<span class="sourceLineNo">106</span>  protected final List&lt;Result&gt; convertFromBatchResult(List&lt;Result&gt; results) {<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    assertTrue(results.size() % 2 == 0);<a name="line.107"></a>
-<span class="sourceLineNo">108</span>    return IntStream.range(0, results.size() / 2).mapToObj(i -&gt; {<a name="line.108"></a>
-<span class="sourceLineNo">109</span>      try {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>        return Result<a name="line.110"></a>
-<span class="sourceLineNo">111</span>            .createCompleteResult(Arrays.asList(results.get(2 * i), results.get(2 * i + 1)));<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      } catch (IOException e) {<a name="line.112"></a>
-<span class="sourceLineNo">113</span>        throw new UncheckedIOException(e);<a name="line.113"></a>
-<span class="sourceLineNo">114</span>      }<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    }).collect(Collectors.toList());<a name="line.115"></a>
-<span class="sourceLineNo">116</span>  }<a name="line.116"></a>
-<span class="sourceLineNo">117</span><a name="line.117"></a>
-<span class="sourceLineNo">118</span>  @Test<a name="line.118"></a>
-<span class="sourceLineNo">119</span>  public void testScanAll() throws Exception {<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    List&lt;Result&gt; results = doScan(createScan());<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    // make sure all scanners are closed at RS side<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    TEST_UTIL.getHBaseCluster().getRegionServerThreads().stream().map(t -&gt; t.getRegionServer())<a name="line.122"></a>
-<span class="sourceLineNo">123</span>        .forEach(rs -&gt; assertEquals(<a name="line.123"></a>
-<span class="sourceLineNo">124</span>          "The scanner count of " + rs.getServerName() + " is " +<a name="line.124"></a>
-<span class="sourceLineNo">125</span>              rs.getRSRpcServices().getScannersCount(),<a name="line.125"></a>
-<span class="sourceLineNo">126</span>          0, rs.getRSRpcServices().getScannersCount()));<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    assertEquals(COUNT, results.size());<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    IntStream.range(0, COUNT).forEach(i -&gt; {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>      Result result = results.get(i);<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      assertEquals(String.format("%03d", i), Bytes.toString(result.getRow()));<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      assertEquals(i, Bytes.toInt(result.getValue(FAMILY, CQ1)));<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    });<a name="line.132"></a>
-<span class="sourceLineNo">133</span>  }<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>  private void assertResultEquals(Result result, int i) {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>    assertEquals(String.format("%03d", i), Bytes.toString(result.getRow()));<a name="line.136"></a>
-<span class="sourceLineNo">137</span>    assertEquals(i, Bytes.toInt(result.getValue(FAMILY, CQ1)));<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    assertEquals(i * i, Bytes.toInt(result.getValue(FAMILY, CQ2)));<a name="line.138"></a>
-<span class="sourceLineNo">139</span>  }<a name="line.139"></a>
-<span class="sourceLineNo">140</span><a name="line.140"></a>
-<span class="sourceLineNo">141</span>  @Test<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  public void testReversedScanAll() throws Exception {<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    List&lt;Result&gt; results = doScan(createScan().setReversed(true));<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    assertEquals(COUNT, results.size());<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    IntStream.range(0, COUNT).forEach(i -&gt; assertResultEquals(results.get(i), COUNT - i - 1));<a name="line.145"></a>
-<span class="sourceLineNo">146</span>  }<a name="line.146"></a>
-<span class="sourceLineNo">147</span><a name="line.147"></a>
-<span class="sourceLineNo">148</span>  @Test<a name="line.148"></a>
-<span class="sourceLineNo">149</span>  public void testScanNoStopKey() throws Exception {<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    int start = 345;<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    List&lt;Result&gt; results =<a name="line.151"></a>
-<span class="sourceLineNo">152</span>        doScan(createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))));<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    assertEquals(COUNT - start, results.size());<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    IntStream.range(0, COUNT - start).forEach(i -&gt; assertResultEquals(results.get(i), start + i));<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>  @Test<a name="line.157"></a>
-<span class="sourceLineNo">158</span>  public void testReverseScanNoStopKey() throws Exception {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    int start = 765;<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    List&lt;Result&gt; results = doScan(<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))).setReversed(true));<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    assertEquals(start + 1, results.size());<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    IntStream.range(0, start + 1).forEach(i -&gt; assertResultEquals(results.get(i), start - i));<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>  private void testScan(int start, boolean startInclusive, int stop, boolean stopInclusive,<a name="line.166"></a>
-<span class="sourceLineNo">167</span>      int limit) throws Exception {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    Scan scan =<a name="line.168"></a>
-<span class="sourceLineNo">169</span>        createScan().withStartRow(Bytes.toBytes(String.format("%03d", start)), startInclusive)<a name="line.169"></a>
-<span class="sourceLineNo">170</span>            .withStopRow(Bytes.toBytes(String.format("%03d", stop)), stopInclusive);<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    if (limit &gt; 0) {<a name="line.171"></a>
-<span class="sourceLineNo">172</span>      scan.setLimit(limit);<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    }<a name="line.173"></a>
-<span class="sourceLineNo">174</span>    List&lt;Result&gt; results = doScan(scan);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    int actualStart = startInclusive ? start : start + 1;<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    int actualStop = stopInclusive ? stop + 1 : stop;<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    int count = actualStop - actualStart;<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    if (limit &gt; 0) {<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      count = Math.min(count, limit);<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    }<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    assertEquals(count, results.size());<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    IntStream.range(0, count).forEach(i -&gt; assertResultEquals(results.get(i), actualStart + i));<a name="line.182"></a>
-<span class="sourceLineNo">183</span>  }<a name="line.183"></a>
-<span class="sourceLineNo">184</span><a name="line.184"></a>
-<span class="sourceLineNo">185</span>  private void testReversedScan(int start, boolean startInclusive, int stop, boolean stopInclusive,<a name="line.185"></a>
-<span class="sourceLineNo">186</span>      int limit) throws Exception {<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    Scan scan = createScan()<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        .withStartRow(Bytes.toBytes(String.format("%03d", start)), startInclusive)<a name="line.188"></a>
-<span class="sourceLineNo">189</span>        .withStopRow(Bytes.toBytes(String.format("%03d", stop)), stopInclusive).setReversed(true);<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    if (limit &gt; 0) {<a name="line.190"></a>
-<span class="sourceLineNo">191</span>      scan.setLimit(limit);<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    }<a name="line.192"></a>
-<span class="sourceLineNo">193</span>    List&lt;Result&gt; results = doScan(scan);<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    int actualStart = startInclusive ? start : start - 1;<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    int actualStop = stopInclusive ? stop - 1 : stop;<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    int count = actualStart - actualStop;<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    if (limit &gt; 0) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>      count = Math.min(count, limit);<a name="line.198"></a>
-<span class="sourceLineNo">199</span>    }<a name="line.199"></a>
-<span class="sourceLineNo">200</span>    assertEquals(count, results.size());<a name="line.200"></a>
-<span class="sourceLineNo">201</span>    IntStream.range(0, count).forEach(i -&gt; assertResultEquals(results.get(i), actualStart - i));<a name="line.201"></a>
-<span class="sourceLineNo">202</span>  }<a name="line.202"></a>
-<span class="sourceLineNo">203</span><a name="line.203"></a>
-<span class="sourceLineNo">204</span>  @Test<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  public void testScanWithStartKeyAndStopKey() throws Exception {<a name="line.205"></a>
-<span class="sourceLineNo">206</span>    testScan(1, true, 998, false, -1); // from first region to last region<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    testScan(123, true, 345, true, -1);<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    testScan(234, true, 456, false, -1);<a name="line.208"></a>
-<span class="sourceLineNo">209</span>    testScan(345, false, 567, true, -1);<a name="line.209"></a>
-<span class="sourceLineNo">210</span>    testScan(456, false, 678, false, -1);<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>  @Test<a name="line.213"></a>
-<span class="sourceLineNo">214</span>  public void testReversedScanWithStartKeyAndStopKey() throws Exception {<a name="line.214"></a>
-<span class="sourceLineNo">215</span>    testReversedScan(998, true, 1, false, -1); // from last region to first region<a name="line.215"></a>
-<span class="sourceLineNo">216</span>    testReversedScan(543, true, 321, true, -1);<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    testReversedScan(654, true, 432, false, -1);<a name="line.217"></a>
-<span class="sourceLineNo">218</span>    testReversedScan(765, false, 543, true, -1);<a name="line.218"></a>
-<span class="sourceLineNo">219</span>    testReversedScan(876, false, 654, false, -1);<a name="line.219"></a>
-<span class="sourceLineNo">220</span>  }<a name="line.220"></a>
-<span class="sourceLineNo">221</span><a name="line.221"></a>
-<span class="sourceLineNo">222</span>  @Test<a name="line.222"></a>
-<span class="sourceLineNo">223</span>  public void testScanAtRegionBoundary() throws Exception {<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    testScan(222, true, 333, true, -1);<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    testScan(333, true, 444, false, -1);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>    testScan(444, false, 555, true, -1);<a name="line.226"></a>
-<span class="sourceLineNo">227</span>    testScan(555, false, 666, false, -1);<a name="line.227"></a>
-<span class="sourceLineNo">228</span>  }<a name="line.228"></a>
-<span class="sourceLineNo">229</span><a name="line.229"></a>
-<span class="sourceLineNo">230</span>  @Test<a name="line.230"></a>
-<span class="sourceLineNo">231</span>  public void testReversedScanAtRegionBoundary() throws Exception {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>    testReversedScan(333, true, 222, true, -1);<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    testReversedScan(444, true, 333, false, -1);<a name="line.233"></a>
-<span class="sourceLineNo">234</span>    testReversedScan(555, false, 444, true, -1);<a name="line.234"></a>
-<span class="sourceLineNo">235</span>    testReversedScan(666, false, 555, false, -1);<a name="line.235"></a>
-<span class="sourceLineNo">236</span>  }<a name="line.236"></a>
-<span class="sourceLineNo">237</span><a name="line.237"></a>
-<span class="sourceLineNo">238</span>  @Test<a name="line.238"></a>
-<span class="sourceLineNo">239</span>  public void testScanWithLimit() throws Exception {<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    testScan(1, true, 998, false, 900); // from first region to last region<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    testScan(123, true, 234, true, 100);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>    testScan(234, true, 456, false, 100);<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    testScan(345, false, 567, true, 100);<a name="line.243"></a>
-<span class="sourceLineNo">244</span>    testScan(456, false, 678, false, 100);<a name="line.244"></a>
-<span class="sourceLineNo">245</span>  }<a name="line.245"></a>
-<span class="sourceLineNo">246</span><a name="line.246"></a>
-<span class="sourceLineNo">247</span>  @Test<a name="line.247"></a>
-<span class="sourceLineNo">248</span>  public void testScanWithLimitGreaterThanActualCount() throws Exception {<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    testScan(1, true, 998, false, 1000); // from first region to last region<a name="line.249"></a>
-<span class="sourceLineNo">250</span>    testScan(123, true, 345, true, 200);<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    testScan(234, true, 456, false, 200);<a name="line.251"></a>
-<span class="sourceLineNo">252</span>    testScan(345, false, 567, true, 200);<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    testScan(456, false, 678, false, 200);<a name="line.253"></a>
-<span class="sourceLineNo">254</span>  }<a name="line.254"></a>
-<span class="sourceLineNo">255</span><a name="line.255"></a>
-<span class="sourceLineNo">256</span>  @Test<a name="line.256"></a>
-<span class="sourceLineNo">257</span>  public void testReversedScanWithLimit() throws Exception {<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    testReversedScan(998, true, 1, false, 900); // from last region to first region<a name="line.258"></a>
-<span class="sourceLineNo">259</span>    testReversedScan(543, true, 321, true, 100);<a name="line.259"></a>
-<span class="sourceLineNo">260</span>    testReversedScan(654, true, 432, false, 100);<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    testReversedScan(765, false, 543, true, 100);<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    testReversedScan(876, false, 654, false, 100);<a name="line.262"></a>
-<span class="sourceLineNo">263</span>  }<a name="line.263"></a>
-<span class="sourceLineNo">264</span><a name="line.264"></a>
-<span class="sourceLineNo">265</span>  @Test<a name="line.265"></a>
-<span class="sourceLineNo">266</span>  public void testReversedScanWithLimitGreaterThanActualCount() throws Exception {<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    testReversedScan(998, true, 1, false, 1000); // from last region to first region<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    testReversedScan(543, true, 321, true, 200);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>    testReversedScan(654, true, 432, false, 200);<a name="line.269"></a>
-<span class="sourceLineNo">270</span>    testReversedScan(765, false, 543, true, 200);<a name="line.270"></a>
-<span class="sourceLineNo">271</span>    testReversedScan(876, false, 654, false, 200);<a name="line.271"></a>
-<span class="sourceLineNo">272</span>  }<a name="line.272"></a>
-<span class="sourceLineNo">273</span>}<a name="line.273"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.util.Pair;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.junit.AfterClass;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.junit.BeforeClass;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.junit.Test;<a name="line.38"></a>
+<span class="sourceLineNo">039</span><a name="line.39"></a>
+<span class="sourceLineNo">040</span>public abstract class AbstractTestAsyncTableScan {<a name="line.40"></a>
+<span class="sourceLineNo">041</span><a name="line.41"></a>
+<span class="sourceLineNo">042</span>  protected static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>  protected static TableName TABLE_NAME = TableName.valueOf("async");<a name="line.44"></a>
+<span class="sourceLineNo">045</span><a name="line.45"></a>
+<span class="sourceLineNo">046</span>  protected static byte[] FAMILY = Bytes.toBytes("cf");<a name="line.46"></a>
+<span class="sourceLineNo">047</span><a name="line.47"></a>
+<span class="sourceLineNo">048</span>  protected static byte[] CQ1 = Bytes.toBytes("cq1");<a name="line.48"></a>
+<span class="sourceLineNo">049</span><a name="line.49"></a>
+<span class="sourceLineNo">050</span>  protected static byte[] CQ2 = Bytes.toBytes("cq2");<a name="line.50"></a>
+<span class="sourceLineNo">051</span><a name="line.51"></a>
+<span class="sourceLineNo">052</span>  protected static int COUNT = 1000;<a name="line.52"></a>
+<span class="sourceLineNo">053</span><a name="line.53"></a>
+<span class="sourceLineNo">054</span>  protected static AsyncConnection ASYNC_CONN;<a name="line.54"></a>
+<span class="sourceLineNo">055</span><a name="line.55"></a>
+<span class="sourceLineNo">056</span>  @BeforeClass<a name="line.56"></a>
+<span class="sourceLineNo">057</span>  public static void setUp() throws Exception {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    TEST_UTIL.startMiniCluster(3);<a name="line.58"></a>
+<span class="sourceLineNo">059</span>    byte[][] splitKeys = new byte[8][];<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    for (int i = 111; i &lt; 999; i += 111) {<a name="line.60"></a>
+<span class="sourceLineNo">061</span>      splitKeys[i / 111 - 1] = Bytes.toBytes(String.format("%03d", i));<a name="line.61"></a>
+<span class="sourceLineNo">062</span>    }<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    TEST_UTIL.createTable(TABLE_NAME, FAMILY, splitKeys);<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    TEST_UTIL.waitTableAvailable(TABLE_NAME);<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    ASYNC_CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get();<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    ASYNC_CONN.getRawTable(TABLE_NAME).putAll(IntStream.range(0, COUNT)<a name="line.66"></a>
+<span class="sourceLineNo">067</span>        .mapToObj(i -&gt; new Put(Bytes.toBytes(String.format("%03d", i)))<a name="line.67"></a>
+<span class="sourceLineNo">068</span>            .addColumn(FAMILY, CQ1, Bytes.toBytes(i)).addColumn(FAMILY, CQ2, Bytes.toBytes(i * i)))<a name="line.68"></a>
+<span class="sourceLineNo">069</span>        .collect(Collectors.toList())).get();<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>  @AfterClass<a name="line.72"></a>
+<span class="sourceLineNo">073</span>  public static void tearDown() throws Exception {<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    ASYNC_CONN.close();<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    TEST_UTIL.shutdownMiniCluster();<a name="line.75"></a>
+<span class="sourceLineNo">076</span>  }<a name="line.76"></a>
+<span class="sourceLineNo">077</span><a name="line.77"></a>
+<span class="sourceLineNo">078</span>  protected static Scan createNormalScan() {<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    return new Scan();<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  }<a name="line.80"></a>
+<span class="sourceLineNo">081</span><a name="line.81"></a>
+<span class="sourceLineNo">082</span>  protected static Scan createBatchScan() {<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    return new Scan().setBatch(1);<a name="line.83"></a>
+<span class="sourceLineNo">084</span>  }<a name="line.84"></a>
+<span class="sourceLineNo">085</span><a name="line.85"></a>
+<span class="sourceLineNo">086</span>  // set a small result size for testing flow control<a name="line.86"></a>
+<span class="sourceLineNo">087</span>  protected static Scan createSmallResultSizeScan() {<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    return new Scan().setMaxResultSize(1);<a name="line.88"></a>
+<span class="sourceLineNo">089</span>  }<a name="line.89"></a>
+<span class="sourceLineNo">090</span><a name="line.90"></a>
+<span class="sourceLineNo">091</span>  protected static Scan createBatchSmallResultSizeScan() {<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    return new Scan().setBatch(1).setMaxResultSize(1);<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>  protected static List&lt;Pair&lt;String, Supplier&lt;Scan&gt;&gt;&gt; getScanCreater() {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    return Arrays.asList(Pair.newPair("normal", AbstractTestAsyncTableScan::createNormalScan),<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      Pair.newPair("batch", AbstractTestAsyncTableScan::createBatchScan),<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      Pair.newPair("smallResultSize", AbstractTestAsyncTableScan::createSmallResultSizeScan),<a name="line.98"></a>
+<span class="sourceLineNo">099</span>      Pair.newPair("batchSmallResultSize",<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        AbstractTestAsyncTableScan::createBatchSmallResultSizeScan));<a name="line.100"></a>
+<span class="sourceLineNo">101</span>  }<a name="line.101"></a>
+<span class="sourceLineNo">102</span><a name="line.102"></a>
+<span class="sourceLineNo">103</span>  protected abstract Scan createScan();<a name="line.103"></a>
+<span class="sourceLineNo">104</span><a name="line.104"></a>
+<span class="sourceLineNo">105</span>  protected abstract List&lt;Result&gt; doScan(Scan scan) throws Exception;<a name="line.105"></a>
+<span class="sourceLineNo">106</span><a name="line.106"></a>
+<span class="sourceLineNo">107</span>  protected final List&lt;Result&gt; convertFromBatchResult(List&lt;Result&gt; results) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    assertTrue(results.size() % 2 == 0);<a name="line.108"></a>
+<span class="sourceLineNo">109</span>    return IntStream.range(0, results.size() / 2).mapToObj(i -&gt; {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>      try {<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        return Result<a name="line.111"></a>
+<span class="sourceLineNo">112</span>            .createCompleteResult(Arrays.asList(results.get(2 * i), results.get(2 * i + 1)));<a name="line.112"></a>
+<span class="sourceLineNo">113</span>      } catch (IOException e) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>        throw new UncheckedIOException(e);<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      }<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    }).collect(Collectors.toList());<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<a name="line.119"></a>
+<span class="sourceLineNo">120</span>  public void testScanAll() throws Exception {<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    List&lt;Result&gt; results = doScan(createScan());<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    // make sure all scanners are closed at RS side<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    TEST_UTIL.getHBaseCluster().getRegionServerThreads().stream().map(t -&gt; t.getRegionServer())<a name="line.123"></a>
+<span class="sourceLineNo">124</span>        .forEach(rs -&gt; assertEquals(<a name="line.124"></a>
+<span class="sourceLineNo">125</span>          "The scanner count of " + rs.getServerName() + " is " +<a name="line.125"></a>
+<span class="sourceLineNo">126</span>              rs.getRSRpcServices().getScannersCount(),<a name="line.126"></a>
+<span class="sourceLineNo">127</span>          0, rs.getRSRpcServices().getScannersCount()));<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    assertEquals(COUNT, results.size());<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    IntStream.range(0, COUNT).forEach(i -&gt; {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>      Result result = results.get(i);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>      assertEquals(String.format("%03d", i), Bytes.toString(result.getRow()));<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      assertEquals(i, Bytes.toInt(result.getValue(FAMILY, CQ1)));<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    });<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  }<a name="line.134"></a>
+<span class="sourceLineNo">135</span><a name="line.135"></a>
+<span class="sourceLineNo">136</span>  private void assertResultEquals(Result result, int i) {<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    assertEquals(String.format("%03d", i), Bytes.toString(result.getRow()));<a name="line.137"></a>
+<span class="sourceLineNo">138</span>    assertEquals(i, Bytes.toInt(result.getValue(FAMILY, CQ1)));<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    assertEquals(i * i, Bytes.toInt(result.getValue(FAMILY, CQ2)));<a name="line.139"></a>
+<span class="sourceLineNo">140</span>  }<a name="line.140"></a>
+<span class="sourceLineNo">141</span><a name="line.141"></a>
+<span class="sourceLineNo">142</span>  @Test<a name="line.142"></a>
+<span class="sourceLineNo">143</span>  public void testReversedScanAll() throws Exception {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    List&lt;Result&gt; results = doScan(createScan().setReversed(true));<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    assertEquals(COUNT, results.size());<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    IntStream.range(0, COUNT).forEach(i -&gt; assertResultEquals(results.get(i), COUNT - i - 1));<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>  @Test<a name="line.149"></a>
+<span class="sourceLineNo">150</span>  public void testScanNoStopKey() throws Exception {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    int start = 345;<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    List&lt;Result&gt; results =<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        doScan(createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))));<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    assertEquals(COUNT - start, results.size());<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    IntStream.range(0, COUNT - start).forEach(i -&gt; assertResultEquals(results.get(i), start + i));<a name="line.155"></a>
+<span class="sourceLineNo">156</span>  }<a name="line.156"></a>
+<span class="sourceLineNo">157</span><a name="line.157"></a>
+<span class="sourceLineNo">158</span>  @Test<a name="line.158"></a>
+<span class="sourceLineNo">159</span>  public void testReverseScanNoStopKey() throws Exception {<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    int start = 765;<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    List&lt;Result&gt; results = doScan(<a name="line.161"></a>
+<span class="sourceLineNo">162</span>      createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))).setReversed(true));<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    assertEquals(start + 1, results.size());<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    IntStream.range(0, start + 1).forEach(i -&gt; assertResultEquals(results.get(i), start - i));<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>  @Test<a name="line.167"></a>
+<span class="sourceLineNo">168</span>  public void testScanWrongColumnFamily() throws Exception {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    try {<a name="line.169"></a>
+<span class="sourceLineNo">170</span>      doScan(createScan().addFamily(Bytes.toBytes("WrongColumnFamily")));<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    } catch (Exception e) {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      assertTrue(e instanceof NoSuchColumnFamilyException<a name="line.172"></a>
+<span class="sourceLineNo">173</span>          || e.getCause() instanceof NoSuchColumnFamilyException);<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    }<a name="line.174"></a>
+<span class="sourceLineNo">175</span>  }<a name="line.175"></a>
+<span class="sourceLineNo">176</span><a name="line.176"></a>
+<span class="sourceLineNo">177</span>  private void testScan(int start, boolean startInclusive, int stop, boolean stopInclusive,<a name="line.177"></a>
+<span class="sourceLineNo">178</span>      int limit) throws Exception {<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    Scan scan =<a name="line.179"></a>
+<span class="sourceLineNo">180</span>        createScan().withStartRow(Bytes.toBytes(String.format("%03d", start)), startInclusive)<a name="line.180"></a>
+<span class="sourceLineNo">181</span>            .withStopRow(Bytes.toBytes(String.format("%03d", stop)), stopInclusive);<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    if (limit &gt; 0) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      scan.setLimit(limit);<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    }<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    List&lt;Result&gt; results = doScan(scan);<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    int actualStart = startInclusive ? start : start + 1;<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    int actualStop = stopInclusive ? stop + 1 : stop;<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    int count = actualStop - actualStart;<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    if (limit &gt; 0) {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      count = Math.min(count, limit);<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    }<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    assertEquals(count, results.size());<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    IntStream.range(0, count).forEach(i -&gt; assertResultEquals(results.get(i), actualStart + i));<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  }<a name="line.194"></a>
+<span class="sourceLineNo">195</span><a name="line.195"></a>
+<span class="sourceLineNo">196</span>  private void testReversedScan(int start, boolean startInclusive, int stop, boolean stopInclusive,<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      int limit) throws Exception {<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    Scan scan = createScan()<a name="line.198"></a>
+<span class="sourceLineNo">199</span>        .withStartRow(Bytes.toBytes(String.format("%03d", start)), startInclusive)<a name="line.199"></a>
+<span class="sourceLineNo">200</span>        .withStopRow(Bytes.toBytes(String.format("%03d", stop)), stopInclusive).setReversed(true);<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    if (limit &gt; 0) {<a name="line.201"></a>
+<span class="sourceLineNo">202</span>      scan.setLimit(limit);<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    }<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    List&lt;Result&gt; results = doScan(scan);<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    int actualStart = startInclusive ? start : start - 1;<a name="line.205"></a>
+<span class="sourceLineNo">206</span>    int actualStop = stopInclusive ? stop - 1 : stop;<a name="line.206"></a>
+<span class="sourceLineNo">207</span>    int count = actualStart - actualStop;<a name="line.207"></a>
+<span class="sourceLineNo">208</span>    if (limit &gt; 0) {<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      count = Math.min(count, limit);<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>    assertEquals(count, results.size());<a name="line.211"></a>
+<span class="sourceLineNo">212</span>    IntStream.range(0, count).forEach(i -&gt; assertResultEquals(results.get(i), actualStart - i));<a name="line.212"></a>
+<span class="sourceLineNo">213</span>  }<a name="line.213"></a>
+<span class="sourceLineNo">214</span><a name="line.214"></a>
+<span class="sourceLineNo">215</span>  @Test<a name="line.215"></a>
+<span class="sourceLineNo">216</span>  public void testScanWithStartKeyAndStopKey() throws Exception {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>    testScan(1, true, 998, false, -1); // from first region to last region<a name="line.217"></a>
+<span class="sourceLineNo">218</span>    testScan(123, true, 345, true, -1);<a name="line.218"></a>
+<span class="sourceLineNo">219</span>    testScan(234, true, 456, false, -1);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>    testScan(345, false, 567, true, -1);<a name="line.220"></a>
+<span class="sourceLineNo">221</span>    testScan(456, false, 678, false, -1);<a name="line.221"></a>
+<span class="sourceLineNo">222</span>  }<a name="line.222"></a>
+<span class="sourceLineNo">223</span><a name="line.223"></a>
+<span class="sourceLineNo">224</span>  @Test<a name="line.224"></a>
+<span class="sourceLineNo">225</span>  public void testReversedScanWithStartKeyAndStopKey() throws Exception {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    testReversedScan(998, true, 1, false, -1); // from last region to first region<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    testReversedScan(543, true, 321, true, -1);<a name="line.227"></a>
+<span class="sourceLineNo">228</span>    testReversedScan(654, true, 432, false, -1);<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    testReversedScan(765, false, 543, true, -1);<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    testReversedScan(876, false, 654, false, -1);<a name="line.230"></a>
+<span class="sourceLineNo">231</span>  }<a name="line.231"></a>
+<span class="sourceLineNo">232</span><a name="line.232"></a>
+<span class="sourceLineNo">233</span>  @Test<a name="line.233"></a>
+<span class="sourceLineNo">234</span>  public void testScanAtRegionBoundary() throws Exception {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>    testScan(222, true, 333, true, -1);<a name="line.235"></a>
+<span class="sourceLineNo">236</span>    testScan(333, true, 444, false, -1);<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    testScan(444, false, 555, true, -1);<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    testScan(555, false, 666, false, -1);<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>  @Test<a name="line.241"></a>
+<span class="sourceLineNo">242</span>  public void testReversedScanAtRegionBoundary() throws Exception {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>    testReversedScan(333, true, 222, true, -1);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>    testReversedScan(444, true, 333, false, -1);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    testReversedScan(555, false, 444, true, -1);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    testReversedScan(666, false, 555, false, -1);<a name="line.246"></a>
+<span class="sourceLineNo">247</span>  }<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>  @Test<a name="line.249"></a>
+<span class="sourceLineNo">250</span>  public void testScanWithLimit() throws Exception {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    testScan(1, true, 998, false, 900); // from first region to last region<a name="line.251"></a>
+<span class="sourceLineNo">252</span>    testScan(123, true, 234, true, 100);<a name="line.252"></a>
+<span class="sourceLineNo">253</span>    testScan(234, true, 456, false, 100);<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    testScan(345, false, 567, true, 100);<a name="line.254"></a>
+<span class="sourceLineNo">255</span>    testScan(456, false, 678, false, 100);<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>  @Test<a name="line.258"></a>
+<span class="sourceLineNo">259</span>  public void testScanWithLimitGreaterThanActualCount() throws Exception {<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    testScan(1, true, 998, false, 1000); // from first region to last region<a name="line.260"></a>
+<span class="sourceLineNo">261</span>    testScan(123, true, 345, true, 200);<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    testScan(234, true, 456, false, 200);<a name="line.262"></a>
+<span class="sourceLineNo">263</span>    testScan(345, false, 567, true, 200);<a name="line.263"></a>
+<span class="sourceLineNo">264</span>    testScan(456, false, 678, false, 200);<a name="line.264"></a>
+<span class="sourceLineNo">265</span>  }<a name="line.265"></a>
+<span class="sourceLineNo">266</span><a name="line.266"></a>
+<span class="sourceLineNo">267</span>  @Test<a name="line.267"></a>
+<span class="sourceLineNo">268</span>  public void testReversedScanWithLimit() throws Exception {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    testReversedScan(998, true, 1, false, 900); // from last region to first region<a name="line.269"></a>
+<span class="sourceLineNo">270</span>    testReversedScan(543, true, 321, true, 100);<a name="line.270"></a>
+<span class="sourceLineNo">271</span>    testReversedScan(654, true, 432, false, 100);<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    testReversedScan(765, false, 543, true, 100);<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    testReversedScan(876, false, 654, false, 100);<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 testReversedScanWithLimitGreaterThanActualCount() throws Exception {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>    testReversedScan(998, true, 1, false, 1000); // from last region to first region<a name="line.278"></a>
+<span class="sourceLineNo">279</span>    testReversedScan(543, true, 321, true, 200);<a name="line.279"></a>
+<span class="sourceLineNo">280</span>    testReversedScan(654, true, 432, false, 200);<a name="line.280"></a>
+<span class="sourceLineNo">281</span>    testReversedScan(765, false, 543, true, 200);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>    testReversedScan(876, false, 654, false, 200);<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>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/986c93ca/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.SimpleChildProcedure.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.SimpleChildProcedure.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.SimpleChildProcedure.html
index 9e2d08d..60a7ac6 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.SimpleChildProcedure.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestStateMachineProcedure.SimpleChildProcedure.html
@@ -101,105 +101,123 @@
 <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>  @Test<a name="line.95"></a>
-<span class="sourceLineNo">096</span>  public void testChildOnLastStep() {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    assertEquals(3, procExecutor.getEnvironment().execCount.get());<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    assertEquals(0, procExecutor.getEnvironment().rollbackCount.get());<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);<a name="line.101"></a>
-<span class="sourceLineNo">102</span>  }<a name="line.102"></a>
-<span class="sourceLineNo">103</span><a name="line.103"></a>
-<span class="sourceLineNo">104</span>  @Test<a name="line.104"></a>
-<span class="sourceLineNo">105</span>  public void testChildOnLastStepDoubleExecution() throws Exception {<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true);<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.107"></a>
-<span class="sourceLineNo">108</span>    ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId);<a name="line.108"></a>
-<span class="sourceLineNo">109</span>    assertEquals(6, procExecutor.getEnvironment().execCount.get());<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    assertEquals(0, procExecutor.getEnvironment().rollbackCount.get());<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);<a name="line.111"></a>
-<span class="sourceLineNo">112</span>  }<a name="line.112"></a>
-<span class="sourceLineNo">113</span><a name="line.113"></a>
-<span class="sourceLineNo">114</span>  @Test<a name="line.114"></a>
-<span class="sourceLineNo">115</span>  public void testChildOnLastStepWithRollback() {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    procExecutor.getEnvironment().triggerChildRollback = true;<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    assertEquals(3, procExecutor.getEnvironment().execCount.get());<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    assertEquals(3, procExecutor.getEnvironment().rollbackCount.get());<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    assertEquals(TEST_FAILURE_EXCEPTION, cause);<a name="line.122"></a>
-<span class="sourceLineNo">123</span>  }<a name="line.123"></a>
-<span class="sourceLineNo">124</span><a name="line.124"></a>
-<span class="sourceLineNo">125</span>  @Test<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  public void testChildOnLastStepWithRollbackDoubleExecution() throws Exception {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    procExecutor.getEnvironment().triggerChildRollback = true;<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true);<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    assertEquals(6, procExecutor.getEnvironment().execCount.get());<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    assertEquals(6, procExecutor.getEnvironment().rollbackCount.get());<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId);<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    assertEquals(TEST_FAILURE_EXCEPTION, cause);<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>  public enum TestSMProcedureState { STEP_1, STEP_2 };<a name="line.137"></a>
-<span class="sourceLineNo">138</span>  public static class TestSMProcedure<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      extends StateMachineProcedure&lt;TestProcEnv, TestSMProcedureState&gt; {<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    protected Flow executeFromState(TestProcEnv env, TestSMProcedureState state) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      LOG.info("EXEC " + state + " " + this);<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      env.execCount.incrementAndGet();<a name="line.142"></a>
-<span class="sourceLineNo">143</span>      switch (state) {<a name="line.143"></a>
-<span class="sourceLineNo">144</span>        case STEP_1:<a name="line.144"></a>
-<span class="sourceLineNo">145</span>          setNextState(TestSMProcedureState.STEP_2);<a name="line.145"></a>
-<span class="sourceLineNo">146</span>          break;<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        case STEP_2:<a name="line.147"></a>
-<span class="sourceLineNo">148</span>          addChildProcedure(new SimpleChildProcedure());<a name="line.148"></a>
-<span class="sourceLineNo">149</span>          return Flow.NO_MORE_STATE;<a name="line.149"></a>
-<span class="sourceLineNo">150</span>      }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      return Flow.HAS_MORE_STATE;<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    }<a name="line.152"></a>
-<span class="sourceLineNo">153</span><a name="line.153"></a>
-<span class="sourceLineNo">154</span>    protected void rollbackState(TestProcEnv env, TestSMProcedureState state) {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      LOG.info("ROLLBACK " + state + " " + this);<a name="line.155"></a>
-<span class="sourceLineNo">156</span>      env.rollbackCount.incrementAndGet();<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>    protected TestSMProcedureState getState(int stateId) {<a name="line.159"></a>
-<span class="sourceLineNo">160</span>      return TestSMProcedureState.values()[stateId];<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    }<a name="line.161"></a>
-<span class="sourceLineNo">162</span><a name="line.162"></a>
-<span class="sourceLineNo">163</span>    protected int getStateId(TestSMProcedureState state) {<a name="line.163"></a>
-<span class="sourceLineNo">164</span>      return state.ordinal();<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>    protected TestSMProcedureState getInitialState() {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      return TestSMProcedureState.STEP_1;<a name="line.168"></a>
+<span class="sourceLineNo">096</span>  public void testAbortStuckProcedure() throws InterruptedException {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    try {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      procExecutor.getEnvironment().loop = true;<a name="line.98"></a>
+<span class="sourceLineNo">099</span>      TestSMProcedure proc = new TestSMProcedure();<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      long procId = procExecutor.submitProcedure(proc);<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      Thread.sleep(1000 + (int) (Math.random() * 4001));<a name="line.101"></a>
+<span class="sourceLineNo">102</span>      proc.abort(procExecutor.getEnvironment());<a name="line.102"></a>
+<span class="sourceLineNo">103</span>      ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.103"></a>
+<span class="sourceLineNo">104</span>      assertEquals(true, proc.isFailed());<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    } finally {<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      procExecutor.getEnvironment().loop = false;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    }<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  }<a name="line.108"></a>
+<span class="sourceLineNo">109</span><a name="line.109"></a>
+<span class="sourceLineNo">110</span>  @Test<a name="line.110"></a>
+<span class="sourceLineNo">111</span>  public void testChildOnLastStep() {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    assertEquals(3, procExecutor.getEnvironment().execCount.get());<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    assertEquals(0, procExecutor.getEnvironment().rollbackCount.get());<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);<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<a name="line.119"></a>
+<span class="sourceLineNo">120</span>  public void testChildOnLastStepDoubleExecution() throws Exception {<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true);<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId);<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    assertEquals(6, procExecutor.getEnvironment().execCount.get());<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    assertEquals(0, procExecutor.getEnvironment().rollbackCount.get());<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);<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>  @Test<a name="line.129"></a>
+<span class="sourceLineNo">130</span>  public void testChildOnLastStepWithRollback() {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    procExecutor.getEnvironment().triggerChildRollback = true;<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    assertEquals(3, procExecutor.getEnvironment().execCount.get());<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    assertEquals(3, procExecutor.getEnvironment().rollbackCount.get());<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId);<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    assertEquals(TEST_FAILURE_EXCEPTION, cause);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
+<span class="sourceLineNo">139</span><a name="line.139"></a>
+<span class="sourceLineNo">140</span>  @Test<a name="line.140"></a>
+<span class="sourceLineNo">141</span>  public void testChildOnLastStepWithRollbackDoubleExecution() throws Exception {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    procExecutor.getEnvironment().triggerChildRollback = true;<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true);<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    long procId = procExecutor.submitProcedure(new TestSMProcedure());<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true);<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    assertEquals(6, procExecutor.getEnvironment().execCount.get());<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    assertEquals(6, procExecutor.getEnvironment().rollbackCount.get());<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    Throwable cause = ProcedureTestingUtility.assertProcFailed(procExecutor, procId);<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    assertEquals(TEST_FAILURE_EXCEPTION, cause);<a name="line.149"></a>
+<span class="sourceLineNo">150</span>  }<a name="line.150"></a>
+<span class="sourceLineNo">151</span><a name="line.151"></a>
+<span class="sourceLineNo">152</span>  public enum TestSMProcedureState { STEP_1, STEP_2 };<a name="line.152"></a>
+<span class="sourceLineNo">153</span>  public static class TestSMProcedure<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      extends StateMachineProcedure&lt;TestProcEnv, TestSMProcedureState&gt; {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    protected Flow executeFromState(TestProcEnv env, TestSMProcedureState state) {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      LOG.info("EXEC " + state + " " + this);<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      env.execCount.incrementAndGet();<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      switch (state) {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        case STEP_1:<a name="line.159"></a>
+<span class="sourceLineNo">160</span>          if (!env.loop) {<a name="line.160"></a>
+<span class="sourceLineNo">161</span>            setNextState(TestSMProcedureState.STEP_2);<a name="line.161"></a>
+<span class="sourceLineNo">162</span>          }<a name="line.162"></a>
+<span class="sourceLineNo">163</span>          break;<a name="line.163"></a>
+<span class="sourceLineNo">164</span>        case STEP_2:<a name="line.164"></a>
+<span class="sourceLineNo">165</span>          addChildProcedure(new SimpleChildProcedure());<a name="line.165"></a>
+<span class="sourceLineNo">166</span>          return Flow.NO_MORE_STATE;<a name="line.166"></a>
+<span class="sourceLineNo">167</span>      }<a name="line.167"></a>
+<span class="sourceLineNo">168</span>      return Flow.HAS_MORE_STATE;<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>  public static class SimpleChildProcedure extends NoopProcedure&lt;TestProcEnv&gt; {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    protected Procedure[] execute(TestProcEnv env) {<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      LOG.info("EXEC " + this);<a name="line.174"></a>
-<span class="sourceLineNo">175</span>      env.execCount.incrementAndGet();<a name="line.175"></a>
-<span class="sourceLineNo">176</span>      if (env.triggerChildRollback) {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>        setFailure("test-failure", TEST_FAILURE_EXCEPTION);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>      }<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      return null;<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>    protected void rollback(TestProcEnv env) {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      LOG.info("ROLLBACK " + this);<a name="line.184"></a>
-<span class="sourceLineNo">185</span>      env.rollbackCount.incrementAndGet();<a name="line.185"></a>
+<span class="sourceLineNo">170</span><a name="line.170"></a>
+<span class="sourceLineNo">171</span>    protected void rollbackState(TestProcEnv env, TestSMProcedureState state) {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      LOG.info("ROLLBACK " + state + " " + this);<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      env.rollbackCount.incrementAndGet();<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    }<a name="line.174"></a>
+<span class="sourceLineNo">175</span><a name="line.175"></a>
+<span class="sourceLineNo">176</span>    protected TestSMProcedureState getState(int stateId) {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>      return TestSMProcedureState.values()[stateId];<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>    protected int getStateId(TestSMProcedureState state) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      return state.ordinal();<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    }<a name="line.182"></a>
+<span class="sourceLineNo">183</span><a name="line.183"></a>
+<span class="sourceLineNo">184</span>    protected TestSMProcedureState getInitialState() {<a name="line.184"></a>
+<span class="sourceLineNo">185</span>      return TestSMProcedureState.STEP_1;<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>  public class TestProcEnv {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    AtomicInteger execCount = new AtomicInteger(0);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    AtomicInteger rollbackCount = new AtomicInteger(0);<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    boolean triggerChildRollback = false;<a name="line.192"></a>
-<span class="sourceLineNo">193</span>  }<a name="line.193"></a>
-<span class="sourceLineNo">194</span>}<a name="line.194"></a>
+<span class="sourceLineNo">189</span>  public static class SimpleChildProcedure extends NoopProcedure&lt;TestProcEnv&gt; {<a name="line.189"></a>
+<span class="sourceLineNo">190</span>    protected Procedure[] execute(TestProcEnv env) {<a name="line.190"></a>
+<span class="sourceLineNo">191</span>      LOG.info("EXEC " + this);<a name="line.191"></a>
+<span class="sourceLineNo">192</span>      env.execCount.incrementAndGet();<a name="line.192"></a>
+<span class="sourceLineNo">193</span>      if (env.triggerChildRollback) {<a name="line.193"></a>
+<span class="sourceLineNo">194</span>        setFailure("test-failure", TEST_FAILURE_EXCEPTION);<a name="line.194"></a>
+<span class="sourceLineNo">195</span>      }<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      return null;<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    }<a name="line.197"></a>
+<span class="sourceLineNo">198</span><a name="line.198"></a>
+<span class="sourceLineNo">199</span>    @Override<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    protected void rollback(TestProcEnv env) {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>      LOG.info("ROLLBACK " + this);<a name="line.201"></a>
+<span class="sourceLineNo">202</span>      env.rollbackCount.incrementAndGet();<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    }<a name="line.203"></a>
+<span class="sourceLineNo">204</span>  }<a name="line.204"></a>
+<span class="sourceLineNo">205</span><a name="line.205"></a>
+<span class="sourceLineNo">206</span>  public class TestProcEnv {<a name="line.206"></a>
+<span class="sourceLineNo">207</span>    AtomicInteger execCount = new AtomicInteger(0);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>    AtomicInteger rollbackCount = new AtomicInteger(0);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>    boolean triggerChildRollback = false;<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    boolean loop = false;<a name="line.210"></a>
+<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
+<span class="sourceLineNo">212</span>}<a name="line.212"></a>
 
 
 


Mime
View raw message