use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class LoadTestTool method applyColumnFamilyOptions.
/**
* Apply column family options such as Bloom filters, compression, and data
* block encoding.
*/
protected void applyColumnFamilyOptions(TableName tableName, byte[][] columnFamilies) throws IOException {
try (Connection conn = ConnectionFactory.createConnection(conf);
Admin admin = conn.getAdmin()) {
TableDescriptor tableDesc = admin.getDescriptor(tableName);
LOG.info("Disabling table " + tableName);
admin.disableTable(tableName);
for (byte[] cf : columnFamilies) {
ColumnFamilyDescriptor columnDesc = tableDesc.getColumnFamily(cf);
boolean isNewCf = columnDesc == null;
ColumnFamilyDescriptorBuilder columnDescBuilder = isNewCf ? ColumnFamilyDescriptorBuilder.newBuilder(cf) : ColumnFamilyDescriptorBuilder.newBuilder(columnDesc);
if (bloomType != null) {
columnDescBuilder.setBloomFilterType(bloomType);
}
if (compressAlgo != null) {
columnDescBuilder.setCompressionType(compressAlgo);
}
if (dataBlockEncodingAlgo != null) {
columnDescBuilder.setDataBlockEncoding(dataBlockEncodingAlgo);
}
if (inMemoryCF) {
columnDescBuilder.setInMemory(inMemoryCF);
}
if (cipher != null) {
byte[] keyBytes = new byte[cipher.getKeyLength()];
new SecureRandom().nextBytes(keyBytes);
columnDescBuilder.setEncryptionType(cipher.getName());
columnDescBuilder.setEncryptionKey(EncryptionUtil.wrapKey(conf, User.getCurrent().getShortName(), new SecretKeySpec(keyBytes, cipher.getName())));
}
if (mobThreshold >= 0) {
columnDescBuilder.setMobEnabled(true);
columnDescBuilder.setMobThreshold(mobThreshold);
}
if (isNewCf) {
admin.addColumnFamily(tableName, columnDescBuilder.build());
} else {
admin.modifyColumnFamily(tableName, columnDescBuilder.build());
}
}
LOG.info("Enabling table " + tableName);
admin.enableTable(tableName);
}
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class BackupSystemTable method getSystemTableForBulkLoadedDataDescriptor.
/**
* 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();
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class BackupSystemTable method getSystemTableDescriptor.
/**
* 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();
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class TestExpiredMobFileCleaner method modifyColumnExpiryDays.
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());
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createTable.
/**
* Create a table.
* @return A Table instance for the created table.
*/
public Table createTable(TableName tableName, byte[][] families, int[] numVersions) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
int i = 0;
for (byte[] family : families) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(numVersions[i]);
if (isNewVersionBehaviorEnabled()) {
cfBuilder.setNewVersionBehavior(true);
}
builder.setColumnFamily(cfBuilder.build());
i++;
}
getAdmin().createTable(builder.build());
// HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are
// assigned
waitUntilAllRegionsAssigned(tableName);
return getConnection().getTable(tableName);
}
Aggregations