HBASE-25080 Should not use AssignmentManager to test whether a table is enabled or not (#2436)

Signed-off-by: Guanghao Zhang <zghao@apache.org>
Signed-off-by: stack <stack@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Duo Zhang 2020-10-03 20:48:38 +08:00 committed by GitHub
parent 5e5166dc40
commit b0170d0e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 19 deletions

View File

@ -386,15 +386,15 @@ public class AssignmentManager {
// ============================================================================================
// Table State Manager helpers
// ============================================================================================
TableStateManager getTableStateManager() {
private TableStateManager getTableStateManager() {
return master.getTableStateManager();
}
public boolean isTableEnabled(final TableName tableName) {
private boolean isTableEnabled(final TableName tableName) {
return getTableStateManager().isTableState(tableName, TableState.State.ENABLED);
}
public boolean isTableDisabled(final TableName tableName) {
private boolean isTableDisabled(final TableName tableName) {
return getTableStateManager().isTableState(tableName,
TableState.State.DISABLED, TableState.State.DISABLING);
}

View File

@ -176,6 +176,11 @@ public abstract class AbstractStateMachineTableProcedure<TState>
}
}
protected boolean isTableEnabled(MasterProcedureEnv env) {
return env.getMasterServices().getTableStateManager().isTableState(getTableName(),
TableState.State.ENABLED);
}
/**
* Check region is online.
*/

View File

@ -149,7 +149,7 @@ public class ModifyTableProcedure
setNextState(ModifyTableState.MODIFY_TABLE_REOPEN_ALL_REGIONS);
break;
case MODIFY_TABLE_REOPEN_ALL_REGIONS:
if (env.getAssignmentManager().isTableEnabled(getTableName())) {
if (isTableEnabled(env)) {
addChildProcedure(new ReopenTableRegionsProcedure(getTableName()));
}
if (deleteColumnFamilyInModify) {

View File

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.master.assignment.RegionStateNode;
@ -105,7 +104,7 @@ public class ReopenTableRegionsProcedure
throws ProcedureSuspendedException, ProcedureYieldException, InterruptedException {
switch (state) {
case REOPEN_TABLE_REGIONS_GET_REGIONS:
if (!env.getAssignmentManager().isTableEnabled(tableName)) {
if (!isTableEnabled(env)) {
LOG.info("Table {} is disabled, give up reopening its regions", tableName);
return Flow.NO_MORE_STATE;
}

View File

@ -53,6 +53,7 @@
import="org.apache.hadoop.hbase.client.RegionLocator"
import="org.apache.hadoop.hbase.client.RegionReplicaUtil"
import="org.apache.hadoop.hbase.client.Table"
import="org.apache.hadoop.hbase.client.TableState"
import="org.apache.hadoop.hbase.client.ColumnFamilyDescriptor"
import="org.apache.hadoop.hbase.http.InfoServer"
import="org.apache.hadoop.hbase.master.HMaster"
@ -647,14 +648,14 @@
</tr>
<tr>
<td>Enabled</td>
<td><%= master.getAssignmentManager().isTableEnabled(table.getName()) %></td>
<td><%= master.getTableStateManager().isTableState(table.getName(), TableState.State.ENABLED) %></td>
<td>Is the table enabled</td>
</tr>
<tr>
<td>Compaction</td>
<td>
<%
if (master.getAssignmentManager().isTableEnabled(table.getName())) {
if (master.getTableStateManager().isTableState(table.getName(), TableState.State.ENABLED)) {
CompactionState compactionState = master.getCompactionState(table.getName());
%><%= compactionState==null?"UNKNOWN":compactionState %><%
} else {

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.master.assignment;
import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK;
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
import static org.mockito.ArgumentMatchers.any;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -61,7 +62,9 @@ import org.apache.zookeeper.KeeperException;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest;
@ -105,17 +108,7 @@ public class MockMasterServices extends MockNoopMasterServices {
null: new SplitWALManager(this);
// Mock an AM.
this.assignmentManager = new AssignmentManager(this, new MockRegionStateStore(this)) {
@Override
public boolean isTableEnabled(final TableName tableName) {
return true;
}
@Override
public boolean isTableDisabled(final TableName tableName) {
return false;
}
};
this.assignmentManager = new AssignmentManager(this, new MockRegionStateStore(this));
this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
this.serverManager = new ServerManager(this);
this.tableStateManager = Mockito.mock(TableStateManager.class);