org.apache.hadoop.hbase.HConstants#FOREVER源码实例Demo

下面列出了org.apache.hadoop.hbase.HConstants#FOREVER 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: MajorCompactorTTL.java
private boolean doesAnyColFamilyHaveTTL(TableDescriptor htd) {
  for (ColumnFamilyDescriptor descriptor : htd.getColumnFamilies()) {
    if (descriptor.getTimeToLive() != HConstants.FOREVER) {
      return true;
    }
  }
  return false;
}
 
源代码2 项目: hbase   文件: HStore.java
/**
 * @return TTL in seconds of the specified family
 */
public static long determineTTLFromFamily(final ColumnFamilyDescriptor family) {
  // HCD.getTimeToLive returns ttl in seconds.  Convert to milliseconds.
  long ttl = family.getTimeToLive();
  if (ttl == HConstants.FOREVER) {
    // Default is unlimited ttl.
    ttl = Long.MAX_VALUE;
  } else if (ttl == -1) {
    ttl = Long.MAX_VALUE;
  } else {
    // Second -> ms adjust for user data
    ttl *= 1000;
  }
  return ttl;
}
 
源代码3 项目: hbase   文件: TestRegionCoprocessorHost.java
private ScanInfo getScanInfo() {
  int oldMaxVersions = 1;
  int oldMinVersions = 0;
  long oldTTL = 10000;

  return new ScanInfo(conf, Bytes.toBytes("cf"), oldMinVersions, oldMaxVersions, oldTTL,
  KeepDeletedCells.FALSE, HConstants.FOREVER, 1000,
    CellComparator.getInstance(), true);
}
 
源代码4 项目: hbase   文件: PrettyPrinter.java
/**
 * Convert a human readable time interval to seconds. Examples of the human readable
 * time intervals are: 50 DAYS 1 HOUR 30 MINUTES , 25000 SECONDS etc.
 * The units of time specified can be in uppercase as well as lowercase. Also, if a
 * single number is specified without any time unit, it is assumed to be in seconds.
 * @param humanReadableInterval
 * @return value in seconds
 */
private static long humanReadableIntervalToSec(final String humanReadableInterval)
        throws HBaseException {
  if (humanReadableInterval == null || humanReadableInterval.equalsIgnoreCase("FOREVER")) {
    return HConstants.FOREVER;
  }

  try {
    return Long.parseLong(humanReadableInterval);
  } catch(NumberFormatException ex) {
    LOG.debug("Given interval value is not a number, parsing for human readable format");
  }

  String days = null;
  String hours = null;
  String minutes = null;
  String seconds = null;
  String expectedTtl = null;
  long ttl;

  Matcher matcher = PrettyPrinter.INTERVAL_PATTERN.matcher(humanReadableInterval);
  if (matcher.matches()) {
    expectedTtl = matcher.group(2);
    days = matcher.group(4);
    hours = matcher.group(6);
    minutes = matcher.group(8);
    seconds = matcher.group(10);
  }
  ttl = 0;
  ttl += days != null ? Long.parseLong(days)*HConstants.DAY_IN_SECONDS:0;
  ttl += hours != null ? Long.parseLong(hours)*HConstants.HOUR_IN_SECONDS:0;
  ttl += minutes != null ? Long.parseLong(minutes)*HConstants.MINUTE_IN_SECONDS:0;
  ttl += seconds != null ? Long.parseLong(seconds):0;

  if (expectedTtl != null && Long.parseLong(expectedTtl) != ttl) {
    throw new HBaseException("Malformed TTL string: TTL values in seconds and human readable" +
            "format do not match");
  }
  return ttl;
}
 
源代码5 项目: hbase   文件: MajorCompactionTTLRequest.java
private long getColFamilyCutoffTime(ColumnFamilyDescriptor colDesc) {
  if (colDesc.getTimeToLive() == HConstants.FOREVER) {
    return -1;
  }
  return System.currentTimeMillis() - (colDesc.getTimeToLive() * 1000L);
}
 
源代码6 项目: hbase   文件: RatioBasedCompactionPolicy.java
@Override
public boolean shouldPerformMajorCompaction(Collection<HStoreFile> filesToCompact)
  throws IOException {
  boolean result = false;
  long mcTime = getNextMajorCompactTime(filesToCompact);
  if (filesToCompact == null || filesToCompact.isEmpty() || mcTime == 0) {
    return result;
  }
  // TODO: Use better method for determining stamp of last major (HBASE-2990)
  long lowTimestamp = StoreUtils.getLowestTimestamp(filesToCompact);
  long now = EnvironmentEdgeManager.currentTime();
  if (lowTimestamp > 0L && lowTimestamp < (now - mcTime)) {
    String regionInfo;
    if (this.storeConfigInfo != null && this.storeConfigInfo instanceof HStore) {
      regionInfo = ((HStore)this.storeConfigInfo).getRegionInfo().getRegionNameAsString();
    } else {
      regionInfo = this.toString();
    }
    // Major compaction time has elapsed.
    long cfTTL = HConstants.FOREVER;
    if (this.storeConfigInfo != null) {
       cfTTL = this.storeConfigInfo.getStoreFileTtl();
    }
    if (filesToCompact.size() == 1) {
      // Single file
      HStoreFile sf = filesToCompact.iterator().next();
      OptionalLong minTimestamp = sf.getMinimumTimestamp();
      long oldest = minTimestamp.isPresent() ? now - minTimestamp.getAsLong() : Long.MIN_VALUE;
      if (sf.isMajorCompactionResult() && (cfTTL == Long.MAX_VALUE || oldest < cfTTL)) {
        float blockLocalityIndex =
          sf.getHDFSBlockDistribution().getBlockLocalityIndex(
          DNS.getHostname(comConf.conf, DNS.ServerType.REGIONSERVER));
        if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
          LOG.debug("Major compaction triggered on only store " + regionInfo
            + "; to make hdfs blocks local, current blockLocalityIndex is "
            + blockLocalityIndex + " (min " + comConf.getMinLocalityToForceCompact() + ")");
          result = true;
        } else {
          LOG.debug("Skipping major compaction of " + regionInfo
            + " because one (major) compacted file only, oldestTime " + oldest
            + "ms is < TTL=" + cfTTL + " and blockLocalityIndex is " + blockLocalityIndex
            + " (min " + comConf.getMinLocalityToForceCompact() + ")");
        }
      } else if (cfTTL != HConstants.FOREVER && oldest > cfTTL) {
        LOG.debug("Major compaction triggered on store " + regionInfo
          + ", because keyvalues outdated; time since last major compaction "
          + (now - lowTimestamp) + "ms");
        result = true;
      }
    } else {
      LOG.debug("Major compaction triggered on store " + regionInfo
        + "; time since last major compaction " + (now - lowTimestamp) + "ms");
      result = true;
    }
  }
  return result;
}
 
源代码7 项目: phoenix   文件: IndexRebuildRegionScanner.java
private boolean isTimestampBeforeTTL(long currentTime, long tsToCheck) {
    if (indexTableTTL == HConstants.FOREVER) {
        return false;
    }
    return tsToCheck < (currentTime - (long) indexTableTTL * 1000);
}
 
源代码8 项目: phoenix   文件: GlobalIndexRegionScanner.java
protected static boolean isTimestampBeforeTTL(long tableTTL, long currentTime, long tsToCheck) {
    if (tableTTL == HConstants.FOREVER) {
        return false;
    }
    return tsToCheck < (currentTime - tableTTL * 1000);
}