From 5db83a69d5377dee45fca8a3bb4e2effb06defc9 Mon Sep 17 00:00:00 2001 From: Keshava Munegowda Date: Wed, 3 Jun 2020 12:45:18 +0530 Subject: [PATCH] Set the Meta data update is false for flush in file channel writes. Signed-off-by: Keshava Munegowda --- .../src/main/java/io/sbk/FileChannel/FileChannelConfig.java | 1 + .../src/main/java/io/sbk/FileChannel/FileChannelWriter.java | 5 +++-- driver-filechannel/src/main/resources/filechannel.properties | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelConfig.java b/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelConfig.java index cf836a4af..d3968863f 100644 --- a/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelConfig.java +++ b/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelConfig.java @@ -13,4 +13,5 @@ public class FileChannelConfig { public String fileName; public boolean isAppend; public boolean reCreate; + public boolean metaUpdate; } diff --git a/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelWriter.java b/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelWriter.java index 200d2e871..3c87e5c50 100644 --- a/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelWriter.java +++ b/driver-filechannel/src/main/java/io/sbk/FileChannel/FileChannelWriter.java @@ -25,8 +25,10 @@ */ public class FileChannelWriter implements Writer { final private FileChannel out; + final private FileChannelConfig config; public FileChannelWriter(int id, Parameters params, FileChannelConfig config) throws IOException { + this.config = config; if (config.isAppend) { this.out = FileChannel.open(Paths.get(config.fileName), StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.APPEND); @@ -34,7 +36,6 @@ public FileChannelWriter(int id, Parameters params, FileChannelConfig config) th this.out = FileChannel.open(Paths.get(config.fileName), StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } - this.out.force(false); } @Override @@ -56,7 +57,7 @@ public CompletableFuture writeAsync(ByteBuffer data) throws IOException { @Override public void flush() throws IOException { - out.force(true); + out.force(config.metaUpdate); } @Override diff --git a/driver-filechannel/src/main/resources/filechannel.properties b/driver-filechannel/src/main/resources/filechannel.properties index 1b1512e71..ef8c488c8 100644 --- a/driver-filechannel/src/main/resources/filechannel.properties +++ b/driver-filechannel/src/main/resources/filechannel.properties @@ -14,3 +14,6 @@ isAppend=false # Is recreate reCreate=true + +#Update meta data while flush +metaUpdate=false \ No newline at end of file