HBASE-14778 Make block cache hit percentages not integer in the metrics system
This commit is contained in:
parent
3de347f6e0
commit
e8e0e86b49
|
@ -151,12 +151,12 @@ public interface MetricsRegionServerWrapper {
|
|||
/**
|
||||
* Get the percent of HFiles' that are local.
|
||||
*/
|
||||
int getPercentFileLocal();
|
||||
double getPercentFileLocal();
|
||||
|
||||
/**
|
||||
* Get the percent of HFiles' that are local for secondary region replicas.
|
||||
*/
|
||||
int getPercentFileLocalSecondaryRegions();
|
||||
double getPercentFileLocalSecondaryRegions();
|
||||
|
||||
/**
|
||||
* Get the size of the split queue
|
||||
|
@ -231,7 +231,7 @@ public interface MetricsRegionServerWrapper {
|
|||
/**
|
||||
* Get the percent of requests with the block cache turned on that hit the block cache.
|
||||
*/
|
||||
int getBlockCacheHitCachingPercent();
|
||||
double getBlockCacheHitCachingPercent();
|
||||
|
||||
/**
|
||||
* Force a re-computation of the metrics.
|
||||
|
@ -276,5 +276,5 @@ public interface MetricsRegionServerWrapper {
|
|||
/**
|
||||
* @return Count of requests blocked because the memstore size is larger than blockingMemStoreSize
|
||||
*/
|
||||
public long getBlockedRequestsCount();
|
||||
long getBlockedRequestsCount();
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ class MetricsRegionServerWrapperImpl
|
|||
private volatile long totalStaticBloomSize = 0;
|
||||
private volatile long numMutationsWithoutWAL = 0;
|
||||
private volatile long dataInMemoryWithoutWAL = 0;
|
||||
private volatile int percentFileLocal = 0;
|
||||
private volatile int percentFileLocalSecondaryRegions = 0;
|
||||
private volatile double percentFileLocal = 0;
|
||||
private volatile double percentFileLocalSecondaryRegions = 0;
|
||||
private volatile long flushedCellsCount = 0;
|
||||
private volatile long compactedCellsCount = 0;
|
||||
private volatile long majorCompactedCellsCount = 0;
|
||||
|
@ -289,15 +289,25 @@ class MetricsRegionServerWrapperImpl
|
|||
if (this.cacheStats == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (this.cacheStats.getHitRatio() * 100);
|
||||
double ratio = this.cacheStats.getHitRatio();
|
||||
if (Double.isNaN(ratio)) {
|
||||
ratio = 0;
|
||||
}
|
||||
return (ratio * 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockCacheHitCachingPercent() {
|
||||
public double getBlockCacheHitCachingPercent() {
|
||||
if (this.cacheStats == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (this.cacheStats.getHitCachingRatio() * 100);
|
||||
|
||||
double ratio = this.cacheStats.getHitCachingRatio();
|
||||
|
||||
if (Double.isNaN(ratio)) {
|
||||
ratio = 0;
|
||||
}
|
||||
return (ratio * 100);
|
||||
}
|
||||
|
||||
@Override public void forceRecompute() {
|
||||
|
@ -384,12 +394,12 @@ class MetricsRegionServerWrapperImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getPercentFileLocal() {
|
||||
public double getPercentFileLocal() {
|
||||
return percentFileLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPercentFileLocalSecondaryRegions() {
|
||||
public double getPercentFileLocalSecondaryRegions() {
|
||||
return percentFileLocalSecondaryRegions;
|
||||
}
|
||||
|
||||
|
@ -464,8 +474,8 @@ class MetricsRegionServerWrapperImpl
|
|||
long tempTotalStaticBloomSize = 0;
|
||||
long tempNumMutationsWithoutWAL = 0;
|
||||
long tempDataInMemoryWithoutWAL = 0;
|
||||
int tempPercentFileLocal = 0;
|
||||
int tempPercentFileLocalSecondaryRegions = 0;
|
||||
double tempPercentFileLocal = 0;
|
||||
double tempPercentFileLocalSecondaryRegions = 0;
|
||||
long tempFlushedCellsCount = 0;
|
||||
long tempCompactedCellsCount = 0;
|
||||
long tempMajorCompactedCellsCount = 0;
|
||||
|
@ -508,13 +518,14 @@ class MetricsRegionServerWrapperImpl
|
|||
|
||||
float localityIndex = hdfsBlocksDistribution.getBlockLocalityIndex(
|
||||
regionServer.getServerName().getHostname());
|
||||
tempPercentFileLocal = (int) (localityIndex * 100);
|
||||
tempPercentFileLocal = Double.isNaN(tempBlockedRequestsCount) ? 0 : (localityIndex * 100);
|
||||
|
||||
float localityIndexSecondaryRegions = hdfsBlocksDistributionSecondaryRegions
|
||||
.getBlockLocalityIndex(regionServer.getServerName().getHostname());
|
||||
tempPercentFileLocalSecondaryRegions = (int) (localityIndexSecondaryRegions * 100);
|
||||
tempPercentFileLocalSecondaryRegions =
|
||||
Double.isNaN(localityIndexSecondaryRegions) ? 0 : (localityIndexSecondaryRegions * 100);
|
||||
|
||||
//Compute the number of requests per second
|
||||
// Compute the number of requests per second
|
||||
long currentTime = EnvironmentEdgeManager.currentTime();
|
||||
|
||||
// assume that it took PERIOD seconds to start the executor.
|
||||
|
@ -523,7 +534,6 @@ class MetricsRegionServerWrapperImpl
|
|||
lastRan = currentTime - period;
|
||||
}
|
||||
|
||||
|
||||
//If we've time traveled keep the last requests per second.
|
||||
if ((currentTime - lastRan) > 0) {
|
||||
long currentRequestCount = getTotalRequestCount();
|
||||
|
@ -539,7 +549,7 @@ class MetricsRegionServerWrapperImpl
|
|||
(metaProvider == null ? 0 : metaProvider.getNumLogFiles());
|
||||
walFileSize = (provider == null ? 0 : provider.getLogFileSize()) +
|
||||
(provider == null ? 0 : provider.getLogFileSize());
|
||||
//Copy over computed values so that no thread sees half computed values.
|
||||
// Copy over computed values so that no thread sees half computed values.
|
||||
numStores = tempNumStores;
|
||||
numStoreFiles = tempNumStoreFiles;
|
||||
memstoreSize = tempMemstoreSize;
|
||||
|
|
|
@ -126,12 +126,12 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getPercentFileLocal() {
|
||||
public double getPercentFileLocal() {
|
||||
return 99;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPercentFileLocalSecondaryRegions() {
|
||||
public double getPercentFileLocalSecondaryRegions() {
|
||||
return 99;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getBlockCacheHitCachingPercent() {
|
||||
public double getBlockCacheHitCachingPercent() {
|
||||
return 97;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue