You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/11/19 01:27:00 UTC
svn commit: r1203916 - in /hbase/trunk: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
src/main/resources/hbase-default.xml
src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
Author: stack
Date: Sat Nov 19 00:26:59 2011
New Revision: 1203916
URL: http://svn.apache.org/viewvc?rev=1203916&view=rev
Log:
HBASE-4815 Disable online altering by default, create a config for it
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
hbase/trunk/src/main/resources/hbase-default.xml
hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1203916&r1=1203915&r2=1203916&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Nov 19 00:26:59 2011
@@ -437,6 +437,7 @@ Release 0.92.0 - Unreleased
HBASE-4796 Race between SplitRegionHandlers for the same region kills the master
HBASE-4816 Regionserver wouldn't go down because split happened exactly at same
time we issued bulk user region close call on our way out
+ HBASE-4815 Disable online altering by default, create a config for it
TESTS
HBASE-4450 test for number of blocks read: to serve as baseline for expected
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java?rev=1203916&r1=1203915&r2=1203916&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java Sat Nov 19 00:26:59 2011
@@ -69,7 +69,8 @@ public abstract class TableEventHandler
try {
this.masterServices.checkTableModifiable(tableName);
} catch (TableNotDisabledException ex) {
- if (eventType.isOnlineSchemaChangeSupported()) {
+ if (isOnlineSchemaChangeAllowed()
+ && eventType.isOnlineSchemaChangeSupported()) {
LOG.debug("Ignoring table not disabled exception " +
"for supporting online schema changes.");
} else {
@@ -79,6 +80,11 @@ public abstract class TableEventHandler
this.tableNameStr = Bytes.toString(this.tableName);
}
+ private boolean isOnlineSchemaChangeAllowed() {
+ return this.server.getConfiguration().getBoolean(
+ "hbase.online.schema.update.enable", false);
+ }
+
@Override
public void process() {
try {
Modified: hbase/trunk/src/main/resources/hbase-default.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/resources/hbase-default.xml?rev=1203916&r1=1203915&r2=1203916&view=diff
==============================================================================
--- hbase/trunk/src/main/resources/hbase-default.xml (original)
+++ hbase/trunk/src/main/resources/hbase-default.xml Sat Nov 19 00:26:59 2011
@@ -782,12 +782,22 @@
</description>
</property>
<property>
+ <name>hbase.online.schema.update.enable</name>
+ <value>false</value>
+ <description>
+ Set true to enable online schema changes. This is an experimental feature.
+ There are known issues modifying table schemas at the same time a region
+ split is happening so your table needs to be quiescent or else you have to
+ be running with splits disabled.
+ </description>
+ </property>
+ <property>
<name>dfs.support.append</name>
<value>true</value>
<description>Does HDFS allow appends to files?
This is an hdfs config. set in here so the hdfs client will do append support.
You must ensure that this config. is true serverside too when running hbase
(You will have to restart your cluster after setting it).
- </description>
-</property>
+ </description>
+ </property>
</configuration>
Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1203916&r1=1203915&r2=1203916&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Sat Nov 19 00:26:59 2011
@@ -308,6 +308,8 @@ public class TestAdmin {
@Test
public void testOnlineChangeTableSchema() throws IOException, InterruptedException {
final byte [] tableName = Bytes.toBytes("changeTableSchemaOnline");
+ TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration().setBoolean(
+ "hbase.online.schema.update.enable", true);
HTableDescriptor [] tables = admin.listTables();
int numTables = tables.length;
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
@@ -389,6 +391,38 @@ public class TestAdmin {
this.admin.listTables();
assertFalse(this.admin.tableExists(tableName));
}
+
+ @Test
+ public void testShouldFailOnlineSchemaUpdateIfOnlineSchemaIsNotEnabled()
+ throws Exception {
+ final byte[] tableName = Bytes.toBytes("changeTableSchemaOnlineFailure");
+ TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration().setBoolean(
+ "hbase.online.schema.update.enable", false);
+ HTableDescriptor[] tables = admin.listTables();
+ int numTables = tables.length;
+ TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
+ tables = this.admin.listTables();
+ assertEquals(numTables + 1, tables.length);
+
+ // FIRST, do htabledescriptor changes.
+ HTableDescriptor htd = this.admin.getTableDescriptor(tableName);
+ // Make a copy and assert copy is good.
+ HTableDescriptor copy = new HTableDescriptor(htd);
+ assertTrue(htd.equals(copy));
+ // Now amend the copy. Introduce differences.
+ long newFlushSize = htd.getMemStoreFlushSize() / 2;
+ copy.setMemStoreFlushSize(newFlushSize);
+ final String key = "anyoldkey";
+ assertTrue(htd.getValue(key) == null);
+ copy.setValue(key, key);
+ boolean expectedException = false;
+ try {
+ modifyTable(tableName, copy);
+ } catch (TableNotDisabledException re) {
+ expectedException = true;
+ }
+ assertTrue("Online schema update should not happen.", expectedException);
+ }
/**
* Modify table is async so wait on completion of the table operation in master.