(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)的更多相关文章

  1. alluxio源码解析-rpc调用概述(1)

    alluxio中几种角色以及角色之间的rpc调用: 作为分布式架构的文件缓存系统,rpc调用必不可少 client作为客户端 master提供thrift rpc的服务,管理以下信息: block信息 ...

  2. [源码解析] 并行分布式框架 Celery 之 worker 启动 (1)

    [源码解析] 并行分布式框架 Celery 之 worker 启动 (1) 目录 [源码解析] 并行分布式框架 Celery 之 worker 启动 (1) 0x00 摘要 0x01 Celery的架 ...

  3. [源码解析] 并行分布式框架 Celery 之 worker 启动 (2)

    [源码解析] 并行分布式框架 Celery 之 worker 启动 (2) 目录 [源码解析] 并行分布式框架 Celery 之 worker 启动 (2) 0x00 摘要 0x01 前文回顾 0x2 ...

  4. alluxio源码解析-层次化存储(4)

    层次化存储-特性介绍: https://www.alluxio.org/docs/1.6/cn/Tiered-Storage-on-Alluxio.html 引入分层存储后,Alluxio管理的数据块 ...

  5. alluxio源码解析-netty部分(2)

    netty简介 Netty是 一个异步事件驱动的网络应用程序框架,用于快速开发可维护的高性能协议服务器和客户端.   netty作为alluxio中重要的通讯组件 在常见的客户端上传,下载中,都会有n ...

  6. [源码解析] 并行分布式任务队列 Celery 之 消费动态流程

    [源码解析] 并行分布式任务队列 Celery 之 消费动态流程 目录 [源码解析] 并行分布式任务队列 Celery 之 消费动态流程 0x00 摘要 0x01 来由 0x02 逻辑 in komb ...

  7. DataX 3.0 源码解析一

    源码解析 基本调用类分析 任务启动由python脚本新建进程进行任务执行,后续执行由Java进行,以下将对java部分进行分 其中的调用原理机制. Engine 首先入口类为com.alibaba.d ...

  8. 【源码解析】BlockManager详解

    1 Block管理模块的组件和功能 BlockManager:BlockManager源码解析 Driver和Executor都会创建 Block的put.get和remove等操作的实际执行者 Bl ...

  9. 【源码解析】凭什么?spring boot 一个 jar 就能开发 web 项目

    问题 为什么开发web项目,spring-boot-starter-web 一个jar就搞定了?这个jar做了什么? 通过 spring-boot 工程可以看到所有开箱即用的的引导模块 spring- ...

随机推荐

  1. 扩展了一些String常用的方法.

    using System; using System.Diagnostics; using System.Security.Cryptography; using System.Text; using ...

  2. Nginx+vsftpd

    一.安装Nginx 关闭selinux和firewalld setenforce sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selin ...

  3. 程序员要搞明白CDN,这篇应该够了

    最近在了解边缘计算,发现我们经常听说的CDN也是边缘计算里的一部分.那么说到CDN,好像只知道它中文叫做内容分发网络.那么具体CDN的原理是什么?能够为用户在浏览网站时带来什么好处呢?解决这两个问题是 ...

  4. windows登陆suse虚拟机

    vmware我还是比较偏向7.1.4版本,其他版本装在win7上似乎有点问题. windows平台下,使用vmware + opensuse的网络配置过程如下: 装完vm后,会在本地连接新创建两个新连 ...

  5. EnjoyingSoft之Mule ESB开发教程系列第五篇:控制消息的流向-数据路由

    目录 1. 使用场景 2. 基于消息头的路由 2.1 使用JSON提交订单的消息 2.2 使用XML提交订单的消息 2.3 使用Choice组件判断订单格式 3. 基于消息内容的路由 4. 其他控制流 ...

  6. ElementUI 源码简析——源码结构篇

    ElementUI 作为当前运用的最广的 Vue PC 端组件库,很多 Vue 组件库的架构都是参照 ElementUI 做的.作为一个有梦想的前端(咸鱼),当然需要好好学习一番这套比较成熟的架构. ...

  7. Java编程思想:内部类基础部分

    public class Test { public static void main(String[] args) { // Parcel1.test(); // Parcel2.test(); / ...

  8. 异步编程之Async,Await和ConfigureAwait的关系

    在.NET Framework 4.5中,async / await关键字已添加到该版本中,简化多线程操作,以使异步编程更易于使用.为了最大化利用资源而不挂起UI,你应该尽可能地尝试使用异步编程.虽然 ...

  9. win10 安装mysql(图文详情)避免卡在最后一步

    win10 安装mysql 本人安装mysql一般都是在镜像文件夹中下载(http://mirrors.sohu.com/),最近系统重做了之后安装mysql5.5.msi,可以安装成功.但是在最后的 ...

  10. SpringMvc返回JSON出现"$.result.currentLevel"

    "$.result.currentLevel" 问题描述 使用SpringMvc返回一个json数据的时候,会在产生的结果中出现如下的问题:"$.result.curre ...