use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method updateRSGroupConfig.
@Override
public UpdateRSGroupConfigResponse updateRSGroupConfig(RpcController controller, UpdateRSGroupConfigRequest request) throws ServiceException {
UpdateRSGroupConfigResponse.Builder builder = UpdateRSGroupConfigResponse.newBuilder();
String groupName = request.getGroupName();
Map<String, String> configuration = new HashMap<>();
request.getConfigurationList().forEach(p -> configuration.put(p.getName(), p.getValue()));
LOG.info("{} update rsgroup {} configuration {}", server.getClientIdAuditPrefix(), groupName, configuration);
try {
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().preUpdateRSGroupConfig(groupName, configuration);
}
server.getRSGroupInfoManager().updateRSGroupConfig(groupName, configuration);
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().postUpdateRSGroupConfig(groupName, configuration);
}
} catch (IOException e) {
throw new ServiceException(e);
}
return builder.build();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method getSpaceQuotaRegionSizes.
@Override
public GetSpaceQuotaRegionSizesResponse getSpaceQuotaRegionSizes(RpcController controller, GetSpaceQuotaRegionSizesRequest request) throws ServiceException {
try {
server.checkInitialized();
MasterQuotaManager quotaManager = this.server.getMasterQuotaManager();
GetSpaceQuotaRegionSizesResponse.Builder builder = GetSpaceQuotaRegionSizesResponse.newBuilder();
if (quotaManager != null) {
Map<RegionInfo, Long> regionSizes = quotaManager.snapshotRegionSizes();
Map<TableName, Long> regionSizesByTable = new HashMap<>();
// Translate hregioninfo+long -> tablename+long
for (Entry<RegionInfo, Long> entry : regionSizes.entrySet()) {
final TableName tableName = entry.getKey().getTable();
Long prevSize = regionSizesByTable.get(tableName);
if (prevSize == null) {
prevSize = 0L;
}
regionSizesByTable.put(tableName, prevSize + entry.getValue());
}
// Serialize them into the protobuf
for (Entry<TableName, Long> tableSize : regionSizesByTable.entrySet()) {
builder.addSizes(RegionSizes.newBuilder().setTableName(ProtobufUtil.toProtoTableName(tableSize.getKey())).setSize(tableSize.getValue()).build());
}
return builder.build();
} else {
LOG.debug("Received space quota region size report but HMaster is not ready to process it," + "skipping");
}
return builder.build();
} catch (Exception e) {
throw new ServiceException(e);
}
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method getRegionInfo.
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public GetRegionInfoResponse getRegionInfo(final RpcController controller, final GetRegionInfoRequest request) throws ServiceException {
RegionInfo ri = null;
try {
ri = getRegionInfo(request.getRegion());
} catch (UnknownRegionException ure) {
throw new ServiceException(ure);
}
GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
if (ri != null) {
builder.setRegionInfo(ProtobufUtil.toRegionInfo(ri));
} else {
// Is it a MOB name? These work differently.
byte[] regionName = request.getRegion().getValue().toByteArray();
TableName tableName = RegionInfo.getTable(regionName);
if (MobUtils.isMobRegionName(tableName, regionName)) {
// a dummy region info contains the compaction state.
RegionInfo mobRegionInfo = MobUtils.getMobRegionInfo(tableName);
builder.setRegionInfo(ProtobufUtil.toRegionInfo(mobRegionInfo));
if (request.hasCompactionState() && request.getCompactionState()) {
builder.setCompactionState(server.getMobCompactionState(tableName));
}
} else {
// If unknown RegionInfo and not a MOB region, it is unknown.
throw new ServiceException(new UnknownRegionException(Bytes.toString(regionName)));
}
}
return builder.build();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method getConfiguredNamespacesAndTablesInRSGroup.
@Override
public GetConfiguredNamespacesAndTablesInRSGroupResponse getConfiguredNamespacesAndTablesInRSGroup(RpcController controller, GetConfiguredNamespacesAndTablesInRSGroupRequest request) throws ServiceException {
GetConfiguredNamespacesAndTablesInRSGroupResponse.Builder builder = GetConfiguredNamespacesAndTablesInRSGroupResponse.newBuilder();
String groupName = request.getGroupName();
LOG.info(server.getClientIdAuditPrefix() + " get configured namespaces and tables in rsgroup " + groupName);
try {
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().preGetConfiguredNamespacesAndTablesInRSGroup(groupName);
}
for (NamespaceDescriptor nd : server.getClusterSchema().getNamespaces()) {
if (groupName.equals(nd.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP))) {
builder.addNamespace(nd.getName());
}
}
for (TableDescriptor td : server.getTableDescriptors().getAll().values()) {
if (td.getRegionServerGroup().map(g -> g.equals(groupName)).orElse(false)) {
builder.addTableName(ProtobufUtil.toProtoTableName(td.getTableName()));
}
}
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().postGetConfiguredNamespacesAndTablesInRSGroup(groupName);
}
} catch (IOException e) {
throw new ServiceException(e);
}
return builder.build();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method getReplicationPeerConfig.
@Override
public GetReplicationPeerConfigResponse getReplicationPeerConfig(RpcController controller, GetReplicationPeerConfigRequest request) throws ServiceException {
GetReplicationPeerConfigResponse.Builder response = GetReplicationPeerConfigResponse.newBuilder();
try {
String peerId = request.getPeerId();
ReplicationPeerConfig peerConfig = server.getReplicationPeerConfig(peerId);
response.setPeerId(peerId);
response.setPeerConfig(ReplicationPeerConfigUtil.convert(peerConfig));
} catch (ReplicationException | IOException e) {
throw new ServiceException(e);
}
return response.build();
}
Aggregations