Search in sources :

Example 46 with ColumnFamilyDescriptorBuilder

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

the class HBaseTestingUtil method createTable.

/**
 * Create a table.
 * @param htd table descriptor
 * @param families array of column families
 * @param splitKeys array of split keys
 * @param type Bloom type
 * @param blockSize block size
 * @param c Configuration to use
 * @return A Table instance for the created table.
 * @throws IOException if getAdmin or createTable fails
 */
public Table createTable(TableDescriptor htd, byte[][] families, byte[][] splitKeys, BloomType type, int blockSize, Configuration c) throws IOException {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(htd);
    for (byte[] family : families) {
        ColumnFamilyDescriptorBuilder cfdb = ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(type).setBlocksize(blockSize);
        if (isNewVersionBehaviorEnabled()) {
            cfdb.setNewVersionBehavior(true);
        }
        builder.setColumnFamily(cfdb.build());
    }
    TableDescriptor td = builder.build();
    if (splitKeys != null) {
        getAdmin().createTable(td, splitKeys);
    } else {
        getAdmin().createTable(td);
    }
    // HBaseAdmin only waits for regions to appear in hbase:meta
    // we should wait until they are assigned
    waitUntilAllRegionsAssigned(td.getTableName());
    return getConnection().getTable(td.getTableName());
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 47 with ColumnFamilyDescriptorBuilder

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

the class HBaseTestingUtil method generateColumnDescriptors.

/**
 * Create a set of column descriptors with the combination of compression, encoding, bloom codecs
 * available.
 * @param prefix family names prefix
 * @return the list of column descriptors
 */
public static List<ColumnFamilyDescriptor> generateColumnDescriptors(final String prefix) {
    List<ColumnFamilyDescriptor> columnFamilyDescriptors = new ArrayList<>();
    long familyId = 0;
    for (Compression.Algorithm compressionType : getSupportedCompressionAlgorithms()) {
        for (DataBlockEncoding encodingType : DataBlockEncoding.values()) {
            for (BloomType bloomType : BloomType.values()) {
                String name = String.format("%s-cf-!@#&-%d!@#", prefix, familyId);
                ColumnFamilyDescriptorBuilder columnFamilyDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(name));
                columnFamilyDescriptorBuilder.setCompressionType(compressionType);
                columnFamilyDescriptorBuilder.setDataBlockEncoding(encodingType);
                columnFamilyDescriptorBuilder.setBloomFilterType(bloomType);
                columnFamilyDescriptors.add(columnFamilyDescriptorBuilder.build());
                familyId++;
            }
        }
    }
    return columnFamilyDescriptors;
}
Also used : DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding) Compression(org.apache.hadoop.hbase.io.compress.Compression) Algorithm(org.apache.hadoop.hbase.io.compress.Compression.Algorithm) BloomType(org.apache.hadoop.hbase.regionserver.BloomType) ArrayList(java.util.ArrayList) ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)

Example 48 with ColumnFamilyDescriptorBuilder

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

the class HBaseTestingUtil 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 49 with ColumnFamilyDescriptorBuilder

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

the class HBaseTestingUtil method createPreSplitLoadTestTable.

/**
 * Creates a pre-split table for load testing. If the table already exists, logs a warning and
 * continues.
 * @return the number of regions the table was split into
 */
public static int createPreSplitLoadTestTable(Configuration conf, TableName tableName, byte[] columnFamily, Algorithm compression, DataBlockEncoding dataBlockEncoding, int numRegionsPerServer, int regionReplication, Durability durability) throws IOException {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
    builder.setDurability(durability);
    builder.setRegionReplication(regionReplication);
    ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(columnFamily);
    cfBuilder.setDataBlockEncoding(dataBlockEncoding);
    cfBuilder.setCompressionType(compression);
    return createPreSplitLoadTestTable(conf, builder.build(), cfBuilder.build(), numRegionsPerServer);
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder)

Example 50 with ColumnFamilyDescriptorBuilder

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

the class HBaseTestingUtil method createTable.

/**
 * Create a table.
 * @return A Table instance for the created table.
 */
public Table createTable(TableName tableName, byte[] family, byte[][] splitRows) throws IOException {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
    ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family);
    if (isNewVersionBehaviorEnabled()) {
        cfBuilder.setNewVersionBehavior(true);
    }
    builder.setColumnFamily(cfBuilder.build());
    getAdmin().createTable(builder.build(), splitRows);
    // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are
    // assigned
    waitUntilAllRegionsAssigned(tableName);
    return getConnection().getTable(tableName);
}
Also used : ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder)

Aggregations

ColumnFamilyDescriptorBuilder (org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder)61 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)43 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)19 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)16 Test (org.junit.Test)9 Table (org.apache.hadoop.hbase.client.Table)7 Admin (org.apache.hadoop.hbase.client.Admin)6 Put (org.apache.hadoop.hbase.client.Put)6 IOException (java.io.IOException)5 Configuration (org.apache.hadoop.conf.Configuration)5 Path (org.apache.hadoop.fs.Path)5 TableName (org.apache.hadoop.hbase.TableName)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 QName (javax.xml.namespace.QName)3 TableNotEnabledException (org.apache.hadoop.hbase.TableNotEnabledException)3 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)3 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)3 FileStatus (org.apache.hadoop.fs.FileStatus)2 FileSystem (org.apache.hadoop.fs.FileSystem)2