Search in sources :

Example 11 with TIOError

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

the class ThriftHBaseServiceHandler method getTIOError.

private TIOError getTIOError(IOException e) {
    TIOError err = new TIOErrorWithCause(e);
    err.setCanRetry(!(e instanceof DoNotRetryIOException));
    err.setMessage(e.getMessage());
    return err;
}
Also used : TIOError(org.apache.hadoop.hbase.thrift2.generated.TIOError) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 12 with TIOError

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

the class ThriftHBaseServiceHandler method getScannerRows.

@Override
public List<TResult> getScannerRows(int scannerId, int numRows) throws TIOError, TIllegalArgument, TException {
    ResultScanner scanner = getScanner(scannerId);
    if (scanner == null) {
        TIllegalArgument ex = new TIllegalArgument();
        ex.setMessage("Invalid scanner Id");
        throw ex;
    }
    try {
        connectionCache.updateConnectionAccessTime();
        return resultsFromHBase(scanner.next(numRows));
    } catch (IOException e) {
        throw getTIOError(e);
    }
}
Also used : ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) TIllegalArgument(org.apache.hadoop.hbase.thrift2.generated.TIllegalArgument) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException)

Example 13 with TIOError

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

the class ThriftHBaseServiceHandler method getScannerResults.

@Override
public List<TResult> getScannerResults(ByteBuffer table, TScan scan, int numRows) throws TIOError, TException {
    Table htable = getTable(table);
    List<TResult> results = null;
    ResultScanner scanner = null;
    try {
        scanner = htable.getScanner(scanFromThrift(scan));
        results = resultsFromHBase(scanner.next(numRows));
    } catch (IOException e) {
        throw getTIOError(e);
    } finally {
        if (scanner != null) {
            scanner.close();
        }
        closeTable(htable);
    }
    return results;
}
Also used : Table(org.apache.hadoop.hbase.client.Table) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) TResult(org.apache.hadoop.hbase.thrift2.generated.TResult)

Example 14 with TIOError

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

the class ThriftHBaseServiceHandler method modifyNamespace.

@Override
public void modifyNamespace(TNamespaceDescriptor namespaceDesc) throws TIOError, TException {
    try {
        NamespaceDescriptor descriptor = namespaceDescriptorFromThrift(namespaceDesc);
        connectionCache.getAdmin().modifyNamespace(descriptor);
    } catch (IOException e) {
        throw getTIOError(e);
    }
}
Also used : TNamespaceDescriptor(org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException)

Example 15 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testExistsWithReadOnly.

@Test
public void testExistsWithReadOnly() throws TException {
    ThriftHBaseServiceHandler handler = createHandler();
    byte[] rowName = Bytes.toBytes("testExists");
    ByteBuffer table = wrap(tableAname);
    TGet get = new TGet(wrap(rowName));
    boolean exceptionCaught = false;
    try {
        handler.exists(table, get);
    } catch (TIOError e) {
        exceptionCaught = true;
    } finally {
        assertFalse(exceptionCaught);
    }
}
Also used : TIOError(org.apache.hadoop.hbase.thrift2.generated.TIOError) TGet(org.apache.hadoop.hbase.thrift2.generated.TGet) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)29 IOException (java.io.IOException)18 ByteBuffer (java.nio.ByteBuffer)17 Test (org.junit.Test)17 TIOError (org.apache.hadoop.hbase.thrift2.generated.TIOError)16 ArrayList (java.util.ArrayList)12 TableName (org.apache.hadoop.hbase.TableName)9 TTableName (org.apache.hadoop.hbase.thrift2.generated.TTableName)9 TColumnValue (org.apache.hadoop.hbase.thrift2.generated.TColumnValue)8 TPut (org.apache.hadoop.hbase.thrift2.generated.TPut)7 TGet (org.apache.hadoop.hbase.thrift2.generated.TGet)6 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)4 TDelete (org.apache.hadoop.hbase.thrift2.generated.TDelete)4 TTableDescriptor (org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor)4 Pattern (java.util.regex.Pattern)2 NamespaceDescriptor (org.apache.hadoop.hbase.NamespaceDescriptor)2 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)2 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)2 TColumnFamilyDescriptor (org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor)2 TNamespaceDescriptor (org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor)2