use of org.apache.hadoop.hbase.master.TableStateManager in project hbase by apache.
the class MasterProcedureTestingUtility method validateTableIsEnabled.
public static void validateTableIsEnabled(final HMaster master, final TableName tableName) throws IOException {
TableStateManager tsm = master.getTableStateManager();
assertTrue(tsm.getTableState(tableName).getState().equals(TableState.State.ENABLED));
}
use of org.apache.hadoop.hbase.master.TableStateManager in project hbase by apache.
the class MasterProcedureTestingUtility method validateTableIsDisabled.
public static void validateTableIsDisabled(final HMaster master, final TableName tableName) throws IOException {
TableStateManager tsm = master.getTableStateManager();
assertTrue(tsm.getTableState(tableName).getState().equals(TableState.State.DISABLED));
}
use of org.apache.hadoop.hbase.master.TableStateManager in project hbase by apache.
the class RSGroupInfoManagerImpl method getRSGroupAssignmentsByTable.
/**
* This is an EXPENSIVE clone. Cloning though is the safest thing to do. Can't let out original
* since it can change and at least the load balancer wants to iterate this exported list. Load
* balancer should iterate over this list because cloned list will ignore disabled table and split
* parent region cases. This method is invoked by {@link #balanceRSGroup}
* @return A clone of current assignments for this group.
*/
Map<TableName, Map<ServerName, List<RegionInfo>>> getRSGroupAssignmentsByTable(TableStateManager tableStateManager, String groupName) throws IOException {
Map<TableName, Map<ServerName, List<RegionInfo>>> result = Maps.newHashMap();
Set<TableName> tablesInGroupCache = new HashSet<>();
for (Map.Entry<RegionInfo, ServerName> entry : masterServices.getAssignmentManager().getRegionStates().getRegionAssignments().entrySet()) {
RegionInfo region = entry.getKey();
TableName tn = region.getTable();
ServerName server = entry.getValue();
if (isTableInGroup(tn, groupName, tablesInGroupCache)) {
if (tableStateManager.isTableState(tn, TableState.State.DISABLED, TableState.State.DISABLING)) {
continue;
}
if (region.isSplitParent()) {
continue;
}
result.computeIfAbsent(tn, k -> new HashMap<>()).computeIfAbsent(server, k -> new ArrayList<>()).add(region);
}
}
RSGroupInfo rsGroupInfo = getRSGroupInfo(groupName);
for (ServerName serverName : masterServices.getServerManager().getOnlineServers().keySet()) {
if (rsGroupInfo.containsServer(serverName.getAddress())) {
for (Map<ServerName, List<RegionInfo>> map : result.values()) {
map.computeIfAbsent(serverName, k -> Collections.emptyList());
}
}
}
return result;
}
use of org.apache.hadoop.hbase.master.TableStateManager in project hbase by apache.
the class TestHbckChore method testForDisabledTable.
@Test
public void testForDisabledTable() throws Exception {
TableName tableName = TableName.valueOf("testForDisabledTable");
RegionInfo hri = createRegionInfo(tableName, 1);
String regionName = hri.getRegionNameAsString();
rsDispatcher.setMockRsExecutor(new GoodRsExecutor());
Future<byte[]> future = submitProcedure(createAssignProcedure(hri));
waitOnFuture(future);
List<ServerName> serverNames = master.getServerManager().getOnlineServersList();
assertEquals(NSERVERS, serverNames.size());
hbckChore.choreForTesting();
Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = hbckChore.getInconsistentRegions();
assertTrue(inconsistentRegions.containsKey(regionName));
Pair<ServerName, List<ServerName>> pair = inconsistentRegions.get(regionName);
ServerName locationInMeta = pair.getFirst();
List<ServerName> reportedRegionServers = pair.getSecond();
assertTrue(serverNames.contains(locationInMeta));
assertEquals(0, reportedRegionServers.size());
// Set table state to disabled, then not in inconsistent regions.
TableStateManager tableStateManager = master.getTableStateManager();
Mockito.when(tableStateManager.isTableState(tableName, TableState.State.DISABLED)).thenReturn(true);
hbckChore.choreForTesting();
inconsistentRegions = hbckChore.getInconsistentRegions();
assertFalse(inconsistentRegions.containsKey(regionName));
}
use of org.apache.hadoop.hbase.master.TableStateManager in project hbase by apache.
the class TestAddToSerialReplicationPeer method testEnablingTable.
@Test
public void testEnablingTable() throws Exception {
TableName tableName = createTable();
try (Table table = UTIL.getConnection().getTable(tableName)) {
for (int i = 0; i < 100; i++) {
table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
}
}
RegionInfo region = UTIL.getAdmin().getRegions(tableName).get(0);
HRegionServer rs = UTIL.getOtherRegionServer(UTIL.getRSForFirstRegionInTable(tableName));
moveRegionAndArchiveOldWals(region, rs);
TableStateManager tsm = UTIL.getMiniHBaseCluster().getMaster().getTableStateManager();
tsm.setTableState(tableName, TableState.State.ENABLING);
Thread t = new Thread(() -> {
try {
addPeer(true);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
t.start();
Thread.sleep(5000);
// we will wait on the disabling table so the thread should still be alive.
assertTrue(t.isAlive());
tsm.setTableState(tableName, TableState.State.ENABLED);
t.join();
try (Table table = UTIL.getConnection().getTable(tableName)) {
for (int i = 0; i < 100; i++) {
table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
}
}
waitUntilReplicationDone(100);
checkOrder(100);
}
Aggregations