Search in sources :

Example 6 with TTableName

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

the class ThriftHBaseServiceHandler method modifyColumnFamily.

@Override
public void modifyColumnFamily(TTableName tableName, TColumnFamilyDescriptor column) throws TIOError, TException {
    try {
        TableName table = tableNameFromThrift(tableName);
        ColumnFamilyDescriptor columnFamilyDescriptor = columnFamilyDescriptorFromThrift(column);
        connectionCache.getAdmin().modifyColumnFamily(table, columnFamilyDescriptor);
    } 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) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) TColumnFamilyDescriptor(org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor)

Example 7 with TTableName

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

the class ThriftUtilities method tableNameFromHBase.

public static TTableName tableNameFromHBase(TableName table) {
    TTableName tableName = new TTableName();
    tableName.setNs(table.getNamespace());
    tableName.setQualifier(table.getQualifier());
    return tableName;
}
Also used : TTableName(org.apache.hadoop.hbase.thrift2.generated.TTableName)

Example 8 with TTableName

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

the class TestThriftHBaseServiceHandler method testExceptionType.

private void testExceptionType(THBaseService.Iface handler, ThriftMetrics metrics, ByteBuffer tTableName, byte[] rowkey, ErrorThrowingGetObserver.ErrorType errorType) {
    long preGetCounter = metricsHelper.getCounter("get_num_ops", metrics.getSource());
    String exceptionKey = errorType.getMetricName();
    long preExceptionCounter = metricsHelper.checkCounterExists(exceptionKey, metrics.getSource()) ? metricsHelper.getCounter(exceptionKey, metrics.getSource()) : 0;
    TGet tGet = new TGet(wrap(rowkey));
    Map<ByteBuffer, ByteBuffer> attributes = new HashMap<>();
    attributes.put(wrap(Bytes.toBytes(ErrorThrowingGetObserver.SHOULD_ERROR_ATTRIBUTE)), wrap(Bytes.toBytes(errorType.name())));
    tGet.setAttributes(attributes);
    try {
        TResult tResult = handler.get(tTableName, tGet);
        fail("Get with error attribute should have thrown an exception");
    } catch (TException e) {
        LOG.info("Received exception: ", e);
        metricsHelper.assertCounter("get_num_ops", preGetCounter + 1, metrics.getSource());
        metricsHelper.assertCounter(exceptionKey, preExceptionCounter + 1, metrics.getSource());
    }
}
Also used : TException(org.apache.thrift.TException) TGet(org.apache.hadoop.hbase.thrift2.generated.TGet) HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer) TResult(org.apache.hadoop.hbase.thrift2.generated.TResult)

Example 9 with TTableName

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

the class ThriftHBaseServiceHandler method deleteColumnFamily.

@Override
public void deleteColumnFamily(TTableName tableName, ByteBuffer column) throws TIOError, TException {
    try {
        TableName table = tableNameFromThrift(tableName);
        connectionCache.getAdmin().deleteColumnFamily(table, column.array());
    } 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)

Example 10 with TTableName

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

the class ThriftHBaseServiceHandler method truncateTable.

@Override
public void truncateTable(TTableName tableName, boolean preserveSplits) throws TIOError, TException {
    try {
        TableName table = tableNameFromThrift(tableName);
        connectionCache.getAdmin().truncateTable(table, preserveSplits);
    } 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)

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