Search in sources :

Example 16 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testGetWithReadOnly.

@Test
public void testGetWithReadOnly() throws Exception {
    ThriftHBaseServiceHandler handler = createHandler();
    byte[] rowName = Bytes.toBytes("testGet");
    ByteBuffer table = wrap(tableAname);
    TGet get = new TGet(wrap(rowName));
    boolean exceptionCaught = false;
    try {
        handler.get(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)

Example 17 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testExistsAllWithReadOnly.

@Test
public void testExistsAllWithReadOnly() throws TException {
    ThriftHBaseServiceHandler handler = createHandler();
    byte[] rowName1 = Bytes.toBytes("testExistsAll1");
    byte[] rowName2 = Bytes.toBytes("testExistsAll2");
    ByteBuffer table = wrap(tableAname);
    List<TGet> gets = new ArrayList<>();
    gets.add(new TGet(wrap(rowName1)));
    gets.add(new TGet(wrap(rowName2)));
    boolean exceptionCaught = false;
    try {
        handler.existsAll(table, gets);
    } 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) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 18 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testDeleteMultipleWithReadOnly.

@Test
public void testDeleteMultipleWithReadOnly() throws Exception {
    ThriftHBaseServiceHandler handler = createHandler();
    ByteBuffer table = wrap(tableAname);
    byte[] rowName1 = Bytes.toBytes("testDeleteMultiple1");
    byte[] rowName2 = Bytes.toBytes("testDeleteMultiple2");
    List<TDelete> deletes = new ArrayList<>(2);
    deletes.add(new TDelete(wrap(rowName1)));
    deletes.add(new TDelete(wrap(rowName2)));
    boolean exceptionCaught = false;
    try {
        handler.deleteMultiple(table, deletes);
    } 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) TDelete(org.apache.hadoop.hbase.thrift2.generated.TDelete) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 19 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testGetMultipleWithReadOnly.

@Test
public void testGetMultipleWithReadOnly() throws Exception {
    ThriftHBaseServiceHandler handler = createHandler();
    ByteBuffer table = wrap(tableAname);
    byte[] rowName1 = Bytes.toBytes("testGetMultiple1");
    byte[] rowName2 = Bytes.toBytes("testGetMultiple2");
    List<TGet> gets = new ArrayList<>(2);
    gets.add(new TGet(wrap(rowName1)));
    gets.add(new TGet(wrap(rowName2)));
    boolean exceptionCaught = false;
    try {
        handler.getMultiple(table, gets);
    } 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) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 20 with TIOError

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

the class TestThriftHBaseServiceHandlerWithReadOnly method testPutMultipleWithReadOnly.

@Test
public void testPutMultipleWithReadOnly() throws Exception {
    ThriftHBaseServiceHandler handler = createHandler();
    ByteBuffer table = wrap(tableAname);
    byte[] rowName1 = Bytes.toBytes("testPutMultiple1");
    byte[] rowName2 = Bytes.toBytes("testPutMultiple2");
    List<TColumnValue> columnValues = new ArrayList<>(2);
    columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
    columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname)));
    List<TPut> puts = new ArrayList<>(2);
    puts.add(new TPut(wrap(rowName1), columnValues));
    puts.add(new TPut(wrap(rowName2), columnValues));
    boolean exceptionCaught = false;
    try {
        handler.putMultiple(table, puts);
    } 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)

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