use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestMemStoreSegmentsIterator method setup.
@Before
public void setup() throws IOException {
Configuration conf = new Configuration();
HBaseTestingUtil hbaseUtility = new HBaseTestingUtil(conf);
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE));
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(FAMILY)).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
RegionInfo info = RegionInfoBuilder.newBuilder(TableName.valueOf(TABLE)).build();
Path rootPath = hbaseUtility.getDataTestDir(ROOT_SUB_PATH);
this.wal = HBaseTestingUtil.createWal(conf, rootPath, info);
this.region = HRegion.createHRegion(info, rootPath, conf, tableDescriptorBuilder.build(), this.wal, true);
this.store = new HStore(this.region, columnFamilyDescriptor, conf, false);
this.comparator = CellComparator.getInstance();
this.compactionKVMax = HConstants.COMPACTION_KV_MAX_DEFAULT;
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestMinVersions method testBaseCase.
/**
* Verify basic minimum versions functionality
*/
@Test
public void testBaseCase() throws Exception {
// 2 version minimum, 1000 versions maximum, ttl = 1s
ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0).setMinVersions(2).setMaxVersions(1000).setTimeToLive(1).setKeepDeletedCells(KeepDeletedCells.FALSE).build();
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamily(cfd).build();
HRegion region = hbu.createLocalHRegion(htd, null, null);
try {
// 2s in the past
long ts = EnvironmentEdgeManager.currentTime() - 2000;
// 1st version
Put p = new Put(T1, ts - 3);
p.addColumn(c0, c0, T1);
region.put(p);
// 2nd version
p = new Put(T1, ts - 2);
p.addColumn(c0, c0, T2);
region.put(p);
// 3rd version
p = new Put(T1, ts - 1);
p.addColumn(c0, c0, T3);
region.put(p);
// 4th version
p = new Put(T1, ts);
p.addColumn(c0, c0, T4);
region.put(p);
Result r = region.get(new Get(T1));
checkResult(r, c0, T4);
Get g = new Get(T1);
g.setTimeRange(0L, ts + 1);
r = region.get(g);
checkResult(r, c0, T4);
// oldest version still exists
g.setTimeRange(0L, ts - 2);
r = region.get(g);
checkResult(r, c0, T1);
// gets see only available versions
// even before compactions
g = new Get(T1);
g.readAllVersions();
// this'll use ScanWildcardColumnTracker
r = region.get(g);
checkResult(r, c0, T4, T3);
g = new Get(T1);
g.readAllVersions();
g.addColumn(c0, c0);
// this'll use ExplicitColumnTracker
r = region.get(g);
checkResult(r, c0, T4, T3);
// now flush
region.flush(true);
// with HBASE-4241 a flush will eliminate the expired rows
g = new Get(T1);
g.setTimeRange(0L, ts - 2);
r = region.get(g);
assertTrue(r.isEmpty());
// major compaction
region.compact(true);
// after compaction the 4th version is still available
g = new Get(T1);
g.setTimeRange(0L, ts + 1);
r = region.get(g);
checkResult(r, c0, T4);
// so is the 3rd
g.setTimeRange(0L, ts);
r = region.get(g);
checkResult(r, c0, T3);
// but the 2nd and earlier versions are gone
g.setTimeRange(0L, ts - 1);
r = region.get(g);
assertTrue(r.isEmpty());
} finally {
HBaseTestingUtil.closeRegionAndWAL(region);
}
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestAccessController method testTableModify.
@Test
public void testTableModify() throws Exception {
AccessTestAction modifyTable = new AccessTestAction() {
@Override
public Object run() throws Exception {
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TEST_TABLE);
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam_" + User.getCurrent().getShortName())).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE, // not needed by AccessController
null, tableDescriptorBuilder.build());
return null;
}
};
verifyAllowed(modifyTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_GROUP_CREATE, USER_GROUP_ADMIN);
verifyDenied(modifyTable, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class StoreFileTrackerBase method createFileContext.
private HFileContext createFileContext(Compression.Algorithm compression, boolean includeMVCCReadpoint, boolean includesTag, Encryption.Context encryptionContext) {
if (compression == null) {
compression = HFile.DEFAULT_COMPRESSION_ALGORITHM;
}
ColumnFamilyDescriptor family = ctx.getFamily();
HFileContext hFileContext = new HFileContextBuilder().withIncludesMvcc(includeMVCCReadpoint).withIncludesTags(includesTag).withCompression(compression).withCompressTags(family.isCompressTags()).withChecksumType(StoreUtils.getChecksumType(conf)).withBytesPerCheckSum(StoreUtils.getBytesPerChecksum(conf)).withBlockSize(family.getBlocksize()).withHBaseCheckSum(true).withDataBlockEncoding(family.getDataBlockEncoding()).withEncryptionContext(encryptionContext).withCreateTime(EnvironmentEdgeManager.currentTime()).withColumnFamily(family.getName()).withTableName(ctx.getTableName().getName()).withCellComparator(ctx.getComparator()).build();
return hFileContext;
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptor in project hbase by apache.
the class TestMaster method testMoveThrowsUnknownRegionException.
@Test
public void testMoveThrowsUnknownRegionException() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tableName);
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("value")).build();
tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
admin.createTable(tableDescriptorBuilder.build());
try {
RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).setStartKey(Bytes.toBytes("A")).setEndKey(Bytes.toBytes("Z")).build();
admin.move(hri.getEncodedNameAsBytes());
fail("Region should not be moved since it is fake");
} catch (IOException ioe) {
assertTrue(ioe instanceof UnknownRegionException);
} finally {
TEST_UTIL.deleteTable(tableName);
}
}
Aggregations