use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method clearDeadServers.
@Override
public ClearDeadServersResponse clearDeadServers(RpcController controller, ClearDeadServersRequest request) throws ServiceException {
LOG.debug(server.getClientIdAuditPrefix() + " clear dead region servers.");
ClearDeadServersResponse.Builder response = ClearDeadServersResponse.newBuilder();
try {
server.checkInitialized();
if (server.cpHost != null) {
server.cpHost.preClearDeadServers();
}
if (server.getServerManager().areDeadServersInProgress()) {
LOG.debug("Some dead server is still under processing, won't clear the dead server list");
response.addAllServerName(request.getServerNameList());
} else {
DeadServer deadServer = server.getServerManager().getDeadServers();
Set<Address> clearedServers = new HashSet<>();
for (HBaseProtos.ServerName pbServer : request.getServerNameList()) {
ServerName serverName = ProtobufUtil.toServerName(pbServer);
final boolean deadInProcess = server.getProcedures().stream().anyMatch(p -> (p instanceof ServerCrashProcedure) && ((ServerCrashProcedure) p).getServerName().equals(serverName));
if (deadInProcess) {
throw new ServiceException(String.format("Dead server '%s' is not 'dead' in fact...", serverName));
}
if (!deadServer.removeDeadServer(serverName)) {
response.addServerName(pbServer);
} else {
clearedServers.add(serverName.getAddress());
}
}
server.getRSGroupInfoManager().removeServers(clearedServers);
LOG.info("Remove decommissioned servers {} from RSGroup done", clearedServers);
}
if (server.cpHost != null) {
server.cpHost.postClearDeadServers(ProtobufUtil.toServerNameList(request.getServerNameList()), ProtobufUtil.toServerNameList(response.getServerNameList()));
}
} catch (IOException io) {
throw new ServiceException(io);
}
return response.build();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method moveRegion.
@Override
public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest req) throws ServiceException {
final byte[] encodedRegionName = req.getRegion().getValue().toByteArray();
RegionSpecifierType type = req.getRegion().getType();
final byte[] destServerName = (req.hasDestServerName()) ? Bytes.toBytes(ProtobufUtil.toServerName(req.getDestServerName()).getServerName()) : null;
MoveRegionResponse mrr = MoveRegionResponse.newBuilder().build();
if (type != RegionSpecifierType.ENCODED_REGION_NAME) {
LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.ENCODED_REGION_NAME + " actual: " + type);
}
try {
server.checkInitialized();
server.move(encodedRegionName, destServerName);
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
return mrr;
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method recommissionRegionServer.
@Override
public RecommissionRegionServerResponse recommissionRegionServer(RpcController controller, RecommissionRegionServerRequest request) throws ServiceException {
try {
server.checkInitialized();
ServerName sn = ProtobufUtil.toServerName(request.getServerName());
List<byte[]> encodedRegionNames = request.getRegionList().stream().map(regionSpecifier -> regionSpecifier.getValue().toByteArray()).collect(Collectors.toList());
if (server.cpHost != null) {
server.cpHost.preRecommissionRegionServer(sn, encodedRegionNames);
}
server.recommissionRegionServer(sn, encodedRegionNames);
if (server.cpHost != null) {
server.cpHost.postRecommissionRegionServer(sn, encodedRegionNames);
}
} catch (IOException io) {
throw new ServiceException(io);
}
return RecommissionRegionServerResponse.newBuilder().build();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method isSnapshotCleanupEnabled.
@Override
public IsSnapshotCleanupEnabledResponse isSnapshotCleanupEnabled(RpcController controller, IsSnapshotCleanupEnabledRequest request) throws ServiceException {
try {
server.checkInitialized();
final boolean isSnapshotCleanupEnabled = server.snapshotCleanupTracker.isSnapshotCleanupEnabled();
return IsSnapshotCleanupEnabledResponse.newBuilder().setEnabled(isSnapshotCleanupEnabled).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method removeRSGroup.
@Override
public RemoveRSGroupResponse removeRSGroup(RpcController controller, RemoveRSGroupRequest request) throws ServiceException {
RemoveRSGroupResponse.Builder builder = RemoveRSGroupResponse.newBuilder();
LOG.info(server.getClientIdAuditPrefix() + " remove rsgroup " + request.getRSGroupName());
try {
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().preRemoveRSGroup(request.getRSGroupName());
}
server.getRSGroupInfoManager().removeRSGroup(request.getRSGroupName());
if (server.getMasterCoprocessorHost() != null) {
server.getMasterCoprocessorHost().postRemoveRSGroup(request.getRSGroupName());
}
} catch (IOException e) {
throw new ServiceException(e);
}
return builder.build();
}
Aggregations