use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandlerWithReadOnly method testPutWithReadOnly.
@Test
public void testPutWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
ByteBuffer table = wrap(tableAname);
byte[] rowName = Bytes.toBytes("testPut");
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);
boolean exceptionCaught = false;
try {
handler.put(table, put);
} 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 testAppendWithReadOnly.
@Test
public void testAppendWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
byte[] rowName = Bytes.toBytes("testAppend");
ByteBuffer table = wrap(tableAname);
byte[] v1 = Bytes.toBytes("42");
List<TColumnValue> appendColumns = new ArrayList<>(1);
appendColumns.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(v1)));
TAppend append = new TAppend(wrap(rowName), appendColumns);
boolean exceptionCaught = false;
try {
handler.append(table, append);
} 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 testScanWithReadOnly.
@Test
public void testScanWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
ByteBuffer table = wrap(tableAname);
TScan scan = new TScan();
boolean exceptionCaught = false;
try {
int scanId = handler.openScanner(table, scan);
handler.getScannerRows(scanId, 10);
handler.closeScanner(scanId);
} catch (TIOError e) {
exceptionCaught = true;
} finally {
assertFalse(exceptionCaught);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TIOError in project hbase by apache.
the class TestThriftHBaseServiceHandlerWithReadOnly method testDeleteWithReadOnly.
@Test
public void testDeleteWithReadOnly() throws Exception {
ThriftHBaseServiceHandler handler = createHandler();
byte[] rowName = Bytes.toBytes("testDelete");
ByteBuffer table = wrap(tableAname);
TDelete delete = new TDelete(wrap(rowName));
boolean exceptionCaught = false;
try {
handler.deleteSingle(table, 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 ThriftHBaseServiceHandler method getRegionLocation.
@Override
public THRegionLocation getRegionLocation(ByteBuffer table, ByteBuffer row, boolean reload) throws TIOError, TException {
RegionLocator locator = null;
try {
locator = getLocator(table);
byte[] rowBytes = byteBufferToByteArray(row);
HRegionLocation hrl = locator.getRegionLocation(rowBytes, reload);
return ThriftUtilities.regionLocationFromHBase(hrl);
} catch (IOException e) {
throw getTIOError(e);
} finally {
if (locator != null) {
try {
locator.close();
} catch (IOException e) {
LOG.warn("Couldn't close the locator.", e);
}
}
}
}
Aggregations