public WALChannel build() {
            String directNotAvailableMsg = WALBlockDeviceChannel.checkAvailable(path);
            boolean isBlockDevice = isBlockDevice(path);
            boolean useDirect = false;
            if (direct != null) {
                // Set by user.
                useDirect = direct;
            } else if (isBlockDevice) {
                // We can only use direct IO for block devices.
                useDirect = true;
            } else if (directNotAvailableMsg == null) {
                // If direct IO is available, we use it by default.
                useDirect = true;
            }

            if (useDirect && directNotAvailableMsg != null) {
                throw new IllegalArgumentException(directNotAvailableMsg);
            }

            if (!isBlockDevice) {
                LOGGER.warn("WAL in a file system, which may cause performance degradation. path: {}", new File(path).getAbsolutePath());
            }

            if (useDirect) {
                return new WALBlockDeviceChannel(path, capacity, initBufferSize, maxBufferSize, recoveryMode);
            } else {
                LOGGER.warn("Direct IO not used for WAL, which may cause performance degradation. path: {}, isBlockDevice: {}, reason: {}",
                    new File(path).getAbsolutePath(), isBlockDevice, directNotAvailableMsg);
                return new WALFileChannel(path, capacity, recoveryMode);
            }
        }
Get the capacity of the given channel.
It returns null if the channel has not been initialized before.
s3stream/src/main/java/com/automq/stream/s3/wal/util/WALChannel.java