You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by mi...@apache.org on 2020/04/24 14:25:00 UTC
[kafka] branch trunk updated: KAFKA-9704: Fix the issue z/OS won't
let us resize file when mmap. (#8224)
This is an automated email from the ASF dual-hosted git repository.
mimaison pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 62b2eac KAFKA-9704: Fix the issue z/OS won't let us resize file when mmap. (#8224)
62b2eac is described below
commit 62b2eac4e1a97e6d77bc57f9100bf22a2f364178
Author: zshuo <sh...@cn.ibm.com>
AuthorDate: Fri Apr 24 22:24:14 2020 +0800
KAFKA-9704: Fix the issue z/OS won't let us resize file when mmap. (#8224)
Reviewers: Mickael Maison <mi...@gmail.com>
---
.../java/org/apache/kafka/common/utils/OperatingSystem.java | 3 +++
core/src/main/scala/kafka/log/AbstractIndex.scala | 12 ++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/clients/src/main/java/org/apache/kafka/common/utils/OperatingSystem.java b/clients/src/main/java/org/apache/kafka/common/utils/OperatingSystem.java
index 9d80295..8dc8b86 100644
--- a/clients/src/main/java/org/apache/kafka/common/utils/OperatingSystem.java
+++ b/clients/src/main/java/org/apache/kafka/common/utils/OperatingSystem.java
@@ -27,8 +27,11 @@ public final class OperatingSystem {
public static final boolean IS_WINDOWS;
+ public static final boolean IS_ZOS;
+
static {
NAME = System.getProperty("os.name").toLowerCase(Locale.ROOT);
IS_WINDOWS = NAME.startsWith("windows");
+ IS_ZOS = NAME.startsWith("z/os");
}
}
diff --git a/core/src/main/scala/kafka/log/AbstractIndex.scala b/core/src/main/scala/kafka/log/AbstractIndex.scala
index 675fbcf..eb0906a 100644
--- a/core/src/main/scala/kafka/log/AbstractIndex.scala
+++ b/core/src/main/scala/kafka/log/AbstractIndex.scala
@@ -184,8 +184,8 @@ abstract class AbstractIndex(@volatile private var _file: File, val baseOffset:
try {
val position = mmap.position()
- /* Windows won't let us modify the file length while the file is mmapped :-( */
- if (OperatingSystem.IS_WINDOWS)
+ /* Windows or z/OS won't let us modify the file length while the file is mmapped :-( */
+ if (OperatingSystem.IS_WINDOWS || OperatingSystem.IS_ZOS)
safeForceUnmap()
raf.setLength(roundedNewSize)
_length = roundedNewSize
@@ -326,16 +326,16 @@ abstract class AbstractIndex(@volatile private var _file: File, val baseOffset:
}
/**
- * Execute the given function in a lock only if we are running on windows. We do this
- * because Windows won't let us resize a file while it is mmapped. As a result we have to force unmap it
+ * Execute the given function in a lock only if we are running on windows or z/OS. We do this
+ * because Windows or z/OS won't let us resize a file while it is mmapped. As a result we have to force unmap it
* and this requires synchronizing reads.
*/
protected def maybeLock[T](lock: Lock)(fun: => T): T = {
- if (OperatingSystem.IS_WINDOWS)
+ if (OperatingSystem.IS_WINDOWS || OperatingSystem.IS_ZOS)
lock.lock()
try fun
finally {
- if (OperatingSystem.IS_WINDOWS)
+ if (OperatingSystem.IS_WINDOWS || OperatingSystem.IS_ZOS)
lock.unlock()
}
}