Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ private 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");
}
}
12 changes: 6 additions & 6 deletions core/src/main/scala/kafka/log/AbstractIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ abstract class AbstractIndex(@volatile var file: File, val baseOffset: Long, val
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
Expand Down Expand Up @@ -322,16 +322,16 @@ abstract class AbstractIndex(@volatile var file: File, val baseOffset: Long, val
}

/**
* 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()
}
}
Expand Down