Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.apache.hadoop.hbase.master;
 import java.util.List;
 import java.util.Map;
Performs bulk reopen of the list of regions provided to it.
 public class BulkReOpen extends BulkAssigner {
   private final Map<ServerNameList<HRegionInfo>> rsToRegions;
   private final AssignmentManager assignmentManager;
   private static final Log LOG = LogFactory.getLog(BulkReOpen.class);
   public BulkReOpen(final Server server,
       final Map<ServerNameList<HRegionInfo>> serverToRegions,
     final AssignmentManager am) {
     this. = am;
     this. = serverToRegions;

Unassign all regions, so that they go through the regular region assignment flow (in assignment manager) and are re-opened.
   protected void populatePool(ExecutorService pool) {
     .debug("Creating threads for each region server ");
     for (Map.Entry<ServerNameList<HRegionInfo>> e : 
         .entrySet()) {
       final List<HRegionInfohris = e.getValue();
       // add plans for the regions that need to be reopened
       Map<StringRegionPlanplans = new HashMap<StringRegionPlan>();
       for (HRegionInfo hri : hris) {
         RegionPlan reOpenPlan = .getRegionReopenPlan(hri);
         plans.put(hri.getEncodedName(), reOpenPlan);
       pool.execute(new Runnable() {
         public void run() {
           try {
           } catch (Throwable t) {
             .warn("Failed bulking re-open " + hris.size()
               + " region(s)"t);

Reopen the regions asynchronously, so always returns true immediately.

   protected boolean waitUntilDone(long timeout) {
     return true;

Configuration knobs "hbase.bulk.reopen.threadpool.size" number of regions that can be reopened concurrently. The maximum number of threads the master creates is never more than the number of region servers. If configuration is not defined it defaults to 20
   protected int getThreadCount() {
     int defaultThreadCount = super.getThreadCount();
     return this..getConfiguration().getInt(
  public boolean bulkReOpen() throws InterruptedExceptionIOException {
    return bulkAssign();

Unassign the list of regions. Configuration knobs: hbase.bulk.waitbetween.reopen indicates the number of milliseconds to wait before unassigning another region from this region server

  private void unassign(
      List<HRegionInforegionsthrows InterruptedException {
    int waitTime = this..getConfiguration().getInt(
        "hbase.bulk.waitbetween.reopen", 0);
    for (HRegionInfo region : regions) {
      if (.isStopped()) {
      if (regionStates.isRegionInTransition(region)) {
      while (regionStates.isRegionInTransition(region)
          && !.isStopped()) {
      if (waitTime > 0 && !.isStopped()) {
New to GrepCode? Check out our FAQ X