Index: src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java (revision 1202032) +++ src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java (working copy) @@ -69,7 +69,8 @@ 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 @@ 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 { Index: src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (revision 1203498) +++ src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (working copy) @@ -308,6 +308,8 @@ @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,7 +391,39 @@ 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. * @param tableName