hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1709571 [2/9] - in /hbase/hbase.apache.org/trunk: ./ devapidocs/ devapidocs/org/apache/hadoop/hbase/classification/class-use/ devapidocs/org/apache/hadoop/hbase/io/hfile/ devapidocs/org/apache/hadoop/hbase/master/balancer/ devapidocs/org/a...
Date Tue, 20 Oct 2015 11:24:45 GMT
Modified: hbase/hbase.apache.org/trunk/xref-test/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html
URL: http://svn.apache.org/viewvc/hbase/hbase.apache.org/trunk/xref-test/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html?rev=1709571&r1=1709570&r2=1709571&view=diff
==============================================================================
--- hbase/hbase.apache.org/trunk/xref-test/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html (original)
+++ hbase/hbase.apache.org/trunk/xref-test/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html Tue Oct 20 11:24:43 2015
@@ -132,376 +132,414 @@
 <a class="jxr_linenumber" name="122" href="#122">122</a>   }
 <a class="jxr_linenumber" name="123" href="#123">123</a> 
 <a class="jxr_linenumber" name="124" href="#124">124</a>   @Test
-<a class="jxr_linenumber" name="125" href="#125">125</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSkewCost() {
+<a class="jxr_linenumber" name="125" href="#125">125</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMoveCost() <strong class="jxr_keyword">throws</strong> Exception {
 <a class="jxr_linenumber" name="126" href="#126">126</a>     Configuration conf = HBaseConfiguration.create();
 <a class="jxr_linenumber" name="127" href="#127">127</a>     StochasticLoadBalancer.CostFunction
-<a class="jxr_linenumber" name="128" href="#128">128</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.RegionCountSkewCostFunction(conf);
+<a class="jxr_linenumber" name="128" href="#128">128</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.MoveCostFunction(conf);
 <a class="jxr_linenumber" name="129" href="#129">129</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong>[] mockCluster : clusterStateMocks) {
-<a class="jxr_linenumber" name="130" href="#130">130</a>       costFunction.init(mockCluster(mockCluster));
-<a class="jxr_linenumber" name="131" href="#131">131</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
-<a class="jxr_linenumber" name="132" href="#132">132</a>       assertTrue(cost &gt;= 0);
-<a class="jxr_linenumber" name="133" href="#133">133</a>       assertTrue(cost &lt;= 1.01);
-<a class="jxr_linenumber" name="134" href="#134">134</a>     }
-<a class="jxr_linenumber" name="135" href="#135">135</a> 
-<a class="jxr_linenumber" name="136" href="#136">136</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 0, 0, 1}));
-<a class="jxr_linenumber" name="137" href="#137">137</a>     assertEquals(0,costFunction.cost(), 0.01);
-<a class="jxr_linenumber" name="138" href="#138">138</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 0, 1, 1}));
-<a class="jxr_linenumber" name="139" href="#139">139</a>     assertEquals(0, costFunction.cost(), 0.01);
-<a class="jxr_linenumber" name="140" href="#140">140</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 1, 1, 1}));
-<a class="jxr_linenumber" name="141" href="#141">141</a>     assertEquals(0, costFunction.cost(), 0.01);
-<a class="jxr_linenumber" name="142" href="#142">142</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 1, 1, 1, 1}));
-<a class="jxr_linenumber" name="143" href="#143">143</a>     assertEquals(0, costFunction.cost(), 0.01);
-<a class="jxr_linenumber" name="144" href="#144">144</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{1, 1, 1, 1, 1}));
-<a class="jxr_linenumber" name="145" href="#145">145</a>     assertEquals(0, costFunction.cost(), 0.01);
-<a class="jxr_linenumber" name="146" href="#146">146</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{10000, 0, 0, 0, 0}));
-<a class="jxr_linenumber" name="147" href="#147">147</a>     assertEquals(1, costFunction.cost(), 0.01);
-<a class="jxr_linenumber" name="148" href="#148">148</a>   }
-<a class="jxr_linenumber" name="149" href="#149">149</a> 
-<a class="jxr_linenumber" name="150" href="#150">150</a>   @Test
-<a class="jxr_linenumber" name="151" href="#151">151</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testTableSkewCost() {
-<a class="jxr_linenumber" name="152" href="#152">152</a>     Configuration conf = HBaseConfiguration.create();
-<a class="jxr_linenumber" name="153" href="#153">153</a>     StochasticLoadBalancer.CostFunction
-<a class="jxr_linenumber" name="154" href="#154">154</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.TableSkewCostFunction(conf);
-<a class="jxr_linenumber" name="155" href="#155">155</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong>[] mockCluster : clusterStateMocks) {
-<a class="jxr_linenumber" name="156" href="#156">156</a>       BaseLoadBalancer.Cluster cluster = mockCluster(mockCluster);
-<a class="jxr_linenumber" name="157" href="#157">157</a>       costFunction.init(cluster);
-<a class="jxr_linenumber" name="158" href="#158">158</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
-<a class="jxr_linenumber" name="159" href="#159">159</a>       assertTrue(cost &gt;= 0);
-<a class="jxr_linenumber" name="160" href="#160">160</a>       assertTrue(cost &lt;= 1.01);
-<a class="jxr_linenumber" name="161" href="#161">161</a>     }
-<a class="jxr_linenumber" name="162" href="#162">162</a>   }
-<a class="jxr_linenumber" name="163" href="#163">163</a> 
-<a class="jxr_linenumber" name="164" href="#164">164</a>   @Test
-<a class="jxr_linenumber" name="165" href="#165">165</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testCostFromArray() {
-<a class="jxr_linenumber" name="166" href="#166">166</a>     Configuration conf = HBaseConfiguration.create();
-<a class="jxr_linenumber" name="167" href="#167">167</a>     StochasticLoadBalancer.CostFromRegionLoadFunction
-<a class="jxr_linenumber" name="168" href="#168">168</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.MemstoreSizeCostFunction(conf);
-<a class="jxr_linenumber" name="169" href="#169">169</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 0, 0, 1}));
-<a class="jxr_linenumber" name="170" href="#170">170</a> 
-<a class="jxr_linenumber" name="171" href="#171">171</a>     <strong class="jxr_keyword">double</strong>[] statOne = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">double</strong>[100];
-<a class="jxr_linenumber" name="172" href="#172">172</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i =0; i &lt; 100; i++) {
-<a class="jxr_linenumber" name="173" href="#173">173</a>       statOne[i] = 10;
-<a class="jxr_linenumber" name="174" href="#174">174</a>     }
-<a class="jxr_linenumber" name="175" href="#175">175</a>     assertEquals(0, costFunction.costFromArray(statOne), 0.01);
-<a class="jxr_linenumber" name="176" href="#176">176</a> 
-<a class="jxr_linenumber" name="177" href="#177">177</a>     <strong class="jxr_keyword">double</strong>[] statTwo= <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">double</strong>[101];
-<a class="jxr_linenumber" name="178" href="#178">178</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i =0; i &lt; 100; i++) {
-<a class="jxr_linenumber" name="179" href="#179">179</a>       statTwo[i] = 0;
-<a class="jxr_linenumber" name="180" href="#180">180</a>     }
-<a class="jxr_linenumber" name="181" href="#181">181</a>     statTwo[100] = 100;
-<a class="jxr_linenumber" name="182" href="#182">182</a>     assertEquals(1, costFunction.costFromArray(statTwo), 0.01);
-<a class="jxr_linenumber" name="183" href="#183">183</a> 
-<a class="jxr_linenumber" name="184" href="#184">184</a>     <strong class="jxr_keyword">double</strong>[] statThree = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">double</strong>[200];
-<a class="jxr_linenumber" name="185" href="#185">185</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i =0; i &lt; 100; i++) {
-<a class="jxr_linenumber" name="186" href="#186">186</a>       statThree[i] = (0);
-<a class="jxr_linenumber" name="187" href="#187">187</a>       statThree[i+100] = 100;
-<a class="jxr_linenumber" name="188" href="#188">188</a>     }
-<a class="jxr_linenumber" name="189" href="#189">189</a>     assertEquals(0.5, costFunction.costFromArray(statThree), 0.01);
-<a class="jxr_linenumber" name="190" href="#190">190</a>   }
-<a class="jxr_linenumber" name="191" href="#191">191</a> 
-<a class="jxr_linenumber" name="192" href="#192">192</a>   @Test(timeout =  60000)
-<a class="jxr_linenumber" name="193" href="#193">193</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testLosingRs() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="194" href="#194">194</a>     <strong class="jxr_keyword">int</strong> numNodes = 3;
-<a class="jxr_linenumber" name="195" href="#195">195</a>     <strong class="jxr_keyword">int</strong> numRegions = 20;
-<a class="jxr_linenumber" name="196" href="#196">196</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 3; <em class="jxr_comment">//all servers except one</em>
-<a class="jxr_linenumber" name="197" href="#197">197</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="198" href="#198">198</a>     <strong class="jxr_keyword">int</strong> numTables = 2;
-<a class="jxr_linenumber" name="199" href="#199">199</a> 
-<a class="jxr_linenumber" name="200" href="#200">200</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; serverMap =
-<a class="jxr_linenumber" name="201" href="#201">201</a>         createServerMap(numNodes, numRegions, numRegionsPerServer, replication, numTables);
-<a class="jxr_linenumber" name="202" href="#202">202</a>     List&lt;ServerAndLoad&gt; list = convertToList(serverMap);
-<a class="jxr_linenumber" name="203" href="#203">203</a> 
-<a class="jxr_linenumber" name="204" href="#204">204</a> 
-<a class="jxr_linenumber" name="205" href="#205">205</a>     List&lt;RegionPlan&gt; plans = loadBalancer.balanceCluster(serverMap);
-<a class="jxr_linenumber" name="206" href="#206">206</a>     assertNotNull(plans);
-<a class="jxr_linenumber" name="207" href="#207">207</a> 
-<a class="jxr_linenumber" name="208" href="#208">208</a>     <em class="jxr_comment">// Apply the plan to the mock cluster.</em>
-<a class="jxr_linenumber" name="209" href="#209">209</a>     List&lt;ServerAndLoad&gt; balancedCluster = reconcile(list, plans, serverMap);
-<a class="jxr_linenumber" name="210" href="#210">210</a> 
-<a class="jxr_linenumber" name="211" href="#211">211</a>     assertClusterAsBalanced(balancedCluster);
-<a class="jxr_linenumber" name="212" href="#212">212</a> 
-<a class="jxr_linenumber" name="213" href="#213">213</a>     ServerName sn = serverMap.keySet().toArray(<strong class="jxr_keyword">new</strong> ServerName[serverMap.size()])[0];
+<a class="jxr_linenumber" name="130" href="#130">130</a>       BaseLoadBalancer.Cluster cluster = mockCluster(mockCluster);
+<a class="jxr_linenumber" name="131" href="#131">131</a>       costFunction.init(cluster);
+<a class="jxr_linenumber" name="132" href="#132">132</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
+<a class="jxr_linenumber" name="133" href="#133">133</a>       assertEquals(0.0f, cost, 0.001);
+<a class="jxr_linenumber" name="134" href="#134">134</a> 
+<a class="jxr_linenumber" name="135" href="#135">135</a>       <em class="jxr_comment">// cluster region number is smaller than maxMoves=600</em>
+<a class="jxr_linenumber" name="136" href="#136">136</a>       cluster.setNumRegions(200);
+<a class="jxr_linenumber" name="137" href="#137">137</a>       cluster.setNumMovedRegions(10);
+<a class="jxr_linenumber" name="138" href="#138">138</a>       cost = costFunction.cost();
+<a class="jxr_linenumber" name="139" href="#139">139</a>       assertEquals(0.05f, cost, 0.001);
+<a class="jxr_linenumber" name="140" href="#140">140</a>       cluster.setNumMovedRegions(100);
+<a class="jxr_linenumber" name="141" href="#141">141</a>       cost = costFunction.cost();
+<a class="jxr_linenumber" name="142" href="#142">142</a>       assertEquals(0.5f, cost, 0.001);
+<a class="jxr_linenumber" name="143" href="#143">143</a>       cluster.setNumMovedRegions(200);
+<a class="jxr_linenumber" name="144" href="#144">144</a>       cost = costFunction.cost();
+<a class="jxr_linenumber" name="145" href="#145">145</a>       assertEquals(1.0f, cost, 0.001);
+<a class="jxr_linenumber" name="146" href="#146">146</a> 
+<a class="jxr_linenumber" name="147" href="#147">147</a> 
+<a class="jxr_linenumber" name="148" href="#148">148</a>       <em class="jxr_comment">// cluster region number is bigger than maxMoves=2500</em>
+<a class="jxr_linenumber" name="149" href="#149">149</a>       cluster.setNumRegions(10000);
+<a class="jxr_linenumber" name="150" href="#150">150</a>       cluster.setNumMovedRegions(250);
+<a class="jxr_linenumber" name="151" href="#151">151</a>       cost = costFunction.cost();
+<a class="jxr_linenumber" name="152" href="#152">152</a>       assertEquals(0.1f, cost, 0.001);
+<a class="jxr_linenumber" name="153" href="#153">153</a>       cluster.setNumMovedRegions(1250);
+<a class="jxr_linenumber" name="154" href="#154">154</a>       cost = costFunction.cost();
+<a class="jxr_linenumber" name="155" href="#155">155</a>       assertEquals(0.5f, cost, 0.001);
+<a class="jxr_linenumber" name="156" href="#156">156</a>       cluster.setNumMovedRegions(2500);
+<a class="jxr_linenumber" name="157" href="#157">157</a>       cost = costFunction.cost();
+<a class="jxr_linenumber" name="158" href="#158">158</a>       assertEquals(1.0f, cost, 0.01);
+<a class="jxr_linenumber" name="159" href="#159">159</a>     }
+<a class="jxr_linenumber" name="160" href="#160">160</a>   }
+<a class="jxr_linenumber" name="161" href="#161">161</a> 
+<a class="jxr_linenumber" name="162" href="#162">162</a>   @Test
+<a class="jxr_linenumber" name="163" href="#163">163</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSkewCost() {
+<a class="jxr_linenumber" name="164" href="#164">164</a>     Configuration conf = HBaseConfiguration.create();
+<a class="jxr_linenumber" name="165" href="#165">165</a>     StochasticLoadBalancer.CostFunction
+<a class="jxr_linenumber" name="166" href="#166">166</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.RegionCountSkewCostFunction(conf);
+<a class="jxr_linenumber" name="167" href="#167">167</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong>[] mockCluster : clusterStateMocks) {
+<a class="jxr_linenumber" name="168" href="#168">168</a>       costFunction.init(mockCluster(mockCluster));
+<a class="jxr_linenumber" name="169" href="#169">169</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
+<a class="jxr_linenumber" name="170" href="#170">170</a>       assertTrue(cost &gt;= 0);
+<a class="jxr_linenumber" name="171" href="#171">171</a>       assertTrue(cost &lt;= 1.01);
+<a class="jxr_linenumber" name="172" href="#172">172</a>     }
+<a class="jxr_linenumber" name="173" href="#173">173</a> 
+<a class="jxr_linenumber" name="174" href="#174">174</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 0, 0, 1}));
+<a class="jxr_linenumber" name="175" href="#175">175</a>     assertEquals(0,costFunction.cost(), 0.01);
+<a class="jxr_linenumber" name="176" href="#176">176</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 0, 1, 1}));
+<a class="jxr_linenumber" name="177" href="#177">177</a>     assertEquals(0, costFunction.cost(), 0.01);
+<a class="jxr_linenumber" name="178" href="#178">178</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 1, 1, 1}));
+<a class="jxr_linenumber" name="179" href="#179">179</a>     assertEquals(0, costFunction.cost(), 0.01);
+<a class="jxr_linenumber" name="180" href="#180">180</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 1, 1, 1, 1}));
+<a class="jxr_linenumber" name="181" href="#181">181</a>     assertEquals(0, costFunction.cost(), 0.01);
+<a class="jxr_linenumber" name="182" href="#182">182</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{1, 1, 1, 1, 1}));
+<a class="jxr_linenumber" name="183" href="#183">183</a>     assertEquals(0, costFunction.cost(), 0.01);
+<a class="jxr_linenumber" name="184" href="#184">184</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{10000, 0, 0, 0, 0}));
+<a class="jxr_linenumber" name="185" href="#185">185</a>     assertEquals(1, costFunction.cost(), 0.01);
+<a class="jxr_linenumber" name="186" href="#186">186</a>   }
+<a class="jxr_linenumber" name="187" href="#187">187</a> 
+<a class="jxr_linenumber" name="188" href="#188">188</a>   @Test
+<a class="jxr_linenumber" name="189" href="#189">189</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testTableSkewCost() {
+<a class="jxr_linenumber" name="190" href="#190">190</a>     Configuration conf = HBaseConfiguration.create();
+<a class="jxr_linenumber" name="191" href="#191">191</a>     StochasticLoadBalancer.CostFunction
+<a class="jxr_linenumber" name="192" href="#192">192</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.TableSkewCostFunction(conf);
+<a class="jxr_linenumber" name="193" href="#193">193</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong>[] mockCluster : clusterStateMocks) {
+<a class="jxr_linenumber" name="194" href="#194">194</a>       BaseLoadBalancer.Cluster cluster = mockCluster(mockCluster);
+<a class="jxr_linenumber" name="195" href="#195">195</a>       costFunction.init(cluster);
+<a class="jxr_linenumber" name="196" href="#196">196</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
+<a class="jxr_linenumber" name="197" href="#197">197</a>       assertTrue(cost &gt;= 0);
+<a class="jxr_linenumber" name="198" href="#198">198</a>       assertTrue(cost &lt;= 1.01);
+<a class="jxr_linenumber" name="199" href="#199">199</a>     }
+<a class="jxr_linenumber" name="200" href="#200">200</a>   }
+<a class="jxr_linenumber" name="201" href="#201">201</a> 
+<a class="jxr_linenumber" name="202" href="#202">202</a>   @Test
+<a class="jxr_linenumber" name="203" href="#203">203</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testCostFromArray() {
+<a class="jxr_linenumber" name="204" href="#204">204</a>     Configuration conf = HBaseConfiguration.create();
+<a class="jxr_linenumber" name="205" href="#205">205</a>     StochasticLoadBalancer.CostFromRegionLoadFunction
+<a class="jxr_linenumber" name="206" href="#206">206</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.MemstoreSizeCostFunction(conf);
+<a class="jxr_linenumber" name="207" href="#207">207</a>     costFunction.init(mockCluster(<strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[]{0, 0, 0, 0, 1}));
+<a class="jxr_linenumber" name="208" href="#208">208</a> 
+<a class="jxr_linenumber" name="209" href="#209">209</a>     <strong class="jxr_keyword">double</strong>[] statOne = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">double</strong>[100];
+<a class="jxr_linenumber" name="210" href="#210">210</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i =0; i &lt; 100; i++) {
+<a class="jxr_linenumber" name="211" href="#211">211</a>       statOne[i] = 10;
+<a class="jxr_linenumber" name="212" href="#212">212</a>     }
+<a class="jxr_linenumber" name="213" href="#213">213</a>     assertEquals(0, costFunction.costFromArray(statOne), 0.01);
 <a class="jxr_linenumber" name="214" href="#214">214</a> 
-<a class="jxr_linenumber" name="215" href="#215">215</a>     ServerName deadSn = ServerName.valueOf(sn.getHostname(), sn.getPort(), sn.getStartcode() - 100);
-<a class="jxr_linenumber" name="216" href="#216">216</a> 
-<a class="jxr_linenumber" name="217" href="#217">217</a>     serverMap.put(deadSn, <strong class="jxr_keyword">new</strong> ArrayList&lt;HRegionInfo&gt;(0));
-<a class="jxr_linenumber" name="218" href="#218">218</a> 
-<a class="jxr_linenumber" name="219" href="#219">219</a>     plans = loadBalancer.balanceCluster(serverMap);
-<a class="jxr_linenumber" name="220" href="#220">220</a>     assertNull(plans);
-<a class="jxr_linenumber" name="221" href="#221">221</a>   }
-<a class="jxr_linenumber" name="222" href="#222">222</a> 
-<a class="jxr_linenumber" name="223" href="#223">223</a>   @Test
-<a class="jxr_linenumber" name="224" href="#224">224</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testReplicaCost() {
-<a class="jxr_linenumber" name="225" href="#225">225</a>     Configuration conf = HBaseConfiguration.create();
-<a class="jxr_linenumber" name="226" href="#226">226</a>     StochasticLoadBalancer.CostFunction
-<a class="jxr_linenumber" name="227" href="#227">227</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.RegionReplicaHostCostFunction(conf);
-<a class="jxr_linenumber" name="228" href="#228">228</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong>[] mockCluster : clusterStateMocks) {
-<a class="jxr_linenumber" name="229" href="#229">229</a>       BaseLoadBalancer.Cluster cluster = mockCluster(mockCluster);
-<a class="jxr_linenumber" name="230" href="#230">230</a>       costFunction.init(cluster);
-<a class="jxr_linenumber" name="231" href="#231">231</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
-<a class="jxr_linenumber" name="232" href="#232">232</a>       assertTrue(cost &gt;= 0);
-<a class="jxr_linenumber" name="233" href="#233">233</a>       assertTrue(cost &lt;= 1.01);
-<a class="jxr_linenumber" name="234" href="#234">234</a>     }
-<a class="jxr_linenumber" name="235" href="#235">235</a>   }
-<a class="jxr_linenumber" name="236" href="#236">236</a> 
-<a class="jxr_linenumber" name="237" href="#237">237</a>   @Test
-<a class="jxr_linenumber" name="238" href="#238">238</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testReplicaCostForReplicas() {
-<a class="jxr_linenumber" name="239" href="#239">239</a>     Configuration conf = HBaseConfiguration.create();
-<a class="jxr_linenumber" name="240" href="#240">240</a>     StochasticLoadBalancer.CostFunction
-<a class="jxr_linenumber" name="241" href="#241">241</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.RegionReplicaHostCostFunction(conf);
+<a class="jxr_linenumber" name="215" href="#215">215</a>     <strong class="jxr_keyword">double</strong>[] statTwo= <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">double</strong>[101];
+<a class="jxr_linenumber" name="216" href="#216">216</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i =0; i &lt; 100; i++) {
+<a class="jxr_linenumber" name="217" href="#217">217</a>       statTwo[i] = 0;
+<a class="jxr_linenumber" name="218" href="#218">218</a>     }
+<a class="jxr_linenumber" name="219" href="#219">219</a>     statTwo[100] = 100;
+<a class="jxr_linenumber" name="220" href="#220">220</a>     assertEquals(1, costFunction.costFromArray(statTwo), 0.01);
+<a class="jxr_linenumber" name="221" href="#221">221</a> 
+<a class="jxr_linenumber" name="222" href="#222">222</a>     <strong class="jxr_keyword">double</strong>[] statThree = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">double</strong>[200];
+<a class="jxr_linenumber" name="223" href="#223">223</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i =0; i &lt; 100; i++) {
+<a class="jxr_linenumber" name="224" href="#224">224</a>       statThree[i] = (0);
+<a class="jxr_linenumber" name="225" href="#225">225</a>       statThree[i+100] = 100;
+<a class="jxr_linenumber" name="226" href="#226">226</a>     }
+<a class="jxr_linenumber" name="227" href="#227">227</a>     assertEquals(0.5, costFunction.costFromArray(statThree), 0.01);
+<a class="jxr_linenumber" name="228" href="#228">228</a>   }
+<a class="jxr_linenumber" name="229" href="#229">229</a> 
+<a class="jxr_linenumber" name="230" href="#230">230</a>   @Test(timeout =  60000)
+<a class="jxr_linenumber" name="231" href="#231">231</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testLosingRs() <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="232" href="#232">232</a>     <strong class="jxr_keyword">int</strong> numNodes = 3;
+<a class="jxr_linenumber" name="233" href="#233">233</a>     <strong class="jxr_keyword">int</strong> numRegions = 20;
+<a class="jxr_linenumber" name="234" href="#234">234</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 3; <em class="jxr_comment">//all servers except one</em>
+<a class="jxr_linenumber" name="235" href="#235">235</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="236" href="#236">236</a>     <strong class="jxr_keyword">int</strong> numTables = 2;
+<a class="jxr_linenumber" name="237" href="#237">237</a> 
+<a class="jxr_linenumber" name="238" href="#238">238</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; serverMap =
+<a class="jxr_linenumber" name="239" href="#239">239</a>         createServerMap(numNodes, numRegions, numRegionsPerServer, replication, numTables);
+<a class="jxr_linenumber" name="240" href="#240">240</a>     List&lt;ServerAndLoad&gt; list = convertToList(serverMap);
+<a class="jxr_linenumber" name="241" href="#241">241</a> 
 <a class="jxr_linenumber" name="242" href="#242">242</a> 
-<a class="jxr_linenumber" name="243" href="#243">243</a>     <strong class="jxr_keyword">int</strong> [] servers = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] {3,3,3,3,3};
-<a class="jxr_linenumber" name="244" href="#244">244</a>     TreeMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt; clusterState = mockClusterServers(servers);
+<a class="jxr_linenumber" name="243" href="#243">243</a>     List&lt;RegionPlan&gt; plans = loadBalancer.balanceCluster(serverMap);
+<a class="jxr_linenumber" name="244" href="#244">244</a>     assertNotNull(plans);
 <a class="jxr_linenumber" name="245" href="#245">245</a> 
-<a class="jxr_linenumber" name="246" href="#246">246</a>     BaseLoadBalancer.Cluster cluster;
-<a class="jxr_linenumber" name="247" href="#247">247</a> 
-<a class="jxr_linenumber" name="248" href="#248">248</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
-<a class="jxr_linenumber" name="249" href="#249">249</a>     costFunction.init(cluster);
-<a class="jxr_linenumber" name="250" href="#250">250</a>     <strong class="jxr_keyword">double</strong> costWithoutReplicas = costFunction.cost();
-<a class="jxr_linenumber" name="251" href="#251">251</a>     assertEquals(0, costWithoutReplicas, 0);
+<a class="jxr_linenumber" name="246" href="#246">246</a>     <em class="jxr_comment">// Apply the plan to the mock cluster.</em>
+<a class="jxr_linenumber" name="247" href="#247">247</a>     List&lt;ServerAndLoad&gt; balancedCluster = reconcile(list, plans, serverMap);
+<a class="jxr_linenumber" name="248" href="#248">248</a> 
+<a class="jxr_linenumber" name="249" href="#249">249</a>     assertClusterAsBalanced(balancedCluster);
+<a class="jxr_linenumber" name="250" href="#250">250</a> 
+<a class="jxr_linenumber" name="251" href="#251">251</a>     ServerName sn = serverMap.keySet().toArray(<strong class="jxr_keyword">new</strong> ServerName[serverMap.size()])[0];
 <a class="jxr_linenumber" name="252" href="#252">252</a> 
-<a class="jxr_linenumber" name="253" href="#253">253</a>     <em class="jxr_comment">// replicate the region from first server to the last server</em>
-<a class="jxr_linenumber" name="254" href="#254">254</a>     HRegionInfo replica1 = RegionReplicaUtil.getRegionInfoForReplica(
-<a class="jxr_linenumber" name="255" href="#255">255</a>       clusterState.firstEntry().getValue().get(0),1);
-<a class="jxr_linenumber" name="256" href="#256">256</a>     clusterState.lastEntry().getValue().add(replica1);
-<a class="jxr_linenumber" name="257" href="#257">257</a> 
-<a class="jxr_linenumber" name="258" href="#258">258</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
-<a class="jxr_linenumber" name="259" href="#259">259</a>     costFunction.init(cluster);
-<a class="jxr_linenumber" name="260" href="#260">260</a>     <strong class="jxr_keyword">double</strong> costWith1ReplicaDifferentServer = costFunction.cost();
-<a class="jxr_linenumber" name="261" href="#261">261</a> 
-<a class="jxr_linenumber" name="262" href="#262">262</a>     assertEquals(0, costWith1ReplicaDifferentServer, 0);
-<a class="jxr_linenumber" name="263" href="#263">263</a> 
-<a class="jxr_linenumber" name="264" href="#264">264</a>     <em class="jxr_comment">// add a third replica to the last server</em>
-<a class="jxr_linenumber" name="265" href="#265">265</a>     HRegionInfo replica2 = RegionReplicaUtil.getRegionInfoForReplica(replica1, 2);
-<a class="jxr_linenumber" name="266" href="#266">266</a>     clusterState.lastEntry().getValue().add(replica2);
-<a class="jxr_linenumber" name="267" href="#267">267</a> 
-<a class="jxr_linenumber" name="268" href="#268">268</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
-<a class="jxr_linenumber" name="269" href="#269">269</a>     costFunction.init(cluster);
-<a class="jxr_linenumber" name="270" href="#270">270</a>     <strong class="jxr_keyword">double</strong> costWith1ReplicaSameServer = costFunction.cost();
-<a class="jxr_linenumber" name="271" href="#271">271</a> 
-<a class="jxr_linenumber" name="272" href="#272">272</a>     assertTrue(costWith1ReplicaDifferentServer &lt; costWith1ReplicaSameServer);
-<a class="jxr_linenumber" name="273" href="#273">273</a> 
-<a class="jxr_linenumber" name="274" href="#274">274</a>     <em class="jxr_comment">// test with replication = 4 for following:</em>
-<a class="jxr_linenumber" name="275" href="#275">275</a> 
-<a class="jxr_linenumber" name="276" href="#276">276</a>     HRegionInfo replica3;
-<a class="jxr_linenumber" name="277" href="#277">277</a>     Iterator&lt;Entry&lt;ServerName, List&lt;HRegionInfo&gt;&gt;&gt; it;
-<a class="jxr_linenumber" name="278" href="#278">278</a>     Entry&lt;ServerName, List&lt;HRegionInfo&gt;&gt; entry;
-<a class="jxr_linenumber" name="279" href="#279">279</a> 
-<a class="jxr_linenumber" name="280" href="#280">280</a>     clusterState = mockClusterServers(servers);
-<a class="jxr_linenumber" name="281" href="#281">281</a>     it = clusterState.entrySet().iterator();
-<a class="jxr_linenumber" name="282" href="#282">282</a>     entry = it.next(); <em class="jxr_comment">//first server</em>
-<a class="jxr_linenumber" name="283" href="#283">283</a>     HRegionInfo hri = entry.getValue().get(0);
-<a class="jxr_linenumber" name="284" href="#284">284</a>     replica1 = RegionReplicaUtil.getRegionInfoForReplica(hri, 1);
-<a class="jxr_linenumber" name="285" href="#285">285</a>     replica2 = RegionReplicaUtil.getRegionInfoForReplica(hri, 2);
-<a class="jxr_linenumber" name="286" href="#286">286</a>     replica3 = RegionReplicaUtil.getRegionInfoForReplica(hri, 3);
-<a class="jxr_linenumber" name="287" href="#287">287</a>     entry.getValue().add(replica1);
-<a class="jxr_linenumber" name="288" href="#288">288</a>     entry.getValue().add(replica2);
-<a class="jxr_linenumber" name="289" href="#289">289</a>     it.next().getValue().add(replica3); <em class="jxr_comment">//2nd server</em>
+<a class="jxr_linenumber" name="253" href="#253">253</a>     ServerName deadSn = ServerName.valueOf(sn.getHostname(), sn.getPort(), sn.getStartcode() - 100);
+<a class="jxr_linenumber" name="254" href="#254">254</a> 
+<a class="jxr_linenumber" name="255" href="#255">255</a>     serverMap.put(deadSn, <strong class="jxr_keyword">new</strong> ArrayList&lt;HRegionInfo&gt;(0));
+<a class="jxr_linenumber" name="256" href="#256">256</a> 
+<a class="jxr_linenumber" name="257" href="#257">257</a>     plans = loadBalancer.balanceCluster(serverMap);
+<a class="jxr_linenumber" name="258" href="#258">258</a>     assertNull(plans);
+<a class="jxr_linenumber" name="259" href="#259">259</a>   }
+<a class="jxr_linenumber" name="260" href="#260">260</a> 
+<a class="jxr_linenumber" name="261" href="#261">261</a>   @Test
+<a class="jxr_linenumber" name="262" href="#262">262</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testReplicaCost() {
+<a class="jxr_linenumber" name="263" href="#263">263</a>     Configuration conf = HBaseConfiguration.create();
+<a class="jxr_linenumber" name="264" href="#264">264</a>     StochasticLoadBalancer.CostFunction
+<a class="jxr_linenumber" name="265" href="#265">265</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.RegionReplicaHostCostFunction(conf);
+<a class="jxr_linenumber" name="266" href="#266">266</a>     <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong>[] mockCluster : clusterStateMocks) {
+<a class="jxr_linenumber" name="267" href="#267">267</a>       BaseLoadBalancer.Cluster cluster = mockCluster(mockCluster);
+<a class="jxr_linenumber" name="268" href="#268">268</a>       costFunction.init(cluster);
+<a class="jxr_linenumber" name="269" href="#269">269</a>       <strong class="jxr_keyword">double</strong> cost = costFunction.cost();
+<a class="jxr_linenumber" name="270" href="#270">270</a>       assertTrue(cost &gt;= 0);
+<a class="jxr_linenumber" name="271" href="#271">271</a>       assertTrue(cost &lt;= 1.01);
+<a class="jxr_linenumber" name="272" href="#272">272</a>     }
+<a class="jxr_linenumber" name="273" href="#273">273</a>   }
+<a class="jxr_linenumber" name="274" href="#274">274</a> 
+<a class="jxr_linenumber" name="275" href="#275">275</a>   @Test
+<a class="jxr_linenumber" name="276" href="#276">276</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testReplicaCostForReplicas() {
+<a class="jxr_linenumber" name="277" href="#277">277</a>     Configuration conf = HBaseConfiguration.create();
+<a class="jxr_linenumber" name="278" href="#278">278</a>     StochasticLoadBalancer.CostFunction
+<a class="jxr_linenumber" name="279" href="#279">279</a>         costFunction = <strong class="jxr_keyword">new</strong> StochasticLoadBalancer.RegionReplicaHostCostFunction(conf);
+<a class="jxr_linenumber" name="280" href="#280">280</a> 
+<a class="jxr_linenumber" name="281" href="#281">281</a>     <strong class="jxr_keyword">int</strong> [] servers = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] {3,3,3,3,3};
+<a class="jxr_linenumber" name="282" href="#282">282</a>     TreeMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt; clusterState = mockClusterServers(servers);
+<a class="jxr_linenumber" name="283" href="#283">283</a> 
+<a class="jxr_linenumber" name="284" href="#284">284</a>     BaseLoadBalancer.Cluster cluster;
+<a class="jxr_linenumber" name="285" href="#285">285</a> 
+<a class="jxr_linenumber" name="286" href="#286">286</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
+<a class="jxr_linenumber" name="287" href="#287">287</a>     costFunction.init(cluster);
+<a class="jxr_linenumber" name="288" href="#288">288</a>     <strong class="jxr_keyword">double</strong> costWithoutReplicas = costFunction.cost();
+<a class="jxr_linenumber" name="289" href="#289">289</a>     assertEquals(0, costWithoutReplicas, 0);
 <a class="jxr_linenumber" name="290" href="#290">290</a> 
-<a class="jxr_linenumber" name="291" href="#291">291</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
-<a class="jxr_linenumber" name="292" href="#292">292</a>     costFunction.init(cluster);
-<a class="jxr_linenumber" name="293" href="#293">293</a>     <strong class="jxr_keyword">double</strong> costWith3ReplicasSameServer = costFunction.cost();
-<a class="jxr_linenumber" name="294" href="#294">294</a> 
-<a class="jxr_linenumber" name="295" href="#295">295</a>     clusterState = mockClusterServers(servers);
-<a class="jxr_linenumber" name="296" href="#296">296</a>     hri = clusterState.firstEntry().getValue().get(0);
-<a class="jxr_linenumber" name="297" href="#297">297</a>     replica1 = RegionReplicaUtil.getRegionInfoForReplica(hri, 1);
-<a class="jxr_linenumber" name="298" href="#298">298</a>     replica2 = RegionReplicaUtil.getRegionInfoForReplica(hri, 2);
-<a class="jxr_linenumber" name="299" href="#299">299</a>     replica3 = RegionReplicaUtil.getRegionInfoForReplica(hri, 3);
-<a class="jxr_linenumber" name="300" href="#300">300</a> 
-<a class="jxr_linenumber" name="301" href="#301">301</a>     clusterState.firstEntry().getValue().add(replica1);
-<a class="jxr_linenumber" name="302" href="#302">302</a>     clusterState.lastEntry().getValue().add(replica2);
-<a class="jxr_linenumber" name="303" href="#303">303</a>     clusterState.lastEntry().getValue().add(replica3);
-<a class="jxr_linenumber" name="304" href="#304">304</a> 
-<a class="jxr_linenumber" name="305" href="#305">305</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
-<a class="jxr_linenumber" name="306" href="#306">306</a>     costFunction.init(cluster);
-<a class="jxr_linenumber" name="307" href="#307">307</a>     <strong class="jxr_keyword">double</strong> costWith2ReplicasOnTwoServers = costFunction.cost();
-<a class="jxr_linenumber" name="308" href="#308">308</a> 
-<a class="jxr_linenumber" name="309" href="#309">309</a>     assertTrue(costWith2ReplicasOnTwoServers &lt; costWith3ReplicasSameServer);
-<a class="jxr_linenumber" name="310" href="#310">310</a>   }
+<a class="jxr_linenumber" name="291" href="#291">291</a>     <em class="jxr_comment">// replicate the region from first server to the last server</em>
+<a class="jxr_linenumber" name="292" href="#292">292</a>     HRegionInfo replica1 = RegionReplicaUtil.getRegionInfoForReplica(
+<a class="jxr_linenumber" name="293" href="#293">293</a>       clusterState.firstEntry().getValue().get(0),1);
+<a class="jxr_linenumber" name="294" href="#294">294</a>     clusterState.lastEntry().getValue().add(replica1);
+<a class="jxr_linenumber" name="295" href="#295">295</a> 
+<a class="jxr_linenumber" name="296" href="#296">296</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
+<a class="jxr_linenumber" name="297" href="#297">297</a>     costFunction.init(cluster);
+<a class="jxr_linenumber" name="298" href="#298">298</a>     <strong class="jxr_keyword">double</strong> costWith1ReplicaDifferentServer = costFunction.cost();
+<a class="jxr_linenumber" name="299" href="#299">299</a> 
+<a class="jxr_linenumber" name="300" href="#300">300</a>     assertEquals(0, costWith1ReplicaDifferentServer, 0);
+<a class="jxr_linenumber" name="301" href="#301">301</a> 
+<a class="jxr_linenumber" name="302" href="#302">302</a>     <em class="jxr_comment">// add a third replica to the last server</em>
+<a class="jxr_linenumber" name="303" href="#303">303</a>     HRegionInfo replica2 = RegionReplicaUtil.getRegionInfoForReplica(replica1, 2);
+<a class="jxr_linenumber" name="304" href="#304">304</a>     clusterState.lastEntry().getValue().add(replica2);
+<a class="jxr_linenumber" name="305" href="#305">305</a> 
+<a class="jxr_linenumber" name="306" href="#306">306</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
+<a class="jxr_linenumber" name="307" href="#307">307</a>     costFunction.init(cluster);
+<a class="jxr_linenumber" name="308" href="#308">308</a>     <strong class="jxr_keyword">double</strong> costWith1ReplicaSameServer = costFunction.cost();
+<a class="jxr_linenumber" name="309" href="#309">309</a> 
+<a class="jxr_linenumber" name="310" href="#310">310</a>     assertTrue(costWith1ReplicaDifferentServer &lt; costWith1ReplicaSameServer);
 <a class="jxr_linenumber" name="311" href="#311">311</a> 
-<a class="jxr_linenumber" name="312" href="#312">312</a>   @Test
-<a class="jxr_linenumber" name="313" href="#313">313</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testNeedsBalanceForColocatedReplicas() {
-<a class="jxr_linenumber" name="314" href="#314">314</a>     <em class="jxr_comment">// check for the case where there are two hosts and with one rack, and where</em>
-<a class="jxr_linenumber" name="315" href="#315">315</a>     <em class="jxr_comment">// both the replicas are hosted on the same server</em>
-<a class="jxr_linenumber" name="316" href="#316">316</a>     List&lt;HRegionInfo&gt; regions = randomRegions(1);
-<a class="jxr_linenumber" name="317" href="#317">317</a>     ServerName s1 = ServerName.valueOf(<span class="jxr_string">"host1"</span>, 1000, 11111);
-<a class="jxr_linenumber" name="318" href="#318">318</a>     ServerName s2 = ServerName.valueOf(<span class="jxr_string">"host11"</span>, 1000, 11111);
-<a class="jxr_linenumber" name="319" href="#319">319</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; map = <strong class="jxr_keyword">new</strong> HashMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt;();
-<a class="jxr_linenumber" name="320" href="#320">320</a>     map.put(s1, regions);
-<a class="jxr_linenumber" name="321" href="#321">321</a>     regions.add(RegionReplicaUtil.getRegionInfoForReplica(regions.get(0), 1));
-<a class="jxr_linenumber" name="322" href="#322">322</a>     <em class="jxr_comment">// until the step above s1 holds two replicas of a region</em>
-<a class="jxr_linenumber" name="323" href="#323">323</a>     regions = randomRegions(1);
-<a class="jxr_linenumber" name="324" href="#324">324</a>     map.put(s2, regions);
-<a class="jxr_linenumber" name="325" href="#325">325</a>     assertTrue(loadBalancer.needsBalance(<strong class="jxr_keyword">new</strong> Cluster(map, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>)));
-<a class="jxr_linenumber" name="326" href="#326">326</a>     <em class="jxr_comment">// check for the case where there are two hosts on the same rack and there are two racks</em>
-<a class="jxr_linenumber" name="327" href="#327">327</a>     <em class="jxr_comment">// and both the replicas are on the same rack</em>
-<a class="jxr_linenumber" name="328" href="#328">328</a>     map.clear();
-<a class="jxr_linenumber" name="329" href="#329">329</a>     regions = randomRegions(1);
-<a class="jxr_linenumber" name="330" href="#330">330</a>     List&lt;HRegionInfo&gt; regionsOnS2 = <strong class="jxr_keyword">new</strong> ArrayList&lt;HRegionInfo&gt;(1);
-<a class="jxr_linenumber" name="331" href="#331">331</a>     regionsOnS2.add(RegionReplicaUtil.getRegionInfoForReplica(regions.get(0), 1));
-<a class="jxr_linenumber" name="332" href="#332">332</a>     map.put(s1, regions);
-<a class="jxr_linenumber" name="333" href="#333">333</a>     map.put(s2, regionsOnS2);
-<a class="jxr_linenumber" name="334" href="#334">334</a>     <em class="jxr_comment">// add another server so that the cluster has some host on another rack</em>
-<a class="jxr_linenumber" name="335" href="#335">335</a>     map.put(ServerName.valueOf(<span class="jxr_string">"host2"</span>, 1000, 11111), randomRegions(1));
-<a class="jxr_linenumber" name="336" href="#336">336</a>     assertTrue(loadBalancer.needsBalance(<strong class="jxr_keyword">new</strong> Cluster(map, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>,
-<a class="jxr_linenumber" name="337" href="#337">337</a>         <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManagerOne</a>())));
-<a class="jxr_linenumber" name="338" href="#338">338</a>   }
-<a class="jxr_linenumber" name="339" href="#339">339</a> 
-<a class="jxr_linenumber" name="340" href="#340">340</a>   @Test (timeout = 60000)
-<a class="jxr_linenumber" name="341" href="#341">341</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSmallCluster() {
-<a class="jxr_linenumber" name="342" href="#342">342</a>     <strong class="jxr_keyword">int</strong> numNodes = 10;
-<a class="jxr_linenumber" name="343" href="#343">343</a>     <strong class="jxr_keyword">int</strong> numRegions = 1000;
-<a class="jxr_linenumber" name="344" href="#344">344</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 40; <em class="jxr_comment">//all servers except one</em>
-<a class="jxr_linenumber" name="345" href="#345">345</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="346" href="#346">346</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
-<a class="jxr_linenumber" name="347" href="#347">347</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="312" href="#312">312</a>     <em class="jxr_comment">// test with replication = 4 for following:</em>
+<a class="jxr_linenumber" name="313" href="#313">313</a> 
+<a class="jxr_linenumber" name="314" href="#314">314</a>     HRegionInfo replica3;
+<a class="jxr_linenumber" name="315" href="#315">315</a>     Iterator&lt;Entry&lt;ServerName, List&lt;HRegionInfo&gt;&gt;&gt; it;
+<a class="jxr_linenumber" name="316" href="#316">316</a>     Entry&lt;ServerName, List&lt;HRegionInfo&gt;&gt; entry;
+<a class="jxr_linenumber" name="317" href="#317">317</a> 
+<a class="jxr_linenumber" name="318" href="#318">318</a>     clusterState = mockClusterServers(servers);
+<a class="jxr_linenumber" name="319" href="#319">319</a>     it = clusterState.entrySet().iterator();
+<a class="jxr_linenumber" name="320" href="#320">320</a>     entry = it.next(); <em class="jxr_comment">//first server</em>
+<a class="jxr_linenumber" name="321" href="#321">321</a>     HRegionInfo hri = entry.getValue().get(0);
+<a class="jxr_linenumber" name="322" href="#322">322</a>     replica1 = RegionReplicaUtil.getRegionInfoForReplica(hri, 1);
+<a class="jxr_linenumber" name="323" href="#323">323</a>     replica2 = RegionReplicaUtil.getRegionInfoForReplica(hri, 2);
+<a class="jxr_linenumber" name="324" href="#324">324</a>     replica3 = RegionReplicaUtil.getRegionInfoForReplica(hri, 3);
+<a class="jxr_linenumber" name="325" href="#325">325</a>     entry.getValue().add(replica1);
+<a class="jxr_linenumber" name="326" href="#326">326</a>     entry.getValue().add(replica2);
+<a class="jxr_linenumber" name="327" href="#327">327</a>     it.next().getValue().add(replica3); <em class="jxr_comment">//2nd server</em>
+<a class="jxr_linenumber" name="328" href="#328">328</a> 
+<a class="jxr_linenumber" name="329" href="#329">329</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
+<a class="jxr_linenumber" name="330" href="#330">330</a>     costFunction.init(cluster);
+<a class="jxr_linenumber" name="331" href="#331">331</a>     <strong class="jxr_keyword">double</strong> costWith3ReplicasSameServer = costFunction.cost();
+<a class="jxr_linenumber" name="332" href="#332">332</a> 
+<a class="jxr_linenumber" name="333" href="#333">333</a>     clusterState = mockClusterServers(servers);
+<a class="jxr_linenumber" name="334" href="#334">334</a>     hri = clusterState.firstEntry().getValue().get(0);
+<a class="jxr_linenumber" name="335" href="#335">335</a>     replica1 = RegionReplicaUtil.getRegionInfoForReplica(hri, 1);
+<a class="jxr_linenumber" name="336" href="#336">336</a>     replica2 = RegionReplicaUtil.getRegionInfoForReplica(hri, 2);
+<a class="jxr_linenumber" name="337" href="#337">337</a>     replica3 = RegionReplicaUtil.getRegionInfoForReplica(hri, 3);
+<a class="jxr_linenumber" name="338" href="#338">338</a> 
+<a class="jxr_linenumber" name="339" href="#339">339</a>     clusterState.firstEntry().getValue().add(replica1);
+<a class="jxr_linenumber" name="340" href="#340">340</a>     clusterState.lastEntry().getValue().add(replica2);
+<a class="jxr_linenumber" name="341" href="#341">341</a>     clusterState.lastEntry().getValue().add(replica3);
+<a class="jxr_linenumber" name="342" href="#342">342</a> 
+<a class="jxr_linenumber" name="343" href="#343">343</a>     cluster = <strong class="jxr_keyword">new</strong> BaseLoadBalancer.Cluster(clusterState, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>);
+<a class="jxr_linenumber" name="344" href="#344">344</a>     costFunction.init(cluster);
+<a class="jxr_linenumber" name="345" href="#345">345</a>     <strong class="jxr_keyword">double</strong> costWith2ReplicasOnTwoServers = costFunction.cost();
+<a class="jxr_linenumber" name="346" href="#346">346</a> 
+<a class="jxr_linenumber" name="347" href="#347">347</a>     assertTrue(costWith2ReplicasOnTwoServers &lt; costWith3ReplicasSameServer);
 <a class="jxr_linenumber" name="348" href="#348">348</a>   }
 <a class="jxr_linenumber" name="349" href="#349">349</a> 
-<a class="jxr_linenumber" name="350" href="#350">350</a>   @Test (timeout = 60000)
-<a class="jxr_linenumber" name="351" href="#351">351</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSmallCluster2() {
-<a class="jxr_linenumber" name="352" href="#352">352</a>     <strong class="jxr_keyword">int</strong> numNodes = 20;
-<a class="jxr_linenumber" name="353" href="#353">353</a>     <strong class="jxr_keyword">int</strong> numRegions = 2000;
-<a class="jxr_linenumber" name="354" href="#354">354</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 40; <em class="jxr_comment">//all servers except one</em>
-<a class="jxr_linenumber" name="355" href="#355">355</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="356" href="#356">356</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
-<a class="jxr_linenumber" name="357" href="#357">357</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="358" href="#358">358</a>   }
-<a class="jxr_linenumber" name="359" href="#359">359</a> 
-<a class="jxr_linenumber" name="360" href="#360">360</a>   @Test (timeout = 60000)
-<a class="jxr_linenumber" name="361" href="#361">361</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSmallCluster3() {
-<a class="jxr_linenumber" name="362" href="#362">362</a>     <strong class="jxr_keyword">int</strong> numNodes = 20;
-<a class="jxr_linenumber" name="363" href="#363">363</a>     <strong class="jxr_keyword">int</strong> numRegions = 2000;
-<a class="jxr_linenumber" name="364" href="#364">364</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 1; <em class="jxr_comment">// all servers except one</em>
-<a class="jxr_linenumber" name="365" href="#365">365</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="366" href="#366">366</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
-<a class="jxr_linenumber" name="367" href="#367">367</a>     <em class="jxr_comment">/*<em class="jxr_comment"> fails because of max moves */</em></em>
-<a class="jxr_linenumber" name="368" href="#368">368</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, false, false);
-<a class="jxr_linenumber" name="369" href="#369">369</a>   }
-<a class="jxr_linenumber" name="370" href="#370">370</a> 
-<a class="jxr_linenumber" name="371" href="#371">371</a>   @Test (timeout = 800000)
-<a class="jxr_linenumber" name="372" href="#372">372</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMidCluster() {
-<a class="jxr_linenumber" name="373" href="#373">373</a>     <strong class="jxr_keyword">int</strong> numNodes = 100;
-<a class="jxr_linenumber" name="374" href="#374">374</a>     <strong class="jxr_keyword">int</strong> numRegions = 10000;
-<a class="jxr_linenumber" name="375" href="#375">375</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 60; <em class="jxr_comment">// all servers except one</em>
-<a class="jxr_linenumber" name="376" href="#376">376</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="377" href="#377">377</a>     <strong class="jxr_keyword">int</strong> numTables = 40;
-<a class="jxr_linenumber" name="378" href="#378">378</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="379" href="#379">379</a>   }
-<a class="jxr_linenumber" name="380" href="#380">380</a> 
-<a class="jxr_linenumber" name="381" href="#381">381</a>   @Test (timeout = 800000)
-<a class="jxr_linenumber" name="382" href="#382">382</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMidCluster2() {
-<a class="jxr_linenumber" name="383" href="#383">383</a>     <strong class="jxr_keyword">int</strong> numNodes = 200;
-<a class="jxr_linenumber" name="384" href="#384">384</a>     <strong class="jxr_keyword">int</strong> numRegions = 100000;
-<a class="jxr_linenumber" name="385" href="#385">385</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 40; <em class="jxr_comment">// all servers except one</em>
-<a class="jxr_linenumber" name="386" href="#386">386</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="387" href="#387">387</a>     <strong class="jxr_keyword">int</strong> numTables = 400;
-<a class="jxr_linenumber" name="388" href="#388">388</a>     testWithCluster(numNodes,
-<a class="jxr_linenumber" name="389" href="#389">389</a>         numRegions,
-<a class="jxr_linenumber" name="390" href="#390">390</a>         numRegionsPerServer,
-<a class="jxr_linenumber" name="391" href="#391">391</a>         replication,
-<a class="jxr_linenumber" name="392" href="#392">392</a>         numTables,
-<a class="jxr_linenumber" name="393" href="#393">393</a>         false, <em class="jxr_comment">/*<em class="jxr_comment"> num large num regions means may not always get to best balance with one run */</em></em>
-<a class="jxr_linenumber" name="394" href="#394">394</a>         false);
-<a class="jxr_linenumber" name="395" href="#395">395</a>   }
-<a class="jxr_linenumber" name="396" href="#396">396</a> 
+<a class="jxr_linenumber" name="350" href="#350">350</a>   @Test
+<a class="jxr_linenumber" name="351" href="#351">351</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testNeedsBalanceForColocatedReplicas() {
+<a class="jxr_linenumber" name="352" href="#352">352</a>     <em class="jxr_comment">// check for the case where there are two hosts and with one rack, and where</em>
+<a class="jxr_linenumber" name="353" href="#353">353</a>     <em class="jxr_comment">// both the replicas are hosted on the same server</em>
+<a class="jxr_linenumber" name="354" href="#354">354</a>     List&lt;HRegionInfo&gt; regions = randomRegions(1);
+<a class="jxr_linenumber" name="355" href="#355">355</a>     ServerName s1 = ServerName.valueOf(<span class="jxr_string">"host1"</span>, 1000, 11111);
+<a class="jxr_linenumber" name="356" href="#356">356</a>     ServerName s2 = ServerName.valueOf(<span class="jxr_string">"host11"</span>, 1000, 11111);
+<a class="jxr_linenumber" name="357" href="#357">357</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; map = <strong class="jxr_keyword">new</strong> HashMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt;();
+<a class="jxr_linenumber" name="358" href="#358">358</a>     map.put(s1, regions);
+<a class="jxr_linenumber" name="359" href="#359">359</a>     regions.add(RegionReplicaUtil.getRegionInfoForReplica(regions.get(0), 1));
+<a class="jxr_linenumber" name="360" href="#360">360</a>     <em class="jxr_comment">// until the step above s1 holds two replicas of a region</em>
+<a class="jxr_linenumber" name="361" href="#361">361</a>     regions = randomRegions(1);
+<a class="jxr_linenumber" name="362" href="#362">362</a>     map.put(s2, regions);
+<a class="jxr_linenumber" name="363" href="#363">363</a>     assertTrue(loadBalancer.needsBalance(<strong class="jxr_keyword">new</strong> Cluster(map, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>)));
+<a class="jxr_linenumber" name="364" href="#364">364</a>     <em class="jxr_comment">// check for the case where there are two hosts on the same rack and there are two racks</em>
+<a class="jxr_linenumber" name="365" href="#365">365</a>     <em class="jxr_comment">// and both the replicas are on the same rack</em>
+<a class="jxr_linenumber" name="366" href="#366">366</a>     map.clear();
+<a class="jxr_linenumber" name="367" href="#367">367</a>     regions = randomRegions(1);
+<a class="jxr_linenumber" name="368" href="#368">368</a>     List&lt;HRegionInfo&gt; regionsOnS2 = <strong class="jxr_keyword">new</strong> ArrayList&lt;HRegionInfo&gt;(1);
+<a class="jxr_linenumber" name="369" href="#369">369</a>     regionsOnS2.add(RegionReplicaUtil.getRegionInfoForReplica(regions.get(0), 1));
+<a class="jxr_linenumber" name="370" href="#370">370</a>     map.put(s1, regions);
+<a class="jxr_linenumber" name="371" href="#371">371</a>     map.put(s2, regionsOnS2);
+<a class="jxr_linenumber" name="372" href="#372">372</a>     <em class="jxr_comment">// add another server so that the cluster has some host on another rack</em>
+<a class="jxr_linenumber" name="373" href="#373">373</a>     map.put(ServerName.valueOf(<span class="jxr_string">"host2"</span>, 1000, 11111), randomRegions(1));
+<a class="jxr_linenumber" name="374" href="#374">374</a>     assertTrue(loadBalancer.needsBalance(<strong class="jxr_keyword">new</strong> Cluster(map, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>,
+<a class="jxr_linenumber" name="375" href="#375">375</a>         <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManagerOne</a>())));
+<a class="jxr_linenumber" name="376" href="#376">376</a>   }
+<a class="jxr_linenumber" name="377" href="#377">377</a> 
+<a class="jxr_linenumber" name="378" href="#378">378</a>   @Test (timeout = 60000)
+<a class="jxr_linenumber" name="379" href="#379">379</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSmallCluster() {
+<a class="jxr_linenumber" name="380" href="#380">380</a>     <strong class="jxr_keyword">int</strong> numNodes = 10;
+<a class="jxr_linenumber" name="381" href="#381">381</a>     <strong class="jxr_keyword">int</strong> numRegions = 1000;
+<a class="jxr_linenumber" name="382" href="#382">382</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 40; <em class="jxr_comment">//all servers except one</em>
+<a class="jxr_linenumber" name="383" href="#383">383</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="384" href="#384">384</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
+<a class="jxr_linenumber" name="385" href="#385">385</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="386" href="#386">386</a>   }
+<a class="jxr_linenumber" name="387" href="#387">387</a> 
+<a class="jxr_linenumber" name="388" href="#388">388</a>   @Test (timeout = 60000)
+<a class="jxr_linenumber" name="389" href="#389">389</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSmallCluster2() {
+<a class="jxr_linenumber" name="390" href="#390">390</a>     <strong class="jxr_keyword">int</strong> numNodes = 20;
+<a class="jxr_linenumber" name="391" href="#391">391</a>     <strong class="jxr_keyword">int</strong> numRegions = 2000;
+<a class="jxr_linenumber" name="392" href="#392">392</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 40; <em class="jxr_comment">//all servers except one</em>
+<a class="jxr_linenumber" name="393" href="#393">393</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="394" href="#394">394</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
+<a class="jxr_linenumber" name="395" href="#395">395</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="396" href="#396">396</a>   }
 <a class="jxr_linenumber" name="397" href="#397">397</a> 
-<a class="jxr_linenumber" name="398" href="#398">398</a>   @Test (timeout = 800000)
-<a class="jxr_linenumber" name="399" href="#399">399</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMidCluster3() {
-<a class="jxr_linenumber" name="400" href="#400">400</a>     <strong class="jxr_keyword">int</strong> numNodes = 100;
+<a class="jxr_linenumber" name="398" href="#398">398</a>   @Test (timeout = 60000)
+<a class="jxr_linenumber" name="399" href="#399">399</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSmallCluster3() {
+<a class="jxr_linenumber" name="400" href="#400">400</a>     <strong class="jxr_keyword">int</strong> numNodes = 20;
 <a class="jxr_linenumber" name="401" href="#401">401</a>     <strong class="jxr_keyword">int</strong> numRegions = 2000;
-<a class="jxr_linenumber" name="402" href="#402">402</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 9; <em class="jxr_comment">// all servers except one</em>
+<a class="jxr_linenumber" name="402" href="#402">402</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 1; <em class="jxr_comment">// all servers except one</em>
 <a class="jxr_linenumber" name="403" href="#403">403</a>     <strong class="jxr_keyword">int</strong> replication = 1;
-<a class="jxr_linenumber" name="404" href="#404">404</a>     <strong class="jxr_keyword">int</strong> numTables = 110;
-<a class="jxr_linenumber" name="405" href="#405">405</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="406" href="#406">406</a>     <em class="jxr_comment">// TODO(eclark): Make sure that the tables are well distributed.</em>
+<a class="jxr_linenumber" name="404" href="#404">404</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
+<a class="jxr_linenumber" name="405" href="#405">405</a>     <em class="jxr_comment">/*<em class="jxr_comment"> fails because of max moves */</em></em>
+<a class="jxr_linenumber" name="406" href="#406">406</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, false, false);
 <a class="jxr_linenumber" name="407" href="#407">407</a>   }
 <a class="jxr_linenumber" name="408" href="#408">408</a> 
-<a class="jxr_linenumber" name="409" href="#409">409</a>   @Test
-<a class="jxr_linenumber" name="410" href="#410">410</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testLargeCluster() {
-<a class="jxr_linenumber" name="411" href="#411">411</a>     <strong class="jxr_keyword">int</strong> numNodes = 1000;
-<a class="jxr_linenumber" name="412" href="#412">412</a>     <strong class="jxr_keyword">int</strong> numRegions = 100000; <em class="jxr_comment">//100 regions per RS</em>
-<a class="jxr_linenumber" name="413" href="#413">413</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 80; <em class="jxr_comment">//all servers except one</em>
-<a class="jxr_linenumber" name="414" href="#414">414</a>     <strong class="jxr_keyword">int</strong> numTables = 100;
-<a class="jxr_linenumber" name="415" href="#415">415</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="409" href="#409">409</a>   @Test (timeout = 800000)
+<a class="jxr_linenumber" name="410" href="#410">410</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMidCluster() {
+<a class="jxr_linenumber" name="411" href="#411">411</a>     <strong class="jxr_keyword">int</strong> numNodes = 100;
+<a class="jxr_linenumber" name="412" href="#412">412</a>     <strong class="jxr_keyword">int</strong> numRegions = 10000;
+<a class="jxr_linenumber" name="413" href="#413">413</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 60; <em class="jxr_comment">// all servers except one</em>
+<a class="jxr_linenumber" name="414" href="#414">414</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="415" href="#415">415</a>     <strong class="jxr_keyword">int</strong> numTables = 40;
 <a class="jxr_linenumber" name="416" href="#416">416</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
 <a class="jxr_linenumber" name="417" href="#417">417</a>   }
 <a class="jxr_linenumber" name="418" href="#418">418</a> 
 <a class="jxr_linenumber" name="419" href="#419">419</a>   @Test (timeout = 800000)
-<a class="jxr_linenumber" name="420" href="#420">420</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testRegionReplicasOnSmallCluster() {
-<a class="jxr_linenumber" name="421" href="#421">421</a>     <strong class="jxr_keyword">int</strong> numNodes = 10;
-<a class="jxr_linenumber" name="422" href="#422">422</a>     <strong class="jxr_keyword">int</strong> numRegions = 1000;
-<a class="jxr_linenumber" name="423" href="#423">423</a>     <strong class="jxr_keyword">int</strong> replication = 3; <em class="jxr_comment">// 3 replicas per region</em>
-<a class="jxr_linenumber" name="424" href="#424">424</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 80; <em class="jxr_comment">//all regions are mostly balanced</em>
-<a class="jxr_linenumber" name="425" href="#425">425</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
-<a class="jxr_linenumber" name="426" href="#426">426</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="427" href="#427">427</a>   }
-<a class="jxr_linenumber" name="428" href="#428">428</a> 
-<a class="jxr_linenumber" name="429" href="#429">429</a>   @Test (timeout = 800000)
-<a class="jxr_linenumber" name="430" href="#430">430</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testRegionReplicationOnMidClusterSameHosts() {
-<a class="jxr_linenumber" name="431" href="#431">431</a>     conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 2000000L);
-<a class="jxr_linenumber" name="432" href="#432">432</a>     conf.setLong(<span class="jxr_string">"hbase.master.balancer.stochastic.maxRunningTime"</span>, 90 * 1000); <em class="jxr_comment">// 90 sec</em>
-<a class="jxr_linenumber" name="433" href="#433">433</a>     conf.setFloat(<span class="jxr_string">"hbase.master.balancer.stochastic.maxMovePercent"</span>, 1.0f);
-<a class="jxr_linenumber" name="434" href="#434">434</a>     loadBalancer.setConf(conf);
-<a class="jxr_linenumber" name="435" href="#435">435</a>     <strong class="jxr_keyword">int</strong> numHosts = 100;
-<a class="jxr_linenumber" name="436" href="#436">436</a>     <strong class="jxr_keyword">int</strong> numRegions = 100 * 100;
-<a class="jxr_linenumber" name="437" href="#437">437</a>     <strong class="jxr_keyword">int</strong> replication = 3; <em class="jxr_comment">// 3 replicas per region</em>
-<a class="jxr_linenumber" name="438" href="#438">438</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 5;
-<a class="jxr_linenumber" name="439" href="#439">439</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
-<a class="jxr_linenumber" name="440" href="#440">440</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; serverMap =
-<a class="jxr_linenumber" name="441" href="#441">441</a>         createServerMap(numHosts, numRegions, numRegionsPerServer, replication, numTables);
-<a class="jxr_linenumber" name="442" href="#442">442</a>     <strong class="jxr_keyword">int</strong> numNodesPerHost = 4;
-<a class="jxr_linenumber" name="443" href="#443">443</a> 
-<a class="jxr_linenumber" name="444" href="#444">444</a>     <em class="jxr_comment">// create a new map with 4 RS per host.</em>
-<a class="jxr_linenumber" name="445" href="#445">445</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; newServerMap = <strong class="jxr_keyword">new</strong> TreeMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt;(serverMap);
-<a class="jxr_linenumber" name="446" href="#446">446</a>     <strong class="jxr_keyword">for</strong> (Map.Entry&lt;ServerName, List&lt;HRegionInfo&gt;&gt; entry : serverMap.entrySet()) {
-<a class="jxr_linenumber" name="447" href="#447">447</a>       <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i=1; i &lt; numNodesPerHost; i++) {
-<a class="jxr_linenumber" name="448" href="#448">448</a>         ServerName s1 = entry.getKey();
-<a class="jxr_linenumber" name="449" href="#449">449</a>         ServerName s2 = ServerName.valueOf(s1.getHostname(), s1.getPort() + i, 1); <em class="jxr_comment">// create an RS for the same host</em>
-<a class="jxr_linenumber" name="450" href="#450">450</a>         newServerMap.put(s2, <strong class="jxr_keyword">new</strong> ArrayList&lt;HRegionInfo&gt;());
-<a class="jxr_linenumber" name="451" href="#451">451</a>       }
-<a class="jxr_linenumber" name="452" href="#452">452</a>     }
-<a class="jxr_linenumber" name="453" href="#453">453</a> 
-<a class="jxr_linenumber" name="454" href="#454">454</a>     testWithCluster(newServerMap, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="420" href="#420">420</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMidCluster2() {
+<a class="jxr_linenumber" name="421" href="#421">421</a>     <strong class="jxr_keyword">int</strong> numNodes = 200;
+<a class="jxr_linenumber" name="422" href="#422">422</a>     <strong class="jxr_keyword">int</strong> numRegions = 100000;
+<a class="jxr_linenumber" name="423" href="#423">423</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 40; <em class="jxr_comment">// all servers except one</em>
+<a class="jxr_linenumber" name="424" href="#424">424</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="425" href="#425">425</a>     <strong class="jxr_keyword">int</strong> numTables = 400;
+<a class="jxr_linenumber" name="426" href="#426">426</a>     testWithCluster(numNodes,
+<a class="jxr_linenumber" name="427" href="#427">427</a>         numRegions,
+<a class="jxr_linenumber" name="428" href="#428">428</a>         numRegionsPerServer,
+<a class="jxr_linenumber" name="429" href="#429">429</a>         replication,
+<a class="jxr_linenumber" name="430" href="#430">430</a>         numTables,
+<a class="jxr_linenumber" name="431" href="#431">431</a>         false, <em class="jxr_comment">/*<em class="jxr_comment"> num large num regions means may not always get to best balance with one run */</em></em>
+<a class="jxr_linenumber" name="432" href="#432">432</a>         false);
+<a class="jxr_linenumber" name="433" href="#433">433</a>   }
+<a class="jxr_linenumber" name="434" href="#434">434</a> 
+<a class="jxr_linenumber" name="435" href="#435">435</a> 
+<a class="jxr_linenumber" name="436" href="#436">436</a>   @Test (timeout = 800000)
+<a class="jxr_linenumber" name="437" href="#437">437</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testMidCluster3() {
+<a class="jxr_linenumber" name="438" href="#438">438</a>     <strong class="jxr_keyword">int</strong> numNodes = 100;
+<a class="jxr_linenumber" name="439" href="#439">439</a>     <strong class="jxr_keyword">int</strong> numRegions = 2000;
+<a class="jxr_linenumber" name="440" href="#440">440</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 9; <em class="jxr_comment">// all servers except one</em>
+<a class="jxr_linenumber" name="441" href="#441">441</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="442" href="#442">442</a>     <strong class="jxr_keyword">int</strong> numTables = 110;
+<a class="jxr_linenumber" name="443" href="#443">443</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="444" href="#444">444</a>     <em class="jxr_comment">// TODO(eclark): Make sure that the tables are well distributed.</em>
+<a class="jxr_linenumber" name="445" href="#445">445</a>   }
+<a class="jxr_linenumber" name="446" href="#446">446</a> 
+<a class="jxr_linenumber" name="447" href="#447">447</a>   @Test
+<a class="jxr_linenumber" name="448" href="#448">448</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testLargeCluster() {
+<a class="jxr_linenumber" name="449" href="#449">449</a>     <strong class="jxr_keyword">int</strong> numNodes = 1000;
+<a class="jxr_linenumber" name="450" href="#450">450</a>     <strong class="jxr_keyword">int</strong> numRegions = 100000; <em class="jxr_comment">//100 regions per RS</em>
+<a class="jxr_linenumber" name="451" href="#451">451</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 80; <em class="jxr_comment">//all servers except one</em>
+<a class="jxr_linenumber" name="452" href="#452">452</a>     <strong class="jxr_keyword">int</strong> numTables = 100;
+<a class="jxr_linenumber" name="453" href="#453">453</a>     <strong class="jxr_keyword">int</strong> replication = 1;
+<a class="jxr_linenumber" name="454" href="#454">454</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
 <a class="jxr_linenumber" name="455" href="#455">455</a>   }
 <a class="jxr_linenumber" name="456" href="#456">456</a> 
-<a class="jxr_linenumber" name="457" href="#457">457</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManager</a> <strong class="jxr_keyword">extends</strong> RackManager {
-<a class="jxr_linenumber" name="458" href="#458">458</a>     <strong class="jxr_keyword">int</strong> numRacks;
-<a class="jxr_linenumber" name="459" href="#459">459</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManager</a>(<strong class="jxr_keyword">int</strong> numRacks) {
-<a class="jxr_linenumber" name="460" href="#460">460</a>       <strong class="jxr_keyword">this</strong>.numRacks = numRacks;
-<a class="jxr_linenumber" name="461" href="#461">461</a>     }
-<a class="jxr_linenumber" name="462" href="#462">462</a>     @Override
-<a class="jxr_linenumber" name="463" href="#463">463</a>     <strong class="jxr_keyword">public</strong> String getRack(ServerName server) {
-<a class="jxr_linenumber" name="464" href="#464">464</a>       <strong class="jxr_keyword">return</strong> <span class="jxr_string">"rack_"</span> + (server.hashCode() % numRacks);
-<a class="jxr_linenumber" name="465" href="#465">465</a>     }
-<a class="jxr_linenumber" name="466" href="#466">466</a>   }
-<a class="jxr_linenumber" name="467" href="#467">467</a> 
-<a class="jxr_linenumber" name="468" href="#468">468</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManagerOne</a> <strong class="jxr_keyword">extends</strong> RackManager {
-<a class="jxr_linenumber" name="469" href="#469">469</a>   @Override
-<a class="jxr_linenumber" name="470" href="#470">470</a>     <strong class="jxr_keyword">public</strong> String getRack(ServerName server) {
-<a class="jxr_linenumber" name="471" href="#471">471</a>       <strong class="jxr_keyword">return</strong> server.getHostname().endsWith(<span class="jxr_string">"1"</span>) ? <span class="jxr_string">"rack1"</span> : <span class="jxr_string">"rack2"</span>;
-<a class="jxr_linenumber" name="472" href="#472">472</a>     }
-<a class="jxr_linenumber" name="473" href="#473">473</a>   }
-<a class="jxr_linenumber" name="474" href="#474">474</a> 
-<a class="jxr_linenumber" name="475" href="#475">475</a>   @Test (timeout = 800000)
-<a class="jxr_linenumber" name="476" href="#476">476</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testRegionReplicationOnMidClusterWithRacks() {
-<a class="jxr_linenumber" name="477" href="#477">477</a>     conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 10000000L);
-<a class="jxr_linenumber" name="478" href="#478">478</a>     conf.setFloat(<span class="jxr_string">"hbase.master.balancer.stochastic.maxMovePercent"</span>, 1.0f);
-<a class="jxr_linenumber" name="479" href="#479">479</a>     conf.setLong(<span class="jxr_string">"hbase.master.balancer.stochastic.maxRunningTime"</span>, 120 * 1000); <em class="jxr_comment">// 120 sec</em>
-<a class="jxr_linenumber" name="480" href="#480">480</a>     loadBalancer.setConf(conf);
-<a class="jxr_linenumber" name="481" href="#481">481</a>     <strong class="jxr_keyword">int</strong> numNodes = 30;
-<a class="jxr_linenumber" name="482" href="#482">482</a>     <strong class="jxr_keyword">int</strong> numRegions = numNodes * 30;
-<a class="jxr_linenumber" name="483" href="#483">483</a>     <strong class="jxr_keyword">int</strong> replication = 3; <em class="jxr_comment">// 3 replicas per region</em>
-<a class="jxr_linenumber" name="484" href="#484">484</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 28;
-<a class="jxr_linenumber" name="485" href="#485">485</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
-<a class="jxr_linenumber" name="486" href="#486">486</a>     <strong class="jxr_keyword">int</strong> numRacks = 4; <em class="jxr_comment">// all replicas should be on a different rack</em>
-<a class="jxr_linenumber" name="487" href="#487">487</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; serverMap =
-<a class="jxr_linenumber" name="488" href="#488">488</a>         createServerMap(numNodes, numRegions, numRegionsPerServer, replication, numTables);
-<a class="jxr_linenumber" name="489" href="#489">489</a>     RackManager rm = <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManager</a>(numRacks);
-<a class="jxr_linenumber" name="490" href="#490">490</a> 
-<a class="jxr_linenumber" name="491" href="#491">491</a>     testWithCluster(serverMap, rm, false, <strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="492" href="#492">492</a>   }
-<a class="jxr_linenumber" name="493" href="#493">493</a> 
-<a class="jxr_linenumber" name="494" href="#494">494</a> }
+<a class="jxr_linenumber" name="457" href="#457">457</a>   @Test (timeout = 800000)
+<a class="jxr_linenumber" name="458" href="#458">458</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testRegionReplicasOnSmallCluster() {
+<a class="jxr_linenumber" name="459" href="#459">459</a>     <strong class="jxr_keyword">int</strong> numNodes = 10;
+<a class="jxr_linenumber" name="460" href="#460">460</a>     <strong class="jxr_keyword">int</strong> numRegions = 1000;
+<a class="jxr_linenumber" name="461" href="#461">461</a>     <strong class="jxr_keyword">int</strong> replication = 3; <em class="jxr_comment">// 3 replicas per region</em>
+<a class="jxr_linenumber" name="462" href="#462">462</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 80; <em class="jxr_comment">//all regions are mostly balanced</em>
+<a class="jxr_linenumber" name="463" href="#463">463</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
+<a class="jxr_linenumber" name="464" href="#464">464</a>     testWithCluster(numNodes, numRegions, numRegionsPerServer, replication, numTables, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="465" href="#465">465</a>   }
+<a class="jxr_linenumber" name="466" href="#466">466</a> 
+<a class="jxr_linenumber" name="467" href="#467">467</a>   @Test (timeout = 800000)
+<a class="jxr_linenumber" name="468" href="#468">468</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testRegionReplicationOnMidClusterSameHosts() {
+<a class="jxr_linenumber" name="469" href="#469">469</a>     conf.setLong(StochasticLoadBalancer.MAX_STEPS_KEY, 2000000L);
+<a class="jxr_linenumber" name="470" href="#470">470</a>     conf.setLong(<span class="jxr_string">"hbase.master.balancer.stochastic.maxRunningTime"</span>, 90 * 1000); <em class="jxr_comment">// 90 sec</em>
+<a class="jxr_linenumber" name="471" href="#471">471</a>     conf.setFloat(<span class="jxr_string">"hbase.master.balancer.stochastic.maxMovePercent"</span>, 1.0f);
+<a class="jxr_linenumber" name="472" href="#472">472</a>     loadBalancer.setConf(conf);
+<a class="jxr_linenumber" name="473" href="#473">473</a>     <strong class="jxr_keyword">int</strong> numHosts = 100;
+<a class="jxr_linenumber" name="474" href="#474">474</a>     <strong class="jxr_keyword">int</strong> numRegions = 100 * 100;
+<a class="jxr_linenumber" name="475" href="#475">475</a>     <strong class="jxr_keyword">int</strong> replication = 3; <em class="jxr_comment">// 3 replicas per region</em>
+<a class="jxr_linenumber" name="476" href="#476">476</a>     <strong class="jxr_keyword">int</strong> numRegionsPerServer = 5;
+<a class="jxr_linenumber" name="477" href="#477">477</a>     <strong class="jxr_keyword">int</strong> numTables = 10;
+<a class="jxr_linenumber" name="478" href="#478">478</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; serverMap =
+<a class="jxr_linenumber" name="479" href="#479">479</a>         createServerMap(numHosts, numRegions, numRegionsPerServer, replication, numTables);
+<a class="jxr_linenumber" name="480" href="#480">480</a>     <strong class="jxr_keyword">int</strong> numNodesPerHost = 4;
+<a class="jxr_linenumber" name="481" href="#481">481</a> 
+<a class="jxr_linenumber" name="482" href="#482">482</a>     <em class="jxr_comment">// create a new map with 4 RS per host.</em>
+<a class="jxr_linenumber" name="483" href="#483">483</a>     Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; newServerMap = <strong class="jxr_keyword">new</strong> TreeMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt;(serverMap);
+<a class="jxr_linenumber" name="484" href="#484">484</a>     <strong class="jxr_keyword">for</strong> (Map.Entry&lt;ServerName, List&lt;HRegionInfo&gt;&gt; entry : serverMap.entrySet()) {
+<a class="jxr_linenumber" name="485" href="#485">485</a>       <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i=1; i &lt; numNodesPerHost; i++) {
+<a class="jxr_linenumber" name="486" href="#486">486</a>         ServerName s1 = entry.getKey();
+<a class="jxr_linenumber" name="487" href="#487">487</a>         ServerName s2 = ServerName.valueOf(s1.getHostname(), s1.getPort() + i, 1); <em class="jxr_comment">// create an RS for the same host</em>
+<a class="jxr_linenumber" name="488" href="#488">488</a>         newServerMap.put(s2, <strong class="jxr_keyword">new</strong> ArrayList&lt;HRegionInfo&gt;());
+<a class="jxr_linenumber" name="489" href="#489">489</a>       }
+<a class="jxr_linenumber" name="490" href="#490">490</a>     }
+<a class="jxr_linenumber" name="491" href="#491">491</a> 
+<a class="jxr_linenumber" name="492" href="#492">492</a>     testWithCluster(newServerMap, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="493" href="#493">493</a>   }
+<a class="jxr_linenumber" name="494" href="#494">494</a> 
+<a class="jxr_linenumber" name="495" href="#495">495</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManager</a> <strong class="jxr_keyword">extends</strong> RackManager {
+<a class="jxr_linenumber" name="496" href="#496">496</a>     <strong class="jxr_keyword">int</strong> numRacks;
+<a class="jxr_linenumber" name="497" href="#497">497</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../../org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.html">ForTestRackManager</a>(<strong class="jxr_keyword">int</strong> numRacks) {
+<a class="jxr_linenumber" name="498" href="#498">498</a>       <strong class="jxr_keyword">this</strong>.numRacks = numRacks;
+<a class="jxr_linenumber" name="499" href="#499">499</a>     }
+<a class="jxr_linenumber" name="500" href="#500">500</a>     @Override
+<a class="jxr_linenumber" name="501" href="#501">501</a>     <strong class="jxr_keyword">public</strong> String getRack(ServerName server) {
+<a class="jxr_linenumber" name="502" href="#502">502</a>       <strong class="jxr_keyword">return</strong> <span class="jxr_string">"rack_"</span> + (server.hashCode() % numRacks);
+<a class="jxr_linenumber" name="503" href="#503">503</a>     }

[... 33 lines stripped ...]



Mime
View raw message