【HBase代码笔记】获取Region信息

通过表名和Row获取Region获取Region

 

根据table名和row获取region信息

TableServers#locateRegion(final byte [] tableName,????? final byte [] row, boolean useCache)

 

HRegionLocation locateRegionInMeta(final byte [] parentTable,????? final byte [] tableName, final byte [] row, boolean useCache)
其实是一存放metadata的regionserver

HRegionInterface getHRegionConnection(

??????? HServerAddress regionServer, boolean getMaster)

server = this.servers.get(regionServer.toString());

??????? if (server == null) { // Get a connection????????? try {??????????? server = (HRegionInterface)HBaseRPC.waitForProxy(

??????????????? serverInterfaceClass, HBaseRPCProtocolVersion.versionID,??????????????? regionServer.getInetSocketAddress(), this.conf, this.maxRPCAttempts, this.rpcTimeout);

HRegionServer的对应方法

public Result getClosestRowBefore(final byte [] regionName,???? final byte [] row, final byte [] family)

?{???? requestCount.incrementAndGet();

???? // locate the region we’re operating on

????? HRegion region = getRegion(regionName);

????? Result r = region.getClosestRowBefore(row, family);

????? return r;

根据返回的result构建HRegionInfo,进而构建HRegionLocation

HRegionInfo regionInfo = (HRegionInfo) Writables.getWritable(

????????????? value, new HRegionInfo());

location = new HRegionLocation(regionInfo,???? ???????new HServerAddress(serverAddress));

原创文章。为了维护文章的版本一致、最新、可追溯,转载请注明: 转载自idouba

本文链接地址: 【HBase代码笔记】获取Region信息


,

No comments yet.

发表评论