HBASE-13213 Split out locality metrics among primary and secondary region
This commit is contained in:
parent
af1715933e
commit
f1601c0d12
|
@ -180,6 +180,9 @@ public interface MetricsRegionServerSource extends BaseSource {
|
|||
String PERCENT_FILES_LOCAL = "percentFilesLocal";
|
||||
String PERCENT_FILES_LOCAL_DESC =
|
||||
"The percent of HFiles that are stored on the local hdfs data node.";
|
||||
String PERCENT_FILES_LOCAL_SECONDARY_REGIONS = "percentFilesLocalSecondaryRegions";
|
||||
String PERCENT_FILES_LOCAL_SECONDARY_REGIONS_DESC =
|
||||
"The percent of HFiles used by secondary regions that are stored on the local hdfs data node.";
|
||||
String SPLIT_QUEUE_LENGTH = "splitQueueLength";
|
||||
String SPLIT_QUEUE_LENGTH_DESC = "Length of the queue for splits.";
|
||||
String COMPACTION_QUEUE_LENGTH = "compactionQueueLength";
|
||||
|
|
|
@ -153,6 +153,11 @@ public interface MetricsRegionServerWrapper {
|
|||
*/
|
||||
int getPercentFileLocal();
|
||||
|
||||
/**
|
||||
* Get the percent of HFiles' that are local for secondary region replicas.
|
||||
*/
|
||||
int getPercentFileLocalSecondaryRegions();
|
||||
|
||||
/**
|
||||
* Get the size of the split queue
|
||||
*/
|
||||
|
|
|
@ -76,7 +76,7 @@ public class MetricsRegionServerSourceImpl
|
|||
slowGet = getMetricsRegistry().newCounter(SLOW_GET_KEY, SLOW_GET_DESC, 0l);
|
||||
|
||||
incrementHisto = getMetricsRegistry().newHistogram(INCREMENT_KEY);
|
||||
slowIncrement = getMetricsRegistry().newCounter(SLOW_INCREMENT_KEY, SLOW_INCREMENT_DESC, 0l);
|
||||
slowIncrement = getMetricsRegistry().newCounter(SLOW_INCREMENT_KEY, SLOW_INCREMENT_DESC, 0L);
|
||||
|
||||
appendHisto = getMetricsRegistry().newHistogram(APPEND_KEY);
|
||||
slowAppend = getMetricsRegistry().newCounter(SLOW_APPEND_KEY, SLOW_APPEND_DESC, 0l);
|
||||
|
@ -212,6 +212,9 @@ public class MetricsRegionServerSourceImpl
|
|||
rsWrap.getDataInMemoryWithoutWAL())
|
||||
.addGauge(Interns.info(PERCENT_FILES_LOCAL, PERCENT_FILES_LOCAL_DESC),
|
||||
rsWrap.getPercentFileLocal())
|
||||
.addGauge(Interns.info(PERCENT_FILES_LOCAL_SECONDARY_REGIONS,
|
||||
PERCENT_FILES_LOCAL_SECONDARY_REGIONS_DESC),
|
||||
rsWrap.getPercentFileLocalSecondaryRegions())
|
||||
.addGauge(Interns.info(SPLIT_QUEUE_LENGTH, SPLIT_QUEUE_LENGTH_DESC),
|
||||
rsWrap.getSplitQueueSize())
|
||||
.addGauge(Interns.info(COMPACTION_QUEUE_LENGTH, COMPACTION_QUEUE_LENGTH_DESC),
|
||||
|
|
|
@ -76,12 +76,14 @@ java.lang.management.ManagementFactory;
|
|||
<th>Requests Per Second</th>
|
||||
<th>Num. Regions</th>
|
||||
<th>Block locality</th>
|
||||
<th>Block locality (Secondary replicas)</th>
|
||||
<th>Slow WAL Append Count</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><% String.format("%.0f", mWrap.getRequestsPerSecond()) %></td>
|
||||
<td><% mWrap.getNumOnlineRegions() %></td>
|
||||
<td><% mWrap.getPercentFileLocal() %></td>
|
||||
<td><% mWrap.getPercentFileLocalSecondaryRegions() %></td>
|
||||
<td><% 0 %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.io.hfile.BlockCache;
|
||||
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
|
||||
|
@ -68,6 +69,7 @@ class MetricsRegionServerWrapperImpl
|
|||
private volatile long numMutationsWithoutWAL = 0;
|
||||
private volatile long dataInMemoryWithoutWAL = 0;
|
||||
private volatile int percentFileLocal = 0;
|
||||
private volatile int percentFileLocalSecondaryRegions = 0;
|
||||
private volatile long flushedCellsCount = 0;
|
||||
private volatile long compactedCellsCount = 0;
|
||||
private volatile long majorCompactedCellsCount = 0;
|
||||
|
@ -362,6 +364,11 @@ class MetricsRegionServerWrapperImpl
|
|||
return percentFileLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPercentFileLocalSecondaryRegions() {
|
||||
return percentFileLocalSecondaryRegions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUpdatesBlockedTime() {
|
||||
if (this.regionServer.cacheFlusher == null) {
|
||||
|
@ -417,6 +424,8 @@ class MetricsRegionServerWrapperImpl
|
|||
|
||||
HDFSBlocksDistribution hdfsBlocksDistribution =
|
||||
new HDFSBlocksDistribution();
|
||||
HDFSBlocksDistribution hdfsBlocksDistributionSecondaryRegions =
|
||||
new HDFSBlocksDistribution();
|
||||
|
||||
long tempNumStores = 0;
|
||||
long tempNumStoreFiles = 0;
|
||||
|
@ -432,6 +441,7 @@ class MetricsRegionServerWrapperImpl
|
|||
long tempNumMutationsWithoutWAL = 0;
|
||||
long tempDataInMemoryWithoutWAL = 0;
|
||||
int tempPercentFileLocal = 0;
|
||||
int tempPercentFileLocalSecondaryRegions = 0;
|
||||
long tempFlushedCellsCount = 0;
|
||||
long tempCompactedCellsCount = 0;
|
||||
long tempMajorCompactedCellsCount = 0;
|
||||
|
@ -465,13 +475,20 @@ class MetricsRegionServerWrapperImpl
|
|||
tempMajorCompactedCellsSize += store.getMajorCompactedCellsSize();
|
||||
}
|
||||
|
||||
hdfsBlocksDistribution.add(r.getHDFSBlocksDistribution());
|
||||
HDFSBlocksDistribution distro = r.getHDFSBlocksDistribution();
|
||||
hdfsBlocksDistribution.add(distro);
|
||||
if (r.getRegionInfo().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {
|
||||
hdfsBlocksDistributionSecondaryRegions.add(distro);
|
||||
}
|
||||
}
|
||||
|
||||
float localityIndex = hdfsBlocksDistribution.getBlockLocalityIndex(
|
||||
regionServer.getServerName().getHostname());
|
||||
tempPercentFileLocal = (int) (localityIndex * 100);
|
||||
|
||||
float localityIndexSecondaryRegions = hdfsBlocksDistributionSecondaryRegions
|
||||
.getBlockLocalityIndex(regionServer.getServerName().getHostname());
|
||||
tempPercentFileLocalSecondaryRegions = (int) (localityIndexSecondaryRegions * 100);
|
||||
|
||||
//Compute the number of requests per second
|
||||
long currentTime = EnvironmentEdgeManager.currentTime();
|
||||
|
@ -509,6 +526,7 @@ class MetricsRegionServerWrapperImpl
|
|||
numMutationsWithoutWAL = tempNumMutationsWithoutWAL;
|
||||
dataInMemoryWithoutWAL = tempDataInMemoryWithoutWAL;
|
||||
percentFileLocal = tempPercentFileLocal;
|
||||
percentFileLocalSecondaryRegions = tempPercentFileLocalSecondaryRegions;
|
||||
flushedCellsCount = tempFlushedCellsCount;
|
||||
compactedCellsCount = tempCompactedCellsCount;
|
||||
majorCompactedCellsCount = tempMajorCompactedCellsCount;
|
||||
|
|
|
@ -130,6 +130,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
|
|||
return 99;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPercentFileLocalSecondaryRegions() {
|
||||
return 99;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompactionQueueSize() {
|
||||
return 411;
|
||||
|
|
|
@ -75,6 +75,7 @@ public class TestMetricsRegionServer {
|
|||
HELPER.assertGauge("mutationsWithoutWALCount", 409, serverSource);
|
||||
HELPER.assertGauge("mutationsWithoutWALSize", 410, serverSource);
|
||||
HELPER.assertGauge("percentFilesLocal", 99, serverSource);
|
||||
HELPER.assertGauge("percentFilesLocalSecondaryRegions", 99, serverSource);
|
||||
HELPER.assertGauge("compactionQueueLength", 411, serverSource);
|
||||
HELPER.assertGauge("flushQueueLength", 412, serverSource);
|
||||
HELPER.assertGauge("blockCacheFreeSize", 413, serverSource);
|
||||
|
|
|
@ -96,6 +96,7 @@ public class TestRegionServerMetrics {
|
|||
@Test
|
||||
public void testLocalFiles() throws Exception {
|
||||
metricsHelper.assertGauge("percentFilesLocal", 0, serverSource);
|
||||
metricsHelper.assertGauge("percentFilesLocalSecondaryRegions", 0, serverSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue