HBASE-16661 Add last major compaction age to per-region metrics
Signed-off-by: Gary Helmling <garyh@apache.org>
This commit is contained in:
parent
66038b8c1a
commit
59ca4dad70
|
@ -29,10 +29,12 @@ public interface MetricsRegionSource extends Comparable<MetricsRegionSource> {
|
||||||
String SIZE_VALUE_NAME = "size";
|
String SIZE_VALUE_NAME = "size";
|
||||||
String COMPACTIONS_COMPLETED_COUNT = "compactionsCompletedCount";
|
String COMPACTIONS_COMPLETED_COUNT = "compactionsCompletedCount";
|
||||||
String COMPACTIONS_FAILED_COUNT = "compactionsFailedCount";
|
String COMPACTIONS_FAILED_COUNT = "compactionsFailedCount";
|
||||||
|
String LAST_MAJOR_COMPACTION_AGE = "lastMajorCompactionAge";
|
||||||
String NUM_BYTES_COMPACTED_COUNT = "numBytesCompactedCount";
|
String NUM_BYTES_COMPACTED_COUNT = "numBytesCompactedCount";
|
||||||
String NUM_FILES_COMPACTED_COUNT = "numFilesCompactedCount";
|
String NUM_FILES_COMPACTED_COUNT = "numFilesCompactedCount";
|
||||||
String COMPACTIONS_COMPLETED_DESC = "Number of compactions that have completed.";
|
String COMPACTIONS_COMPLETED_DESC = "Number of compactions that have completed.";
|
||||||
String COMPACTIONS_FAILED_DESC = "Number of compactions that have failed.";
|
String COMPACTIONS_FAILED_DESC = "Number of compactions that have failed.";
|
||||||
|
String LAST_MAJOR_COMPACTION_DESC = "Age of the last major compaction in milliseconds.";
|
||||||
String NUM_BYTES_COMPACTED_DESC =
|
String NUM_BYTES_COMPACTED_DESC =
|
||||||
"Sum of filesize on all files entering a finished, successful or aborted, compaction";
|
"Sum of filesize on all files entering a finished, successful or aborted, compaction";
|
||||||
String NUM_FILES_COMPACTED_DESC =
|
String NUM_FILES_COMPACTED_DESC =
|
||||||
|
|
|
@ -100,6 +100,11 @@ public interface MetricsRegionWrapper {
|
||||||
|
|
||||||
long getNumCompactionsCompleted();
|
long getNumCompactionsCompleted();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Age of the last major compaction
|
||||||
|
*/
|
||||||
|
long getLastMajorCompactionAge();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total number of compactions that have been reported as failed on this region.
|
* Returns the total number of compactions that have been reported as failed on this region.
|
||||||
* Note that a given compaction can be reported as both completed and failed if an exception
|
* Note that a given compaction can be reported as both completed and failed if an exception
|
||||||
|
|
|
@ -268,6 +268,10 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
||||||
regionNamePrefix + MetricsRegionSource.COMPACTIONS_FAILED_COUNT,
|
regionNamePrefix + MetricsRegionSource.COMPACTIONS_FAILED_COUNT,
|
||||||
MetricsRegionSource.COMPACTIONS_FAILED_DESC),
|
MetricsRegionSource.COMPACTIONS_FAILED_DESC),
|
||||||
this.regionWrapper.getNumCompactionsFailed());
|
this.regionWrapper.getNumCompactionsFailed());
|
||||||
|
mrb.addCounter(Interns.info(
|
||||||
|
regionNamePrefix + MetricsRegionSource.LAST_MAJOR_COMPACTION_AGE,
|
||||||
|
MetricsRegionSource.LAST_MAJOR_COMPACTION_DESC),
|
||||||
|
this.regionWrapper.getLastMajorCompactionAge());
|
||||||
mrb.addCounter(Interns.info(
|
mrb.addCounter(Interns.info(
|
||||||
regionNamePrefix + MetricsRegionSource.NUM_BYTES_COMPACTED_COUNT,
|
regionNamePrefix + MetricsRegionSource.NUM_BYTES_COMPACTED_COUNT,
|
||||||
MetricsRegionSource.NUM_BYTES_COMPACTED_DESC),
|
MetricsRegionSource.NUM_BYTES_COMPACTED_DESC),
|
||||||
|
|
|
@ -143,6 +143,11 @@ public class TestMetricsRegionSourceImpl {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLastMajorCompactionAge() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getNumCompactionsCompleted() {
|
public long getNumCompactionsCompleted() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1663,7 +1663,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getOldestHfileTs(boolean majorCompactioOnly) throws IOException {
|
public long getOldestHfileTs(boolean majorCompactionOnly) throws IOException {
|
||||||
long result = Long.MAX_VALUE;
|
long result = Long.MAX_VALUE;
|
||||||
for (Store store : getStores()) {
|
for (Store store : getStores()) {
|
||||||
Collection<StoreFile> storeFiles = store.getStorefiles();
|
Collection<StoreFile> storeFiles = store.getStorefiles();
|
||||||
|
@ -1673,12 +1673,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
if (sfReader == null) continue;
|
if (sfReader == null) continue;
|
||||||
HFile.Reader reader = sfReader.getHFileReader();
|
HFile.Reader reader = sfReader.getHFileReader();
|
||||||
if (reader == null) continue;
|
if (reader == null) continue;
|
||||||
if (majorCompactioOnly) {
|
if (majorCompactionOnly) {
|
||||||
byte[] val = reader.loadFileInfo().get(StoreFile.MAJOR_COMPACTION_KEY);
|
byte[] val = reader.loadFileInfo().get(StoreFile.MAJOR_COMPACTION_KEY);
|
||||||
if (val == null) continue;
|
if (val == null || !Bytes.toBoolean(val)) continue;
|
||||||
if (val == null || !Bytes.toBoolean(val)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result = Math.min(result, reader.getFileContext().getFileCreateTime());
|
result = Math.min(result, reader.getFileContext().getFileCreateTime());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,15 +25,20 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
|
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||||
import org.apache.hadoop.metrics2.MetricsExecutor;
|
import org.apache.hadoop.metrics2.MetricsExecutor;
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable {
|
public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable {
|
||||||
|
|
||||||
|
private static final Log LOG = LogFactory.getLog(MetricsRegionWrapperImpl.class);
|
||||||
|
|
||||||
public static final int PERIOD = 45;
|
public static final int PERIOD = 45;
|
||||||
public static final String UNKNOWN = "unknown";
|
public static final String UNKNOWN = "unknown";
|
||||||
|
|
||||||
|
@ -135,6 +140,18 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
return this.region.compactionsFinished.get();
|
return this.region.compactionsFinished.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLastMajorCompactionAge() {
|
||||||
|
long lastMajorCompactionTs = 0L;
|
||||||
|
try {
|
||||||
|
lastMajorCompactionTs = this.region.getOldestHfileTs(true);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
LOG.error("Could not load HFile info ", ioe);
|
||||||
|
}
|
||||||
|
long now = EnvironmentEdgeManager.currentTime();
|
||||||
|
return now - lastMajorCompactionTs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getNumCompactionsFailed() {
|
public long getNumCompactionsFailed() {
|
||||||
return this.region.compactionsFailed.get();
|
return this.region.compactionsFailed.get();
|
||||||
|
|
|
@ -141,10 +141,10 @@ public interface Region extends ConfigurationObserver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can be used to determine the last time all files of this region were major compacted.
|
* This can be used to determine the last time all files of this region were major compacted.
|
||||||
* @param majorCompactioOnly Only consider HFile that are the result of major compaction
|
* @param majorCompactionOnly Only consider HFile that are the result of major compaction
|
||||||
* @return the timestamp of the oldest HFile for all stores of this region
|
* @return the timestamp of the oldest HFile for all stores of this region
|
||||||
*/
|
*/
|
||||||
long getOldestHfileTs(boolean majorCompactioOnly) throws IOException;
|
long getOldestHfileTs(boolean majorCompactionOnly) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return map of column family names to max sequence id that was read from storage when this
|
* @return map of column family names to max sequence id that was read from storage when this
|
||||||
|
|
|
@ -115,6 +115,11 @@ public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLastMajorCompactionAge() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getNumCompactionsFailed() {
|
public long getNumCompactionsFailed() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue