use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.
the class TestClientOperationTimeout method testMultiPutsTimeout.
/**
* Tests that a batch mutate on a table throws {@link RetriesExhaustedException} when the
* operation takes longer than 'hbase.client.operation.timeout'.
*/
@Test
public void testMultiPutsTimeout() {
DELAY_BATCH_MUTATE = 600;
Put put1 = new Put(ROW).addColumn(FAMILY, QUALIFIER, VALUE);
Put put2 = new Put(ROW).addColumn(FAMILY, QUALIFIER, VALUE);
List<Put> puts = Arrays.asList(put1, put2);
try {
TABLE.batch(puts, new Object[2]);
fail("should not reach here");
} catch (Exception e) {
LOG.info("Got exception for batch", e);
assertThat(e, instanceOf(RetriesExhaustedException.class));
assertThat(e.getCause(), instanceOf(RetriesExhaustedException.class));
assertThat(e.getCause().getCause(), instanceOf(CallTimeoutException.class));
}
}
use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.
the class TestReplicationSink method testRethrowRetriesExhaustedException.
@Test
public void testRethrowRetriesExhaustedException() throws Exception {
TableName notExistTable = TableName.valueOf("notExistTable");
List<WALEntry> entries = new ArrayList<>();
List<Cell> cells = new ArrayList<>();
for (int i = 0; i < 10; i++) {
entries.add(createEntry(notExistTable, i, KeyValue.Type.Put, cells));
}
try {
SINK.replicateEntries(entries, CellUtil.createCellScanner(cells.iterator()), replicationClusterId, baseNamespaceDir, hfileArchiveDir);
Assert.fail("Should re-throw TableNotFoundException.");
} catch (TableNotFoundException e) {
}
entries.clear();
cells.clear();
for (int i = 0; i < 10; i++) {
entries.add(createEntry(TABLE_NAME1, i, KeyValue.Type.Put, cells));
}
try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) {
try (Admin admin = conn.getAdmin()) {
admin.disableTable(TABLE_NAME1);
try {
SINK.replicateEntries(entries, CellUtil.createCellScanner(cells.iterator()), replicationClusterId, baseNamespaceDir, hfileArchiveDir);
Assert.fail("Should re-throw RetriesExhaustedWithDetailsException.");
} catch (RetriesExhaustedException e) {
} finally {
admin.enableTable(TABLE_NAME1);
}
}
}
}
use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.
the class CustomSaslAuthenticationProviderTestBase method testNegativeAuthentication.
@Test
public void testNegativeAuthentication() throws Exception {
// Validate that we can read that record back out as the user with our custom auth'n
UserGroupInformation user1 = UserGroupInformation.createUserForTesting("user1", new String[0]);
user1.addToken(createPasswordToken("user1", "definitely not the password", clusterId));
user1.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Configuration clientConf = getClientConf();
clientConf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
// should still be a SaslException in both the cases.
try (Connection conn = ConnectionFactory.createConnection(clientConf);
Table t = conn.getTable(tableName)) {
t.get(new Get(Bytes.toBytes("r1")));
fail("Should not successfully authenticate with HBase");
} catch (MasterRegistryFetchException mfe) {
Throwable cause = mfe.getCause();
assertTrue(cause.getMessage(), cause.getMessage().contains("SaslException"));
} catch (RetriesExhaustedException re) {
assertTrue(re.getMessage(), re.getMessage().contains("SaslException"));
} catch (Exception e) {
// Any other exception is unexpected.
fail("Unexpected exception caught, was expecting a authentication error: " + Throwables.getStackTraceAsString(e));
}
return null;
}
});
}
Aggregations