use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandler method testExists.
@Test
public void testExists() throws TIOError, TException {
ThriftHBaseServiceHandler handler = createHandler();
byte[] rowName = Bytes.toBytes("testExists");
ByteBuffer table = wrap(tableAname);
TGet get = new TGet(wrap(rowName));
assertFalse(handler.exists(table, get));
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)));
TPut put = new TPut(wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
}
use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandler method testExistsAll.
@Test
public void testExistsAll() throws TIOError, 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(rowName2)));
gets.add(new TGet(wrap(rowName2)));
List<Boolean> existsResult1 = handler.existsAll(table, gets);
assertFalse(existsResult1.get(0));
assertFalse(existsResult1.get(1));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
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<TPut>();
puts.add(new TPut(wrap(rowName1), columnValues));
puts.add(new TPut(wrap(rowName2), columnValues));
handler.putMultiple(table, puts);
List<Boolean> existsResult2 = handler.existsAll(table, gets);
assertTrue(existsResult2.get(0));
assertTrue(existsResult2.get(1));
}
use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandlerWithReadOnly method testCheckAndMutateWithReadOnly.
@Test
public void testCheckAndMutateWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
ByteBuffer table = wrap(tableAname);
ByteBuffer row = wrap(Bytes.toBytes("row"));
ByteBuffer family = wrap(familyAname);
ByteBuffer qualifier = wrap(qualifierAname);
ByteBuffer value = wrap(valueAname);
List<TColumnValue> columnValuesB = new ArrayList<>(1);
TColumnValue columnValueB = new TColumnValue(family, wrap(qualifierBname), wrap(valueBname));
columnValuesB.add(columnValueB);
TPut putB = new TPut(row, columnValuesB);
putB.setColumnValues(columnValuesB);
TRowMutations tRowMutations = new TRowMutations(row, Arrays.<TMutation>asList(TMutation.put(putB)));
boolean exceptionCaught = false;
try {
handler.checkAndMutate(table, row, family, qualifier, TCompareOperator.EQUAL, value, tRowMutations);
} catch (TIOError e) {
exceptionCaught = true;
assertTrue(e.getCause() instanceof DoNotRetryIOException);
assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
} finally {
assertTrue(exceptionCaught);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandlerWithReadOnly method testCheckAndDeleteWithReadOnly.
@Test
public void testCheckAndDeleteWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
byte[] rowName = Bytes.toBytes("testCheckAndDelete");
ByteBuffer table = wrap(tableAname);
TDelete delete = new TDelete(wrap(rowName));
boolean exceptionCaught = false;
try {
handler.checkAndDelete(table, wrap(rowName), wrap(familyAname), wrap(qualifierAname), wrap(valueAname), delete);
} catch (TIOError e) {
exceptionCaught = true;
assertTrue(e.getCause() instanceof DoNotRetryIOException);
assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
} finally {
assertTrue(exceptionCaught);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandlerWithReadOnly method testIncrementWithReadOnly.
@Test
public void testIncrementWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
byte[] rowName = Bytes.toBytes("testIncrement");
ByteBuffer table = wrap(tableAname);
List<TColumnIncrement> incrementColumns = new ArrayList<>(1);
incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);
boolean exceptionCaught = false;
try {
handler.increment(table, increment);
} catch (TIOError e) {
exceptionCaught = true;
assertTrue(e.getCause() instanceof DoNotRetryIOException);
assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
} finally {
assertTrue(exceptionCaught);
}
}
Aggregations