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- ...
随机推荐
- 大话Spark(9)-源码之TaskScheduler
上篇文章讲到DAGScheduler会把job划分为多个Stage,每个Stage中都会创建一批Task,然后把Task封装为TaskSet提交到TaskScheduler. 这里我们来一起看下Tas ...
- React躬行记(8)——样式
由于React推崇组件模式,因此会要求HTML.CSS和JavaScript混合在一起,虽然这与过去的关注点分离正好相反,但是更有利于组件之间的隔离.React已将HTML用JSX封装,而对CSS只进 ...
- kafka介绍及安装配置(windows)
Kafka介绍 Kafka是分布式的发布—订阅消息系统.它最初由LinkedIn(领英)公司发布,使用Scala和Java语言编写,与2010年12月份开源,成为Apache的顶级项目.Kafka是一 ...
- 双剑合璧——掌握 cURL 和 Dig 走天涯
如今随着大量的应用转移到网络,作为开发者,会经常做一些通讯测试,例如从网站获取信息.模拟用户向网站提交或者上传数据,查看应用通讯情况等等,现在变成了非常重要的任务. 一起来认识 cURL cURL 是 ...
- 下载历史版本CentOS
搜索centos 进入主页面向下移动滚动找到 点击后向下移动,选择需要的版本进行tree 选择 OK!
- [Spring-Cloud-Alibaba] Sentinel 整合RestTemplate & Feign
Sentinel API Github : WIKI Sphu (指明要保护的资源名称) Tracer (指明调用来源,异常统计接口) ContextUtil(标示进入调用链入口) 流控规则(针对来源 ...
- Linux文件权限设置教程
Linux的文件基本权限有9个,分别是owenr.group.others三种身份各自有自己的r.w和x,比如"rwxrwxrwx",就表示owener具有r.w.x权限,同样gr ...
- 个人永久性免费-Excel催化剂功能第50波-批量打印、导出PDF、双面打印功能
在倡导无纸化办公的今天,是否打印是一个碍眼的功能呢,某些时候的确是,但对于数据的留存,在现在鼓吹区块链技术的今天,仍然不失它的核心价值,数据报表.单据打印出来留存,仍然是一种不可或缺的数据存档和防篡改 ...
- Excel催化剂开源第19波-一些虽简单但不知道时还是很难受的知识点
通常许多的知识都是在知与不知之间,不一定非要很深奥,特别是Excel这样的应用工具层面,明明已经摆在那里,你不知道时,永远地不知道,知道了,简单学习下就已经实现出最终的功能效果. 在程序猿世界里,也是 ...
- Mybatis方法入参处理
1,在单个入参的情况下,mybatis不做任何处理,#{参数名} 即可,甚至连参数名都可以不需要,因为只有一个参数,或者使用 Mybatis的内置参数 _parameter. 2,多个入参: 接口方法 ...