use of org.apache.hadoop.hbase.master.procedure.DisableTableProcedure in project hbase by apache.
the class TableNamespaceManager method migrateNamespaceTable.
private void migrateNamespaceTable() throws IOException {
try (Table nsTable = masterServices.getConnection().getTable(TableName.NAMESPACE_TABLE_NAME);
ResultScanner scanner = nsTable.getScanner(new Scan().addFamily(TableDescriptorBuilder.NAMESPACE_FAMILY_INFO_BYTES).readAllVersions());
BufferedMutator mutator = masterServices.getConnection().getBufferedMutator(TableName.META_TABLE_NAME)) {
for (Result result; ; ) {
result = scanner.next();
if (result == null) {
break;
}
Put put = new Put(result.getRow());
result.getColumnCells(TableDescriptorBuilder.NAMESPACE_FAMILY_INFO_BYTES, TableDescriptorBuilder.NAMESPACE_COL_DESC_BYTES).forEach(c -> put.addColumn(HConstants.NAMESPACE_FAMILY, HConstants.NAMESPACE_COL_DESC_QUALIFIER, c.getTimestamp(), CellUtil.cloneValue(c)));
mutator.mutate(put);
}
}
// schedule a disable procedure instead of block waiting here, as when disabling a table we will
// wait until master is initialized, but we are part of the initialization...
masterServices.getMasterProcedureExecutor().submitProcedure(new DisableTableProcedure(masterServices.getMasterProcedureExecutor().getEnvironment(), TableName.NAMESPACE_TABLE_NAME, false));
}
use of org.apache.hadoop.hbase.master.procedure.DisableTableProcedure in project hbase by apache.
the class TestSplitOrMergeStatus method testSplitRegionReplicaRitRecovery.
@Test
public void testSplitRegionReplicaRitRecovery() throws Exception {
int startRowNum = 11;
int rowCount = 60;
final TableName tableName = TableName.valueOf(name.getMethodName());
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).setRegionReplication(2).build());
TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
ServerName serverName = RegionReplicaTestHelper.getRSCarryingReplica(TEST_UTIL, tableName, 1).get();
List<RegionInfo> regions = TEST_UTIL.getAdmin().getRegions(tableName);
insertData(tableName, startRowNum, rowCount);
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
// Split region of the table
long procId = procExec.submitProcedure(new SplitTableRegionProcedure(procExec.getEnvironment(), regions.get(0), splitKey));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
// Disable the table
long procId1 = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, false));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId1);
// Delete Table
long procId2 = procExec.submitProcedure(new DeleteTableProcedure(procExec.getEnvironment(), tableName));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId2);
AssignmentTestingUtil.killRs(TEST_UTIL, serverName);
Threads.sleepWithoutInterrupt(5000);
boolean hasRegionsInTransition = TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates().hasRegionsInTransition();
assertEquals(false, hasRegionsInTransition);
}
use of org.apache.hadoop.hbase.master.procedure.DisableTableProcedure in project hbase by apache.
the class TestRaceBetweenSCPAndDTP method test.
@Test
public void test() throws Exception {
RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
ServerName sn = am.getRegionStates().getRegionState(region).getServerName();
LOG.info("ServerName={}, region={}", sn, region);
ARRIVE_GET_REGIONS_ON_TABLE = new CountDownLatch(1);
RESUME_GET_REGIONS_ON_SERVER = new CountDownLatch(1);
// Assign to local variable because this static gets set to null in above running thread and
// so NPE.
CountDownLatch cdl = ARRIVE_GET_REGIONS_ON_TABLE;
UTIL.getAdmin().disableTableAsync(NAME);
cdl.await();
ProcedureExecutor<?> procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
UTIL.getMiniHBaseCluster().stopRegionServer(sn);
long pid = Procedure.NO_PROC_ID;
do {
Threads.sleep(1);
pid = getSCPPID(procExec);
} while (pid != Procedure.NO_PROC_ID);
final long scppid = pid;
UTIL.waitFor(60000, () -> procExec.isFinished(scppid));
RESUME_GET_REGIONS_ON_SERVER.countDown();
long dtpProcId = procExec.getProcedures().stream().filter(p -> p instanceof DisableTableProcedure).map(p -> (DisableTableProcedure) p).findAny().get().getProcId();
UTIL.waitFor(60000, () -> procExec.isFinished(dtpProcId));
}
Aggregations