use of org.apache.flink.core.fs.FSDataOutputStream in project flink by apache.
the class FileSystemBlobStoreTest method fileSystemBlobStoreCallsSyncOnPut.
@Test
public void fileSystemBlobStoreCallsSyncOnPut(@TempDir Path storageDirectory) throws IOException {
final Path blobStoreDirectory = storageDirectory.resolve("blobStore");
final AtomicReference<TestingLocalDataOutputStream> createdOutputStream = new AtomicReference<>();
final FunctionWithException<org.apache.flink.core.fs.Path, FSDataOutputStream, IOException> outputStreamFactory = value -> {
final File file = new File(value.toString());
FileUtils.createParentDirectories(file);
final TestingLocalDataOutputStream outputStream = new TestingLocalDataOutputStream(file);
createdOutputStream.compareAndSet(null, outputStream);
return outputStream;
};
try (FileSystemBlobStore fileSystemBlobStore = new FileSystemBlobStore(new TestFs(outputStreamFactory), blobStoreDirectory.toString())) {
final BlobKey blobKey = BlobKey.createKey(BlobKey.BlobType.PERMANENT_BLOB);
final File localFile = storageDirectory.resolve("localFile").toFile();
FileUtils.createParentDirectories(localFile);
FileUtils.writeStringToFile(localFile, "foobar", StandardCharsets.UTF_8);
fileSystemBlobStore.put(localFile, new JobID(), blobKey);
assertThat(createdOutputStream.get().hasSyncBeenCalled()).isTrue();
}
}
Aggregations