Search in sources :

Example 6 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testCheckAndPutWithReadOnly.

@Test
public void testCheckAndPutWithReadOnly() throws Exception {
    ThriftHBaseServiceHandler handler = createHandler();
    byte[] rowName = Bytes.toBytes("testCheckAndPut");
    ByteBuffer table = wrap(tableAname);
    List<TColumnValue> columnValuesA = new ArrayList<>(1);
    TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname));
    columnValuesA.add(columnValueA);
    TPut putA = new TPut(wrap(rowName), columnValuesA);
    putA.setColumnValues(columnValuesA);
    List<TColumnValue> columnValuesB = new ArrayList<>(1);
    TColumnValue columnValueB = new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname));
    columnValuesB.add(columnValueB);
    TPut putB = new TPut(wrap(rowName), columnValuesB);
    putB.setColumnValues(columnValuesB);
    boolean exceptionCaught = false;
    try {
        handler.checkAndPut(table, wrap(rowName), wrap(familyAname), wrap(qualifierAname), wrap(valueAname), putB);
    } catch (TIOError e) {
        exceptionCaught = true;
        assertTrue(e.getCause() instanceof DoNotRetryIOException);
        assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
    } finally {
        assertTrue(exceptionCaught);
    }
}
Also used : TIOError(org.apache.hadoop.hbase.thrift2.generated.TIOError) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ArrayList(java.util.ArrayList) TColumnValue(org.apache.hadoop.hbase.thrift2.generated.TColumnValue) TPut(org.apache.hadoop.hbase.thrift2.generated.TPut) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 7 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testMutateRowWithReadOnly.

@Test
public void testMutateRowWithReadOnly() throws Exception {
    ThriftHBaseServiceHandler handler = createHandler();
    byte[] rowName = Bytes.toBytes("testMutateRow");
    ByteBuffer table = wrap(tableAname);
    List<TColumnValue> columnValuesA = new ArrayList<>(1);
    TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname));
    columnValuesA.add(columnValueA);
    TPut putA = new TPut(wrap(rowName), columnValuesA);
    putA.setColumnValues(columnValuesA);
    TDelete delete = new TDelete(wrap(rowName));
    List<TMutation> mutations = new ArrayList<>(2);
    TMutation mutationA = TMutation.put(putA);
    mutations.add(mutationA);
    TMutation mutationB = TMutation.deleteSingle(delete);
    mutations.add(mutationB);
    TRowMutations tRowMutations = new TRowMutations(wrap(rowName), mutations);
    boolean exceptionCaught = false;
    try {
        handler.mutateRow(table, tRowMutations);
    } catch (TIOError e) {
        exceptionCaught = true;
        assertTrue(e.getCause() instanceof DoNotRetryIOException);
        assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
    } finally {
        assertTrue(exceptionCaught);
    }
}
Also used : DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ArrayList(java.util.ArrayList) TDelete(org.apache.hadoop.hbase.thrift2.generated.TDelete) TColumnValue(org.apache.hadoop.hbase.thrift2.generated.TColumnValue) ByteBuffer(java.nio.ByteBuffer) TIOError(org.apache.hadoop.hbase.thrift2.generated.TIOError) TMutation(org.apache.hadoop.hbase.thrift2.generated.TMutation) TRowMutations(org.apache.hadoop.hbase.thrift2.generated.TRowMutations) TPut(org.apache.hadoop.hbase.thrift2.generated.TPut) Test(org.junit.Test)

Example 8 with TIOError

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

the class ThriftHBaseServiceHandler method enableTable.

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

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

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

the class ThriftHBaseServiceHandler method createNamespace.

@Override
public void createNamespace(TNamespaceDescriptor namespaceDesc) throws TIOError, TException {
    try {
        NamespaceDescriptor descriptor = namespaceDescriptorFromThrift(namespaceDesc);
        connectionCache.getAdmin().createNamespace(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)

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