Search in sources :

Example 16 with TTableName

use of org.apache.hadoop.hbase.thrift2.generated.TTableName 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 17 with TTableName

use of org.apache.hadoop.hbase.thrift2.generated.TTableName 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 18 with TTableName

use of org.apache.hadoop.hbase.thrift2.generated.TTableName 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)

Example 19 with TTableName

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

the class ThriftUtilities method tableNamesArrayFromThrift.

public static TableName[] tableNamesArrayFromThrift(List<TTableName> tableNames) {
    TableName[] out = new TableName[tableNames.size()];
    int index = 0;
    for (TTableName tableName : tableNames) {
        out[index++] = tableNameFromThrift(tableName);
    }
    return out;
}
Also used : TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName) TableName(org.apache.hadoop.hbase.TableName) TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName)

Aggregations

TTableName (org.apache.hadoop.hbase.thrift2.generated.TTableName)18 IOException (java.io.IOException)12 TableName (org.apache.hadoop.hbase.TableName)12 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)9 TColumnFamilyDescriptor (org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor)7 TTableDescriptor (org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor)6 ByteBuffer (java.nio.ByteBuffer)4 THBaseService (org.apache.hadoop.hbase.thrift2.generated.THBaseService)4 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)3 TGet (org.apache.hadoop.hbase.thrift2.generated.TGet)3 TResult (org.apache.hadoop.hbase.thrift2.generated.TResult)3 TException (org.apache.thrift.TException)3 Test (org.junit.Test)3 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)2 Put (org.apache.hadoop.hbase.client.Put)2 Table (org.apache.hadoop.hbase.client.Table)2 ThriftMetrics (org.apache.hadoop.hbase.thrift.ThriftMetrics)2 TColumnValue (org.apache.hadoop.hbase.thrift2.generated.TColumnValue)2 TPut (org.apache.hadoop.hbase.thrift2.generated.TPut)2 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)2