FileSystem fs = FileSystem.Factory.get();
FileSystem#createFile(AlluxioURI),它返回一个可用于写入文件的流对象。例如:FileSystem fs = FileSystem.Factory.get();AlluxioURI path = new AlluxioURI("/myFile");// Create a file and get its output streamFileOutStream out = fs.createFile(path);// Write dataout.write(...);// Close and complete fileout.close();
FileSystem fs = FileSystem.Factory.get();AlluxioURI path = new AlluxioURI("/myFile");// Generate options to set a custom blocksize of 128 MBCreateFileOptions options = CreateFileOptions.defaults().setBlockSize(128 * Constants.MB);FileOutStream out = fs.createFile(path, options);
Read Type | Behavior |
CACHE_PROMOTE | 如果读取的数据在 Worker 上时,该数据被移动到 Worker 的最高层。 如果该数据不在本地 Worker 的 Alluxio 存储中,那么就将一个副本添加到本地 Alluxio Worker 中 如果 alluxio.user.file.cache.partially.read.block 设置为 true,没有完全读取的数据块也会被全部存到 Alluxio 内。相反,一个数据块只有完全被读取时,才能被缓存。 |
CACHE | 如果该数据不在本地 Worker 的 Alluxio 存储中,那么就将一个副本添加到本地 Alluxio Worker 中。 如果 alluxio.user.file.cache.partially.read.block 设置为 true,没有完全读取的数据块也会被全部存到 Alluxio 内。相反,一个数据块只有完全被读取时,才能被缓存。 |
NO_CACHE | 仅读取数据,不在 Alluxio 中存储副本。 |
Write Type | Behavior |
CACHE_THROUGH | 数据被同步地写入到 Alluxio 的 Worker 和底层存储系统。 |
MUST_CACHE | 数据被同步地写入到 Alluxio 的 Worker。但不会被写入到底层存储系统。这是默认写类型。 |
THROUGH | 数据被同步地写入到底层存储系统。但不会被写入到 Alluxio 的 Worker。 |
ASYNC_THROUGH | 数据被同步地写入到 Alluxio 的 Worker,并异步地写入到底层存储系统。处于实验阶段。 |
alluxio.user.file.write.location.policy.class。内置的策略包括:alluxio.client.file.policyFileWriteLocationPolicy 制定适合自己的策略。alluxio.user.file.write.tier.default 配置项修改默认设置,或通过 FileSystem#createFile(AlluxioURI)API 调用覆盖它。FileSystem fs = FileSystem.Factory.get();AlluxioURI path = new AlluxioURI("/myFile");// Open the file for readingFileInStream in = fs.openFile(path);// Read datain.read(...);// Close file relinquishing the lockin.close();
文档反馈