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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations