Search in sources :

Example 21 with HBaseIOException

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

the class RSGroupBasedLoadBalancer method retainAssignment.

@Override
@NonNull
public Map<ServerName, List<RegionInfo>> retainAssignment(Map<RegionInfo, ServerName> regions, List<ServerName> servers) throws HBaseIOException {
    try {
        Map<ServerName, List<RegionInfo>> assignments = new TreeMap<>();
        List<Pair<List<RegionInfo>, List<ServerName>>> pairs = generateGroupAssignments(Lists.newArrayList(regions.keySet()), servers);
        for (Pair<List<RegionInfo>, List<ServerName>> pair : pairs) {
            List<RegionInfo> regionList = pair.getFirst();
            Map<RegionInfo, ServerName> currentAssignmentMap = Maps.newTreeMap();
            regionList.forEach(r -> currentAssignmentMap.put(r, regions.get(r)));
            Map<ServerName, List<RegionInfo>> pairResult = this.internalBalancer.retainAssignment(currentAssignmentMap, pair.getSecond());
            pairResult.forEach((server, rs) -> assignments.computeIfAbsent(server, s -> Lists.newArrayList()).addAll(rs));
        }
        return assignments;
    } catch (IOException e) {
        throw new HBaseIOException("Failed to do online retain assignment", e);
    }
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) List(java.util.List) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) TreeMap(java.util.TreeMap) Pair(org.apache.hadoop.hbase.util.Pair) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Example 22 with HBaseIOException

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

the class RSGroupBasedLoadBalancer method initialize.

@Override
public void initialize() throws IOException {
    if (rsGroupInfoManager == null) {
        rsGroupInfoManager = masterServices.getRSGroupInfoManager();
        if (rsGroupInfoManager == null) {
            String msg = "RSGroupInfoManager hasn't been initialized";
            LOG.error(msg);
            throw new HBaseIOException(msg);
        }
        rsGroupInfoManager.start();
    }
    // Create the balancer
    Configuration conf = masterServices.getConfiguration();
    Class<? extends LoadBalancer> balancerClass;
    @SuppressWarnings("deprecation") String balancerClassName = conf.get(HBASE_RSGROUP_LOADBALANCER_CLASS);
    if (balancerClassName == null) {
        balancerClass = conf.getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, LoadBalancerFactory.getDefaultLoadBalancerClass(), LoadBalancer.class);
    } else {
        try {
            balancerClass = Class.forName(balancerClassName).asSubclass(LoadBalancer.class);
        } catch (ClassNotFoundException e) {
            throw new IOException(e);
        }
    }
    this.provider = new MasterClusterInfoProvider(masterServices);
    // avoid infinite nesting
    if (getClass().isAssignableFrom(balancerClass)) {
        balancerClass = LoadBalancerFactory.getDefaultLoadBalancerClass();
    }
    internalBalancer = ReflectionUtils.newInstance(balancerClass);
    internalBalancer.setClusterInfoProvider(provider);
    // special handling for favor node balancers
    if (internalBalancer instanceof FavoredNodesPromoter) {
        favoredNodesManager = new FavoredNodesManager(provider);
        ((FavoredNodesPromoter) internalBalancer).setFavoredNodesManager(favoredNodesManager);
    }
    internalBalancer.initialize();
    // init fallback groups
    this.fallbackEnabled = conf.getBoolean(FALLBACK_GROUP_ENABLE_KEY, false);
}
Also used : MasterClusterInfoProvider(org.apache.hadoop.hbase.master.balancer.MasterClusterInfoProvider) Configuration(org.apache.hadoop.conf.Configuration) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) FavoredNodesPromoter(org.apache.hadoop.hbase.favored.FavoredNodesPromoter) LoadBalancer(org.apache.hadoop.hbase.master.LoadBalancer) FavoredNodesManager(org.apache.hadoop.hbase.favored.FavoredNodesManager) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Example 23 with HBaseIOException

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

the class HMaster method executeRegionPlansWithThrottling.

/**
 * Execute region plans with throttling
 * @param plans to execute
 * @return succeeded plans
 */
public List<RegionPlan> executeRegionPlansWithThrottling(List<RegionPlan> plans) {
    List<RegionPlan> successRegionPlans = new ArrayList<>();
    int maxRegionsInTransition = getMaxRegionsInTransition();
    long balanceStartTime = EnvironmentEdgeManager.currentTime();
    long cutoffTime = balanceStartTime + this.maxBalancingTime;
    // number of RegionPlans balanced so far
    int rpCount = 0;
    if (plans != null && !plans.isEmpty()) {
        int balanceInterval = this.maxBalancingTime / plans.size();
        LOG.info("Balancer plans size is " + plans.size() + ", the balance interval is " + balanceInterval + " ms, and the max number regions in transition is " + maxRegionsInTransition);
        for (RegionPlan plan : plans) {
            LOG.info("balance " + plan);
            // TODO: bulk assign
            try {
                this.assignmentManager.balance(plan);
            } catch (HBaseIOException hioe) {
                // should ignore failed plans here, avoiding the whole balance plans be aborted
                // later calls of balance() can fetch up the failed and skipped plans
                LOG.warn("Failed balance plan {}, skipping...", plan, hioe);
            }
            // rpCount records balance plans processed, does not care if a plan succeeds
            rpCount++;
            successRegionPlans.add(plan);
            if (this.maxBalancingTime > 0) {
                balanceThrottling(balanceStartTime + rpCount * balanceInterval, maxRegionsInTransition, cutoffTime);
            }
            // if performing next balance exceeds cutoff time, exit the loop
            if (this.maxBalancingTime > 0 && rpCount < plans.size() && EnvironmentEdgeManager.currentTime() > cutoffTime) {
                // TODO: After balance, there should not be a cutoff time (keeping it as
                // a security net for now)
                LOG.debug("No more balancing till next balance run; maxBalanceTime=" + this.maxBalancingTime);
                break;
            }
        }
    }
    LOG.debug("Balancer is going into sleep until next period in {}ms", getConfiguration().getInt(HConstants.HBASE_BALANCER_PERIOD, HConstants.DEFAULT_HBASE_BALANCER_PERIOD));
    return successRegionPlans;
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) ArrayList(java.util.ArrayList) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)

Example 24 with HBaseIOException

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

the class HMaster method decommissionRegionServers.

/**
 * Mark region server(s) as decommissioned (previously called 'draining') to prevent additional
 * regions from getting assigned to them. Also unload the regions on the servers asynchronously.0
 * @param servers Region servers to decommission.
 */
public void decommissionRegionServers(final List<ServerName> servers, final boolean offload) throws IOException {
    List<ServerName> serversAdded = new ArrayList<>(servers.size());
    // Place the decommission marker first.
    String parentZnode = getZooKeeper().getZNodePaths().drainingZNode;
    for (ServerName server : servers) {
        try {
            String node = ZNodePaths.joinZNode(parentZnode, server.getServerName());
            ZKUtil.createAndFailSilent(getZooKeeper(), node);
        } catch (KeeperException ke) {
            throw new HBaseIOException(this.zooKeeper.prefix("Unable to decommission '" + server.getServerName() + "'."), ke);
        }
        if (this.serverManager.addServerToDrainList(server)) {
            serversAdded.add(server);
        }
    }
    // Move the regions off the decommissioned servers.
    if (offload) {
        final List<ServerName> destServers = this.serverManager.createDestinationServersList();
        for (ServerName server : serversAdded) {
            final List<RegionInfo> regionsOnServer = this.assignmentManager.getRegionsOnServer(server);
            for (RegionInfo hri : regionsOnServer) {
                ServerName dest = balancer.randomAssignment(hri, destServers);
                if (dest == null) {
                    throw new HBaseIOException("Unable to determine a plan to move " + hri);
                }
                RegionPlan rp = new RegionPlan(hri, server, dest);
                this.assignmentManager.moveAsync(rp);
            }
        }
    }
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) KeeperException(org.apache.zookeeper.KeeperException)

Example 25 with HBaseIOException

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

the class MasterRegion method createWAL.

private static WAL createWAL(WALFactory walFactory, MasterRegionWALRoller walRoller, String serverName, FileSystem walFs, Path walRootDir, RegionInfo regionInfo) throws IOException {
    String logName = AbstractFSWALProvider.getWALDirectoryName(serverName);
    Path walDir = new Path(walRootDir, logName);
    LOG.debug("WALDir={}", walDir);
    if (walFs.exists(walDir)) {
        throw new HBaseIOException("Already created wal directory at " + walDir + " for local region " + regionInfo);
    }
    if (!walFs.mkdirs(walDir)) {
        throw new IOException("Can not create wal directory " + walDir + " for local region " + regionInfo);
    }
    WAL wal = walFactory.getWAL(regionInfo);
    walRoller.addWAL(wal);
    return wal;
}
Also used : Path(org.apache.hadoop.fs.Path) WAL(org.apache.hadoop.hbase.wal.WAL) AbstractFSWAL(org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Aggregations

HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)36 IOException (java.io.IOException)19 ServerName (org.apache.hadoop.hbase.ServerName)17 ArrayList (java.util.ArrayList)13 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)13 List (java.util.List)8 HashMap (java.util.HashMap)7 InterruptedIOException (java.io.InterruptedIOException)5 Map (java.util.Map)5 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)5 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)5 Test (org.junit.Test)5 TreeMap (java.util.TreeMap)4 Configuration (org.apache.hadoop.conf.Configuration)4 NonNull (edu.umd.cs.findbugs.annotations.NonNull)3 ExecutionException (java.util.concurrent.ExecutionException)3 RegionLocations (org.apache.hadoop.hbase.RegionLocations)3 TableName (org.apache.hadoop.hbase.TableName)3 FavoredNodeAssignmentHelper (org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper)3 RSGroupAdminEndpoint (org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)3