HBASE-3657 reduce copying of HRegionInfo's

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1082686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-03-17 20:46:57 +00:00
parent 4723e3b017
commit c980f1d16a
5 changed files with 10 additions and 9 deletions

View File

@ -79,6 +79,7 @@ Release 0.91.0 - Unreleased
HBASE-3440 Clean out load_table.rb and make sure all roads lead to
completebulkload tool (Vidhyashankar Venkataraman via Stack)
HBASE-3653 Parallelize Server Requests on HBase Client
HBASE-3657 reduce copying of HRegionInfo's (Ted Yu via Stack)
TASK
HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -1343,13 +1343,13 @@ public class AssignmentManager extends ZooKeeperListener {
* @throws InterruptedException
* @throws IOException
*/
public void assignUserRegions(List<HRegionInfo> regions, List<HServerInfo> servers) throws IOException, InterruptedException {
public void assignUserRegions(HRegionInfo[] regions, List<HServerInfo> servers) throws IOException, InterruptedException {
if (regions == null)
return;
Map<HServerInfo, List<HRegionInfo>> bulkPlan = null;
// Generate a round-robin bulk assignment plan
bulkPlan = LoadBalancer.roundRobinAssignment(regions, servers);
LOG.info("Bulk assigning " + regions.size() + " region(s) round-robin across " +
LOG.info("Bulk assigning " + regions.length + " region(s) round-robin across " +
servers.size() + " server(s)");
// Use fixed count thread pool assigning.
BulkAssigner ba = new BulkStartupAssigner(this.master, bulkPlan, this);
@ -1385,7 +1385,7 @@ public class AssignmentManager extends ZooKeeperListener {
bulkPlan = LoadBalancer.retainAssignment(allRegions, servers);
} else {
// assign regions in round-robin fashion
assignUserRegions(new ArrayList<HRegionInfo>(allRegions.keySet()), servers);
assignUserRegions(allRegions.keySet().toArray(new HRegionInfo[allRegions.size()]), servers);
return;
}
LOG.info("Bulk assigning " + allRegions.size() + " region(s) across " +

View File

@ -866,7 +866,7 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
// 5. Trigger immediate assignment of the regions in round-robin fashion
List<HServerInfo> servers = serverManager.getOnlineServersList();
try {
this.assignmentManager.assignUserRegions(Arrays.asList(newRegions), servers);
this.assignmentManager.assignUserRegions(newRegions, servers);
} catch (InterruptedException ie) {
LOG.error("Caught " + ie + " during round-robin assignment");
throw new IOException(ie);

View File

@ -392,13 +392,13 @@ public class LoadBalancer {
* assignment is possible (ie. no regions or no servers)
*/
public static Map<HServerInfo,List<HRegionInfo>> roundRobinAssignment(
List<HRegionInfo> regions, List<HServerInfo> servers) {
if(regions.size() == 0 || servers.size() == 0) {
HRegionInfo[] regions, List<HServerInfo> servers) {
if(regions.length == 0 || servers.size() == 0) {
return null;
}
Map<HServerInfo,List<HRegionInfo>> assignments =
new TreeMap<HServerInfo,List<HRegionInfo>>();
int numRegions = regions.size();
int numRegions = regions.length;
int numServers = servers.size();
int max = (int)Math.ceil((float)numRegions/numServers);
int serverIdx = 0;
@ -410,7 +410,7 @@ public class LoadBalancer {
HServerInfo server = servers.get((j+serverIdx) % numServers);
List<HRegionInfo> serverRegions = new ArrayList<HRegionInfo>(max);
for (int i=regionIdx; i<numRegions; i += numServers) {
serverRegions.add(regions.get(i % numRegions));
serverRegions.add(regions[i % numRegions]);
}
assignments.put(server, serverRegions);
regionIdx++;

View File

@ -276,7 +276,7 @@ public class TestLoadBalancer {
List<HRegionInfo> regions = randomRegions(mock[0]);
List<HServerInfo> servers = randomServers(mock[1], 0);
Map<HServerInfo,List<HRegionInfo>> assignments =
LoadBalancer.roundRobinAssignment(regions, servers);
LoadBalancer.roundRobinAssignment(regions.toArray(new HRegionInfo[regions.size()]), servers);
float average = (float)regions.size()/servers.size();
int min = (int)Math.floor(average);
int max = (int)Math.ceil(average);