Search in sources :

Example 6 with TTableDescriptor

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

the class ThriftHBaseServiceHandler method modifyTable.

@Override
public void modifyTable(TTableDescriptor desc) throws TIOError, TException {
    try {
        TableDescriptor descriptor = tableDescriptorFromThrift(desc);
        connectionCache.getAdmin().modifyTable(descriptor);
    } catch (IOException e) {
        throw getTIOError(e);
    }
}
Also used : DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) TTableDescriptor(org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 7 with TTableDescriptor

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

the class ThriftHBaseServiceHandler method getTableDescriptor.

@Override
public TTableDescriptor getTableDescriptor(TTableName table) throws TIOError, TException {
    try {
        TableName tableName = ThriftUtilities.tableNameFromThrift(table);
        TableDescriptor tableDescriptor = connectionCache.getAdmin().getDescriptor(tableName);
        return tableDescriptorFromHBase(tableDescriptor);
    } catch (IOException e) {
        throw getTIOError(e);
    }
}
Also used : TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName) TableName(org.apache.hadoop.hbase.TableName) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) TTableDescriptor(org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 8 with TTableDescriptor

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

the class ThriftHBaseServiceHandler method createTable.

@Override
public void createTable(TTableDescriptor desc, List<ByteBuffer> splitKeys) throws TIOError, TException {
    try {
        TableDescriptor descriptor = tableDescriptorFromThrift(desc);
        byte[][] split = splitKeyFromThrift(splitKeys);
        if (split != null) {
            connectionCache.getAdmin().createTable(descriptor, split);
        } else {
            connectionCache.getAdmin().createTable(descriptor);
        }
    } catch (IOException e) {
        throw getTIOError(e);
    }
}
Also used : DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) TTableDescriptor(org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 9 with TTableDescriptor

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

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

the class ThriftAdmin method createTable.

@Override
public void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOException {
    TTableDescriptor tTableDescriptor = ThriftUtilities.tableDescriptorFromHBase(desc);
    List<ByteBuffer> splitKeyInBuffer = ThriftUtilities.splitKeyFromHBase(splitKeys);
    try {
        client.createTable(tTableDescriptor, splitKeyInBuffer);
    } catch (TException e) {
        throw new IOException(e);
    }
}
Also used : TException(org.apache.thrift.TException) TTableDescriptor(org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Aggregations

TTableDescriptor (org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor)11 IOException (java.io.IOException)6 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)5 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)4 TColumnFamilyDescriptor (org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor)4 TTableName (org.apache.hadoop.hbase.thrift2.generated.TTableName)4 ByteBuffer (java.nio.ByteBuffer)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 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 TableName (org.apache.hadoop.hbase.TableName)1 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)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