HBASE-22426 Disable region split/merge switch doen't work when 'hbase.assignment.usezk' is set true

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Pankaj 2019-05-16 00:55:02 +05:30 committed by Andrew Purtell
parent 55e2a36a58
commit 4895fad5b0
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
3 changed files with 66 additions and 6 deletions

View File

@ -67,6 +67,7 @@ import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.TableStateManager;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Admin.MasterSwitchType;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.coordination.BaseCoordinatedStateManager;
@ -1082,8 +1083,11 @@ public class AssignmentManager extends ZooKeeperListener {
case RS_ZK_REQUEST_REGION_SPLIT:
case RS_ZK_REGION_SPLITTING:
case RS_ZK_REGION_SPLIT:
if (!handleRegionSplitting(
rt, encodedName, prettyPrintedRegionName, sn)) {
// If region split not enabled then skip only if event type is RS_ZK_REQUEST_REGION_SPLIT,
// allow on-going split operations
if ((!isRegionSplitOrMergeEnabled(rt, prettyPrintedRegionName, MasterSwitchType.SPLIT)
&& rt.getEventType() == EventType.RS_ZK_REQUEST_REGION_SPLIT)
|| !handleRegionSplitting(rt, encodedName, prettyPrintedRegionName, sn)) {
deleteSplittingNode(encodedName, sn);
}
break;
@ -1093,8 +1097,11 @@ public class AssignmentManager extends ZooKeeperListener {
case RS_ZK_REGION_MERGED:
// Merged region is a new region, we can't find it in the region states now.
// However, the two merging regions are not new. They should be in state for merging.
if (!handleRegionMerging(
rt, encodedName, prettyPrintedRegionName, sn)) {
// If region merge not enabled then skip only if event type is RS_ZK_REQUEST_REGION_MERGE,
// allow on-going merge operations
if ((!isRegionSplitOrMergeEnabled(rt, prettyPrintedRegionName, MasterSwitchType.MERGE)
&& rt.getEventType() == EventType.RS_ZK_REQUEST_REGION_MERGE)
|| !handleRegionMerging(rt, encodedName, prettyPrintedRegionName, sn)) {
deleteMergingNode(encodedName, sn);
}
break;
@ -1222,6 +1229,24 @@ public class AssignmentManager extends ZooKeeperListener {
}
}
/**
* Check whether region split or merge enabled.
* @param rt Region transition info
* @param prettyPrintedRegionName Region name
* @param switchType Region operation type
* @param eventType Event type
* @return true if region split/merge enabled
*/
private boolean isRegionSplitOrMergeEnabled(RegionTransition rt, String prettyPrintedRegionName,
MasterSwitchType switchType) {
if (!((HMaster) server).getSplitOrMergeTracker().isSplitOrMergeEnabled(switchType)) {
LOG.warn("Region " + switchType + " not enabled, skipping " + rt.getEventType()
+ " of reigon " + prettyPrintedRegionName);
return false;
}
return true;
}
// For unit tests only
boolean wasClosedHandlerCalled(HRegionInfo hri) {
AtomicBoolean b = closedRegionHandlerCalled.get(hri);

View File

@ -46,7 +46,7 @@ import static org.junit.Assert.assertTrue;
public class TestSplitOrMergeStatus {
private static final Log LOG = LogFactory.getLog(TestSplitOrMergeStatus.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static byte [] FAMILY = Bytes.toBytes("testFamily");
/**

View File

@ -0,0 +1,35 @@
/**
* 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.client;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
@Category({ MediumTests.class, ClientTests.class })
public class TestSplitOrMergeStatusWithZKBasedAssignment extends TestSplitOrMergeStatus {
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean("hbase.assignment.usezk", true);
TEST_UTIL.startMiniCluster(2);
}
}