Skip to content

Commit

Permalink
Set the Meta data update is false for flush in file channel writes.
Browse files Browse the repository at this point in the history
Signed-off-by: Keshava Munegowda <[email protected]>
  • Loading branch information
kmgowda committed Jun 3, 2020
1 parent dab376f commit 5db83a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class FileChannelConfig {
public String fileName;
public boolean isAppend;
public boolean reCreate;
public boolean metaUpdate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
*/
public class FileChannelWriter implements Writer<ByteBuffer> {
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);
} else {
this.out = FileChannel.open(Paths.get(config.fileName), StandardOpenOption.WRITE,
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
}
this.out.force(false);
}

@Override
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions driver-filechannel/src/main/resources/filechannel.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ isAppend=false

# Is recreate
reCreate=true

#Update meta data while flush
metaUpdate=false

0 comments on commit 5db83a6

Please sign in to comment.