HBASE-2515 ChangeTableState considers split&&offline regions as being served

HBASE-2528  ServerManager.ServerMonitor isn't daemonized


git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@942962 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2010-05-11 00:17:35 +00:00
parent 479c53423c
commit 026227e87f
4 changed files with 132 additions and 2 deletions

View File

@ -306,6 +306,7 @@ Release 0.21.0 - Unreleased
HBASE-2503 PriorityQueue isn't thread safe, KeyValueHeap uses it that way
HBASE-2431 Master does not respect generation stamps, may result in meta
getting permanently offlined
HBASE-2515 ChangeTableState considers split&&offline regions as being served
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable
@ -554,6 +555,7 @@ Release 0.21.0 - Unreleased
HBASE-2414 Enhance test suite to be able to specify distributed scenarios
HBASE-2518 Kill all the trailing whitespaces in the code base
(Benoit Sigoure via Stack)
HBASE-2528 ServerManager.ServerMonitor isn't daemonized
NEW FEATURES
HBASE-1961 HBase EC2 scripts

View File

@ -148,13 +148,15 @@ public class ServerManager implements HConstants {
this.minimumServerCount = c.getInt("hbase.regions.server.count.min", 0);
this.serverMonitorThread = new ServerMonitor(metaRescanInterval,
this.master.getShutdownRequested());
this.serverMonitorThread.start();
String n = Thread.currentThread().getName();
Threads.setDaemonThreadRunning(this.serverMonitorThread,
n + ".serverMonitor");
this.oldLogCleaner = new OldLogsCleaner(
c.getInt("hbase.master.meta.thread.rescanfrequency",60 * 1000),
this.master.getShutdownRequested(), c,
master.getFileSystem(), master.getOldLogDir());
Threads.setDaemonThreadRunning(oldLogCleaner,
"ServerManager.oldLogCleaner");
n + ".oldLogCleaner");
}

View File

@ -183,6 +183,8 @@ class CompactSplitThread extends Thread implements HConstants {
Put put = new Put(oldRegionInfo.getRegionName());
put.add(CATALOG_FAMILY, REGIONINFO_QUALIFIER,
Writables.getBytes(oldRegionInfo));
put.add(CATALOG_FAMILY, SERVER_QUALIFIER, EMPTY_BYTE_ARRAY);
put.add(CATALOG_FAMILY, STARTCODE_QUALIFIER, EMPTY_BYTE_ARRAY);
put.add(CATALOG_FAMILY, SPLITA_QUALIFIER,
Writables.getBytes(newRegions[0].getRegionInfo()));
put.add(CATALOG_FAMILY, SPLITB_QUALIFIER,

View File

@ -0,0 +1,124 @@
/**
* Copyright 2010 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.master;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HMsg;
import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
/**
* Disabling is tricky. This class tests how the Master behaves during those
*/
public class TestMasterWithDisabling {
private static final Log LOG = LogFactory.getLog(TestMasterWithDisabling.class);
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static final byte[] TABLENAME = Bytes.toBytes("disabling");
private static final byte[] FAMILYNAME = Bytes.toBytes("fam");
@BeforeClass
public static void beforeAllTests() throws Exception {
// Start a cluster of two regionservers.
TEST_UTIL.startMiniCluster(2);
}
@AfterClass
public static void afterAllTests() throws IOException {
TEST_UTIL.shutdownMiniCluster();
}
@Test
public void testDisableBetweenSplit() throws IOException {
// Table that splits like crazy
HTableDescriptor htd = new HTableDescriptor(TABLENAME);
htd.setMaxFileSize(1024);
htd.setMemStoreFlushSize(1024);
HColumnDescriptor hcd = new HColumnDescriptor(FAMILYNAME);
htd.addFamily(hcd);
TEST_UTIL.getHBaseAdmin().createTable(htd);
HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
HBase2515Listener list = new HBase2515Listener(TEST_UTIL.getHBaseAdmin());
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
HMaster m = cluster.getMaster();
m.getRegionServerOperationQueue().
registerRegionServerOperationListener(list);
try {
TEST_UTIL.loadTable(t, FAMILYNAME);
} catch (IOException ex) {
// We disable the table during a split, we will end up here
LOG.info("Expected", ex);
}
// Check that there's no region in flight, HBASE-2515
assertEquals(0,cluster.getMaster().
getClusterStatus().getRegionsInTransition().size());
}
/**
* Simple listener that simulates a very long processing of a split. When
* we catch it, we first disable the table then let the processing go forward
*/
static class HBase2515Listener implements RegionServerOperationListener {
HBaseAdmin admin;
public HBase2515Listener(HBaseAdmin admin) {
this.admin = admin;
}
@Override
public boolean process(HServerInfo serverInfo, HMsg incomingMsg) {
if (!incomingMsg.isType(HMsg.Type.MSG_REPORT_SPLIT_INCLUDES_DAUGHTERS)) {
return true;
}
try {
LOG.info("Disabling table");
admin.disableTable(TABLENAME);
} catch (IOException e) {
LOG.warn(e);
fail("Disable should always work");
}
return true;
}
@Override
public boolean process(RegionServerOperation op) throws IOException {
return true;
}
@Override
public void processed(RegionServerOperation op) {
}
}
}