Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright The Apache Software Foundation 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 http://www.apache.org/licenses/LICENSE-2.0 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.regionserver;
 
 
 
Handles processing region merges. Put in a queue, owned by HRegionServer.
 
 class RegionMergeRequest implements Runnable {
   static final Log LOG = LogFactory.getLog(RegionMergeRequest.class);
   private final HRegion region_a;
   private final HRegion region_b;
   private final HRegionServer server;
   private final boolean forcible;
   private TableLock tableLock;
 
   RegionMergeRequest(HRegion aHRegion bHRegionServer hrsboolean forcible) {
     Preconditions.checkNotNull(hrs);
     this. = a;
     this. = b;
     this. = hrs;
     this. = forcible;
   }
 
   @Override
   public String toString() {
     return "MergeRequest,regions:" +  + ", " +  + ", forcible="
         + ;
   }
 
   @Override
   public void run() {
     if (this..isStopping() || this..isStopped()) {
       .debug("Skipping merge because server is stopping="
           + this..isStopping() + " or stopped=" + this..isStopped());
       return;
     }
     try {
       final long startTime = EnvironmentEdgeManager.currentTimeMillis();
           );
 
       //acquire a shared read lock on the table, so that table schema modifications
       //do not happen concurrently
           , "MERGE_REGIONS:" + .getRegionNameAsString() + ", " + .getRegionNameAsString());
       try {
         .acquire();
       } catch (IOException ex) {
          = null;
         throw ex;
       }
 
       // If prepare does not return true, for some reason -- logged inside in
       // the prepare call -- we are not ready to merge just now. Just return.
       if (!mt.prepare(this.)) return;
       try {
         mt.execute(this.this.);
       } catch (Exception e) {
         if (this..isStopping() || this..isStopped()) {
           .info(
               "Skip rollback/cleanup of failed merge of " +  + " and "
                   +  + " because server is"
                   + (this..isStopping() ? " stopping" : " stopped"), e);
           return;
         }
         try {
           .warn("Running rollback/cleanup of failed merge of "
                   +  +" and " + "; " + e.getMessage(), e);
           if (mt.rollback(this.this.)) {
             .info("Successful rollback of failed merge of "
                +  +" and ");
          } else {
            this..abort("Abort; we got an error after point-of-no-return"
                + "when merging " +  + " and " + );
          }
        } catch (RuntimeException ee) {
          String msg = "Failed rollback of failed merge of "
              +  +" and " + " -- aborting server";
          // If failed rollback, kill this server to avoid having a hole in
          // table.
          .info(msgee);
          this..abort(msg);
        }
        return;
      }
      .info("Regions merged, hbase:meta updated, and report to master. region_a="
          +  + ", region_b=" +  + ",merged region="
          + mt.getMergedRegionInfo().getRegionNameAsString()
          + ". Region merge took "
          + StringUtils.formatTimeDiff(EnvironmentEdgeManager.currentTimeMillis(), startTime));
    } catch (IOException ex) {
      .error("Merge failed " + this,
          RemoteExceptionHandler.checkIOException(ex));
      .checkFileSystem();
    } finally {
      releaseTableLock();
    }
  }
  protected void releaseTableLock() {
    if (this. != null) {
      try {
        this..release();
      } catch (IOException ex) {
        .error("Could not release the table lock (something is really wrong). " 
           + "Aborting this server to avoid holding the lock forever.");
        this..abort("Abort; we got an error when releasing the table lock "
                         + "on " + .getRegionNameAsString());
      }
    }
  }
New to GrepCode? Check out our FAQ X