HBASE-4907 NPE of MobUtils.hasMobColumns in Build failed in Jenkins: HBase-Trunk_matrix » latest1.8,Hadoop #513 (Jingcheng Du)

This commit is contained in:
stack 2015-12-04 10:53:09 -08:00
parent 8b3d1f1444
commit 03e4712f0c
2 changed files with 42 additions and 39 deletions

View File

@ -31,7 +31,6 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.TableNotDisabledException;
@ -345,19 +344,13 @@ public class DeleteTableProcedure
LOG.debug("Table '" + tableName + "' archived!"); LOG.debug("Table '" + tableName + "' archived!");
} }
// Archive the mob data if there is a mob-enabled column // Archive mob data
HTableDescriptor htd = env.getMasterServices().getTableDescriptors().get(tableName); Path mobTableDir = FSUtils.getTableDir(new Path(mfs.getRootDir(), MobConstants.MOB_DIR_NAME),
boolean hasMob = MobUtils.hasMobColumns(htd); tableName);
Path mobTableDir = null; Path regionDir =
if (hasMob) { new Path(mobTableDir, MobUtils.getMobRegionInfo(tableName).getEncodedName());
// Archive mob data if (fs.exists(regionDir)) {
mobTableDir = FSUtils.getTableDir(new Path(mfs.getRootDir(), MobConstants.MOB_DIR_NAME), HFileArchiver.archiveRegion(fs, mfs.getRootDir(), mobTableDir, regionDir);
tableName);
Path regionDir =
new Path(mobTableDir, MobUtils.getMobRegionInfo(tableName).getEncodedName());
if (fs.exists(regionDir)) {
HFileArchiver.archiveRegion(fs, mfs.getRootDir(), mobTableDir, regionDir);
}
} }
// Delete table directory from FS (temp directory) // Delete table directory from FS (temp directory)
@ -366,7 +359,7 @@ public class DeleteTableProcedure
} }
// Delete the table directory where the mob files are saved // Delete the table directory where the mob files are saved
if (hasMob && mobTableDir != null && fs.exists(mobTableDir)) { if (mobTableDir != null && fs.exists(mobTableDir)) {
if (!fs.delete(mobTableDir, true)) { if (!fs.delete(mobTableDir, true)) {
throw new IOException("Couldn't delete mob dir " + mobTableDir); throw new IOException("Couldn't delete mob dir " + mobTableDir);
} }

View File

@ -195,32 +195,15 @@ public class TestCreateTableProcedure {
@Test(timeout=90000) @Test(timeout=90000)
public void testRollbackAndDoubleExecution() throws Exception { public void testRollbackAndDoubleExecution() throws Exception {
final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecution"); final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecution");
testRollbackAndDoubleExecution(MasterProcedureTestingUtility.createHTD(tableName, "f1", "f2"));
}
// create the table @Test(timeout=90000)
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); public void testRollbackAndDoubleExecutionOnMobTable() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true); final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecutionOnMobTable");
// Start the Create procedure && kill the executor
final byte[][] splitKeys = new byte[][] {
Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c")
};
HTableDescriptor htd = MasterProcedureTestingUtility.createHTD(tableName, "f1", "f2"); HTableDescriptor htd = MasterProcedureTestingUtility.createHTD(tableName, "f1", "f2");
htd.setRegionReplication(3); htd.getFamily(Bytes.toBytes("f1")).setMobEnabled(true);
HRegionInfo[] regions = ModifyRegionUtils.createHRegionInfos(htd, splitKeys); testRollbackAndDoubleExecution(htd);
long procId = procExec.submitProcedure(
new CreateTableProcedure(procExec.getEnvironment(), htd, regions), nonceGroup, nonce);
// NOTE: the 4 (number of CreateTableState steps) is hardcoded,
// so you have to look at this test at least once when you add a new step.
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(
procExec, procId, 4, CreateTableState.values());
MasterProcedureTestingUtility.validateTableDeletion(
UTIL.getHBaseCluster().getMaster(), tableName, regions, "f1", "f2");
// are we able to create the table after a rollback?
resetProcExecutorTestingKillFlag();
testSimpleCreate(tableName, splitKeys);
} }
@Test(timeout=90000) @Test(timeout=90000)
@ -282,4 +265,31 @@ public class TestCreateTableProcedure {
} }
} }
} }
private void testRollbackAndDoubleExecution(HTableDescriptor htd) throws Exception {
// create the table
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
// Start the Create procedure && kill the executor
final byte[][] splitKeys = new byte[][] {
Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c")
};
htd.setRegionReplication(3);
HRegionInfo[] regions = ModifyRegionUtils.createHRegionInfos(htd, splitKeys);
long procId = procExec.submitProcedure(
new CreateTableProcedure(procExec.getEnvironment(), htd, regions), nonceGroup, nonce);
// NOTE: the 4 (number of CreateTableState steps) is hardcoded,
// so you have to look at this test at least once when you add a new step.
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(
procExec, procId, 4, CreateTableState.values());
TableName tableName = htd.getTableName();
MasterProcedureTestingUtility.validateTableDeletion(
UTIL.getHBaseCluster().getMaster(), tableName, regions, "f1", "f2");
// are we able to create the table after a rollback?
resetProcExecutorTestingKillFlag();
testSimpleCreate(tableName, splitKeys);
}
} }