hbase put regionserver处理分析

RegionServerput数据流程分析:

client端通过MultiServerCallable.call调用rsrpcmulti方法。

regionServer实例ClientProtos.ClientService.BlockingInterface接口。



publicMultiResponse multi(finalRpcControllerrpcc,finalMultiRequest request)

throwsServiceException {

//rpc controller is how we bring in data via the back door; it isunprotobuf'ed data.

//It is also the conduit via which we pass back data.

PayloadCarryingRpcControllercontroller= (PayloadCarryingRpcController)rpcc;

CellScannercellScanner= controller!= null?controller.cellScanner():null;

if(controller!= null)controller.setCellScanner(null);

List<CellScannable>cellsToReturn= null;

MultiResponse.BuilderresponseBuilder= MultiResponse.newBuilder();

RegionActionResult.BuilderregionActionResultBuilder= RegionActionResult.newBuilder();



得到当前提交的数据,数据按region,list的方式传入过来。

for(RegionAction regionAction: request.getRegionActionList()){

this.requestCount.add(regionAction.getActionCount());

regionActionResultBuilder.clear();

HRegion region;

try{

从当前regionserver中的onlnieRegions中得到请求的region.

1.onlineRegions中取出HRegion实例,如果不为空,按如下流程走,否则:执行到5

2.如果onlineRegions列表中不包含此region,movedRegions列表中拿到region,regionmoved超时是2分钟,

如果movedRegions列表中能拿到此region,同时move时间超时,并从movedRegions列表中移出引region返回null,

否则返回正在movedregion,如果movedRegions中返回的region不为null,throwRegionMovedException

3.regionsInTransitionInRS中获取此region,如果能拿到,同时拿到的值为true,表示region还在做opening操作。

Throw RegionOpeningException

4.如果以上得到的值都为null,表示此server中没有此region,throw NotServingRegionException

此时基本上只有一个可能,region在做split.或者move到其它server(刚完成move,client求时不在此server)

5.如果1中拿到region,表示正常,region在此server中。

region= getRegion(regionAction.getRegion());

} catch(IOException e){

regionActionResultBuilder.setException(ResponseConverter.buildException(e));

responseBuilder.addRegionActionResult(regionActionResultBuilder.build());

continue; // For this region it's a failure.

}

检查是否是原子操作:

if(regionAction.hasAtomic()&& regionAction.getAtomic()){

//How does this call happen? It may need some work to play well w/ thesurroundings.

//Need to return an item per Action along w/ Action index. TODO.

Try{

执行原子操作:保证一个region中所有的action的操作的mvcc的值相同,如果有一个操作失败,整体rollback

mutateRows(region,regionAction.getActionList(),cellScanner);

} catch(IOException e){

//As it's atomic, we may expect it's a global failure.

regionActionResultBuilder.setException(ResponseConverter.buildException(e));

}

} else{

//doNonAtomicRegionMutation manages the exception internally

执行非原子操作:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值