hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [30/51] [partial] hbase-site git commit: Published site at 29a192ef3cbe3b9cc12a6ee38f39e1199ac9790f.
Date Thu, 11 Feb 2016 17:34:36 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/8bb348c6/devapidocs/src-html/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.Cluster.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.Cluster.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.Cluster.html
index ccccc8d..d2f53d2 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.Cluster.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.Cluster.html
@@ -89,16 +89,16 @@
 <span class="sourceLineNo">081</span>      return UNKNOWN_RACK;<a name="line.81"></a>
 <span class="sourceLineNo">082</span>    }<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">084</span><a name="line.84"></a>
 <span class="sourceLineNo">085</span>  /**<a name="line.85"></a>
 <span class="sourceLineNo">086</span>   * The constructor that uses the basic MetricsBalancer<a name="line.86"></a>
 <span class="sourceLineNo">087</span>   */<a name="line.87"></a>
 <span class="sourceLineNo">088</span>  protected BaseLoadBalancer() {<a name="line.88"></a>
 <span class="sourceLineNo">089</span>    metricsBalancer = new MetricsBalancer();<a name="line.89"></a>
 <span class="sourceLineNo">090</span>  }<a name="line.90"></a>
-<span class="sourceLineNo">091</span>  <a name="line.91"></a>
+<span class="sourceLineNo">091</span><a name="line.91"></a>
 <span class="sourceLineNo">092</span>  /**<a name="line.92"></a>
-<span class="sourceLineNo">093</span>   * This Constructor accepts an instance of MetricsBalancer, <a name="line.93"></a>
+<span class="sourceLineNo">093</span>   * This Constructor accepts an instance of MetricsBalancer,<a name="line.93"></a>
 <span class="sourceLineNo">094</span>   * which will be used instead of creating a new one<a name="line.94"></a>
 <span class="sourceLineNo">095</span>   */<a name="line.95"></a>
 <span class="sourceLineNo">096</span>  protected BaseLoadBalancer(MetricsBalancer metricsBalancer) {<a name="line.96"></a>
@@ -1287,284 +1287,251 @@
 <span class="sourceLineNo">1279</span>  }<a name="line.1279"></a>
 <span class="sourceLineNo">1280</span><a name="line.1280"></a>
 <span class="sourceLineNo">1281</span>  /**<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>   * Generates an immediate assignment plan to be used by a new master for<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>   * regions in transition that do not have an already known destination.<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>   *<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>   * Takes a list of regions that need immediate assignment and a list of all<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>   * available servers. Returns a map of regions to the server they should be<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>   * assigned to.<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span>   *<a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>   * This method will return quickly and does not do any intelligent balancing.<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>   * The goal is to make a fast decision not the best decision possible.<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>   *<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>   * Currently this is random.<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>   *<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>   * @param regions<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>   * @param servers<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>   * @return map of regions to the server it should be assigned to<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>   */<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>  @Override<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>  public Map&lt;HRegionInfo, ServerName&gt; immediateAssignment(List&lt;HRegionInfo&gt; regions,<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>      List&lt;ServerName&gt; servers) {<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>    metricsBalancer.incrMiscInvocations();<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>    if (servers == null || servers.isEmpty()) {<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>      LOG.warn("Wanted to do random assignment but no servers to assign to");<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>      return null;<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>    }<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span><a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>    Map&lt;HRegionInfo, ServerName&gt; assignments = new TreeMap&lt;HRegionInfo, ServerName&gt;();<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>    for (HRegionInfo region : regions) {<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>      assignments.put(region, randomAssignment(region, servers));<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>    }<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>    return assignments;<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>  }<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span><a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>  /**<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>   * Used to assign a single region to a random server.<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>   */<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>  @Override<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>  public ServerName randomAssignment(HRegionInfo regionInfo, List&lt;ServerName&gt; servers) {<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>    metricsBalancer.incrMiscInvocations();<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>    if (servers != null &amp;&amp; servers.contains(masterServerName)) {<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>      if (shouldBeOnMaster(regionInfo)) {<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>        return masterServerName;<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>      }<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>      servers = new ArrayList&lt;ServerName&gt;(servers);<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      // Guarantee not to put other regions on master<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>      servers.remove(masterServerName);<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>    }<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span><a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>    int numServers = servers == null ? 0 : servers.size();<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>    if (numServers == 0) {<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>      LOG.warn("Wanted to do retain assignment but no servers to assign to");<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>      return null;<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>    }<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>    if (numServers == 1) { // Only one server, nothing fancy we can do here<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>      return servers.get(0);<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>    }<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span><a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>    List&lt;HRegionInfo&gt; regions = Lists.newArrayList(regionInfo);<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>    Cluster cluster = createCluster(servers, regions);<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>    return randomAssignment(cluster, regionInfo, servers);<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>  }<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span><a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>  /**<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>   * Generates a bulk assignment startup plan, attempting to reuse the existing<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>   * assignment information from META, but adjusting for the specified list of<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>   * available/online servers available for assignment.<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>   * &lt;p&gt;<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>   * Takes a map of all regions to their existing assignment from META. Also<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>   * takes a list of online servers for regions to be assigned to. Attempts to<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>   * retain all assignment, so in some instances initial assignment will not be<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>   * completely balanced.<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>   * &lt;p&gt;<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>   * Any leftover regions without an existing server to be assigned to will be<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>   * assigned randomly to available servers.<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>   *<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>   * @param regions regions and existing assignment from meta<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>   * @param servers available servers<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>   * @return map of servers and regions to be assigned to them<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>   */<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>  @Override<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>  public Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; retainAssignment(Map&lt;HRegionInfo, ServerName&gt; regions,<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>      List&lt;ServerName&gt; servers) {<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>    // Update metrics<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>    metricsBalancer.incrMiscInvocations();<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>    Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; assignments<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>      = assignMasterRegions(regions.keySet(), servers);<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>    if (assignments != null &amp;&amp; !assignments.isEmpty()) {<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>      servers = new ArrayList&lt;ServerName&gt;(servers);<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>      // Guarantee not to put other regions on master<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>      servers.remove(masterServerName);<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>      List&lt;HRegionInfo&gt; masterRegions = assignments.get(masterServerName);<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>      if (!masterRegions.isEmpty()) {<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>        regions = new HashMap&lt;HRegionInfo, ServerName&gt;(regions);<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>        for (HRegionInfo region: masterRegions) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>          regions.remove(region);<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>        }<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>      }<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>    }<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>    if (regions == null || regions.isEmpty()) {<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>      return assignments;<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>    }<a name="line.1381"></a>
+<span class="sourceLineNo">1282</span>   * Used to assign a single region to a random server.<a name="line.1282"></a>
+<span class="sourceLineNo">1283</span>   */<a name="line.1283"></a>
+<span class="sourceLineNo">1284</span>  @Override<a name="line.1284"></a>
+<span class="sourceLineNo">1285</span>  public ServerName randomAssignment(HRegionInfo regionInfo, List&lt;ServerName&gt; servers) {<a name="line.1285"></a>
+<span class="sourceLineNo">1286</span>    metricsBalancer.incrMiscInvocations();<a name="line.1286"></a>
+<span class="sourceLineNo">1287</span>    if (servers != null &amp;&amp; servers.contains(masterServerName)) {<a name="line.1287"></a>
+<span class="sourceLineNo">1288</span>      if (shouldBeOnMaster(regionInfo)) {<a name="line.1288"></a>
+<span class="sourceLineNo">1289</span>        return masterServerName;<a name="line.1289"></a>
+<span class="sourceLineNo">1290</span>      }<a name="line.1290"></a>
+<span class="sourceLineNo">1291</span>      servers = new ArrayList&lt;ServerName&gt;(servers);<a name="line.1291"></a>
+<span class="sourceLineNo">1292</span>      // Guarantee not to put other regions on master<a name="line.1292"></a>
+<span class="sourceLineNo">1293</span>      servers.remove(masterServerName);<a name="line.1293"></a>
+<span class="sourceLineNo">1294</span>    }<a name="line.1294"></a>
+<span class="sourceLineNo">1295</span><a name="line.1295"></a>
+<span class="sourceLineNo">1296</span>    int numServers = servers == null ? 0 : servers.size();<a name="line.1296"></a>
+<span class="sourceLineNo">1297</span>    if (numServers == 0) {<a name="line.1297"></a>
+<span class="sourceLineNo">1298</span>      LOG.warn("Wanted to do retain assignment but no servers to assign to");<a name="line.1298"></a>
+<span class="sourceLineNo">1299</span>      return null;<a name="line.1299"></a>
+<span class="sourceLineNo">1300</span>    }<a name="line.1300"></a>
+<span class="sourceLineNo">1301</span>    if (numServers == 1) { // Only one server, nothing fancy we can do here<a name="line.1301"></a>
+<span class="sourceLineNo">1302</span>      return servers.get(0);<a name="line.1302"></a>
+<span class="sourceLineNo">1303</span>    }<a name="line.1303"></a>
+<span class="sourceLineNo">1304</span><a name="line.1304"></a>
+<span class="sourceLineNo">1305</span>    List&lt;HRegionInfo&gt; regions = Lists.newArrayList(regionInfo);<a name="line.1305"></a>
+<span class="sourceLineNo">1306</span>    Cluster cluster = createCluster(servers, regions);<a name="line.1306"></a>
+<span class="sourceLineNo">1307</span>    return randomAssignment(cluster, regionInfo, servers);<a name="line.1307"></a>
+<span class="sourceLineNo">1308</span>  }<a name="line.1308"></a>
+<span class="sourceLineNo">1309</span><a name="line.1309"></a>
+<span class="sourceLineNo">1310</span>  /**<a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>   * Generates a bulk assignment startup plan, attempting to reuse the existing<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>   * assignment information from META, but adjusting for the specified list of<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span>   * available/online servers available for assignment.<a name="line.1313"></a>
+<span class="sourceLineNo">1314</span>   * &lt;p&gt;<a name="line.1314"></a>
+<span class="sourceLineNo">1315</span>   * Takes a map of all regions to their existing assignment from META. Also<a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>   * takes a list of online servers for regions to be assigned to. Attempts to<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>   * retain all assignment, so in some instances initial assignment will not be<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>   * completely balanced.<a name="line.1318"></a>
+<span class="sourceLineNo">1319</span>   * &lt;p&gt;<a name="line.1319"></a>
+<span class="sourceLineNo">1320</span>   * Any leftover regions without an existing server to be assigned to will be<a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>   * assigned randomly to available servers.<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>   *<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span>   * @param regions regions and existing assignment from meta<a name="line.1323"></a>
+<span class="sourceLineNo">1324</span>   * @param servers available servers<a name="line.1324"></a>
+<span class="sourceLineNo">1325</span>   * @return map of servers and regions to be assigned to them<a name="line.1325"></a>
+<span class="sourceLineNo">1326</span>   */<a name="line.1326"></a>
+<span class="sourceLineNo">1327</span>  @Override<a name="line.1327"></a>
+<span class="sourceLineNo">1328</span>  public Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; retainAssignment(Map&lt;HRegionInfo, ServerName&gt; regions,<a name="line.1328"></a>
+<span class="sourceLineNo">1329</span>      List&lt;ServerName&gt; servers) {<a name="line.1329"></a>
+<span class="sourceLineNo">1330</span>    // Update metrics<a name="line.1330"></a>
+<span class="sourceLineNo">1331</span>    metricsBalancer.incrMiscInvocations();<a name="line.1331"></a>
+<span class="sourceLineNo">1332</span>    Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; assignments<a name="line.1332"></a>
+<span class="sourceLineNo">1333</span>      = assignMasterRegions(regions.keySet(), servers);<a name="line.1333"></a>
+<span class="sourceLineNo">1334</span>    if (assignments != null &amp;&amp; !assignments.isEmpty()) {<a name="line.1334"></a>
+<span class="sourceLineNo">1335</span>      servers = new ArrayList&lt;ServerName&gt;(servers);<a name="line.1335"></a>
+<span class="sourceLineNo">1336</span>      // Guarantee not to put other regions on master<a name="line.1336"></a>
+<span class="sourceLineNo">1337</span>      servers.remove(masterServerName);<a name="line.1337"></a>
+<span class="sourceLineNo">1338</span>      List&lt;HRegionInfo&gt; masterRegions = assignments.get(masterServerName);<a name="line.1338"></a>
+<span class="sourceLineNo">1339</span>      if (!masterRegions.isEmpty()) {<a name="line.1339"></a>
+<span class="sourceLineNo">1340</span>        regions = new HashMap&lt;HRegionInfo, ServerName&gt;(regions);<a name="line.1340"></a>
+<span class="sourceLineNo">1341</span>        for (HRegionInfo region: masterRegions) {<a name="line.1341"></a>
+<span class="sourceLineNo">1342</span>          regions.remove(region);<a name="line.1342"></a>
+<span class="sourceLineNo">1343</span>        }<a name="line.1343"></a>
+<span class="sourceLineNo">1344</span>      }<a name="line.1344"></a>
+<span class="sourceLineNo">1345</span>    }<a name="line.1345"></a>
+<span class="sourceLineNo">1346</span>    if (regions == null || regions.isEmpty()) {<a name="line.1346"></a>
+<span class="sourceLineNo">1347</span>      return assignments;<a name="line.1347"></a>
+<span class="sourceLineNo">1348</span>    }<a name="line.1348"></a>
+<span class="sourceLineNo">1349</span><a name="line.1349"></a>
+<span class="sourceLineNo">1350</span>    int numServers = servers == null ? 0 : servers.size();<a name="line.1350"></a>
+<span class="sourceLineNo">1351</span>    if (numServers == 0) {<a name="line.1351"></a>
+<span class="sourceLineNo">1352</span>      LOG.warn("Wanted to do retain assignment but no servers to assign to");<a name="line.1352"></a>
+<span class="sourceLineNo">1353</span>      return null;<a name="line.1353"></a>
+<span class="sourceLineNo">1354</span>    }<a name="line.1354"></a>
+<span class="sourceLineNo">1355</span>    if (numServers == 1) { // Only one server, nothing fancy we can do here<a name="line.1355"></a>
+<span class="sourceLineNo">1356</span>      ServerName server = servers.get(0);<a name="line.1356"></a>
+<span class="sourceLineNo">1357</span>      assignments.put(server, new ArrayList&lt;HRegionInfo&gt;(regions.keySet()));<a name="line.1357"></a>
+<span class="sourceLineNo">1358</span>      return assignments;<a name="line.1358"></a>
+<span class="sourceLineNo">1359</span>    }<a name="line.1359"></a>
+<span class="sourceLineNo">1360</span><a name="line.1360"></a>
+<span class="sourceLineNo">1361</span>    // Group all of the old assignments by their hostname.<a name="line.1361"></a>
+<span class="sourceLineNo">1362</span>    // We can't group directly by ServerName since the servers all have<a name="line.1362"></a>
+<span class="sourceLineNo">1363</span>    // new start-codes.<a name="line.1363"></a>
+<span class="sourceLineNo">1364</span><a name="line.1364"></a>
+<span class="sourceLineNo">1365</span>    // Group the servers by their hostname. It's possible we have multiple<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>    // servers on the same host on different ports.<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>    ArrayListMultimap&lt;String, ServerName&gt; serversByHostname = ArrayListMultimap.create();<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span>    for (ServerName server : servers) {<a name="line.1368"></a>
+<span class="sourceLineNo">1369</span>      assignments.put(server, new ArrayList&lt;HRegionInfo&gt;());<a name="line.1369"></a>
+<span class="sourceLineNo">1370</span>      serversByHostname.put(server.getHostname(), server);<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>    }<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span><a name="line.1372"></a>
+<span class="sourceLineNo">1373</span>    // Collection of the hostnames that used to have regions<a name="line.1373"></a>
+<span class="sourceLineNo">1374</span>    // assigned, but for which we no longer have any RS running<a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>    // after the cluster restart.<a name="line.1375"></a>
+<span class="sourceLineNo">1376</span>    Set&lt;String&gt; oldHostsNoLongerPresent = Sets.newTreeSet();<a name="line.1376"></a>
+<span class="sourceLineNo">1377</span><a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>    int numRandomAssignments = 0;<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span>    int numRetainedAssigments = 0;<a name="line.1379"></a>
+<span class="sourceLineNo">1380</span><a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>    Cluster cluster = createCluster(servers, regions.keySet());<a name="line.1381"></a>
 <span class="sourceLineNo">1382</span><a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>    int numServers = servers == null ? 0 : servers.size();<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>    if (numServers == 0) {<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>      LOG.warn("Wanted to do retain assignment but no servers to assign to");<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>      return null;<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>    }<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>    if (numServers == 1) { // Only one server, nothing fancy we can do here<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>      ServerName server = servers.get(0);<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>      assignments.put(server, new ArrayList&lt;HRegionInfo&gt;(regions.keySet()));<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>      return assignments;<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>    }<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span><a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>    // Group all of the old assignments by their hostname.<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>    // We can't group directly by ServerName since the servers all have<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>    // new start-codes.<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span><a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>    // Group the servers by their hostname. It's possible we have multiple<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>    // servers on the same host on different ports.<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>    ArrayListMultimap&lt;String, ServerName&gt; serversByHostname = ArrayListMultimap.create();<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>    for (ServerName server : servers) {<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>      assignments.put(server, new ArrayList&lt;HRegionInfo&gt;());<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>      serversByHostname.put(server.getHostname(), server);<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>    }<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span><a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>    // Collection of the hostnames that used to have regions<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>    // assigned, but for which we no longer have any RS running<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>    // after the cluster restart.<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>    Set&lt;String&gt; oldHostsNoLongerPresent = Sets.newTreeSet();<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span><a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>    int numRandomAssignments = 0;<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>    int numRetainedAssigments = 0;<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span><a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>    Cluster cluster = createCluster(servers, regions.keySet());<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span><a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>    for (Map.Entry&lt;HRegionInfo, ServerName&gt; entry : regions.entrySet()) {<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>      HRegionInfo region = entry.getKey();<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>      ServerName oldServerName = entry.getValue();<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>      List&lt;ServerName&gt; localServers = new ArrayList&lt;ServerName&gt;();<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>      if (oldServerName != null) {<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>        localServers = serversByHostname.get(oldServerName.getHostname());<a name="line.1421"></a>
+<span class="sourceLineNo">1383</span>    for (Map.Entry&lt;HRegionInfo, ServerName&gt; entry : regions.entrySet()) {<a name="line.1383"></a>
+<span class="sourceLineNo">1384</span>      HRegionInfo region = entry.getKey();<a name="line.1384"></a>
+<span class="sourceLineNo">1385</span>      ServerName oldServerName = entry.getValue();<a name="line.1385"></a>
+<span class="sourceLineNo">1386</span>      List&lt;ServerName&gt; localServers = new ArrayList&lt;ServerName&gt;();<a name="line.1386"></a>
+<span class="sourceLineNo">1387</span>      if (oldServerName != null) {<a name="line.1387"></a>
+<span class="sourceLineNo">1388</span>        localServers = serversByHostname.get(oldServerName.getHostname());<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span>      }<a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>      if (localServers.isEmpty()) {<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span>        // No servers on the new cluster match up with this hostname,<a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>        // assign randomly.<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>        ServerName randomServer = randomAssignment(cluster, region, servers);<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span>        assignments.get(randomServer).add(region);<a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>        numRandomAssignments++;<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>        if (oldServerName != null) oldHostsNoLongerPresent.add(oldServerName.getHostname());<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span>      } else if (localServers.size() == 1) {<a name="line.1397"></a>
+<span class="sourceLineNo">1398</span>        // the usual case - one new server on same host<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>        ServerName target = localServers.get(0);<a name="line.1399"></a>
+<span class="sourceLineNo">1400</span>        assignments.get(target).add(region);<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span>        cluster.doAssignRegion(region, target);<a name="line.1401"></a>
+<span class="sourceLineNo">1402</span>        numRetainedAssigments++;<a name="line.1402"></a>
+<span class="sourceLineNo">1403</span>      } else {<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>        // multiple new servers in the cluster on this same host<a name="line.1404"></a>
+<span class="sourceLineNo">1405</span>        if (localServers.contains(oldServerName)) {<a name="line.1405"></a>
+<span class="sourceLineNo">1406</span>          assignments.get(oldServerName).add(region);<a name="line.1406"></a>
+<span class="sourceLineNo">1407</span>          cluster.doAssignRegion(region, oldServerName);<a name="line.1407"></a>
+<span class="sourceLineNo">1408</span>        } else {<a name="line.1408"></a>
+<span class="sourceLineNo">1409</span>          ServerName target = null;<a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>          for (ServerName tmp: localServers) {<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span>            if (tmp.getPort() == oldServerName.getPort()) {<a name="line.1411"></a>
+<span class="sourceLineNo">1412</span>              target = tmp;<a name="line.1412"></a>
+<span class="sourceLineNo">1413</span>              break;<a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>            }<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span>          }<a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>          if (target == null) {<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>            target = randomAssignment(cluster, region, localServers);<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>          }<a name="line.1418"></a>
+<span class="sourceLineNo">1419</span>          assignments.get(target).add(region);<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>        }<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span>        numRetainedAssigments++;<a name="line.1421"></a>
 <span class="sourceLineNo">1422</span>      }<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>      if (localServers.isEmpty()) {<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>        // No servers on the new cluster match up with this hostname,<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>        // assign randomly.<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>        ServerName randomServer = randomAssignment(cluster, region, servers);<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>        assignments.get(randomServer).add(region);<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>        numRandomAssignments++;<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>        if (oldServerName != null) oldHostsNoLongerPresent.add(oldServerName.getHostname());<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>      } else if (localServers.size() == 1) {<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>        // the usual case - one new server on same host<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>        ServerName target = localServers.get(0);<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>        assignments.get(target).add(region);<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>        cluster.doAssignRegion(region, target);<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>        numRetainedAssigments++;<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>      } else {<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>        // multiple new servers in the cluster on this same host<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>        if (localServers.contains(oldServerName)) {<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>          assignments.get(oldServerName).add(region);<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>          cluster.doAssignRegion(region, oldServerName);<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>        } else {<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>          ServerName target = null;<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>          for (ServerName tmp: localServers) {<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>            if (tmp.getPort() == oldServerName.getPort()) {<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>              target = tmp;<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>              break;<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>            }<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>          }<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>          if (target == null) {<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>            target = randomAssignment(cluster, region, localServers);<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>          }<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>          assignments.get(target).add(region);<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>        }<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>        numRetainedAssigments++;<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>      }<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>    }<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span><a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>    String randomAssignMsg = "";<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>    if (numRandomAssignments &gt; 0) {<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>      randomAssignMsg =<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>          numRandomAssignments + " regions were assigned "<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span>              + "to random hosts, since the old hosts for these regions are no "<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>              + "longer present in the cluster. These hosts were:\n  "<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>              + Joiner.on("\n  ").join(oldHostsNoLongerPresent);<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>    }<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span><a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>    LOG.info("Reassigned " + regions.size() + " regions. " + numRetainedAssigments<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>        + " retained the pre-restart assignment. " + randomAssignMsg);<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>    return assignments;<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>  }<a name="line.1470"></a>
+<span class="sourceLineNo">1423</span>    }<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span><a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>    String randomAssignMsg = "";<a name="line.1425"></a>
+<span class="sourceLineNo">1426</span>    if (numRandomAssignments &gt; 0) {<a name="line.1426"></a>
+<span class="sourceLineNo">1427</span>      randomAssignMsg =<a name="line.1427"></a>
+<span class="sourceLineNo">1428</span>          numRandomAssignments + " regions were assigned "<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span>              + "to random hosts, since the old hosts for these regions are no "<a name="line.1429"></a>
+<span class="sourceLineNo">1430</span>              + "longer present in the cluster. These hosts were:\n  "<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span>              + Joiner.on("\n  ").join(oldHostsNoLongerPresent);<a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>    }<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span><a name="line.1433"></a>
+<span class="sourceLineNo">1434</span>    LOG.info("Reassigned " + regions.size() + " regions. " + numRetainedAssigments<a name="line.1434"></a>
+<span class="sourceLineNo">1435</span>        + " retained the pre-restart assignment. " + randomAssignMsg);<a name="line.1435"></a>
+<span class="sourceLineNo">1436</span>    return assignments;<a name="line.1436"></a>
+<span class="sourceLineNo">1437</span>  }<a name="line.1437"></a>
+<span class="sourceLineNo">1438</span><a name="line.1438"></a>
+<span class="sourceLineNo">1439</span>  @Override<a name="line.1439"></a>
+<span class="sourceLineNo">1440</span>  public void initialize() throws HBaseIOException{<a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>  }<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span><a name="line.1442"></a>
+<span class="sourceLineNo">1443</span>  @Override<a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>  public void regionOnline(HRegionInfo regionInfo, ServerName sn) {<a name="line.1444"></a>
+<span class="sourceLineNo">1445</span>  }<a name="line.1445"></a>
+<span class="sourceLineNo">1446</span><a name="line.1446"></a>
+<span class="sourceLineNo">1447</span>  @Override<a name="line.1447"></a>
+<span class="sourceLineNo">1448</span>  public void regionOffline(HRegionInfo regionInfo) {<a name="line.1448"></a>
+<span class="sourceLineNo">1449</span>  }<a name="line.1449"></a>
+<span class="sourceLineNo">1450</span><a name="line.1450"></a>
+<span class="sourceLineNo">1451</span>  @Override<a name="line.1451"></a>
+<span class="sourceLineNo">1452</span>  public boolean isStopped() {<a name="line.1452"></a>
+<span class="sourceLineNo">1453</span>    return stopped;<a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>  }<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span><a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>  @Override<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>  public void stop(String why) {<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>    LOG.info("Load Balancer stop requested: "+why);<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span>    stopped = true;<a name="line.1459"></a>
+<span class="sourceLineNo">1460</span>  }<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span><a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>  /**<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span>   * Used to assign a single region to a random server.<a name="line.1463"></a>
+<span class="sourceLineNo">1464</span>   */<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span>  private ServerName randomAssignment(Cluster cluster, HRegionInfo regionInfo,<a name="line.1465"></a>
+<span class="sourceLineNo">1466</span>      List&lt;ServerName&gt; servers) {<a name="line.1466"></a>
+<span class="sourceLineNo">1467</span>    int numServers = servers.size(); // servers is not null, numServers &gt; 1<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span>    ServerName sn = null;<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>    final int maxIterations = numServers * 4;<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>    int iterations = 0;<a name="line.1470"></a>
 <span class="sourceLineNo">1471</span><a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>  @Override<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>  public void initialize() throws HBaseIOException{<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>  }<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span><a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>  @Override<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>  public void regionOnline(HRegionInfo regionInfo, ServerName sn) {<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>  }<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span><a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>  @Override<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>  public void regionOffline(HRegionInfo regionInfo) {<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>  }<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span><a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>  @Override<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>  public boolean isStopped() {<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>    return stopped;<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>  }<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span><a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>  @Override<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>  public void stop(String why) {<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>    LOG.info("Load Balancer stop requested: "+why);<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>    stopped = true;<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>  }<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span><a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>  /**<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>   * Used to assign a single region to a random server.<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>   */<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>  private ServerName randomAssignment(Cluster cluster, HRegionInfo regionInfo,<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>      List&lt;ServerName&gt; servers) {<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>    int numServers = servers.size(); // servers is not null, numServers &gt; 1<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>    ServerName sn = null;<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>    final int maxIterations = numServers * 4;<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>    int iterations = 0;<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span><a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>    do {<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>      int i = RANDOM.nextInt(numServers);<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>      sn = servers.get(i);<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>    } while (cluster.wouldLowerAvailability(regionInfo, sn)<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>        &amp;&amp; iterations++ &lt; maxIterations);<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>    cluster.doAssignRegion(regionInfo, sn);<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>    return sn;<a name="line.1511"></a>
+<span class="sourceLineNo">1472</span>    do {<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>      int i = RANDOM.nextInt(numServers);<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>      sn = servers.get(i);<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span>    } while (cluster.wouldLowerAvailability(regionInfo, sn)<a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>        &amp;&amp; iterations++ &lt; maxIterations);<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>    cluster.doAssignRegion(regionInfo, sn);<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span>    return sn;<a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>  }<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span><a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>  /**<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>   * Round robin a list of regions to a list of servers<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>   */<a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>  private void roundRobinAssignment(Cluster cluster, List&lt;HRegionInfo&gt; regions,<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span>      List&lt;HRegionInfo&gt; unassignedRegions, List&lt;ServerName&gt; servers,<a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>      Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; assignments) {<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span><a name="line.1487"></a>
+<span class="sourceLineNo">1488</span>    int numServers = servers.size();<a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>    int numRegions = regions.size();<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>    int max = (int) Math.ceil((float) numRegions / numServers);<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>    int serverIdx = 0;<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>    if (numServers &gt; 1) {<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>      serverIdx = RANDOM.nextInt(numServers);<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>    }<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>    int regionIdx = 0;<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span><a name="line.1496"></a>
+<span class="sourceLineNo">1497</span>    for (int j = 0; j &lt; numServers; j++) {<a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>      ServerName server = servers.get((j + serverIdx) % numServers);<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>      List&lt;HRegionInfo&gt; serverRegions = new ArrayList&lt;HRegionInfo&gt;(max);<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>      for (int i = regionIdx; i &lt; numRegions; i += numServers) {<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>        HRegionInfo region = regions.get(i % numRegions);<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>        if (cluster.wouldLowerAvailability(region, server)) {<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>          unassignedRegions.add(region);<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>        } else {<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>          serverRegions.add(region);<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span>          cluster.doAssignRegion(region, server);<a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>        }<a name="line.1507"></a>
+<span class="sourceLineNo">1508</span>      }<a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>      assignments.put(server, serverRegions);<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>      regionIdx++;<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>    }<a name="line.1511"></a>
 <span class="sourceLineNo">1512</span>  }<a name="line.1512"></a>
 <span class="sourceLineNo">1513</span><a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>  /**<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>   * Round robin a list of regions to a list of servers<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>   */<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>  private void roundRobinAssignment(Cluster cluster, List&lt;HRegionInfo&gt; regions,<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>      List&lt;HRegionInfo&gt; unassignedRegions, List&lt;ServerName&gt; servers,<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; assignments) {<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span><a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>    int numServers = servers.size();<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>    int numRegions = regions.size();<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>    int max = (int) Math.ceil((float) numRegions / numServers);<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>    int serverIdx = 0;<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>    if (numServers &gt; 1) {<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>      serverIdx = RANDOM.nextInt(numServers);<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>    }<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>    int regionIdx = 0;<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span><a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>    for (int j = 0; j &lt; numServers; j++) {<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>      ServerName server = servers.get((j + serverIdx) % numServers);<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>      List&lt;HRegionInfo&gt; serverRegions = new ArrayList&lt;HRegionInfo&gt;(max);<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>      for (int i = regionIdx; i &lt; numRegions; i += numServers) {<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>        HRegionInfo region = regions.get(i % numRegions);<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>        if (cluster.wouldLowerAvailability(region, server)) {<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>          unassignedRegions.add(region);<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>        } else {<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>          serverRegions.add(region);<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>          cluster.doAssignRegion(region, server);<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>        }<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>      }<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>      assignments.put(server, serverRegions);<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>      regionIdx++;<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>    }<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>  }<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span><a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>  protected Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; getRegionAssignmentsByServer(<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>    Collection&lt;HRegionInfo&gt; regions) {<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>    if (this.services != null &amp;&amp; this.services.getAssignmentManager() != null) {<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>      return this.services.getAssignmentManager().getSnapShotOfAssignment(regions);<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>    } else {<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>      return new HashMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt;();<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>    }<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>  }<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span><a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>  @Override<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>  public void onConfigurationChange(Configuration conf) {<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>  }<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>}<a name="line.1559"></a>
+<span class="sourceLineNo">1514</span>  protected Map&lt;ServerName, List&lt;HRegionInfo&gt;&gt; getRegionAssignmentsByServer(<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>    Collection&lt;HRegionInfo&gt; regions) {<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>    if (this.services != null &amp;&amp; this.services.getAssignmentManager() != null) {<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>      return this.services.getAssignmentManager().getSnapShotOfAssignment(regions);<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>    } else {<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>      return new HashMap&lt;ServerName, List&lt;HRegionInfo&gt;&gt;();<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>    }<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>  }<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span><a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>  @Override<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>  public void onConfigurationChange(Configuration conf) {<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>  }<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>}<a name="line.1526"></a>
 
 
 


Mime
View raw message