use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method scheduleSCPsForUnknownServers.
@Override
public MasterProtos.ScheduleSCPsForUnknownServersResponse scheduleSCPsForUnknownServers(RpcController controller, MasterProtos.ScheduleSCPsForUnknownServersRequest request) throws ServiceException {
List<Long> pids = new ArrayList<>();
final Set<ServerName> serverNames = server.getAssignmentManager().getRegionStates().getRegionStates().stream().map(RegionState::getServerName).collect(Collectors.toSet());
final Set<ServerName> unknownServerNames = serverNames.stream().filter(sn -> server.getServerManager().isServerUnknown(sn)).collect(Collectors.toSet());
for (ServerName sn : unknownServerNames) {
LOG.info("{} schedule ServerCrashProcedure for unknown {}", this.server.getClientIdAuditPrefix(), sn);
if (shouldSubmitSCP(sn)) {
pids.add(this.server.getServerManager().expireServer(sn, true));
} else {
pids.add(Procedure.NO_PROC_ID);
}
}
return MasterProtos.ScheduleSCPsForUnknownServersResponse.newBuilder().addAllPid(pids).build();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method reportRegionSpaceUse.
@Override
public RegionSpaceUseReportResponse reportRegionSpaceUse(RpcController controller, RegionSpaceUseReportRequest request) throws ServiceException {
try {
server.checkInitialized();
if (!QuotaUtil.isQuotaEnabled(server.getConfiguration())) {
return RegionSpaceUseReportResponse.newBuilder().build();
}
MasterQuotaManager quotaManager = this.server.getMasterQuotaManager();
if (quotaManager != null) {
final long now = EnvironmentEdgeManager.currentTime();
for (RegionSpaceUse report : request.getSpaceUseList()) {
quotaManager.addRegionSize(ProtobufUtil.toRegionInfo(report.getRegionInfo()), report.getRegionSize(), now);
}
} else {
LOG.debug("Received region space usage report but HMaster is not ready to process it, " + "skipping");
}
return RegionSpaceUseReportResponse.newBuilder().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 fixMeta.
@Override
public FixMetaResponse fixMeta(RpcController controller, FixMetaRequest request) throws ServiceException {
rpcPreCheck("fixMeta");
try {
MetaFixer mf = new MetaFixer(this.server);
mf.fix();
return FixMetaResponse.newBuilder().build();
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method regionServerStartup.
@Override
public RegionServerStartupResponse regionServerStartup(RpcController controller, RegionServerStartupRequest request) throws ServiceException {
// Register with server manager
try {
server.checkServiceStarted();
int versionNumber = 0;
String version = "0.0.0";
VersionInfo versionInfo = VersionInfoUtil.getCurrentClientVersionInfo();
if (versionInfo != null) {
version = versionInfo.getVersion();
versionNumber = VersionInfoUtil.getVersionNumber(versionInfo);
}
InetAddress ia = server.getRemoteInetAddress(request.getPort(), request.getServerStartCode());
// if regionserver passed hostname to use,
// then use it instead of doing a reverse DNS lookup
ServerName rs = server.getServerManager().regionServerStartup(request, versionNumber, version, ia);
// Send back some config info
RegionServerStartupResponse.Builder resp = createConfigurationSubset();
NameStringPair.Builder entry = NameStringPair.newBuilder().setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER).setValue(rs.getHostname());
resp.addMapEntries(entry.build());
return resp.build();
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class MasterRpcServices method setRegionStateInMeta.
/**
* Update state of the region in meta only. This is required by hbck in some situations to cleanup
* stuck assign/ unassign regions procedures for the table.
*
* @return previous states of the regions
*/
@Override
public SetRegionStateInMetaResponse setRegionStateInMeta(RpcController controller, SetRegionStateInMetaRequest request) throws ServiceException {
rpcPreCheck("setRegionStateInMeta");
SetRegionStateInMetaResponse.Builder builder = SetRegionStateInMetaResponse.newBuilder();
try {
for (RegionSpecifierAndState s : request.getStatesList()) {
RegionSpecifier spec = s.getRegionSpecifier();
String encodedName;
if (spec.getType() == RegionSpecifierType.ENCODED_REGION_NAME) {
encodedName = spec.getValue().toStringUtf8();
} else {
// TODO: actually, a full region name can save a lot on meta scan, improve later.
encodedName = RegionInfo.encodeRegionName(spec.getValue().toByteArray());
}
RegionInfo info = this.server.getAssignmentManager().loadRegionFromMeta(encodedName);
LOG.trace("region info loaded from meta table: {}", info);
RegionState prevState = this.server.getAssignmentManager().getRegionStates().getRegionState(info);
RegionState.State newState = RegionState.State.convert(s.getState());
LOG.info("{} set region={} state from {} to {}", server.getClientIdAuditPrefix(), info, prevState.getState(), newState);
Put metaPut = MetaTableAccessor.makePutFromRegionInfo(info, EnvironmentEdgeManager.currentTime());
metaPut.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER, Bytes.toBytes(newState.name()));
List<Put> putList = new ArrayList<>();
putList.add(metaPut);
MetaTableAccessor.putsToMetaTable(this.server.getConnection(), putList);
// Loads from meta again to refresh AM cache with the new region state
this.server.getAssignmentManager().loadRegionFromMeta(encodedName);
builder.addStates(RegionSpecifierAndState.newBuilder().setRegionSpecifier(spec).setState(prevState.getState().convert()));
}
} catch (Exception e) {
throw new ServiceException(e);
}
return builder.build();
}
Aggregations