alluxio源码解析-rpc调用概述-client和worker之间的block模块的通讯架构(netty版本)(3)
(1.8版本)client和worker之间的block模块的通讯架构
block作为alluxio文件读取或者存储的最小基本单位,都是通过BlockOutStream和BlockInputtream实现的
其中具体的数据包传输有Short circuit和netty两种实现:
- Short circuit:通过本地的ramdisk传输和netty传输
- tcp传输:只通过netty传输
输入流代码中,关于两种实现的选择逻辑:
1 public static BlockInStream create(FileSystemContext context, BlockInfo info,
2 WorkerNetAddress dataSource, BlockInStreamSource dataSourceType, InStreamOptions options)
3 throws IOException {
4 URIStatus status = options.getStatus();
5 OpenFileOptions readOptions = options.getOptions();
6
7 boolean promote = readOptions.getReadType().isPromote();
8
9 long blockId = info.getBlockId();
10 long blockSize = info.getLength();
11
12 // Construct the partial read request
13 Protocol.ReadRequest.Builder builder =
14 Protocol.ReadRequest.newBuilder().setBlockId(blockId).setPromote(promote);
15 // Add UFS fallback options
16 builder.setOpenUfsBlockOptions(options.getOpenUfsBlockOptions(blockId));
17
18 boolean shortCircuit = Configuration.getBoolean(PropertyKey.USER_SHORT_CIRCUIT_ENABLED);
19 boolean sourceSupportsDomainSocket = NettyUtils.isDomainSocketSupported(dataSource);
20 boolean sourceIsLocal = dataSourceType == BlockInStreamSource.LOCAL;
21
22 // Short circuit
23 if (sourceIsLocal && shortCircuit && !sourceSupportsDomainSocket) {
24 LOG.debug("Creating short circuit input stream for block {} @ {}", blockId, dataSource);
25 try {
26 return createLocalBlockInStream(context, dataSource, blockId, blockSize, options);
27 } catch (NotFoundException e) {
28 // Failed to do short circuit read because the block is not available in Alluxio.
29 // We will try to read via netty. So this exception is ignored.
30 LOG.warn("Failed to create short circuit input stream for block {} @ {}. Falling back to "
31 + "network transfer", blockId, dataSource);
32 }
33 }
34
35 // Netty
36 LOG.debug("Creating netty input stream for block {} @ {} from client {} reading through {}",
37 blockId, dataSource, NetworkAddressUtils.getClientHostName(), dataSource);
38 return createNettyBlockInStream(context, dataSource, dataSourceType, builder.buildPartial(),
39 blockSize, options);
40 }
输出流代码中,关于两种实现的选择逻辑:
1 /**
2 * @param context the file system context
3 * @param blockId the block ID
4 * @param blockSize the block size in bytes
5 * @param address the Alluxio worker address
6 * @param options the out stream options
7 * @return the {@link PacketWriter} instance
8 */
9 public static PacketWriter create(FileSystemContext context, long blockId, long blockSize,
10 WorkerNetAddress address, OutStreamOptions options) throws IOException {
11 if (CommonUtils.isLocalHost(address) && Configuration
12 .getBoolean(PropertyKey.USER_SHORT_CIRCUIT_ENABLED) && !NettyUtils
13 .isDomainSocketSupported(address)) {
14 LOG.debug("Creating short circuit output stream for block {} @ {}", blockId, address);
15 return LocalFilePacketWriter.create(context, address, blockId, options);
16 } else {
17 LOG.debug("Creating netty output stream for block {} @ {} from client {}", blockId, address,
18 NetworkAddressUtils.getClientHostName());
19 return NettyPacketWriter
20 .create(context, address, blockId, blockSize, Protocol.RequestType.ALLUXIO_BLOCK,
21 options);
22 }
23 }
short-circuit策略
针对block的的创建/摧毁,通过netty进行网络通讯
针对block的实际内容,直接通过ramdisk写到本地,避免了使用netty进行网络通讯,
short-circuit通讯-客户端:
下图是Netty版本的客户端+LocalFileBlockWriter+LocalFileBlockReader调用过程
short-circuit通讯-服务端:
下图是Netty版本的服务端调用
非short-circuit
非short-circuit通讯-客户端:
下图是Netty版本的客户端调用过程
非short-circuit通讯-服务端:
下图是Netty版本的服务端调用
下一篇将介绍BlockWorker相关的功能
alluxio源码解析-rpc调用概述-client和worker之间的block模块的通讯架构(netty版本)(3)的更多相关文章
- alluxio源码解析-rpc调用概述(1)
alluxio中几种角色以及角色之间的rpc调用: 作为分布式架构的文件缓存系统,rpc调用必不可少 client作为客户端 master提供thrift rpc的服务,管理以下信息: block信息 ...
- [源码解析] 并行分布式框架 Celery 之 worker 启动 (1)
[源码解析] 并行分布式框架 Celery 之 worker 启动 (1) 目录 [源码解析] 并行分布式框架 Celery 之 worker 启动 (1) 0x00 摘要 0x01 Celery的架 ...
- [源码解析] 并行分布式框架 Celery 之 worker 启动 (2)
[源码解析] 并行分布式框架 Celery 之 worker 启动 (2) 目录 [源码解析] 并行分布式框架 Celery 之 worker 启动 (2) 0x00 摘要 0x01 前文回顾 0x2 ...
- alluxio源码解析-层次化存储(4)
层次化存储-特性介绍: https://www.alluxio.org/docs/1.6/cn/Tiered-Storage-on-Alluxio.html 引入分层存储后,Alluxio管理的数据块 ...
- alluxio源码解析-netty部分(2)
netty简介 Netty是 一个异步事件驱动的网络应用程序框架,用于快速开发可维护的高性能协议服务器和客户端. netty作为alluxio中重要的通讯组件 在常见的客户端上传,下载中,都会有n ...
- [源码解析] 并行分布式任务队列 Celery 之 消费动态流程
[源码解析] 并行分布式任务队列 Celery 之 消费动态流程 目录 [源码解析] 并行分布式任务队列 Celery 之 消费动态流程 0x00 摘要 0x01 来由 0x02 逻辑 in komb ...
- DataX 3.0 源码解析一
源码解析 基本调用类分析 任务启动由python脚本新建进程进行任务执行,后续执行由Java进行,以下将对java部分进行分 其中的调用原理机制. Engine 首先入口类为com.alibaba.d ...
- 【源码解析】BlockManager详解
1 Block管理模块的组件和功能 BlockManager:BlockManager源码解析 Driver和Executor都会创建 Block的put.get和remove等操作的实际执行者 Bl ...
- 【源码解析】凭什么?spring boot 一个 jar 就能开发 web 项目
问题 为什么开发web项目,spring-boot-starter-web 一个jar就搞定了?这个jar做了什么? 通过 spring-boot 工程可以看到所有开箱即用的的引导模块 spring- ...
随机推荐
- Ray-基础部分目录
基础部分: 引言 Actor编写-ESGrain与ESRepGrain 消息发布器与消息存储器 Event编写 Handler之CoreHandler编写 Handler之ToReadHandler编 ...
- tmux终端复用神器简单使用
创建命名Tmux会话(tmux new -s session_name)tmux new -s session_name chongchong 暂退Tmux会话(Ctrl + a d)直接关窗口 返回 ...
- 《ElasticSearch6.x实战教程》之简单搜索、Java客户端(上)
第五章-简单搜索 众里寻他千百度 搜索是ES的核心,本节讲解一些基本的简单的搜索. 掌握ES搜索查询的RESTful的API犹如掌握关系型数据库的SQL语句,尽管Java客户端API为我们不需要我们去 ...
- Orleans 知多少 | 2. 核心概念一览
Orleans 术语解读 上面这张图中包含了Orleans中的几个核心概念: Grain Silo Orleans Cluster Orleans Client 从这张图,我们应该能理清他们之间的关系 ...
- 个人永久性免费-Excel催化剂功能第23波-非同一般地批量拆分工作表
工作薄的合并,许多Excel插件已有提供,Excel催化剂也提供了最佳的解决方案,另外还有工作薄的拆分和工作表的拆分,同样也是各大插件必备功能. 至于工作薄拆分,那是伪需求,Excel催化剂永远只会带 ...
- [02] HEVD 内核漏洞之栈溢出
作者:huity出处:http://www.cnblogs.com/huity35/版权:本文版权归作者所有.文章在看雪.博客园.个人博客同时发布.转载:欢迎转载,但未经作者同意,必须保留此段声明:必 ...
- Java EE.JSP.指令
JSP的指令是从JSP向Web容器发送消息,它用来设置页面的全局属性,如输出内容类型等. JSP的指令的格式为:<%@ 指令名 属性="属性值"%> 1.page指令 ...
- PHP--数据库访问(增、删、改、查)
练习通过数据库查询一个表,操作这个表的增.删.改.查的功能! 一.主页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transition ...
- Python_Day1_人人都爱列表
列表由一系列按特定顺序排列的元素组成.你可以创建包含字母表中所有字母.数字0~9或 所有家庭成员姓名的列表;也可以将任何东西加入列表中,其中的元素之间可以没有任何关系. 鉴于列表通常包含多个元素,给列 ...
- 第一篇博客 安装open live writer
第一篇博客安装open live writer http://openlivewriter.org/ 有的人可能会打不开,所以我准备了一个百度云的链接地址 链接:https://pan.baidu.c ...