(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相关的功能

最新文章

  1. ios App与网页交互
  2. 移动端关于meta的几个常用标签
  3. OpenXml入门
  4. visual studio 中快捷键的使用
  5. Java 使用 Redis
  6. [转载]iOS本地推送-备用
  7. zoj3201(树形dp)
  8. 发布开源库到JCenter所遇到的一些问题记录
  9. JavaScript基础系列
  10. Guitar Por如何演奏刮弦
  11. 【Mybatis】一对一实例
  12. scala recursive value x$5 needs type
  13. 基于STL优先队列和邻接表的dijkstra算法
  14. JavaScript基础入门教程(一)
  15. powerdesigner设计的pdm模型导出清晰图片格式
  16. Android Activity中状态保存机制
  17. FPGA基础学习(1) -- FFT IP核(Quartus)
  18. Markdown快速上手指南
  19. Centos6.5_64位系统下安装Oracle 11g
  20. Poj_1088_滑雪(DP)

热门文章

  1. python3 连接数据库注意点
  2. Java连载5-标识符、关键字和字面值
  3. 成功解决 org.mybatis.spring.MyBatisSystemException问题!!
  4. 判断List中是否含有某个实体bean
  5. Java面试题汇总---基础版(附答案)
  6. MyBatis bind标签的用法
  7. QRowTable表格控件(三)-效率优化之-合理使用QStandardItem
  8. UVA10375 选择与除法 Choose and divide 题解
  9. UVA514 铁轨 Rails:题解
  10. Vue匿名组件使用keep-alive后动态清除缓存