001/* 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020package org.apache.hadoop.hbase.util; 021 022import org.apache.hadoop.hbase.ServerName; 023import org.apache.hadoop.hbase.client.Admin; 024import org.apache.hadoop.hbase.client.RegionInfo; 025import org.apache.yetus.audience.InterfaceAudience; 026import org.slf4j.Logger; 027import org.slf4j.LoggerFactory; 028 029import java.util.List; 030import java.util.concurrent.Callable; 031 032/** 033 * Move Regions without Acknowledging.Usefule in case of RS shutdown as we might want to shut the 034 * RS down anyways and not abort on a stuck region. Improves movement performance 035 */ 036@InterfaceAudience.Private 037class MoveWithoutAck implements Callable<Boolean> { 038 039 private static final Logger LOG = LoggerFactory.getLogger(MoveWithoutAck.class); 040 041 private final RegionInfo region; 042 private final ServerName targetServer; 043 private final List<RegionInfo> movedRegions; 044 private final ServerName sourceServer; 045 private final Admin admin; 046 047 MoveWithoutAck(Admin admin, RegionInfo regionInfo, ServerName sourceServer, 048 ServerName targetServer, List<RegionInfo> movedRegions) { 049 this.admin = admin; 050 this.region = regionInfo; 051 this.targetServer = targetServer; 052 this.movedRegions = movedRegions; 053 this.sourceServer = sourceServer; 054 } 055 056 @Override 057 public Boolean call() { 058 try { 059 LOG.info("Moving region: {} from {} to {}", region.getEncodedName(), sourceServer, 060 targetServer); 061 admin.move(region.getEncodedNameAsBytes(), targetServer); 062 LOG.info("Requested move {} from {} to {}", region.getEncodedName(), sourceServer, 063 targetServer); 064 } catch (Exception e) { 065 LOG.error("Error Moving Region: {}", region.getEncodedName(), e); 066 } finally { 067 movedRegions.add(region); 068 } 069 return true; 070 } 071}