當前位置: 首頁>>代碼示例>>Java>>正文


Java HConstants.FOREVER屬性代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HConstants.FOREVER屬性的典型用法代碼示例。如果您正苦於以下問題:Java HConstants.FOREVER屬性的具體用法?Java HConstants.FOREVER怎麽用?Java HConstants.FOREVER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.hadoop.hbase.HConstants的用法示例。


在下文中一共展示了HConstants.FOREVER屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: determineTTLFromFamily

/**
 * @param family
 * @return TTL in seconds of the specified family
 */
private static long determineTTLFromFamily(final HColumnDescriptor 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;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:18,代碼來源:HStore.java

示例2: isMajorCompaction

@Override
public boolean isMajorCompaction(final Collection<StoreFile> 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 = System.currentTimeMillis();
  if (lowTimestamp > 0l && lowTimestamp < (now - mcTime)) {
    // Major compaction time has elapsed.
    long cfTtl = this.storeConfigInfo.getStoreFileTtl();
    if (filesToCompact.size() == 1) {
      // Single file
      StoreFile sf = filesToCompact.iterator().next();
      Long minTimestamp = sf.getMinimumTimestamp();
      long oldest = (minTimestamp == null)
          ? Long.MIN_VALUE
          : now - minTimestamp.longValue();
      if (sf.isMajorCompaction() &&
          (cfTtl == HConstants.FOREVER || oldest < cfTtl)) {
        float blockLocalityIndex = sf.getHDFSBlockDistribution().getBlockLocalityIndex(
            RSRpcServices.getHostname(comConf.conf, false)
        );
        if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Major compaction triggered on only store " + this +
                "; to make hdfs blocks local, current blockLocalityIndex is " +
                blockLocalityIndex + " (min " + comConf.getMinLocalityToForceCompact() +
                ")");
          }
          result = true;
        } else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Skipping major compaction of " + this +
                " 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 " + this +
          ", because keyvalues outdated; time since last major compaction " +
          (now - lowTimestamp) + "ms");
        result = true;
      }
    } else {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Major compaction triggered on store " + this +
            "; time since last major compaction " + (now - lowTimestamp) + "ms");
      }
      result = true;
    }
  }
  return result;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:59,代碼來源:RatioBasedCompactionPolicy.java


注:本文中的org.apache.hadoop.hbase.HConstants.FOREVER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。