Search in sources :

Example 86 with TableDescriptorBuilder

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

the class HBaseTestingUtility method createModifyableTableDescriptor.

public TableDescriptorBuilder createModifyableTableDescriptor(final TableName name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name);
    for (byte[] cfName : new byte[][] { fam1, fam2, fam3 }) {
        ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(cfName).setMinVersions(minVersions).setMaxVersions(versions).setKeepDeletedCells(keepDeleted).setBlockCacheEnabled(false).setTimeToLive(ttl);
        if (isNewVersionBehaviorEnabled()) {
            cfBuilder.setNewVersionBehavior(true);
        }
        builder.setColumnFamily(cfBuilder.build());
    }
    return builder;
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder)

Example 87 with TableDescriptorBuilder

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

the class HBaseTestingUtility method createTableDescriptor.

public TableDescriptor createTableDescriptor(final TableName tableName, byte[][] families, int maxVersions) {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
    for (byte[] family : families) {
        ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(maxVersions);
        if (isNewVersionBehaviorEnabled()) {
            cfBuilder.setNewVersionBehavior(true);
        }
        builder.setColumnFamily(cfBuilder.build());
    }
    return builder.build();
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder)

Example 88 with TableDescriptorBuilder

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

the class TestHBaseStore method testNewVersionBehavior.

@Test
public void testNewVersionBehavior() throws IOException {
    // Following Test fails in HBase 2.0.5 when NEW_VERSION_BEHAVIOR == true
    // Persisting for cases where qualifier ==  null, deleting row does not delete the column family.
    // Once these issues are fixed, we could remove the workarounds we have added on
    // HBaseDataStore #put method.
    Connection conn = ConnectionFactory.createConnection(conf);
    TableName test = TableName.valueOf("Test");
    TableDescriptorBuilder tableDescBuilder = TableDescriptorBuilder.newBuilder(test);
    ColumnFamilyDescriptorBuilder columnDescBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("test-family"));
    columnDescBuilder.setNewVersionBehavior(true);
    ColumnFamilyDescriptor columnDescriptor = columnDescBuilder.build();
    tableDescBuilder.setColumnFamily(columnDescriptor);
    TableDescriptor tableDescriptor = tableDescBuilder.build();
    conn.getAdmin().createTable(tableDescriptor);
    Table table = conn.getTable(test);
    Put put = new Put(Bytes.toBytes("com.example/http"));
    put.addColumn(Bytes.toBytes("test-family"), null, Bytes.toBytes("test-value"));
    table.put(put);
    Delete del = new Delete(Bytes.toBytes("com.example/http"));
    table.delete(del);
    Get get = new Get(Bytes.toBytes("com.example/http"));
    // get.addColumn(Bytes.toBytes("test-family"), null);
    Result result = table.get(get);
    byte[] value = result.getValue(Bytes.toBytes("test-family"), null);
    if (value != null) {
    // Test failed, this should be null after the delete row operation.
    }
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) TableName(org.apache.hadoop.hbase.TableName) Table(org.apache.hadoop.hbase.client.Table) Get(org.apache.hadoop.hbase.client.Get) Connection(org.apache.hadoop.hbase.client.Connection) ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) 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 89 with TableDescriptorBuilder

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

the class HBaseStoreManager method createTable.

private TableDescriptor createTable(TableName tableName, String cfName, int ttlInSeconds, Admin adm) throws IOException {
    TableDescriptorBuilder desc = TableDescriptorBuilder.newBuilder(tableName);
    ColumnFamilyDescriptorBuilder columnDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(cfName));
    setCFOptions(columnDescriptor, ttlInSeconds);
    desc.setColumnFamily(columnDescriptor.build());
    TableDescriptor td = desc.build();
    // total regions to create
    int count;
    String src;
    if (MIN_REGION_COUNT <= (count = regionCount)) {
        src = "region count configuration";
    } else if (0 < regionsPerServer && MIN_REGION_COUNT <= (count = regionsPerServer * getEstimatedRegionServerCount(adm))) {
        src = "ClusterStatus server count";
    } else {
        count = -1;
        src = "default";
    }
    if (MIN_REGION_COUNT < count) {
        adm.createTable(td, getStartKey(count), getEndKey(count), count);
        logger.debug("Created table {} with region count {} from {}", tableName, count, src);
    } else {
        adm.createTable(td);
        logger.debug("Created table {} with default start key, end key, and region count", tableName);
    }
    return td;
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 90 with TableDescriptorBuilder

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

the class IntegrationTestBackupRestore method createTable.

private void createTable(TableName tableName) throws Exception {
    long startTime, endTime;
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
    TableDescriptor desc = builder.build();
    ColumnFamilyDescriptorBuilder cbuilder = ColumnFamilyDescriptorBuilder.newBuilder(COLUMN_NAME.getBytes(Charset.defaultCharset()));
    ColumnFamilyDescriptor[] columns = new ColumnFamilyDescriptor[] { cbuilder.build() };
    LOG.info("Creating table {} with {} splits.", tableName, regionsCountPerServer * regionServerCount);
    startTime = EnvironmentEdgeManager.currentTime();
    HBaseTestingUtil.createPreSplitLoadTestTable(util.getConfiguration(), desc, columns, regionsCountPerServer);
    util.waitTableAvailable(tableName);
    endTime = EnvironmentEdgeManager.currentTime();
    LOG.info("Pre-split table created successfully in {}ms.", (endTime - startTime));
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

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