简体   繁体   English

akka流中异步文件IO的当前状态是什么?

[英]What is the current state of asynchronous file IO in akka streams?

Target: 目标:

I would like to see Akka's file IO to be as asynchronous and non-blocking as possible. 我希望看到Akka的文件IO尽可能异步且无阻塞。

My status of knowledge so far: 到目前为止,我的知识水平:

In older project documentation you can read this: 较早的项目文档中,您可以阅读以下内容:

Note 注意

Since the current version of Akka (2.3.x) needs to support JDK6, the currently provided File IO implementations are not able to utilise Asynchronous File IO operations, as these were introduced in JDK7 (and newer). 由于Akka(2.3.x)的当前版本需要支持JDK6,因此当前提供的File IO实现无法利用Asynchronous File IO操作,因为这些操作是在JDK7(及更高版本)中引入的。 Once Akka is free to require JDK8 (from 2.4.x) these implementations will be updated to make use of the new NIO APIs (ie AsynchronousFileChannel). 一旦Akka自由地需要JDK8(从2.4.x版本开始),这些实现将被更新以利用新的NIO API(即AsynchronousFileChannel)。

The current akka version is '2.5.4'. 当前的akka​​版本是“ 2.5.4”。 The current version of akka-stream is '2.11' or '2.12'. 当前版本的akka​​-stream是'2.11'或'2.12'。 In the current documentation the note from abhove is missing and it is only explicitly mentioned that file IO means blocking operations which are processed by a dispatcher dedicated to IO operations. 当前文档中 ,缺少abhove的注释,仅明确提及文件IO意味着阻止了操作,这些操作由专用于IO操作的调度程序处理。

In the 'MANIFEST.MF' file inside the akka-streams Jar-File there is a line: 在akka-streams Jar-File内的'MANIFEST.MF'文件中,有一行:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

So I guess it requires Java 8. 所以我想这需要Java 8。

There is a question related to scala asynchronous file IO but its from January 2015. One of the answers contains: 一个与scala异步文件IO相关的问题 ,但该问题始于2015年1月。 答案之一包括:

Akka IO, while not providing file IO in it's core, has a module developed by Dario Rexin, which allows to use AsynchronousFileChannel with Akka IO in a very simple manner. Akka IO虽然未在其核心中提供文件IO,但具有由Dario Rexin开发的模块,该模块允许以非常简单的方式将AsynchronousFileChannel与Akka IO一起使用。 Have a look at this library to make use of it: https://github.com/drexin/akka-io-file 看看这个库可以利用它: https : //github.com/drexin/akka-io-file

Questions: 问题:

  1. How asynchronous is the current state of akka streams file IO? akka流文件IO的当前状态如何异步?
  2. Does akka streams file IO use 'AsynchronousFileChannel' from Java's NIO? akka流文件IO是否使用Java的NIO中的“ AsynchronousFileChannel”?
  3. Do I have to do something to use 'AsynchronousFileChannel' from Java's NIO? 我需要做一些事情来使用Java NIO中的'AsynchronousFileChannel'吗?
  1. How asynchronous is the current state of akka streams file IO? akka流文件IO的当前状态如何异步?

Perusing the source code shows that Akka Stream's FileIO uses java.nio.ByteBuffer and java.nio.channels.FileChannel . 仔细阅读源代码可知,Akka Stream的FileIO使用java.nio.ByteBufferjava.nio.channels.FileChannel And as the documentation states, the file IO operations run in isolation on a dedicated dispatcher. 并且如文档所述,文件IO操作在专用调度程序上独立运行。

There is an open pull request that attempts to use AsynchronousFileChannel . 有一个尝试使用AsynchronousFileChannel的打开请求请求 Based on the benchmark results reported in that PR, the PR might be closed in favor of trying a newer approach with synchronous NIO as captured in another PR . 根据该PR中报告的基准测试结果,可能会关闭PR,以尝试使用另一种PR中捕获的具有同步NIO的新方法。

  1. Does akka streams file IO use 'AsynchronousFileChannel' from Java's NIO? akka流文件IO是否使用Java的NIO中的“ AsynchronousFileChannel”?

No. 没有。

  1. Do I have to do something to use 'AsynchronousFileChannel' from Java's NIO? 我需要做一些事情来使用Java NIO中的'AsynchronousFileChannel'吗?

This question is moot, because Akka Streams does not use AsynchronousFileChannel . 这个问题没有什么意义,因为Akka Streams不使用AsynchronousFileChannel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM