HBASE-15239 Remove unused LoadBalancer.immediateAssignment()

This commit is contained in:
Matteo Bertozzi 2016-02-10 09:16:42 -08:00
parent df829ea7d1
commit d53318163b
4 changed files with 4 additions and 88 deletions

View File

@ -40,10 +40,6 @@ import org.apache.hadoop.hbase.TableName;
* <p>Cluster-wide load balancing will occur only when there are no regions in
* transition and according to a fixed period of a time using {@link #balanceCluster(Map)}.
*
* <p>Inline region placement with {@link #immediateAssignment} can be used when
* the Master needs to handle closed regions that it currently does not have
* a destination set for. This can happen during master failover.
*
* <p>On cluster startup, bulk assignment can be used to determine
* locations for all Regions in a cluster.
*
@ -105,17 +101,6 @@ public interface LoadBalancer extends Configurable, Stoppable, ConfigurationObse
List<ServerName> servers
) throws HBaseIOException;
/**
* Sync assign a region
* @param regions
* @param servers
* @return Map regioninfos to servernames
*/
Map<HRegionInfo, ServerName> immediateAssignment(
List<HRegionInfo> regions,
List<ServerName> servers
) throws HBaseIOException;
/**
* Get a random region server from the list
* @param regionInfo Region for which this selection is being done.

View File

@ -1278,39 +1278,6 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
rackManager);
}
/**
* Generates an immediate assignment plan to be used by a new master for
* regions in transition that do not have an already known destination.
*
* Takes a list of regions that need immediate assignment and a list of all
* available servers. Returns a map of regions to the server they should be
* assigned to.
*
* This method will return quickly and does not do any intelligent balancing.
* The goal is to make a fast decision not the best decision possible.
*
* Currently this is random.
*
* @param regions
* @param servers
* @return map of regions to the server it should be assigned to
*/
@Override
public Map<HRegionInfo, ServerName> immediateAssignment(List<HRegionInfo> regions,
List<ServerName> servers) {
metricsBalancer.incrMiscInvocations();
if (servers == null || servers.isEmpty()) {
LOG.warn("Wanted to do random assignment but no servers to assign to");
return null;
}
Map<HRegionInfo, ServerName> assignments = new TreeMap<HRegionInfo, ServerName>();
for (HRegionInfo region : regions) {
assignments.put(region, randomAssignment(region, servers));
}
return assignments;
}
/**
* Used to assign a single region to a random server.
*/

View File

@ -46,10 +46,6 @@ import com.google.common.collect.MinMaxPriorityQueue;
* <p>Cluster-wide load balancing will occur only when there are no regions in
* transition and according to a fixed period of a time using {@link #balanceCluster(Map)}.
*
* <p>Inline region placement with {@link #immediateAssignment} can be used when
* the Master needs to handle closed regions that it currently does not have
* a destination set for. This can happen during master failover.
*
* <p>On cluster startup, bulk assignment can be used to determine
* locations for all Regions in a cluster.
*

View File

@ -117,38 +117,6 @@ public class TestBaseLoadBalancer extends BalancerTestBase {
}
/**
* Tests immediate assignment.
*
* Invariant is that all regions have an assignment.
*
* @throws Exception
*/
@Test (timeout=30000)
public void testImmediateAssignment() throws Exception {
List<ServerName> tmp = getListOfServerNames(randomServers(1, 0));
tmp.add(master);
ServerName sn = loadBalancer.randomAssignment(HRegionInfo.FIRST_META_REGIONINFO, tmp);
assertEquals(master, sn);
HRegionInfo hri = randomRegions(1, -1).get(0);
sn = loadBalancer.randomAssignment(hri, tmp);
assertNotEquals(master, sn);
tmp = new ArrayList<ServerName>();
tmp.add(master);
sn = loadBalancer.randomAssignment(hri, tmp);
assertNull("Should not assign user regions on master", sn);
for (int[] mock : regionsAndServersMocks) {
LOG.debug("testImmediateAssignment with " + mock[0] + " regions and " + mock[1] + " servers");
List<HRegionInfo> regions = randomRegions(mock[0]);
List<ServerAndLoad> servers = randomServers(mock[1], 0);
List<ServerName> list = getListOfServerNames(servers);
Map<HRegionInfo, ServerName> assignments = loadBalancer.immediateAssignment(regions, list);
assertImmediateAssignment(regions, list, assignments);
returnRegions(regions);
returnServers(list);
}
}
/**
* All regions have an assignment.
* @param regions