Skip to content
Open
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 @@ -34,6 +34,21 @@ public interface MetricsIOSource extends BaseSource {
*/
String METRICS_CONTEXT = "regionserver";

/**
* The name of the metrics context that metrics will be under JMX context.
*/
String METRICS_JMX_CONTEXT_PREFIX = "Regionserver";

/**
* The name of the metrics context that metrics will be under JMX context
*/
String MASTER_METRICS_JMX_CONTEXT_PREFIX = "Master";

/**
* The name of the metrics context that metrics will be under.
*/
String MASTER_METRICS_CONTEXT = "master";

/**
* Description
*/
Expand All @@ -42,7 +57,9 @@ public interface MetricsIOSource extends BaseSource {
/**
* The name of the metrics context that metrics will be under in jmx
*/
String METRICS_JMX_CONTEXT = "RegionServer,sub=" + METRICS_NAME;
String METRICS_JMX_CONTEXT = METRICS_JMX_CONTEXT_PREFIX + ",sub=" + METRICS_NAME;

String MASTER_METRICS_JMX_CONTEXT = MASTER_METRICS_JMX_CONTEXT_PREFIX + ",sub=" + METRICS_NAME;


String FS_READ_TIME_HISTO_KEY = "fsReadTime";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class MetricsIOSourceImpl extends BaseSourceImpl implements MetricsIOSour
private final MetricHistogram fsPReadTimeHisto;
private final MetricHistogram fsWriteTimeHisto;

public MetricsIOSourceImpl(MetricsIOWrapper wrapper) {
this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT, wrapper);
public MetricsIOSourceImpl(MetricsIOWrapper wrapper, String context, String jmxContext) {
this(METRICS_NAME, METRICS_DESCRIPTION, context, jmxContext, wrapper);
}

public MetricsIOSourceImpl(String metricsName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public interface MetricsRegionServerSourceFactory {

/**
* Create a MetricsIOSource from a MetricsIOWrapper.
*
* @param jmxContext
* @param context
* @return A metrics IO source
*/
MetricsIOSource createIO(MetricsIOWrapper wrapper);
MetricsIOSource createIO(MetricsIOWrapper wrapper, String context, String jmxContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public MetricsTableSource createTable(String table, MetricsTableWrapperAggregate
return new MetricsTableSourceImpl(table, getTableAggregate(), wrapper);
}

public MetricsIOSource createIO(MetricsIOWrapper wrapper) {
return new MetricsIOSourceImpl(wrapper);
public MetricsIOSource createIO(MetricsIOWrapper wrapper, String context, String jmxContext) {
return new MetricsIOSourceImpl(wrapper, context, jmxContext);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class MetricsIO {
private final MetricsIOSource source;
private final MetricsIOWrapper wrapper;

public MetricsIO(MetricsIOWrapper wrapper) {
public MetricsIO(MetricsIOWrapper wrapper, String context, String jmxContext) {
this(CompatibilitySingletonFactory.getInstance(MetricsRegionServerSourceFactory.class)
.createIO(wrapper), wrapper);
.createIO(wrapper, context, jmxContext), wrapper);
}

MetricsIO(MetricsIOSource source, MetricsIOWrapper wrapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.io.hfile.ReaderContext.ReaderType;
import org.apache.hadoop.hbase.regionserver.CellSink;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.ShipperListener;
import org.apache.hadoop.hbase.util.BloomFilterWriter;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -172,9 +173,6 @@ public final class HFile {
// For tests. Gets incremented when we read a block whether from HDFS or from Cache.
public static final LongAdder DATABLOCK_READ_COUNT = new LongAdder();

/** Static instance for the metrics so that HFileReaders access the same instance */
static final MetricsIO metrics = new MetricsIO(new MetricsIOWrapperImpl());

/**
* Shutdown constructor.
*/
Expand All @@ -198,14 +196,14 @@ public static final long getChecksumFailuresCount() {

public static final void updateReadLatency(long latencyMillis, boolean pread) {
if (pread) {
metrics.updateFsPreadTime(latencyMillis);
HRegionServer.getMetricsIO().updateFsPreadTime(latencyMillis);
} else {
metrics.updateFsReadTime(latencyMillis);
HRegionServer.getMetricsIO().updateFsReadTime(latencyMillis);
}
}

public static final void updateWriteLatency(long latencyMillis) {
metrics.updateFsWriteTime(latencyMillis);
HRegionServer.getMetricsIO().updateFsWriteTime(latencyMillis);
}

/** API required to write an {@link HFile} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
import org.apache.hadoop.hbase.executor.ExecutorType;
import org.apache.hadoop.hbase.favored.FavoredNodesManager;
import org.apache.hadoop.hbase.http.InfoServer;
import org.apache.hadoop.hbase.io.MetricsIO;
import org.apache.hadoop.hbase.io.MetricsIOSource;
import org.apache.hadoop.hbase.io.MetricsIOWrapperImpl;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils;
import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
Expand Down Expand Up @@ -462,6 +465,8 @@ public void run() {
// Cached clusterId on stand by masters to serve clusterID requests from clients.
private final CachedClusterId cachedClusterId;

private static MetricsIO metricsIO;

public static class RedirectServlet extends HttpServlet {
private static final long serialVersionUID = 2894774810058302473L;
private final int regionServerInfoPort;
Expand Down Expand Up @@ -546,6 +551,9 @@ public HMaster(final Configuration conf) throws IOException {
}

this.metricsMaster = new MetricsMaster(new MetricsMasterWrapperImpl(this));
// init it here.
metricsIO = new MetricsIO(new MetricsIOWrapperImpl(), MetricsIOSource.MASTER_METRICS_CONTEXT,
MetricsIOSource.MASTER_METRICS_JMX_CONTEXT_PREFIX);

// preload table descriptor at startup
this.preLoadTableDescriptors = conf.getBoolean("hbase.master.preload.tabledescriptors", true);
Expand Down Expand Up @@ -1319,6 +1327,10 @@ private void initMobCleaner() {
getChoreService().scheduleChore(mobFileCompactionChore);
}

public MetricsIO getMetricsMaster() {
return metricsIO;
}

/**
* <p>
* Create a {@link ServerManager} instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
import org.apache.hadoop.hbase.executor.ExecutorType;
import org.apache.hadoop.hbase.fs.HFileSystem;
import org.apache.hadoop.hbase.http.InfoServer;
import org.apache.hadoop.hbase.io.MetricsIO;
import org.apache.hadoop.hbase.io.MetricsIOSource;
import org.apache.hadoop.hbase.io.MetricsIOWrapperImpl;
import org.apache.hadoop.hbase.io.hfile.BlockCache;
import org.apache.hadoop.hbase.io.hfile.BlockCacheFactory;
import org.apache.hadoop.hbase.io.hfile.HFile;
Expand Down Expand Up @@ -390,6 +393,7 @@ public class HRegionServer extends Thread implements

private MetricsRegionServer metricsRegionServer;
MetricsRegionServerWrapperImpl metricsRegionServerImpl;
private static MetricsIO metricsIO;
private SpanReceiverHost spanReceiverHost;

/**
Expand Down Expand Up @@ -1597,6 +1601,9 @@ protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
this.metricsRegionServerImpl = new MetricsRegionServerWrapperImpl(this);
this.metricsRegionServer = new MetricsRegionServer(
metricsRegionServerImpl, conf, metricsTable);
// init it here.
metricsIO = new MetricsIO(new MetricsIOWrapperImpl(), MetricsIOSource.METRICS_CONTEXT,
MetricsIOSource.METRICS_JMX_CONTEXT_PREFIX);
// Now that we have a metrics source, start the pause monitor
this.pauseMonitor = new JvmPauseMonitor(conf, getMetrics().getMetricsSource());
pauseMonitor.start();
Expand Down Expand Up @@ -3732,6 +3739,10 @@ public MetricsRegionServer getMetrics() {
return metricsRegionServer;
}

public static MetricsIO getMetricsIO() {
return metricsIO;
}

@Override
public SecureBulkLoadManager getSecureBulkLoadManager() {
return this.secureBulkLoadManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testMetrics() {
MetricsIO metrics = new MetricsIO(new MetricsIOWrapper() {
@Override
public long getChecksumFailures() { return 40; }
});
}, "regionserver","regionserver");

metrics.updateFsReadTime(100);
metrics.updateFsReadTime(200);
Expand Down