Search in sources :

Example 11 with ColumnDescriptor

use of org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor in project hbase by apache.

the class ThriftHBaseServiceHandler method createTable.

@Override
public void createTable(ByteBuffer in_tableName, List<ColumnDescriptor> columnFamilies) throws IOError, IllegalArgument, AlreadyExists {
    TableName tableName = getTableName(in_tableName);
    try {
        if (getAdmin().tableExists(tableName)) {
            throw new AlreadyExists("table name already in use");
        }
        TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
        for (ColumnDescriptor col : columnFamilies) {
            builder.setColumnFamily(ThriftUtilities.colDescFromThrift(col));
        }
        getAdmin().createTable(builder.build());
    } catch (IOException e) {
        LOG.warn(e.getMessage(), e);
        throw getIOError(e);
    } catch (IllegalArgumentException e) {
        LOG.warn(e.getMessage(), e);
        throw new IllegalArgument(Throwables.getStackTraceAsString(e));
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) ColumnDescriptor(org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) AlreadyExists(org.apache.hadoop.hbase.thrift.generated.AlreadyExists) IllegalArgument(org.apache.hadoop.hbase.thrift.generated.IllegalArgument)

Aggregations

ColumnDescriptor (org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor)11 ArrayList (java.util.ArrayList)7 Hbase (org.apache.hadoop.hbase.thrift.generated.Hbase)6 Mutation (org.apache.hadoop.hbase.thrift.generated.Mutation)5 TRowResult (org.apache.hadoop.hbase.thrift.generated.TRowResult)5 Test (org.junit.Test)4 ByteBuffer (java.nio.ByteBuffer)3 AlreadyExists (org.apache.hadoop.hbase.thrift.generated.AlreadyExists)3 IOException (java.io.IOException)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)2 TProtocol (org.apache.thrift.protocol.TProtocol)2 TSocket (org.apache.thrift.transport.TSocket)2 TTransport (org.apache.thrift.transport.TTransport)2 NumberFormat (java.text.NumberFormat)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 TableName (org.apache.hadoop.hbase.TableName)1