Search in sources :

Example 6 with TColumnFamilyDescriptor

use of org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor in project hbase by apache.

the class TestThrift2HttpServer method talkToThriftServer.

@Override
protected void talkToThriftServer(String url, int customHeaderSize) throws Exception {
    THttpClient httpClient = new THttpClient(url);
    httpClient.open();
    if (customHeaderSize > 0) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < customHeaderSize; i++) {
            sb.append("a");
        }
        httpClient.setCustomHeader("User-Agent", sb.toString());
    }
    try {
        TProtocol prot;
        prot = new TBinaryProtocol(httpClient);
        THBaseService.Client client = new THBaseService.Client(prot);
        TTableName tTableName = new TTableName();
        tTableName.setNs(Bytes.toBytes(""));
        tTableName.setQualifier(Bytes.toBytes(TABLENAME));
        if (!tableCreated) {
            Assert.assertTrue(!client.tableExists(tTableName));
            TTableDescriptor tTableDescriptor = new TTableDescriptor();
            tTableDescriptor.setTableName(tTableName);
            TColumnFamilyDescriptor columnFamilyDescriptor = new TColumnFamilyDescriptor();
            columnFamilyDescriptor.setName(Bytes.toBytes(TABLENAME));
            tTableDescriptor.addToColumns(columnFamilyDescriptor);
            client.createTable(tTableDescriptor, new ArrayList<>());
            tableCreated = true;
        }
        Assert.assertTrue(client.tableExists(tTableName));
    } finally {
        httpClient.close();
    }
}
Also used : TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName) TProtocol(org.apache.thrift.protocol.TProtocol) TColumnFamilyDescriptor(org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor) THttpClient(org.apache.thrift.transport.THttpClient) TTableDescriptor(org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor) THttpClient(org.apache.thrift.transport.THttpClient) THBaseService(org.apache.hadoop.hbase.thrift2.generated.THBaseService)

Example 7 with TColumnFamilyDescriptor

use of org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor in project hbase by apache.

the class ThriftAdmin method modifyColumnFamily.

@Override
public void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException {
    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
    TColumnFamilyDescriptor tColumnFamilyDescriptor = ThriftUtilities.columnFamilyDescriptorFromHBase(columnFamily);
    try {
        client.modifyColumnFamily(tTableName, tColumnFamilyDescriptor);
    } catch (TException e) {
        throw new IOException(e);
    }
}
Also used : TException(org.apache.thrift.TException) TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName) TColumnFamilyDescriptor(org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor) IOException(java.io.IOException)

Example 8 with TColumnFamilyDescriptor

use of org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor in project hbase by apache.

the class ThriftAdmin method addColumnFamily.

@Override
public void addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) throws IOException {
    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
    TColumnFamilyDescriptor tColumnFamilyDescriptor = ThriftUtilities.columnFamilyDescriptorFromHBase(columnFamily);
    try {
        client.addColumnFamily(tTableName, tColumnFamilyDescriptor);
    } catch (TException e) {
        throw new IOException(e);
    }
}
Also used : TException(org.apache.thrift.TException) TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName) TColumnFamilyDescriptor(org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor) IOException(java.io.IOException)

Aggregations

TColumnFamilyDescriptor (org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor)8 TTableName (org.apache.hadoop.hbase.thrift2.generated.TTableName)7 IOException (java.io.IOException)4 TTableDescriptor (org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 TableName (org.apache.hadoop.hbase.TableName)2 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)2 THBaseService (org.apache.hadoop.hbase.thrift2.generated.THBaseService)2 TException (org.apache.thrift.TException)2 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)2 TProtocol (org.apache.thrift.protocol.TProtocol)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TNamespaceDescriptor (org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor)1 Bytes (org.apache.hadoop.hbase.util.Bytes)1 Bytes.getBytes (org.apache.hadoop.hbase.util.Bytes.getBytes)1 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)1 THttpClient (org.apache.thrift.transport.THttpClient)1 TSocket (org.apache.thrift.transport.TSocket)1