HBASE-15664 Use Long.MAX_VALUE instead of HConstants.FOREVER in CompactionPolicy

This commit is contained in:
zhangduo 2016-04-18 11:46:34 +08:00
parent a56b374c52
commit f2e0aca2b6
2 changed files with 3 additions and 4 deletions

View File

@ -36,7 +36,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HDFSBlocksDistribution; import org.apache.hadoop.hbase.HDFSBlocksDistribution;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.regionserver.RSRpcServices;
@ -118,8 +117,8 @@ public class DateTieredCompactionPolicy extends SortedCompactionPolicy {
for (StoreFile file: filesToCompact) { for (StoreFile file: filesToCompact) {
Long minTimestamp = file.getMinimumTimestamp(); Long minTimestamp = file.getMinimumTimestamp();
long oldest = (minTimestamp == null) ? (Long)Long.MIN_VALUE : now - minTimestamp.longValue(); long oldest = (minTimestamp == null) ? Long.MIN_VALUE : now - minTimestamp.longValue();
if (cfTTL != HConstants.FOREVER && oldest >= cfTTL) { if (cfTTL != Long.MAX_VALUE && oldest >= cfTTL) {
LOG.debug("Major compaction triggered on store " + this LOG.debug("Major compaction triggered on store " + this
+ "; for TTL maintenance"); + "; for TTL maintenance");
return true; return true;

View File

@ -70,7 +70,7 @@ public class RatioBasedCompactionPolicy extends SortedCompactionPolicy {
StoreFile sf = filesToCompact.iterator().next(); StoreFile sf = filesToCompact.iterator().next();
Long minTimestamp = sf.getMinimumTimestamp(); Long minTimestamp = sf.getMinimumTimestamp();
long oldest = (minTimestamp == null) ? Long.MIN_VALUE : now - minTimestamp.longValue(); long oldest = (minTimestamp == null) ? Long.MIN_VALUE : now - minTimestamp.longValue();
if (sf.isMajorCompaction() && (cfTTL == HConstants.FOREVER || oldest < cfTTL)) { if (sf.isMajorCompaction() && (cfTTL == Long.MAX_VALUE || oldest < cfTTL)) {
float blockLocalityIndex = float blockLocalityIndex =
sf.getHDFSBlockDistribution().getBlockLocalityIndex( sf.getHDFSBlockDistribution().getBlockLocalityIndex(
RSRpcServices.getHostname(comConf.conf, false)); RSRpcServices.getHostname(comConf.conf, false));