use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestColumnFamilyDescriptorDefaultVersions method testHColumnDescriptorCachedMaxVersions.
@Test
public void testHColumnDescriptorCachedMaxVersions() throws Exception {
ColumnFamilyDescriptor familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setMaxVersions(5).build();
// Verify the max version
assertEquals(5, familyDescriptor.getMaxVersions());
// modify the max version
familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(familyDescriptor).setValue(Bytes.toBytes(HConstants.VERSIONS), Bytes.toBytes("8")).build();
// Verify the max version
assertEquals(8, familyDescriptor.getMaxVersions());
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestColumnFamilyDescriptorDefaultVersions method verifyHColumnDescriptor.
private void verifyHColumnDescriptor(int expected, final TableName tableName, final byte[]... families) throws IOException {
Admin admin = TEST_UTIL.getAdmin();
// Verify descriptor from master
TableDescriptor htd = admin.getDescriptor(tableName);
ColumnFamilyDescriptor[] hcds = htd.getColumnFamilies();
verifyColumnFamilyDescriptor(expected, hcds, tableName, families);
// Verify descriptor from HDFS
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
Path tableDir = CommonFSUtils.getTableDir(mfs.getRootDir(), tableName);
TableDescriptor td = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
hcds = td.getColumnFamilies();
verifyColumnFamilyDescriptor(expected, hcds, tableName, families);
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestNamespace method createTableInDefaultNamespace.
@Test
public void createTableInDefaultNamespace() throws Exception {
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName()));
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("cf1")).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
TableDescriptor tableDescriptor = tableDescriptorBuilder.build();
admin.createTable(tableDescriptor);
assertTrue(admin.listTableDescriptors().size() == 1);
admin.disableTable(tableDescriptor.getTableName());
admin.deleteTable(tableDescriptor.getTableName());
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestEncryptionKeyRotation method createTableAndFlush.
private void createTableAndFlush(TableDescriptor tableDescriptor) throws Exception {
ColumnFamilyDescriptor cfd = tableDescriptor.getColumnFamilies()[0];
// Create the test table
TEST_UTIL.getAdmin().createTable(tableDescriptor);
TEST_UTIL.waitTableAvailable(tableDescriptor.getTableName(), 5000);
// Create a store file
Table table = TEST_UTIL.getConnection().getTable(tableDescriptor.getTableName());
try {
table.put(new Put(Bytes.toBytes("testrow")).addColumn(cfd.getName(), Bytes.toBytes("q"), Bytes.toBytes("value")));
} finally {
table.close();
}
TEST_UTIL.getAdmin().flush(tableDescriptor.getTableName());
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestHRegion method testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization.
/**
* Testcase to check state of region initialization task set to ABORTED or not
* if any exceptions during initialization
*
* @throws Exception
*/
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
RegionInfo info;
try {
FileSystem fs = Mockito.mock(FileSystem.class);
Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tableName);
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("cf")).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
info = RegionInfoBuilder.newBuilder(tableName).build();
Path path = new Path(dir + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
region = HRegion.newHRegion(path, null, fs, CONF, info, tableDescriptorBuilder.build(), null);
// region initialization throws IOException and set task state to ABORTED.
region.initialize();
fail("Region initialization should fail due to IOException");
} catch (IOException io) {
List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
for (MonitoredTask monitoredTask : tasks) {
if (!(monitoredTask instanceof MonitoredRPCHandler) && monitoredTask.getDescription().contains(region.toString())) {
assertTrue("Region state should be ABORTED.", monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
break;
}
}
}
}
Aggregations