use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtil method createPreSplitLoadTestTable.
/**
* Creates a pre-split table for load testing. If the table already exists, logs a warning and
* continues.
* @return the number of regions the table was split into
*/
public static int createPreSplitLoadTestTable(Configuration conf, TableName tableName, byte[][] columnFamilies, Algorithm compression, DataBlockEncoding dataBlockEncoding, int numRegionsPerServer, int regionReplication, Durability durability) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
builder.setDurability(durability);
builder.setRegionReplication(regionReplication);
ColumnFamilyDescriptor[] hcds = new ColumnFamilyDescriptor[columnFamilies.length];
for (int i = 0; i < columnFamilies.length; i++) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(columnFamilies[i]);
cfBuilder.setDataBlockEncoding(dataBlockEncoding);
cfBuilder.setCompressionType(compression);
hcds[i] = cfBuilder.build();
}
return createPreSplitLoadTestTable(conf, builder.build(), hcds, numRegionsPerServer);
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtil method createLocalHRegionWithInMemoryFlags.
public HRegion createLocalHRegionWithInMemoryFlags(TableName tableName, byte[] startKey, byte[] stopKey, Configuration conf, boolean isReadOnly, Durability durability, WAL wal, boolean[] compactedMemStore, byte[]... families) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
builder.setReadOnly(isReadOnly);
int i = 0;
for (byte[] family : families) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family);
if (compactedMemStore != null && i < compactedMemStore.length) {
cfBuilder.setInMemoryCompaction(MemoryCompactionPolicy.BASIC);
} else {
cfBuilder.setInMemoryCompaction(MemoryCompactionPolicy.NONE);
}
i++;
// Set default to be three versions.
cfBuilder.setMaxVersions(Integer.MAX_VALUE);
builder.setColumnFamily(cfBuilder.build());
}
builder.setDurability(durability);
RegionInfo info = RegionInfoBuilder.newBuilder(tableName).setStartKey(startKey).setEndKey(stopKey).build();
return createLocalHRegion(info, conf, builder.build(), wal);
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class TestChangingEncoding method prepareTest.
private void prepareTest(String testId) throws IOException {
tableName = TableName.valueOf("test_table_" + testId);
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tableName);
columnFamilyDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(CF));
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptorBuilder.build());
try (Admin admin = TEST_UTIL.getConnection().getAdmin()) {
admin.createTable(tableDescriptorBuilder.build());
}
numBatchesWritten = 0;
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class TestMobFileCache method createMobStoreFile.
/**
* Create the mob store file
*/
private Path createMobStoreFile(ColumnFamilyDescriptor columnFamilyDescriptor) throws IOException {
// Setting up a Store
TableName tn = TableName.valueOf(TABLE);
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tn);
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
HMobStore mobStore = (HMobStore) region.getStore(columnFamilyDescriptor.getName());
KeyValue key1 = new KeyValue(ROW, columnFamilyDescriptor.getName(), QF1, 1, VALUE);
KeyValue key2 = new KeyValue(ROW, columnFamilyDescriptor.getName(), QF2, 1, VALUE);
KeyValue key3 = new KeyValue(ROW2, columnFamilyDescriptor.getName(), QF3, 1, VALUE2);
KeyValue[] keys = new KeyValue[] { key1, key2, key3 };
int maxKeyCount = keys.length;
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tn).build();
StoreFileWriter mobWriter = mobStore.createWriterInTmp(currentDate, maxKeyCount, columnFamilyDescriptor.getCompactionCompressionType(), regionInfo.getStartKey(), false);
Path mobFilePath = mobWriter.getPath();
String fileName = mobFilePath.getName();
mobWriter.append(key1);
mobWriter.append(key2);
mobWriter.append(key3);
mobWriter.close();
String targetPathName = MobUtils.formatDate(currentDate);
Path targetPath = new Path(mobStore.getPath(), targetPathName);
mobStore.commitFile(mobFilePath, targetPath);
return new Path(targetPath, fileName);
}
use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.
the class TestNamespaceAuditor method testStatePreserve.
@Test
public void testStatePreserve() throws Exception {
final String nsp1 = prefix + "_testStatePreserve";
NamespaceDescriptor nspDesc = NamespaceDescriptor.create(nsp1).addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "20").addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "10").build();
ADMIN.createNamespace(nspDesc);
TableName tableOne = TableName.valueOf(nsp1 + TableName.NAMESPACE_DELIM + "table1");
TableName tableTwo = TableName.valueOf(nsp1 + TableName.NAMESPACE_DELIM + "table2");
TableName tableThree = TableName.valueOf(nsp1 + TableName.NAMESPACE_DELIM + "table3");
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
TableDescriptorBuilder tableDescOne = TableDescriptorBuilder.newBuilder(tableOne);
tableDescOne.setColumnFamily(columnFamilyDescriptor);
TableDescriptorBuilder tableDescTwo = TableDescriptorBuilder.newBuilder(tableTwo);
tableDescTwo.setColumnFamily(columnFamilyDescriptor);
TableDescriptorBuilder tableDescThree = TableDescriptorBuilder.newBuilder(tableThree);
tableDescThree.setColumnFamily(columnFamilyDescriptor);
ADMIN.createTable(tableDescOne.build(), Bytes.toBytes("1"), Bytes.toBytes("1000"), 3);
ADMIN.createTable(tableDescTwo.build(), Bytes.toBytes("1"), Bytes.toBytes("1000"), 3);
ADMIN.createTable(tableDescThree.build(), Bytes.toBytes("1"), Bytes.toBytes("1000"), 4);
ADMIN.disableTable(tableThree);
deleteTable(tableThree);
// wait for chore to complete
UTIL.waitFor(1000, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return (getNamespaceState(nsp1).getTables().size() == 2);
}
});
NamespaceTableAndRegionInfo before = getNamespaceState(nsp1);
killActiveMaster();
NamespaceTableAndRegionInfo after = getNamespaceState(nsp1);
assertEquals("Expected: " + before.getTables() + " Found: " + after.getTables(), before.getTables().size(), after.getTables().size());
}
Aggregations