本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.ProtobufUtil.toServerName方法的典型用法代码示例。如果您正苦于以下问题:Java ProtobufUtil.toServerName方法的具体用法?Java ProtobufUtil.toServerName怎么用?Java ProtobufUtil.toServerName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.protobuf.ProtobufUtil
的用法示例。
在下文中一共展示了ProtobufUtil.toServerName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: regionServerReport
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Override
public RegionServerReportResponse regionServerReport(
RpcController controller, RegionServerReportRequest request) throws ServiceException {
try {
master.checkServiceStarted();
ClusterStatusProtos.ServerLoad sl = request.getLoad();
ServerName serverName = ProtobufUtil.toServerName(request.getServer());
ServerLoad oldLoad = master.serverManager.getLoad(serverName);
master.serverManager.regionServerReport(serverName, new ServerLoad(sl));
if (sl != null && master.metricsMaster != null) {
// Up our metrics.
master.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests()
- (oldLoad != null ? oldLoad.getTotalNumberOfRequests() : 0));
}
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
return RegionServerReportResponse.newBuilder().build();
}
示例2: getServerHoldingRegion
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Override
public ServerName getServerHoldingRegion(TableName tn, byte[] regionName) throws IOException {
HRegionLocation regionLoc = null;
try (RegionLocator locator = connection.getRegionLocator(tn)) {
regionLoc = locator.getRegionLocation(regionName);
}
if (regionLoc == null) {
LOG.warn("Cannot find region server holding region " + Bytes.toString(regionName) +
", start key [" + Bytes.toString(HRegionInfo.getStartKey(regionName)) + "]");
return null;
}
AdminProtos.AdminService.BlockingInterface client =
((ClusterConnection)this.connection).getAdmin(regionLoc.getServerName());
ServerInfo info = ProtobufUtil.getServerInfo(null, client);
return ProtobufUtil.toServerName(info.getServerName());
}
示例3: toByteArray
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
* @return This instance serialized into a byte array
* @see #parseFrom(byte[])
*/
public byte [] toByteArray() {
// First create a pb ServerName. Then create a ByteString w/ the TaskState
// bytes in it. Finally create a SplitLogTaskState passing in the two
// pbs just created.
HBaseProtos.ServerName snpb = ProtobufUtil.toServerName(this.originServer);
ZooKeeperProtos.SplitLogTask slts =
ZooKeeperProtos.SplitLogTask.newBuilder().setServerName(snpb).setState(this.state).
setMode(this.mode).build();
return ProtobufUtil.prependPBMagic(slts.toByteArray());
}
示例4: getFavoredNodesList
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
* @param favoredNodes The PB'ed bytes of favored nodes
* @return the array of {@link ServerName} for the byte array of favored nodes.
* @throws InvalidProtocolBufferException
*/
public static ServerName[] getFavoredNodesList(byte[] favoredNodes)
throws InvalidProtocolBufferException {
FavoredNodes f = FavoredNodes.parseFrom(favoredNodes);
List<HBaseProtos.ServerName> protoNodes = f.getFavoredNodeList();
ServerName[] servers = new ServerName[protoNodes.size()];
int i = 0;
for (HBaseProtos.ServerName node : protoNodes) {
servers[i++] = ProtobufUtil.toServerName(node);
}
return servers;
}
示例5: reportRSFatalError
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Override
public ReportRSFatalErrorResponse reportRSFatalError(
RpcController controller, ReportRSFatalErrorRequest request) throws ServiceException {
String errorText = request.getErrorMessage();
ServerName sn = ProtobufUtil.toServerName(request.getServer());
String msg = "Region server " + sn
+ " reported a fatal error:\n" + errorText;
LOG.error(msg);
master.rsFatals.add(msg);
return ReportRSFatalErrorResponse.newBuilder().build();
}
示例6: reportRegionStateTransition
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Override
public ReportRegionStateTransitionResponse reportRegionStateTransition(RpcController c,
ReportRegionStateTransitionRequest req) throws ServiceException {
try {
master.checkServiceStarted();
RegionStateTransition rt = req.getTransition(0);
TableName tableName = ProtobufUtil.toTableName(
rt.getRegionInfo(0).getTableName());
RegionStates regionStates = master.assignmentManager.getRegionStates();
if (!(TableName.META_TABLE_NAME.equals(tableName)
&& regionStates.getRegionState(HRegionInfo.FIRST_META_REGIONINFO) != null)
&& !master.assignmentManager.isFailoverCleanupDone()) {
// Meta region is assigned before master finishes the
// failover cleanup. So no need this check for it
throw new PleaseHoldException("Master is rebuilding user regions");
}
ServerName sn = ProtobufUtil.toServerName(req.getServer());
String error = master.assignmentManager.onRegionTransition(sn, rt);
ReportRegionStateTransitionResponse.Builder rrtr =
ReportRegionStateTransitionResponse.newBuilder();
if (error != null) {
rrtr.setErrorMessage(error);
}
return rrtr.build();
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
示例7: closeRegion
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
* Close a region on the region server.
*
* @param controller the RPC controller
* @param request the request
* @throws ServiceException
*/
@Override
@QosPriority(priority=HConstants.ADMIN_QOS)
public CloseRegionResponse closeRegion(final RpcController controller,
final CloseRegionRequest request) throws ServiceException {
final ServerName sn = (request.hasDestinationServer() ?
ProtobufUtil.toServerName(request.getDestinationServer()) : null);
try {
checkOpen();
if (request.hasServerStartCode()) {
// check that we are the same server that this RPC is intended for.
long serverStartCode = request.getServerStartCode();
if (regionServer.serverName.getStartcode() != serverStartCode) {
throw new ServiceException(new DoNotRetryIOException("This RPC was intended for a " +
"different server with startCode: " + serverStartCode + ", this server is: "
+ regionServer.serverName));
}
}
final String encodedRegionName = ProtobufUtil.getRegionEncodedName(request.getRegion());
// Can be null if we're calling close on a region that's not online
final Region region = regionServer.getFromOnlineRegions(encodedRegionName);
if ((region != null) && (region .getCoprocessorHost() != null)) {
region.getCoprocessorHost().preClose(false);
}
requestCount.increment();
LOG.info("Close " + encodedRegionName + ", moving to " + sn);
CloseRegionCoordination.CloseRegionDetails crd = regionServer.getCoordinatedStateManager()
.getCloseRegionCoordination().parseFromProtoRequest(request);
boolean closed = regionServer.closeRegion(encodedRegionName, false, crd, sn);
CloseRegionResponse.Builder builder = CloseRegionResponse.newBuilder().setClosed(closed);
return builder.build();
} catch (IOException ie) {
throw new ServiceException(ie);
}
}
示例8: SplitLogTask
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
SplitLogTask(final ZooKeeperProtos.SplitLogTask slt) {
this.originServer = ProtobufUtil.toServerName(slt.getServerName());
this.state = slt.getState();
this.mode = (slt.hasMode()) ? slt.getMode() :
ZooKeeperProtos.SplitLogTask.RecoveryMode.UNKNOWN;
}
示例9: getServerName
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
public ServerName getServerName() {
return ProtobufUtil.toServerName(this.rt.getServerName());
}