今天有空闲时间看一下HBASE的写入代码

MutiAction类,是一个action的container,包括get . put. delete。并且是根据region name分组的。其中核心的就是add方法,根据传进来的region name将action分组

  1. public final class MultiAction<R> {
  2. // TODO: This class should not be visible outside of the client package.
  3.  
  4. // map of regions to lists of puts/gets/deletes for that region.
  5. public Map<byte[], List<Action<R>>> actions =
  6. new TreeMap<byte[], List<Action<R>>>(Bytes.BYTES_COMPARATOR);
  7.  
  8. private long nonceGroup = HConstants.NO_NONCE;
  9.  
  10. public MultiAction() {
  11. super();
  12. }
  13.  
  14. /**
  15. * Get the total number of Actions
  16. *
  17. * @return total number of Actions for all groups in this container.
  18. */
  19. public int size() {
  20. int size = 0;
  21. for (List<?> l : actions.values()) {
  22. size += l.size();
  23. }
  24. return size;
  25. }
  26.  
  27. /**
  28. * Add an Action to this container based on it's regionName. If the regionName
  29. * is wrong, the initial execution will fail, but will be automatically
  30. * retried after looking up the correct region.
  31. *
  32. * @param regionName
  33. * @param a
  34. */
  35. public void add(byte[] regionName, Action<R> a) {
  36. add(regionName, Arrays.asList(a));
  37. }
  38.  
  39. /**
  40. * Add an Action to this container based on it's regionName. If the regionName
  41. * is wrong, the initial execution will fail, but will be automatically
  42. * retried after looking up the correct region.
  43. *
  44. * @param regionName
  45. * @param actionList list of actions to add for the region
  46. */
  47. public void add(byte[] regionName, List<Action<R>> actionList){
  48. List<Action<R>> rsActions = actions.get(regionName);
  49. if (rsActions == null) {
  50. rsActions = new ArrayList<Action<R>>(actionList.size());
  51. actions.put(regionName, rsActions);
  52. }
  53. rsActions.addAll(actionList);
  54. }
  55.  
  56. public void setNonceGroup(long nonceGroup) {
  57. this.nonceGroup = nonceGroup;
  58. }
  59.  
  60. public Set<byte[]> getRegions() {
  61. return actions.keySet();
  62. }
  63.  
  64. public boolean hasNonceGroup() {
  65. return nonceGroup != HConstants.NO_NONCE;
  66. }
  67.  
  68. public long getNonceGroup() {
  69. return this.nonceGroup;
  70. }
  71. }  

接下来介绍AyncProcess类,该类

待续

Hbase put写入源码分析的更多相关文章

  1. 【RocketMQ源码分析】深入消息存储(1)

    最近在学习RocketMQ相关的东西,在学习之余沉淀几篇笔记. RocketMQ有很多值得关注的设计点,消息发送.消息消费.路由中心NameServer.消息过滤.消息存储.主从同步.事务消息等等. ...

  2. Hbase写入hdfs源码分析

    版权声明:本文由熊训德原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/258 来源:腾云阁 https://www.qclo ...

  3. Hbase WAL线程模型源码分析

    版权声明:本文由熊训德原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/257 来源:腾云阁 https://www.qclo ...

  4. Hbase源码分析:Hbase UI中Requests Per Second的具体含义

    Hbase源码分析:Hbase UI中Requests Per Second的具体含义 让运维加监控,被问到Requests Per Second(见下图)的具体含义是什么?我一时竟回答不上来,虽然大 ...

  5. 浅谈ZooKeeper基本原理与源码分析

    最近一直有小伙伴私信我,问一些关于Zookeeper的知识,下边关于的Zookeeper的知识整理了一下,一起学习一下. 看完本文对于Zookeeper想深入全面了解的读者朋友们,小编这里整理了一份更 ...

  6. spark源码分析以及优化

    第一章.spark源码分析之RDD四种依赖关系 一.RDD四种依赖关系 RDD四种依赖关系,分别是 ShuffleDependency.PrunDependency.RangeDependency和O ...

  7. 图解Janusgraph系列-图数据底层序列化源码分析(Data Serialize)

    图解Janusgraph系列-图数据底层序列化源码分析(Data Serialize) 大家好,我是洋仔,JanusGraph图解系列文章,实时更新~ 图数据库文章总目录: 整理所有图相关文章,请移步 ...

  8. 【图解源码】Zookeeper3.7源码分析,包含服务启动流程源码、网络通信源码、RequestProcessor处理请求源码

    Zookeeper3.7源码剖析 能力目标 能基于Maven导入最新版Zookeeper源码 能说出Zookeeper单机启动流程 理解Zookeeper默认通信中4个线程的作用 掌握Zookeepe ...

  9. zookeeper源码分析之四服务端(单机)处理请求流程

    上文: zookeeper源码分析之一服务端启动过程 中,我们介绍了zookeeper服务器的启动过程,其中单机是ZookeeperServer启动,集群使用QuorumPeer启动,那么这次我们分析 ...

随机推荐

  1. 10道Python常见面试题

    1.MySQL索引种类 1.普通索引 2.唯一索引 3.主键索引 4.组合索引 5.全文索引 2.索引在什么情况下遵循最左前缀的规则? 最左前缀原理的一部分,索引index1:(a,b,c),只会走a ...

  2. dtd语法

    dtd语法 <!ELEMENT 元素名 约束> //简单元素三种:没有子元素的元素 eg: <!ELEMENT name (#PCDATA)> (#PCDATA):约束name ...

  3. 在Angular4中使用ng2-baidu-map详解

    一.引言 之前在Angular4使用过百度地图,记录一下踩过的坑 二.实现 1.安装 npm install angular2-baidu-map 2.在app.module.ts配置 ak key在 ...

  4. Python 安装第三方库,pip install 安装慢,安装不上的解决办法

    今天来说一下,有些刚刚接触python的朋友,在使用pip install安装python 第三方库的过程中 会出现网速很慢,或者是安装下载到中途,停止,卡主,或者是下载报错等问题.如下图: 还有一些 ...

  5. NCcat学习使用

    一.使用手册 1.简介:nc/NetCat是一款端口监听工具,可以用来建立系统之间的连接.传输文件.TCP代理等. 2.命令参数     nc [-options] hostname port[s] ...

  6. pdfium

    https://github.com/SubtleCow/AccessControlListsintheDOM/tree/4673d995e5614bc682cecd22f9b2919b2360273 ...

  7. 201871010111-刘佳华《面向对象程序设计(java)》第四周学习总结

    201871010111-刘佳华<面向对象程序设计(java)>第四周学习总结 实验时间 2019-9-20 第一部分:总结第四章理论知识 4.1:类与对象的概念. 类:类是构造对象的模板 ...

  8. 【使用篇二】SpringBoot单元测试(10)

    SpringCloud单元测试:https://www.cnblogs.com/myitnews/p/11796321.html 1. 创建项目Maven Project,修改pom.xml < ...

  9. Artificial Intelligence in Finance

    https://sigmoidal.io/real-applications-of-ai-in-finance/ Artificial Intelligence is taking the finan ...

  10. 洛谷 U86564 排队形

    洛谷 U86564 排队形 题目传送门 题目背景 \(JDFZ2019\)秋季运动会开始辣!为了使强大的高一 · \(6\)班有一个更好的精神面貌,班主任\(T\)老师和体委\(LY\),\(LYB\ ...