hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1203919 - in /hbase/branches/0.92: 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
Date Sat, 19 Nov 2011 00:28:02 GMT
Author: stack
Date: Sat Nov 19 00:28:01 2011
New Revision: 1203919

URL: http://svn.apache.org/viewvc?rev=1203919&view=rev
Log:
HBASE-4815 Disable online altering by default, create a config for it

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
    hbase/branches/0.92/src/main/resources/hbase-default.xml
    hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1203919&r1=1203918&r2=1203919&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Sat Nov 19 00:28:01 2011
@@ -447,6 +447,7 @@ Release 0.92.0 - Unreleased
    HBASE-4790  Occasional TestDistributedLogSplitting failure (Jinchao)
    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
 
   IMPROVEMENTS
    HBASE-3290  Max Compaction Size (Nicolas Spiegelberg via Stack)  

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java?rev=1203919&r1=1203918&r2=1203919&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
Sat Nov 19 00:28:01 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/branches/0.92/src/main/resources/hbase-default.xml
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/resources/hbase-default.xml?rev=1203919&r1=1203918&r2=1203919&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/resources/hbase-default.xml (original)
+++ hbase/branches/0.92/src/main/resources/hbase-default.xml Sat Nov 19 00:28:01 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/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1203919&r1=1203918&r2=1203919&view=diff
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Sat Nov
19 00:28:01 2011
@@ -319,6 +319,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);
@@ -400,6 +402,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.



Mime
View raw message