Search in sources :

Example 1 with RetriesExhaustedException

use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.

the class MetaTableLocator method verifyRegionLocation.

/**
   * Verify we can connect to <code>hostingServer</code> and that its carrying
   * <code>regionName</code>.
   * @param hostingServer Interface to the server hosting <code>regionName</code>
   * @param address The servername that goes with the <code>metaServer</code>
   * Interface.  Used logging.
   * @param regionName The regionname we are interested in.
   * @return True if we were able to verify the region located at other side of
   * the Interface.
   * @throws IOException
   */
// TODO: We should be able to get the ServerName from the AdminProtocol
// rather than have to pass it in.  Its made awkward by the fact that the
// HRI is likely a proxy against remote server so the getServerName needs
// to be fixed to go to a local method or to a cache before we can do this.
private boolean verifyRegionLocation(final ClusterConnection connection, AdminService.BlockingInterface hostingServer, final ServerName address, final byte[] regionName) throws IOException {
    if (hostingServer == null) {
        LOG.info("Passed hostingServer is null");
        return false;
    }
    Throwable t;
    HBaseRpcController controller = connection.getRpcControllerFactory().newController();
    try {
        // Try and get regioninfo from the hosting server.
        return ProtobufUtil.getRegionInfo(controller, hostingServer, regionName) != null;
    } catch (ConnectException e) {
        t = e;
    } catch (RetriesExhaustedException e) {
        t = e;
    } catch (RemoteException e) {
        IOException ioe = e.unwrapRemoteException();
        t = ioe;
    } catch (IOException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause instanceof EOFException) {
            t = cause;
        } else if (cause != null && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
            t = cause;
        } else {
            t = e;
        }
    }
    LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) + " at address=" + address + ", exception=" + t.getMessage());
    return false;
}
Also used : HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) EOFException(java.io.EOFException) IOException(java.io.IOException) RemoteException(org.apache.hadoop.ipc.RemoteException) ConnectException(java.net.ConnectException)

Example 2 with RetriesExhaustedException

use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.

the class SplitLogWorker method splitLog.

/**
 * @return Result either DONE, RESIGNED, or ERR.
 */
static Status splitLog(String filename, CancelableProgressable p, Configuration conf, RegionServerServices server, LastSequenceId sequenceIdChecker, WALFactory factory) {
    Path walDir;
    FileSystem fs;
    try {
        walDir = CommonFSUtils.getWALRootDir(conf);
        fs = walDir.getFileSystem(conf);
    } catch (IOException e) {
        LOG.warn("Resigning, could not find root dir or fs", e);
        return Status.RESIGNED;
    }
    try {
        if (!processSyncReplicationWAL(filename, conf, server, fs, walDir)) {
            return Status.DONE;
        }
    } catch (IOException e) {
        LOG.warn("failed to process sync replication wal {}", filename, e);
        return Status.RESIGNED;
    }
    // encountered a bad non-retry-able persistent error.
    try {
        SplitLogWorkerCoordination splitLogWorkerCoordination = server.getCoordinatedStateManager() == null ? null : server.getCoordinatedStateManager().getSplitLogWorkerCoordination();
        if (!WALSplitter.splitLogFile(walDir, fs.getFileStatus(new Path(walDir, filename)), fs, conf, p, sequenceIdChecker, splitLogWorkerCoordination, factory, server)) {
            return Status.PREEMPTED;
        }
    } catch (InterruptedIOException iioe) {
        LOG.warn("Resigning, interrupted splitting WAL {}", filename, iioe);
        return Status.RESIGNED;
    } catch (IOException e) {
        if (e instanceof FileNotFoundException) {
            // A wal file may not exist anymore. Nothing can be recovered so move on
            LOG.warn("Done, WAL {} does not exist anymore", filename, e);
            return Status.DONE;
        }
        Throwable cause = e.getCause();
        if (e instanceof RetriesExhaustedException && (cause instanceof NotServingRegionException || cause instanceof ConnectException || cause instanceof SocketTimeoutException)) {
            LOG.warn("Resigning, can't connect to target regionserver splitting WAL {}", filename, e);
            return Status.RESIGNED;
        } else if (cause instanceof InterruptedException) {
            LOG.warn("Resigning, interrupted splitting WAL {}", filename, e);
            return Status.RESIGNED;
        }
        LOG.warn("Error splitting WAL {}", filename, e);
        return Status.ERR;
    }
    LOG.debug("Done splitting WAL {}", filename);
    return Status.DONE;
}
Also used : Path(org.apache.hadoop.fs.Path) InterruptedIOException(java.io.InterruptedIOException) SplitLogWorkerCoordination(org.apache.hadoop.hbase.coordination.SplitLogWorkerCoordination) SocketTimeoutException(java.net.SocketTimeoutException) RetriesExhaustedException(org.apache.hadoop.hbase.client.RetriesExhaustedException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) FileSystem(org.apache.hadoop.fs.FileSystem) FileNotFoundException(java.io.FileNotFoundException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 3 with RetriesExhaustedException

use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.

the class TestClientOperationTimeout method testPutTimeout.

/**
 * Tests that a put on a table throws {@link RetriesExhaustedException} when the operation takes
 * longer than 'hbase.client.operation.timeout'.
 */
@Test
public void testPutTimeout() {
    DELAY_MUTATE = 600;
    Put put = new Put(ROW);
    put.addColumn(FAMILY, QUALIFIER, VALUE);
    try {
        TABLE.put(put);
        fail("should not reach here");
    } catch (Exception e) {
        LOG.info("Got exception for put", e);
        assertThat(e, instanceOf(RetriesExhaustedException.class));
        assertThat(e.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 4 with RetriesExhaustedException

use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.

the class TestClientOperationTimeout method testScanTimeout.

/**
 * Tests that scan on a table throws {@link RetriesExhaustedException} when the operation takes
 * longer than 'hbase.client.scanner.timeout.period'.
 */
@Test
public void testScanTimeout() throws IOException, InterruptedException {
    // cache the region location.
    try (RegionLocator locator = TABLE.getRegionLocator()) {
        locator.getRegionLocation(HConstants.EMPTY_BYTE_ARRAY);
    }
    // sleep a bit to make sure the location has been cached as it is an async operation.
    Thread.sleep(100);
    DELAY_SCAN = 600;
    try (ResultScanner scanner = TABLE.getScanner(new Scan())) {
        scanner.next();
        fail("should not reach here");
    } catch (Exception e) {
        LOG.info("Got exception for scan", e);
        assertThat(e, instanceOf(RetriesExhaustedException.class));
        assertThat(e.getCause(), instanceOf(CallTimeoutException.class));
    }
}
Also used : RegionLocator(org.apache.hadoop.hbase.client.RegionLocator) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) Scan(org.apache.hadoop.hbase.client.Scan) 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 5 with RetriesExhaustedException

use of org.apache.hadoop.hbase.client.RetriesExhaustedException in project hbase by apache.

the class TestClientOperationTimeout method testGetTimeout.

/**
 * Tests that a get on a table throws {@link RetriesExhaustedException} when the operation takes
 * longer than 'hbase.client.operation.timeout'.
 */
@Test
public void testGetTimeout() {
    DELAY_GET = 600;
    try {
        TABLE.get(new Get(ROW));
        fail("should not reach here");
    } catch (Exception e) {
        LOG.info("Got exception for get", e);
        assertThat(e, instanceOf(RetriesExhaustedException.class));
        assertThat(e.getCause(), instanceOf(CallTimeoutException.class));
    }
}
Also used : Get(org.apache.hadoop.hbase.client.Get) 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)

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