Search in sources :

Example 86 with ColumnFamilyDescriptor

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;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) Before(org.junit.Before)

Example 87 with ColumnFamilyDescriptor

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);
    }
}
Also used : Get(org.apache.hadoop.hbase.client.Get) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 88 with ColumnFamilyDescriptor

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);
}
Also used : TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) Test(org.junit.Test)

Example 89 with ColumnFamilyDescriptor

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;
}
Also used : HFileContextBuilder(org.apache.hadoop.hbase.io.hfile.HFileContextBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) HFileContext(org.apache.hadoop.hbase.io.hfile.HFileContext)

Example 90 with ColumnFamilyDescriptor

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);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) Test(org.junit.Test)

Aggregations

ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)199 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)95 Test (org.junit.Test)92 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)78 IOException (java.io.IOException)44 TableName (org.apache.hadoop.hbase.TableName)44 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)42 Path (org.apache.hadoop.fs.Path)41 Admin (org.apache.hadoop.hbase.client.Admin)36 Configuration (org.apache.hadoop.conf.Configuration)34 ArrayList (java.util.ArrayList)32 Put (org.apache.hadoop.hbase.client.Put)32 FileSystem (org.apache.hadoop.fs.FileSystem)28 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)24 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)22 Get (org.apache.hadoop.hbase.client.Get)20 Result (org.apache.hadoop.hbase.client.Result)19 ColumnFamilyDescriptorBuilder (org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder)17 Scan (org.apache.hadoop.hbase.client.Scan)17 Table (org.apache.hadoop.hbase.client.Table)17