Java Code Examples for org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder#setTimeToLive()

The following examples show how to use org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder#setTimeToLive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackupSystemTable.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Get backup system table descriptor
 * @return table's descriptor
 */
public static TableDescriptor getSystemTableDescriptor(Configuration conf) {
  TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(getTableName(conf));

  ColumnFamilyDescriptorBuilder colBuilder =
      ColumnFamilyDescriptorBuilder.newBuilder(SESSIONS_FAMILY);

  colBuilder.setMaxVersions(1);
  Configuration config = HBaseConfiguration.create();
  int ttl = config.getInt(BackupRestoreConstants.BACKUP_SYSTEM_TTL_KEY,
    BackupRestoreConstants.BACKUP_SYSTEM_TTL_DEFAULT);
  colBuilder.setTimeToLive(ttl);

  ColumnFamilyDescriptor colSessionsDesc = colBuilder.build();
  builder.setColumnFamily(colSessionsDesc);

  colBuilder = ColumnFamilyDescriptorBuilder.newBuilder(META_FAMILY);
  colBuilder.setTimeToLive(ttl);
  builder.setColumnFamily(colBuilder.build());
  return builder.build();
}
 
Example 2
Source File: BackupSystemTable.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Get backup system table descriptor
 * @return table's descriptor
 */
public static TableDescriptor getSystemTableForBulkLoadedDataDescriptor(Configuration conf) {
  TableDescriptorBuilder builder =
      TableDescriptorBuilder.newBuilder(getTableNameForBulkLoadedData(conf));

  ColumnFamilyDescriptorBuilder colBuilder =
      ColumnFamilyDescriptorBuilder.newBuilder(SESSIONS_FAMILY);
  colBuilder.setMaxVersions(1);
  Configuration config = HBaseConfiguration.create();
  int ttl = config.getInt(BackupRestoreConstants.BACKUP_SYSTEM_TTL_KEY,
    BackupRestoreConstants.BACKUP_SYSTEM_TTL_DEFAULT);
  colBuilder.setTimeToLive(ttl);
  ColumnFamilyDescriptor colSessionsDesc = colBuilder.build();
  builder.setColumnFamily(colSessionsDesc);
  colBuilder = ColumnFamilyDescriptorBuilder.newBuilder(META_FAMILY);
  colBuilder.setTimeToLive(ttl);
  builder.setColumnFamily(colBuilder.build());
  return builder.build();
}
 
Example 3
Source File: TestExpiredMobFileCleaner.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void modifyColumnExpiryDays(int expireDays) throws Exception {
  ColumnFamilyDescriptorBuilder columnFamilyDescriptorBuilder =
    ColumnFamilyDescriptorBuilder
      .newBuilder(Bytes.toBytes(family))
      .setMobEnabled(true)
      .setMobThreshold(3L);
  // change ttl as expire days to make some row expired
  int timeToLive = expireDays * secondsOfDay();
  columnFamilyDescriptorBuilder.setTimeToLive(timeToLive);

  admin.modifyColumnFamily(tableName, columnFamilyDescriptorBuilder.build());
}
 
Example 4
Source File: TestMajorCompactorTTL.java    From hbase with Apache License 2.0 5 votes vote down vote up
protected void modifyTTL(TableName tableName) throws IOException, InterruptedException {
  // Set the TTL to 5 secs, so all the files just written above will get cleaned up on compact.
  admin.disableTable(tableName);
  utility.waitTableDisabled(tableName.getName());
  TableDescriptor descriptor = admin.getDescriptor(tableName);
  ColumnFamilyDescriptor colDesc = descriptor.getColumnFamily(FAMILY);
  ColumnFamilyDescriptorBuilder cFDB = ColumnFamilyDescriptorBuilder.newBuilder(colDesc);
  cFDB.setTimeToLive(5);
  admin.modifyColumnFamily(tableName, cFDB.build());
  admin.enableTable(tableName);
  utility.waitTableEnabled(tableName);
}
 
Example 5
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static ColumnFamilyDescriptor columnFamilyDescriptorFromThrift(
    TColumnFamilyDescriptor in) {
  ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder
      .newBuilder(in.getName());

  if (in.isSetAttributes()) {
    for (Map.Entry<ByteBuffer, ByteBuffer> attribute : in.getAttributes().entrySet()) {
      builder.setValue(attribute.getKey().array(), attribute.getValue().array());
    }
  }
  if (in.isSetConfiguration()) {
    for (Map.Entry<String, String> conf : in.getConfiguration().entrySet()) {
      builder.setConfiguration(conf.getKey(), conf.getValue());
    }
  }
  if (in.isSetBlockSize()) {
    builder.setBlocksize(in.getBlockSize());
  }
  if (in.isSetBloomnFilterType()) {
    builder.setBloomFilterType(bloomFilterFromThrift(in.getBloomnFilterType()));
  }
  if (in.isSetCompressionType()) {
    builder.setCompressionType(compressionAlgorithmFromThrift(in.getCompressionType()));
  }
  if (in.isSetDfsReplication()) {
    builder.setDFSReplication(in.getDfsReplication());
  }
  if (in.isSetDataBlockEncoding()) {
    builder.setDataBlockEncoding(dataBlockEncodingFromThrift(in.getDataBlockEncoding()));
  }
  if (in.isSetKeepDeletedCells()) {
    builder.setKeepDeletedCells(keepDeletedCellsFromThrift(in.getKeepDeletedCells()));
  }
  if (in.isSetMaxVersions()) {
    builder.setMaxVersions(in.getMaxVersions());
  }
  if (in.isSetMinVersions()) {
    builder.setMinVersions(in.getMinVersions());
  }
  if (in.isSetScope()) {
    builder.setScope(in.getScope());
  }
  if (in.isSetTimeToLive()) {
    builder.setTimeToLive(in.getTimeToLive());
  }
  if (in.isSetBlockCacheEnabled()) {
    builder.setBlockCacheEnabled(in.isBlockCacheEnabled());
  }
  if (in.isSetCacheBloomsOnWrite()) {
    builder.setCacheBloomsOnWrite(in.isCacheBloomsOnWrite());
  }
  if (in.isSetCacheDataOnWrite()) {
    builder.setCacheDataOnWrite(in.isCacheDataOnWrite());
  }
  if (in.isSetCacheIndexesOnWrite()) {
    builder.setCacheIndexesOnWrite(in.isCacheIndexesOnWrite());
  }
  if (in.isSetCompressTags()) {
    builder.setCompressTags(in.isCompressTags());
  }
  if (in.isSetEvictBlocksOnClose()) {
    builder.setEvictBlocksOnClose(in.isEvictBlocksOnClose());
  }
  if (in.isSetInMemory()) {
    builder.setInMemory(in.isInMemory());
  }


  return builder.build();
}
 
Example 6
Source File: PropertiesInSyncIT.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Helper method to modify the synced properties for a column family descriptor
 * @param cfdb The column family descriptor builder object
 * @throws SQLException
 */
private void modifySyncedPropsForCF(ColumnFamilyDescriptorBuilder cfdb) throws SQLException {
    cfdb.setTimeToLive(MODIFIED_TTL_VALUE);
    cfdb.setKeepDeletedCells(MODIFIED_KEEP_DELETED_CELLS_VALUE);
    cfdb.setScope(MODIFIED_REPLICATION_SCOPE_VALUE);
}