use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor 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.ColumnFamilyDescriptor 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.ColumnFamilyDescriptor in project hbase by apache.
the class TestSnapshotManifest method createRegionManifest.
private Path createRegionManifest() throws IOException {
byte[] startKey = Bytes.toBytes("AAAAAA");
byte[] stopKey = Bytes.toBytes("BBBBBB");
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(TABLE_NAME).build();
SnapshotRegionManifest.Builder dataRegionManifestBuilder = SnapshotRegionManifest.newBuilder();
dataRegionManifestBuilder.setRegionInfo(ProtobufUtil.toRegionInfo(regionInfo));
for (ColumnFamilyDescriptor hcd : builder.getTableDescriptor().getColumnFamilies()) {
SnapshotRegionManifest.FamilyFiles.Builder family = SnapshotRegionManifest.FamilyFiles.newBuilder();
family.setFamilyName(UnsafeByteOperations.unsafeWrap(hcd.getName()));
for (int j = 0; j < TEST_NUM_REGIONFILES; ++j) {
SnapshotRegionManifest.StoreFile.Builder sfManifest = SnapshotRegionManifest.StoreFile.newBuilder();
sfManifest.setName(String.format("%064d", j));
sfManifest.setFileSize(j * 1024);
family.addStoreFiles(sfManifest.build());
}
dataRegionManifestBuilder.addFamilyFiles(family.build());
}
SnapshotRegionManifest manifest = dataRegionManifestBuilder.build();
Path regionPath = new Path(snapshotDir, SnapshotManifestV2.SNAPSHOT_MANIFEST_PREFIX + regionInfo.getEncodedName());
FSDataOutputStream stream = fs.create(regionPath);
try {
manifest.writeTo(stream);
} finally {
stream.close();
}
return regionPath;
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestSnapshotManifest method createDataManifest.
private Path createDataManifest() throws IOException {
SnapshotDataManifest.Builder dataManifestBuilder = SnapshotDataManifest.newBuilder();
byte[] startKey = null;
byte[] stopKey = null;
for (int i = 1; i <= TEST_NUM_REGIONS; i++) {
stopKey = Bytes.toBytes(String.format("%016d", i));
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(TABLE_NAME).build();
SnapshotRegionManifest.Builder dataRegionManifestBuilder = SnapshotRegionManifest.newBuilder();
for (ColumnFamilyDescriptor hcd : builder.getTableDescriptor().getColumnFamilies()) {
SnapshotRegionManifest.FamilyFiles.Builder family = SnapshotRegionManifest.FamilyFiles.newBuilder();
family.setFamilyName(UnsafeByteOperations.unsafeWrap(hcd.getName()));
for (int j = 0; j < 100; ++j) {
SnapshotRegionManifest.StoreFile.Builder sfManifest = SnapshotRegionManifest.StoreFile.newBuilder();
sfManifest.setName(String.format("%032d", i));
sfManifest.setFileSize((1 + i) * (1 + i) * 1024);
family.addStoreFiles(sfManifest.build());
}
dataRegionManifestBuilder.addFamilyFiles(family.build());
}
dataRegionManifestBuilder.setRegionInfo(ProtobufUtil.toRegionInfo(regionInfo));
dataManifestBuilder.addRegionManifests(dataRegionManifestBuilder.build());
startKey = stopKey;
}
dataManifestBuilder.setTableSchema(ProtobufUtil.toTableSchema(builder.getTableDescriptor()));
SnapshotDataManifest dataManifest = dataManifestBuilder.build();
return writeDataManifest(dataManifest);
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor 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) {
}
}
Aggregations