Skip to content

Commit

Permalink
HBASE-26021: Undo the incompatible serialization change in HBASE-7767
Browse files Browse the repository at this point in the history
Revert "HBASE-7767 Get rid of ZKTable, and table enable/disable state in ZK (Andrey Stepachev)"

Fixes the ConnectionRegistry and dependencies due to the revert.
  • Loading branch information
bharathv authored and Bharath Vissapragada committed Jun 29, 2021
1 parent 395eb0c commit a33f9be
Show file tree
Hide file tree
Showing 85 changed files with 11,522 additions and 13,016 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ public boolean isTableAvailable(byte[] tableName, byte[][] splitKeys)
return wrappedConnection.isTableAvailable(tableName, splitKeys);
}

@Override
public TableState getTableState(TableName tableName) throws IOException {
return wrappedConnection.getTableState(tableName);
}

@Override
public HTableDescriptor[] listTables() throws IOException {
return wrappedConnection.listTables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetProcedureResultRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetProcedureResultResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsBalancerEnabledRequest;
Expand Down Expand Up @@ -1003,7 +1001,7 @@ public HRegionLocation getRegionLocation(final byte[] tableName,

@Override
public boolean isTableEnabled(TableName tableName) throws IOException {
return getTableState(tableName).inStates(TableState.State.ENABLED);
return this.registry.isTableOnlineState(tableName, true);
}

@Override
Expand All @@ -1013,7 +1011,7 @@ public boolean isTableEnabled(byte[] tableName) throws IOException {

@Override
public boolean isTableDisabled(TableName tableName) throws IOException {
return getTableState(tableName).inStates(TableState.State.DISABLED);
return this.registry.isTableOnlineState(tableName, false);
}

@Override
Expand Down Expand Up @@ -2138,13 +2136,6 @@ public ListTableNamesByNamespaceResponse listTableNamesByNamespace(
return stub.listTableNamesByNamespace(controller, request);
}

@Override
public GetTableStateResponse getTableState(
RpcController controller, GetTableStateRequest request)
throws ServiceException {
return stub.getTableState(controller, request);
}

@Override
public void close() {
release(this.mss);
Expand Down Expand Up @@ -2774,19 +2765,6 @@ public RpcRetryingCallerFactory getRpcRetryingCallerFactory() {
public RpcControllerFactory getRpcControllerFactory() {
return this.rpcControllerFactory;
}

public TableState getTableState(TableName tableName) throws IOException {
MasterKeepAliveConnection master = getKeepAliveMasterService();
try {
GetTableStateResponse resp = master.getTableState(null,
RequestConverter.buildGetTableStateRequest(tableName));
return TableState.convert(resp.getTableState());
} catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se);
} finally {
master.close();
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.RegionLocations;
import org.apache.hadoop.hbase.TableName;

/**
* Implementations hold cluster information such as this cluster's id, location of hbase:meta, etc.
Expand Down Expand Up @@ -51,6 +52,11 @@ interface ConnectionRegistry {
*/
String getClusterId() throws IOException;

/**
* @param enabled Return true if table is enabled
*/
boolean isTableOnlineState(TableName tableName, boolean enabled) throws IOException;

/**
* @return Count of 'running' regionservers
* @throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ boolean isMasterRunning()
@Deprecated
boolean isTableDisabled(byte[] tableName) throws IOException;

/**
* Retrieve TableState, represent current table state.
* @param tableName table state for
* @return state of the table
*/
public TableState getTableState(TableName tableName) throws IOException;

/**
* @param tableName table name
* @return true if all regions of the table are available, false otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.RegionLocations;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil;
import org.apache.hadoop.hbase.exceptions.MasterRegistryFetchException;
Expand All @@ -62,6 +63,8 @@
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetMetaRegionLocationsResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetNumLiveRSRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetNumLiveRSResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateResponse;

/**
* Master based registry implementation. Makes RPCs to the configured master addresses from config
Expand Down Expand Up @@ -206,6 +209,22 @@ public GetNumLiveRSResponse call(ClientMetaService.Interface stub, RpcController
return resp.getNumRegionServers();
}

@Override
public boolean isTableOnlineState(TableName tableName, boolean enabled) throws IOException {
final GetTableStateRequest request = GetTableStateRequest.newBuilder().setTableName(
tableName.getNameAsString()).setIsEnabled(enabled).build();
GetTableStateResponse resp = doCall(new Callable<GetTableStateResponse>() {
@Override
public GetTableStateResponse call(ClientMetaService.Interface stub, RpcController controller)
throws IOException {
BlockingRpcCallback<GetTableStateResponse> cb = new BlockingRpcCallback<>();
stub.getTableState(controller, request, cb);
return cb.get();
}
});
return resp.getEnabledOrDisabled();
}

@Override
public void close() {
if (rpcClient != null) {
Expand Down Expand Up @@ -262,5 +281,4 @@ void populateMasterStubs(Set<ServerName> masters) throws IOException {
ImmutableSet<String> getParsedMasterServers() {
return masterAddr2Stub.keySet();
}

}

This file was deleted.

Loading

0 comments on commit a33f9be

Please sign in to comment.