HBASE-21107 add a metrics for netty direct memory
This commit is contained in:
parent
b7cdfe3ab0
commit
bdc168713d
|
@ -95,6 +95,11 @@ public interface MetricsHBaseServerSource extends ExceptionTrackingSource {
|
||||||
String NUM_LIFO_MODE_SWITCHES_NAME = "numLifoModeSwitches";
|
String NUM_LIFO_MODE_SWITCHES_NAME = "numLifoModeSwitches";
|
||||||
String NUM_LIFO_MODE_SWITCHES_DESC = "Total number of calls in general queue which " +
|
String NUM_LIFO_MODE_SWITCHES_DESC = "Total number of calls in general queue which " +
|
||||||
"were served from the tail of the queue";
|
"were served from the tail of the queue";
|
||||||
|
// Direct Memory Usage metrics
|
||||||
|
String NETTY_DM_USAGE_NAME = "nettyDirectMemoryUsage";
|
||||||
|
|
||||||
|
String NETTY_DM_USAGE_DESC = "Current Netty direct memory usage.";
|
||||||
|
|
||||||
|
|
||||||
void authorizationSuccess();
|
void authorizationSuccess();
|
||||||
|
|
||||||
|
|
|
@ -56,4 +56,6 @@ public interface MetricsHBaseServerWrapper {
|
||||||
int getActiveReadRpcHandlerCount();
|
int getActiveReadRpcHandlerCount();
|
||||||
|
|
||||||
int getActiveScanRpcHandlerCount();
|
int getActiveScanRpcHandlerCount();
|
||||||
|
|
||||||
|
long getNettyDmUsage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,9 @@ public class MetricsHBaseServerSourceImpl extends ExceptionTrackingSourceImpl
|
||||||
.addGauge(Interns.info(NUM_ACTIVE_READ_HANDLER_NAME, NUM_ACTIVE_READ_HANDLER_DESC),
|
.addGauge(Interns.info(NUM_ACTIVE_READ_HANDLER_NAME, NUM_ACTIVE_READ_HANDLER_DESC),
|
||||||
wrapper.getActiveReadRpcHandlerCount())
|
wrapper.getActiveReadRpcHandlerCount())
|
||||||
.addGauge(Interns.info(NUM_ACTIVE_SCAN_HANDLER_NAME, NUM_ACTIVE_SCAN_HANDLER_DESC),
|
.addGauge(Interns.info(NUM_ACTIVE_SCAN_HANDLER_NAME, NUM_ACTIVE_SCAN_HANDLER_DESC),
|
||||||
wrapper.getActiveScanRpcHandlerCount());
|
wrapper.getActiveScanRpcHandlerCount())
|
||||||
|
.addGauge(Interns.info(NETTY_DM_USAGE_NAME, NETTY_DM_USAGE_DESC),
|
||||||
|
wrapper.getNettyDmUsage());
|
||||||
}
|
}
|
||||||
|
|
||||||
metricsRegistry.snapshot(mrb, all);
|
metricsRegistry.snapshot(mrb, all);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.ipc;
|
package org.apache.hadoop.hbase.ipc;
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.util.DirectMemoryUtils;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
|
@ -169,4 +170,13 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
|
||||||
}
|
}
|
||||||
return server.getScheduler().getActiveScanRpcHandlerCount();
|
return server.getScheduler().getActiveScanRpcHandlerCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getNettyDmUsage() {
|
||||||
|
if (!isServerStarted() || this.server.getScheduler() == null) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DirectMemoryUtils.getNettyDirectMemoryUsage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,10 @@ import org.apache.yetus.audience.InterfaceStability;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
|
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
|
||||||
|
import org.apache.hbase.thirdparty.io.netty.buffer.ByteBufAllocatorMetric;
|
||||||
|
import org.apache.hbase.thirdparty.io.netty.buffer.ByteBufAllocatorMetricProvider;
|
||||||
|
import org.apache.hbase.thirdparty.io.netty.buffer.PooledByteBufAllocator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for interacting with and monitoring DirectByteBuffer allocations.
|
* Utilities for interacting with and monitoring DirectByteBuffer allocations.
|
||||||
|
@ -124,6 +128,16 @@ public class DirectMemoryUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current amount of direct memory used by netty module.
|
||||||
|
*/
|
||||||
|
public static long getNettyDirectMemoryUsage() {
|
||||||
|
|
||||||
|
ByteBufAllocatorMetric metric = ((ByteBufAllocatorMetricProvider)
|
||||||
|
PooledByteBufAllocator.DEFAULT).metric();
|
||||||
|
return metric.usedDirectMemory();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DirectByteBuffers are garbage collected by using a phantom reference and a
|
* DirectByteBuffers are garbage collected by using a phantom reference and a
|
||||||
* reference queue. Every once a while, the JVM checks the reference queue and
|
* reference queue. Every once a while, the JVM checks the reference queue and
|
||||||
|
|
|
@ -103,4 +103,9 @@ public class MetricsHBaseServerWrapperStub implements MetricsHBaseServerWrapper{
|
||||||
public int getActiveScanRpcHandlerCount() {
|
public int getActiveScanRpcHandlerCount() {
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getNettyDmUsage() {
|
||||||
|
return 100L;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue