org.apache.hadoop.hbase.client.Increment.setTTL()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.apache.hadoop.hbase.client.Increment.setTTL()方法的一些代码示例,展示了Increment.setTTL()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Increment.setTTL()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Increment
类名称:Increment
方法名:setTTL

Increment.setTTL介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

incr.setTTL(5000);

代码示例来源:origin: apache/metron

/**
  * Creates an HBase Increment for a counter.
  *
  * @param rowKey     The row key.
  * @param cols       The columns to include.
  * @param durability The durability of the increment.
  */
 private Increment createIncrement(byte[] rowKey, ColumnList cols, Durability durability, long timeToLiveMillis) {
  Increment inc = new Increment(rowKey);
  inc.setDurability(durability);
  inc.setTTL(timeToLiveMillis);
  cols.getCounters().forEach(cnt -> inc.addColumn(cnt.getFamily(), cnt.getQualifier(), cnt.getIncrement()));
  return inc;
 }
}

代码示例来源:origin: ManbangGroup/cantor

@Override
public boolean heartbeat(int instanceNumber, int ttl) {
  try {
    Increment increment = new Increment(
        Bytes.toBytes(String.format(RUNNING_STATE_FMT, instanceNumber)));
    byte[] col = Bytes.toBytes("state");
    increment.addColumn(INST_FAMILY, col, 1);
    increment.setTTL((long) ttl);
    metaTable.increment(increment);
    return true;
  } catch (Exception e) {
    if (log.isErrorEnabled())
      log.error("[HBase] Failed to heartbeat.", e);
    return false;
  }
}

代码示例来源:origin: ManbangGroup/cantor

/**
 * @return the value before increment
 */
@Override
public Optional<Long> incrementAndGet(long category, long ts, long range) {
  String tbl = String.format(TABLE_FMT, category % TABLE_COUNT);
  Table table = tableConnections.get(tbl);
  try {
    Increment increment = new Increment(Bytes.toBytes(String.format(ROW_KEY_FMT, ts)));
    increment.setTTL(ttl);
    byte[] col = Bytes.toBytes(String.valueOf(category));
    increment.addColumn(SERVICE_FAMILY, col, range);
    Result result = table.increment(increment);
    Long afterInc = Bytes.toLong(result.getValue(SERVICE_FAMILY, col));
    return Optional.of(afterInc);
  } catch (Exception e) {
    if (log.isErrorEnabled())
      log.error(
          "increment range value failed for [ category: {} ] [ timestamp {} ] [ range {} ]",
          category, ts, range, e);
    return Optional.empty();
  }
}

代码示例来源:origin: org.apache.hbase/hbase-server

incr.setTTL(5000);

相关文章