use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class BaseTestHBaseFsck method setupMobTable.
/**
* Setup a clean table with a mob-enabled column.
*
* @param tablename The name of a table to be created.
* @throws Exception
*/
void setupMobTable(TableName tablename) throws Exception {
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tablename);
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(FAM).setMobEnabled(true).setMobThreshold(0).build();
// If a table has no CF's it doesn't get checked
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
createTable(TEST_UTIL, tableDescriptorBuilder.build(), SPLITS);
tbl = connection.getTable(tablename, tableExecutorService);
List<Put> puts = new ArrayList<>(ROWKEYS.length);
for (byte[] row : ROWKEYS) {
Put p = new Put(row);
p.addColumn(FAM, Bytes.toBytes("val"), row);
puts.add(p);
}
tbl.put(puts);
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class BaseTestHBaseFsck method setupTableWithRegionReplica.
/**
* Setup a clean table with a certain region_replica count
*
* It will set tbl which needs to be closed after test
*
* @throws Exception
*/
void setupTableWithRegionReplica(TableName tablename, int replicaCount) throws Exception {
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tablename);
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(FAM).build();
tableDescriptorBuilder.setRegionReplication(replicaCount);
// If a table has no CF's it doesn't get checked
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
createTable(TEST_UTIL, tableDescriptorBuilder.build(), SPLITS);
tbl = connection.getTable(tablename, tableExecutorService);
List<Put> puts = new ArrayList<>(ROWKEYS.length);
for (byte[] row : ROWKEYS) {
Put p = new Put(row);
p.addColumn(FAM, Bytes.toBytes("val"), row);
puts.add(p);
}
tbl.put(puts);
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class MobSnapshotTestingUtils method createMobTable.
/**
* Create a Mob table.
* @return An Table instance for the created table.
*/
public static Table createMobTable(final HBaseTestingUtil util, final TableName tableName, final byte[]... families) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
for (byte[] family : families) {
// Disable blooms (they are on by default as of 0.95) but we disable them
// here because
// tests have hard coded counts of what to expect in block cache, etc.,
// and blooms being
// on is interfering.
builder.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(BloomType.NONE).setMobEnabled(true).setMobThreshold(0L).build());
}
util.getAdmin().createTable(builder.build());
// HBaseAdmin only waits for regions to appear in hbase:meta we should wait
// until they are assigned
util.waitUntilAllRegionsAssigned(tableName);
return ConnectionFactory.createConnection(util.getConfiguration()).getTable(tableName);
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class TestVisibilityLabels method testUserShouldNotDoDDLOpOnLabelsTable.
@Test
public void testUserShouldNotDoDDLOpOnLabelsTable() throws Exception {
Admin admin = TEST_UTIL.getAdmin();
try {
admin.disableTable(LABELS_TABLE_NAME);
fail("Lables table should not get disabled by user.");
} catch (Exception e) {
}
try {
admin.deleteTable(LABELS_TABLE_NAME);
fail("Lables table should not get disabled by user.");
} catch (Exception e) {
}
try {
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("testFamily")).build();
admin.addColumnFamily(LABELS_TABLE_NAME, columnFamilyDescriptor);
fail("Lables table should not get altered by user.");
} catch (Exception e) {
}
try {
admin.deleteColumnFamily(LABELS_TABLE_NAME, VisibilityConstants.LABELS_TABLE_FAMILY);
fail("Lables table should not get altered by user.");
} catch (Exception e) {
}
try {
ColumnFamilyDescriptor familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(VisibilityConstants.LABELS_TABLE_FAMILY).setBloomFilterType(BloomType.ROWCOL).build();
admin.modifyColumnFamily(LABELS_TABLE_NAME, familyDescriptor);
fail("Lables table should not get altered by user.");
} catch (Exception e) {
}
try {
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(LABELS_TABLE_NAME);
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f1")).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f2")).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
admin.modifyTable(tableDescriptorBuilder.build());
fail("Lables table should not get altered by user.");
} catch (Exception e) {
}
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class TestBulkLoadHFilesSplitRecovery method createTableDesc.
private TableDescriptor createTableDesc(TableName name, int cfs) {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name);
IntStream.range(0, cfs).mapToObj(i -> ColumnFamilyDescriptorBuilder.of(family(i))).forEachOrdered(builder::setColumnFamily);
return builder.build();
}
Aggregations