Fix refactoring
This commit is contained in:
parent
9c167a322a
commit
d9fd4113e0
@ -19,7 +19,7 @@ public class MetricUtils {
|
||||
MethodHandle handle = null;
|
||||
try {
|
||||
// Find the class
|
||||
var pooledBufferClass = Class.forName("io.netty5.buffer.api.pool.PooledBufferAllocatorMetricUtils");
|
||||
var pooledBufferClass = Class.forName("io.netty5.buffer.api.pool.PooledBufferAllocatorMetric");
|
||||
// Find the handle of the method
|
||||
handle = lookup.findVirtual(pooledBufferClass, "arenaMetrics", MethodType.methodType(List.class));
|
||||
} catch (NoSuchMethodException | IllegalAccessException | ClassNotFoundException ignored) {
|
||||
@ -40,7 +40,7 @@ public class MetricUtils {
|
||||
// Invoke the method to get the metrics
|
||||
return (List<PoolArenaMetric>) GET_ARENA_METRICS.invoke(metric);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,20 +39,20 @@ public class JMXNettyMonitoringManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void register(String name, BufferAllocator metric) {
|
||||
public void register(String name, BufferAllocator allocator) {
|
||||
try {
|
||||
name = name.replaceAll("[^\\p{IsAlphabetic}\\p{IsDigit}_]", "_");
|
||||
String type;
|
||||
StandardMBean mbean;
|
||||
if (metric instanceof PooledBufferAllocator pooledMetric) {
|
||||
for (var arenaMetric : MetricUtils.getPoolArenaMetrics(pooledMetric)) {
|
||||
String arenaType = pooledMetric.isDirectBufferPooled() ? "direct" : "heap";
|
||||
if (allocator instanceof PooledBufferAllocator pooledAllocator) {
|
||||
for (var arenaMetric : MetricUtils.getPoolArenaMetrics(pooledAllocator)) {
|
||||
String arenaType = pooledAllocator.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);
|
||||
var jmx = new JMXPooledNettyMonitoring(name, pooledAllocator);
|
||||
type = "pooled";
|
||||
mbean = new StandardMBean(jmx, JMXNettyMonitoringMBean.class);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user