use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class TestRSGroupsWithACL method setUpTableAndUserPermissions.
private static void setUpTableAndUserPermissions() throws Exception {
TableDescriptorBuilder tableBuilder = TableDescriptorBuilder.newBuilder(TEST_TABLE);
ColumnFamilyDescriptorBuilder cfd = ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY);
cfd.setMaxVersions(100);
tableBuilder.setColumnFamily(cfd.build());
createTable(TEST_UTIL, USER_OWNER, tableBuilder.build(), new byte[][] { Bytes.toBytes("s") });
// Set up initial grants
grantGlobal(TEST_UTIL, USER_ADMIN.getShortName(), Permission.Action.ADMIN, Permission.Action.CREATE, Permission.Action.READ, Permission.Action.WRITE);
grantOnTable(TEST_UTIL, USER_RW.getShortName(), TEST_TABLE, TEST_FAMILY, null, Permission.Action.READ, Permission.Action.WRITE);
// USER_CREATE is USER_RW plus CREATE permissions
grantOnTable(TEST_UTIL, USER_CREATE.getShortName(), TEST_TABLE, null, null, Permission.Action.CREATE, Permission.Action.READ, Permission.Action.WRITE);
grantOnTable(TEST_UTIL, USER_RO.getShortName(), TEST_TABLE, TEST_FAMILY, null, Permission.Action.READ);
grantGlobal(TEST_UTIL, toGroupEntry(GROUP_ADMIN), Permission.Action.ADMIN);
grantGlobal(TEST_UTIL, toGroupEntry(GROUP_CREATE), Permission.Action.CREATE);
grantGlobal(TEST_UTIL, toGroupEntry(GROUP_READ), Permission.Action.READ);
grantGlobal(TEST_UTIL, toGroupEntry(GROUP_WRITE), Permission.Action.WRITE);
assertEquals(4, PermissionStorage.getTablePermissions(conf, TEST_TABLE).size());
try {
assertEquals(4, AccessControlClient.getUserPermissions(systemUserConnection, TEST_TABLE.toString()).size());
} catch (AssertionError e) {
fail(e.getMessage());
} catch (Throwable e) {
LOG.error("error during call of AccessControlClient.getUserPermissions. ", e);
}
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder 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.ColumnFamilyDescriptorBuilder 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.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method generateColumnDescriptors.
/**
* Create a set of column descriptors with the combination of compression,
* encoding, bloom codecs available.
* @param prefix family names prefix
* @return the list of column descriptors
*/
public static List<ColumnFamilyDescriptor> generateColumnDescriptors(final String prefix) {
List<ColumnFamilyDescriptor> columnFamilyDescriptors = new ArrayList<>();
long familyId = 0;
for (Compression.Algorithm compressionType : getSupportedCompressionAlgorithms()) {
for (DataBlockEncoding encodingType : DataBlockEncoding.values()) {
for (BloomType bloomType : BloomType.values()) {
String name = String.format("%s-cf-!@#&-%d!@#", prefix, familyId);
ColumnFamilyDescriptorBuilder columnFamilyDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(name));
columnFamilyDescriptorBuilder.setCompressionType(compressionType);
columnFamilyDescriptorBuilder.setDataBlockEncoding(encodingType);
columnFamilyDescriptorBuilder.setBloomFilterType(bloomType);
columnFamilyDescriptors.add(columnFamilyDescriptorBuilder.build());
familyId++;
}
}
}
return columnFamilyDescriptors;
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder 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.
}
}
Aggregations