This is an automated email from the ASF dual-hosted git repository.
chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 988b92d9d3 Add static declaration for useFallocate in DirectWriter
(#3388)
988b92d9d3 is described below
commit 988b92d9d3364513dd3857b89a95f515b99d4e87
Author: wenbingshen <[email protected]>
AuthorDate: Wed Jul 13 22:37:27 2022 +0800
Add static declaration for useFallocate in DirectWriter (#3388)
### Motivation
The work of the `BP-47` has been very meaningful. I am reading and learning
it.
As the title, `useFallocate` in `DirectWriter` has no practical meaning,
because the judgment of SystemUtils.IS_OS_LINUX always happens.
---
.../bookie/storage/directentrylogger/DirectWriter.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/directentrylogger/DirectWriter.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/directentrylogger/DirectWriter.java
index 13cd7c34f2..d441fb0340 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/directentrylogger/DirectWriter.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/directentrylogger/DirectWriter.java
@@ -49,7 +49,7 @@ class DirectWriter implements LogWriter {
final List<Future<?>> outstandingWrites = new ArrayList<Future<?>>();
Buffer nativeBuffer;
long offset;
- private volatile boolean useFallocate = true;
+ private static volatile boolean useFallocate = true;
DirectWriter(int id,
String filename,
@@ -77,7 +77,7 @@ class DirectWriter implements LogWriter {
if (useFallocate) {
if (!SystemUtils.IS_OS_LINUX) {
- useFallocate = false;
+ disableUseFallocate();
slog.warn(Events.FALLOCATE_NOT_AVAILABLE);
} else {
try {
@@ -86,7 +86,7 @@ class DirectWriter implements LogWriter {
} catch (NativeIOException ex) {
// fallocate(2) is not supported on all filesystems.
Since this is an optimization, disable
// subsequent usage instead of failing the operation.
- useFallocate = false;
+ disableUseFallocate();
slog.kv("message", ex.getMessage())
.kv("file", filename)
.kv("errno", ex.getErrno())
@@ -99,6 +99,10 @@ class DirectWriter implements LogWriter {
this.nativeBuffer = bufferPool.acquire();
}
+ private static void disableUseFallocate() {
+ DirectWriter.useFallocate = false;
+ }
+
@Override
public int logId() {
return id;