use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createModifyableTableDescriptor.
public TableDescriptorBuilder createModifyableTableDescriptor(final TableName name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name);
for (byte[] cfName : new byte[][] { fam1, fam2, fam3 }) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(cfName).setMinVersions(minVersions).setMaxVersions(versions).setKeepDeletedCells(keepDeleted).setBlockCacheEnabled(false).setTimeToLive(ttl);
if (isNewVersionBehaviorEnabled()) {
cfBuilder.setNewVersionBehavior(true);
}
builder.setColumnFamily(cfBuilder.build());
}
return builder;
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createTableDescriptor.
public TableDescriptor createTableDescriptor(final TableName tableName, byte[][] families, int maxVersions) {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
for (byte[] family : families) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(maxVersions);
if (isNewVersionBehaviorEnabled()) {
cfBuilder.setNewVersionBehavior(true);
}
builder.setColumnFamily(cfBuilder.build());
}
return builder.build();
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project gora by apache.
the class TestHBaseStore method testNewVersionBehavior.
@Test
public void testNewVersionBehavior() throws IOException {
// Following Test fails in HBase 2.0.5 when NEW_VERSION_BEHAVIOR == true
// Persisting for cases where qualifier == null, deleting row does not delete the column family.
// Once these issues are fixed, we could remove the workarounds we have added on
// HBaseDataStore #put method.
Connection conn = ConnectionFactory.createConnection(conf);
TableName test = TableName.valueOf("Test");
TableDescriptorBuilder tableDescBuilder = TableDescriptorBuilder.newBuilder(test);
ColumnFamilyDescriptorBuilder columnDescBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("test-family"));
columnDescBuilder.setNewVersionBehavior(true);
ColumnFamilyDescriptor columnDescriptor = columnDescBuilder.build();
tableDescBuilder.setColumnFamily(columnDescriptor);
TableDescriptor tableDescriptor = tableDescBuilder.build();
conn.getAdmin().createTable(tableDescriptor);
Table table = conn.getTable(test);
Put put = new Put(Bytes.toBytes("com.example/http"));
put.addColumn(Bytes.toBytes("test-family"), null, Bytes.toBytes("test-value"));
table.put(put);
Delete del = new Delete(Bytes.toBytes("com.example/http"));
table.delete(del);
Get get = new Get(Bytes.toBytes("com.example/http"));
// get.addColumn(Bytes.toBytes("test-family"), null);
Result result = table.get(get);
byte[] value = result.getValue(Bytes.toBytes("test-family"), null);
if (value != null) {
// Test failed, this should be null after the delete row operation.
}
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project janusgraph by JanusGraph.
the class HBaseStoreManager method createTable.
private TableDescriptor createTable(TableName tableName, String cfName, int ttlInSeconds, Admin adm) throws IOException {
TableDescriptorBuilder desc = TableDescriptorBuilder.newBuilder(tableName);
ColumnFamilyDescriptorBuilder columnDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(cfName));
setCFOptions(columnDescriptor, ttlInSeconds);
desc.setColumnFamily(columnDescriptor.build());
TableDescriptor td = desc.build();
// total regions to create
int count;
String src;
if (MIN_REGION_COUNT <= (count = regionCount)) {
src = "region count configuration";
} else if (0 < regionsPerServer && MIN_REGION_COUNT <= (count = regionsPerServer * getEstimatedRegionServerCount(adm))) {
src = "ClusterStatus server count";
} else {
count = -1;
src = "default";
}
if (MIN_REGION_COUNT < count) {
adm.createTable(td, getStartKey(count), getEndKey(count), count);
logger.debug("Created table {} with region count {} from {}", tableName, count, src);
} else {
adm.createTable(td);
logger.debug("Created table {} with default start key, end key, and region count", tableName);
}
return td;
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class IntegrationTestBackupRestore method createTable.
private void createTable(TableName tableName) throws Exception {
long startTime, endTime;
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
TableDescriptor desc = builder.build();
ColumnFamilyDescriptorBuilder cbuilder = ColumnFamilyDescriptorBuilder.newBuilder(COLUMN_NAME.getBytes(Charset.defaultCharset()));
ColumnFamilyDescriptor[] columns = new ColumnFamilyDescriptor[] { cbuilder.build() };
LOG.info("Creating table {} with {} splits.", tableName, regionsCountPerServer * regionServerCount);
startTime = EnvironmentEdgeManager.currentTime();
HBaseTestingUtil.createPreSplitLoadTestTable(util.getConfiguration(), desc, columns, regionsCountPerServer);
util.waitTableAvailable(tableName);
endTime = EnvironmentEdgeManager.currentTime();
LOG.info("Pre-split table created successfully in {}ms.", (endTime - startTime));
}
Aggregations