Search in sources :

Example 11 with HBaseIOException

use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.

the class RSGroupBasedLoadBalancer method generateGroupMaps.

private void generateGroupMaps(List<HRegionInfo> regions, List<ServerName> servers, ListMultimap<String, HRegionInfo> regionMap, ListMultimap<String, ServerName> serverMap) throws HBaseIOException {
    try {
        for (HRegionInfo region : regions) {
            String groupName = rsGroupInfoManager.getRSGroupOfTable(region.getTable());
            if (groupName == null) {
                LOG.warn("Group for table " + region.getTable() + " is null");
            }
            regionMap.put(groupName, region);
        }
        for (String groupKey : regionMap.keySet()) {
            RSGroupInfo info = rsGroupInfoManager.getRSGroup(groupKey);
            serverMap.putAll(groupKey, filterOfflineServers(info, servers));
            if (serverMap.get(groupKey).size() < 1) {
                serverMap.put(groupKey, LoadBalancer.BOGUS_SERVER_NAME);
            }
        }
    } catch (IOException e) {
        throw new HBaseIOException("Failed to generate group maps", e);
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Example 12 with HBaseIOException

use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.

the class RSGroupBasedLoadBalancer method retainAssignment.

@Override
public Map<ServerName, List<HRegionInfo>> retainAssignment(Map<HRegionInfo, ServerName> regions, List<ServerName> servers) throws HBaseIOException {
    try {
        Map<ServerName, List<HRegionInfo>> assignments = new TreeMap<>();
        ListMultimap<String, HRegionInfo> groupToRegion = ArrayListMultimap.create();
        Set<HRegionInfo> misplacedRegions = getMisplacedRegions(regions);
        for (HRegionInfo region : regions.keySet()) {
            if (!misplacedRegions.contains(region)) {
                String groupName = rsGroupInfoManager.getRSGroupOfTable(region.getTable());
                groupToRegion.put(groupName, region);
            }
        }
        // assignments.
        for (String key : groupToRegion.keySet()) {
            Map<HRegionInfo, ServerName> currentAssignmentMap = new TreeMap<HRegionInfo, ServerName>();
            List<HRegionInfo> regionList = groupToRegion.get(key);
            RSGroupInfo info = rsGroupInfoManager.getRSGroup(key);
            List<ServerName> candidateList = filterOfflineServers(info, servers);
            for (HRegionInfo region : regionList) {
                currentAssignmentMap.put(region, regions.get(region));
            }
            if (candidateList.size() > 0) {
                assignments.putAll(this.internalBalancer.retainAssignment(currentAssignmentMap, candidateList));
            }
        }
        for (HRegionInfo region : misplacedRegions) {
            String groupName = rsGroupInfoManager.getRSGroupOfTable(region.getTable());
            ;
            RSGroupInfo info = rsGroupInfoManager.getRSGroup(groupName);
            List<ServerName> candidateList = filterOfflineServers(info, servers);
            ServerName server = this.internalBalancer.randomAssignment(region, candidateList);
            if (server != null) {
                if (!assignments.containsKey(server)) {
                    assignments.put(server, new ArrayList<>());
                }
                assignments.get(server).add(region);
            } else {
                //if not server is available assign to bogus so it ends up in RIT
                if (!assignments.containsKey(LoadBalancer.BOGUS_SERVER_NAME)) {
                    assignments.put(LoadBalancer.BOGUS_SERVER_NAME, new ArrayList<>());
                }
                assignments.get(LoadBalancer.BOGUS_SERVER_NAME).add(region);
            }
        }
        return assignments;
    } catch (IOException e) {
        throw new HBaseIOException("Failed to do online retain assignment", e);
    }
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) TreeMap(java.util.TreeMap) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 13 with HBaseIOException

use of org.apache.hadoop.hbase.HBaseIOException in project hbase by apache.

the class RSGroupBasedLoadBalancer method initialize.

@Override
public void initialize() throws HBaseIOException {
    try {
        if (rsGroupInfoManager == null) {
            List<RSGroupAdminEndpoint> cps = masterServices.getMasterCoprocessorHost().findCoprocessors(RSGroupAdminEndpoint.class);
            if (cps.size() != 1) {
                String msg = "Expected one implementation of GroupAdminEndpoint but found " + cps.size();
                LOG.error(msg);
                throw new HBaseIOException(msg);
            }
            rsGroupInfoManager = cps.get(0).getGroupInfoManager();
        }
    } catch (IOException e) {
        throw new HBaseIOException("Failed to initialize GroupInfoManagerImpl", e);
    }
    // Create the balancer
    Class<? extends LoadBalancer> balancerKlass = config.getClass(HBASE_RSGROUP_LOADBALANCER_CLASS, StochasticLoadBalancer.class, LoadBalancer.class);
    internalBalancer = ReflectionUtils.newInstance(balancerKlass, config);
    internalBalancer.setMasterServices(masterServices);
    internalBalancer.setClusterStatus(clusterStatus);
    internalBalancer.setConf(config);
    internalBalancer.initialize();
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Aggregations

HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)13 IOException (java.io.IOException)6 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)6 ServerName (org.apache.hadoop.hbase.ServerName)6 InterruptedIOException (java.io.InterruptedIOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 RegionLocations (org.apache.hadoop.hbase.RegionLocations)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MutableObject (org.apache.commons.lang.mutable.MutableObject)1 Configuration (org.apache.hadoop.conf.Configuration)1 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)1 MultiActionResultTooLarge (org.apache.hadoop.hbase.MultiActionResultTooLarge)1 TableName (org.apache.hadoop.hbase.TableName)1