Support allocator metrics
This commit is contained in:
parent
48ba4d15de
commit
2fd311f67a
@ -1,9 +1,14 @@
|
||||
package it.cavallium.dbengine.netty;
|
||||
|
||||
import io.netty5.buffer.api.BufferAllocator;
|
||||
import io.netty5.buffer.api.pool.MetricUtils;
|
||||
import io.netty5.buffer.api.pool.PoolArenaMetric;
|
||||
import io.netty5.buffer.api.pool.PooledBufferAllocator;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.MBeanRegistrationException;
|
||||
import javax.management.MBeanServer;
|
||||
@ -40,6 +45,13 @@ public class JMXNettyMonitoringManager {
|
||||
String type;
|
||||
StandardMBean mbean;
|
||||
if (metric instanceof PooledBufferAllocator pooledMetric) {
|
||||
for (var arenaMetric : MetricUtils.getPoolArenaMetrics(pooledMetric)) {
|
||||
String arenaType = pooledMetric.isDirectBufferPooled() ? "direct" : "heap";
|
||||
var jmx = new JMXPoolArenaNettyMonitoring(arenaMetric);
|
||||
mbean = new StandardMBean(jmx, JMXPoolArenaNettyMonitoringMBean.class);
|
||||
ObjectName botObjectName = new ObjectName("io.netty.stats:name=PoolArena,type=" + arenaType + ",arenaId=" + nextArenaId.getAndIncrement());
|
||||
platformMBeanServer.registerMBean(mbean, botObjectName);
|
||||
}
|
||||
var jmx = new JMXPooledNettyMonitoring(name, pooledMetric);
|
||||
type = "pooled";
|
||||
mbean = new StandardMBean(jmx, JMXNettyMonitoringMBean.class);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package it.cavallium.dbengine.netty;
|
||||
|
||||
import io.netty5.buffer.PoolArenaMetric;
|
||||
|
||||
import io.netty5.buffer.api.pool.PoolArenaMetric;
|
||||
|
||||
public class JMXPoolArenaNettyMonitoring implements JMXPoolArenaNettyMonitoringMBean {
|
||||
|
||||
@ -18,7 +19,7 @@ public class JMXPoolArenaNettyMonitoring implements JMXPoolArenaNettyMonitoringM
|
||||
@Deprecated
|
||||
@Override
|
||||
public Integer getNumTinySubpages() {
|
||||
return metric.numTinySubpages();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,7 +39,7 @@ public class JMXPoolArenaNettyMonitoring implements JMXPoolArenaNettyMonitoringM
|
||||
|
||||
@Override
|
||||
public Long getNumTinyAllocations() {
|
||||
return metric.numTinyAllocations();
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,7 +64,7 @@ public class JMXPoolArenaNettyMonitoring implements JMXPoolArenaNettyMonitoringM
|
||||
|
||||
@Override
|
||||
public Long getNumTinyDeallocations() {
|
||||
return metric.numTinyDeallocations();
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,7 +90,7 @@ public class JMXPoolArenaNettyMonitoring implements JMXPoolArenaNettyMonitoringM
|
||||
@Deprecated
|
||||
@Override
|
||||
public Long getNumActiveTinyAllocations() {
|
||||
return metric.numActiveTinyAllocations();
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user