Skip to content
Closed
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 @@ -1160,7 +1160,7 @@ public class ServiceConfiguration implements PulsarConfiguration {
+ " It's shared across all the topics running in the same broker.\n\n"
+ " Use -1 to disable the memory limitation. Default is 1/2 of direct memory.\n\n")
private int maxMessagePublishBufferSizeInMB = Math.max(64,
(int) (io.netty.util.internal.PlatformDependent.maxDirectMemory() / 2 / (1024 * 1024)));
(int) (io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory() / 2 / (1024 * 1024)));

@FieldContext(
category = CATEGORY_SERVER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@
import java.util.Arrays;
import java.util.Date;
import java.util.Optional;

// CHECKSTYLE.OFF: IllegalImport
import io.netty.util.internal.PlatformDependent;
// CHECKSTYLE.ON: IllegalImport
import org.apache.bookkeeper.common.util.ReflectionUtils;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.proto.BookieServer;
import org.apache.bookkeeper.replication.AutoRecoveryMain;
import org.apache.bookkeeper.stats.StatsProvider;
import org.apache.bookkeeper.util.DirectMemoryUtils;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.util.datetime.FixedDateFormat;
Expand Down Expand Up @@ -169,7 +172,7 @@ private static class BrokerStarter {
}

int maxFrameSize = brokerConfig.getMaxMessageSize() + Commands.MESSAGE_SIZE_FRAME_PADDING;
if (maxFrameSize >= DirectMemoryUtils.maxDirectMemory()) {
if (maxFrameSize >= PlatformDependent.estimateMaxDirectMemory()) {
throw new IllegalArgumentException("Max message size need smaller than jvm directMemory");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static SystemResourceUsage getSystemResourceUsage(final BrokerHostUsage b

// Collect JVM direct memory
systemResourceUsage.setDirectMemory(new ResourceUsage((double) (getJvmDirectMemoryUsed() / MIBI),
(double) (io.netty.util.internal.PlatformDependent.maxDirectMemory() / MIBI)));
(double) (io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory() / MIBI)));

return systemResourceUsage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public double get() {
Gauge.build("jvm_memory_direct_bytes_max", "-").create().setChild(new Child() {
@Override
public double get() {
return io.netty.util.internal.PlatformDependent.maxDirectMemory();
return io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory();
}
}).register(CollectorRegistry.defaultRegistry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<Metrics> generate() {
m.put("jvm_total_memory", r.totalMemory());

m.put("jvm_direct_memory_used", getJvmDirectMemoryUsed());
m.put("jvm_max_direct_memory", io.netty.util.internal.PlatformDependent.maxDirectMemory());
m.put("jvm_max_direct_memory", io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory());
m.put("jvm_thread_cnt", getThreadCount());

this.gcLogger.logMetrics(m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private Optional<Long> calculateClientMemoryLimit(Optional<ThreadRuntimeFactoryC
}

private long getBytesPercentDirectMem(double percent) {
return (long) (io.netty.util.internal.PlatformDependent.maxDirectMemory() * (percent / 100));
return (long) (io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory() * (percent / 100));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public double get() {
Gauge.build("jvm_memory_direct_bytes_max", "-").create().setChild(new Gauge.Child() {
@Override
public double get() {
return io.netty.util.internal.PlatformDependent.maxDirectMemory();
return io.netty.util.internal.PlatformDependent.estimateMaxDirectMemory();
}
}).register(CollectorRegistry.defaultRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public double get() {
Gauge.build("jvm_memory_direct_bytes_max", "-").create().setChild(new Child() {
@Override
public double get() {
return PlatformDependent.maxDirectMemory();
return PlatformDependent.estimateMaxDirectMemory();
}
}).register(CollectorRegistry.defaultRegistry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.websocket.stats;

// CHECKSTYLE.OFF: IllegalImport
import static io.netty.util.internal.PlatformDependent.maxDirectMemory;
import static org.apache.pulsar.common.stats.Metrics.create;
import static org.apache.pulsar.common.util.Runnables.catchingAndLoggingThrowables;
import java.lang.management.ManagementFactory;
Expand All @@ -29,6 +28,8 @@
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import io.netty.util.internal.PlatformDependent;
import org.apache.pulsar.common.stats.Metrics;
import org.apache.pulsar.websocket.WebSocketService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -65,7 +66,7 @@ public Metrics generate() {
m.put("jvm_max_memory", r.maxMemory());
m.put("jvm_total_memory", r.totalMemory());

m.put("jvm_max_direct_memory", maxDirectMemory());
m.put("jvm_max_direct_memory", PlatformDependent.estimateMaxDirectMemory());
m.put("jvm_thread_cnt", getThreadCount());

m.put("jvm_gc_young_pause", currentYoungGcTime);
Expand Down