Search in sources :

Example 16 with RetriesExhaustedException

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));
    }
}
Also used : Put(org.apache.hadoop.hbase.client.Put) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) SocketTimeoutException(java.net.SocketTimeoutException) IOException(java.io.IOException) CallTimeoutException(org.apache.hadoop.hbase.ipc.CallTimeoutException) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) Test(org.junit.Test)

Example 17 with RetriesExhaustedException

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);
            }
        }
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) ArrayList(java.util.ArrayList) Connection(org.apache.hadoop.hbase.client.Connection) WALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry) Admin(org.apache.hadoop.hbase.client.Admin) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 18 with RetriesExhaustedException

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;
        }
    });
}
Also used : MasterRegistryFetchException(org.apache.hadoop.hbase.exceptions.MasterRegistryFetchException) Table(org.apache.hadoop.hbase.client.Table) Configuration(org.apache.hadoop.conf.Configuration) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) Get(org.apache.hadoop.hbase.client.Get) Connection(org.apache.hadoop.hbase.client.Connection) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) AccessDeniedException(org.apache.hadoop.hbase.security.AccessDeniedException) IOException(java.io.IOException) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) MasterRegistryFetchException(org.apache.hadoop.hbase.exceptions.MasterRegistryFetchException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Aggregations

RetriesExhaustedException (org.apache.hadoop.hbase.client.RetriesExhaustedException)18 Test (org.junit.Test)10 IOException (java.io.IOException)9 SocketTimeoutException (java.net.SocketTimeoutException)5 Get (org.apache.hadoop.hbase.client.Get)4 CallTimeoutException (org.apache.hadoop.hbase.ipc.CallTimeoutException)4 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)3 Connection (org.apache.hadoop.hbase.client.Connection)3 Put (org.apache.hadoop.hbase.client.Put)3 Table (org.apache.hadoop.hbase.client.Table)3 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)3 FileNotFoundException (java.io.FileNotFoundException)2 ConnectException (java.net.ConnectException)2 ArrayList (java.util.ArrayList)2 Configuration (org.apache.hadoop.conf.Configuration)2 TableName (org.apache.hadoop.hbase.TableName)2 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)2 EOFException (java.io.EOFException)1 InterruptedIOException (java.io.InterruptedIOException)1 Socket (java.net.Socket)1