Search in sources :

Example 36 with TableDescriptorBuilder

use of org.apache.hadoop.hbase.client.TableDescriptorBuilder 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);
}
Also used : ArrayList(java.util.ArrayList) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) Put(org.apache.hadoop.hbase.client.Put)

Example 37 with TableDescriptorBuilder

use of org.apache.hadoop.hbase.client.TableDescriptorBuilder 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);
}
Also used : ArrayList(java.util.ArrayList) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) Put(org.apache.hadoop.hbase.client.Put)

Example 38 with TableDescriptorBuilder

use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.

the class MobSnapshotTestingUtils method createMobTable.

/**
 * Create a Mob table.
 * @return An Table instance for the created table.
 */
public static Table createMobTable(final HBaseTestingUtil util, final TableName tableName, final byte[]... families) throws IOException {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
    for (byte[] family : families) {
        // Disable blooms (they are on by default as of 0.95) but we disable them
        // here because
        // tests have hard coded counts of what to expect in block cache, etc.,
        // and blooms being
        // on is interfering.
        builder.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(BloomType.NONE).setMobEnabled(true).setMobThreshold(0L).build());
    }
    util.getAdmin().createTable(builder.build());
    // HBaseAdmin only waits for regions to appear in hbase:meta we should wait
    // until they are assigned
    util.waitUntilAllRegionsAssigned(tableName);
    return ConnectionFactory.createConnection(util.getConfiguration()).getTable(tableName);
}
Also used : TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder)

Example 39 with TableDescriptorBuilder

use of org.apache.hadoop.hbase.client.TableDescriptorBuilder 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) {
    }
}
Also used : TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) Admin(org.apache.hadoop.hbase.client.Admin) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) IOException(java.io.IOException) Test(org.junit.Test)

Example 40 with TableDescriptorBuilder

use of org.apache.hadoop.hbase.client.TableDescriptorBuilder in project hbase by apache.

the class TestBulkLoadHFilesSplitRecovery method createTableDesc.

private TableDescriptor createTableDesc(TableName name, int cfs) {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name);
    IntStream.range(0, cfs).mapToObj(i -> ColumnFamilyDescriptorBuilder.of(family(i))).forEachOrdered(builder::setColumnFamily);
    return builder.build();
}
Also used : Result(org.apache.hadoop.hbase.client.Result) FileSystem(org.apache.hadoop.fs.FileSystem) LoggerFactory(org.slf4j.LoggerFactory) ByteBuffer(java.nio.ByteBuffer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) Path(org.apache.hadoop.fs.Path) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) Mockito.doReturn(org.mockito.Mockito.doReturn) Pair(org.apache.hadoop.hbase.util.Pair) CommonFSUtils(org.apache.hadoop.hbase.util.CommonFSUtils) AfterClass(org.junit.AfterClass) ProtobufUtil(org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) LargeTests(org.apache.hadoop.hbase.testclassification.LargeTests) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) Category(org.junit.experimental.categories.Category) Multimap(org.apache.hbase.thirdparty.com.google.common.collect.Multimap) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) List(java.util.List) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) BeforeClass(org.junit.BeforeClass) CompletableFuture(java.util.concurrent.CompletableFuture) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) Mockito.spy(org.mockito.Mockito.spy) Deque(java.util.Deque) HConstants(org.apache.hadoop.hbase.HConstants) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TestName(org.junit.rules.TestName) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) AsyncClusterConnection(org.apache.hadoop.hbase.client.AsyncClusterConnection) Bytes(org.apache.hadoop.hbase.util.Bytes) MiscTests(org.apache.hadoop.hbase.testclassification.MiscTests) TableName(org.apache.hadoop.hbase.TableName) Logger(org.slf4j.Logger) TableExistsException(org.apache.hadoop.hbase.TableExistsException) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Scan(org.apache.hadoop.hbase.client.Scan) TestHRegionServerBulkLoad(org.apache.hadoop.hbase.regionserver.TestHRegionServerBulkLoad) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) Admin(org.apache.hadoop.hbase.client.Admin) Connection(org.apache.hadoop.hbase.client.Connection) Table(org.apache.hadoop.hbase.client.Table) CoprocessorHost(org.apache.hadoop.hbase.coprocessor.CoprocessorHost) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Assert.assertEquals(org.junit.Assert.assertEquals) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder)

Aggregations

TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)190 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)76 Test (org.junit.Test)68 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)61 ColumnFamilyDescriptorBuilder (org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder)47 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)39 TableName (org.apache.hadoop.hbase.TableName)34 Path (org.apache.hadoop.fs.Path)31 Admin (org.apache.hadoop.hbase.client.Admin)29 Put (org.apache.hadoop.hbase.client.Put)25 IOException (java.io.IOException)24 Configuration (org.apache.hadoop.conf.Configuration)20 Table (org.apache.hadoop.hbase.client.Table)18 ArrayList (java.util.ArrayList)17 FileSystem (org.apache.hadoop.fs.FileSystem)15 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)15 Before (org.junit.Before)12 Cell (org.apache.hadoop.hbase.Cell)11 NamespaceDescriptor (org.apache.hadoop.hbase.NamespaceDescriptor)10 HashMap (java.util.HashMap)9