Search in sources :

Example 21 with NotServingRegionException

use of org.apache.hadoop.hbase.NotServingRegionException in project hbase by apache.

the class ServerManager method closeRegionSilentlyAndWait.

/**
 * Contacts a region server and waits up to timeout ms
 * to close the region.  This bypasses the active hmaster.
 * Pass -1 as timeout if you do not want to wait on result.
 */
public static void closeRegionSilentlyAndWait(AsyncClusterConnection connection, ServerName server, RegionInfo region, long timeout) throws IOException, InterruptedException {
    AsyncRegionServerAdmin admin = connection.getRegionServerAdmin(server);
    try {
        FutureUtils.get(admin.closeRegion(ProtobufUtil.buildCloseRegionRequest(server, region.getRegionName())));
    } catch (IOException e) {
        LOG.warn("Exception when closing region: " + region.getRegionNameAsString(), e);
    }
    if (timeout < 0) {
        return;
    }
    long expiration = timeout + EnvironmentEdgeManager.currentTime();
    while (EnvironmentEdgeManager.currentTime() < expiration) {
        try {
            RegionInfo rsRegion = ProtobufUtil.toRegionInfo(FutureUtils.get(admin.getRegionInfo(RequestConverter.buildGetRegionInfoRequest(region.getRegionName()))).getRegionInfo());
            if (rsRegion == null) {
                return;
            }
        } catch (IOException ioe) {
            if (ioe instanceof NotServingRegionException || (ioe instanceof RemoteWithExtrasException && ((RemoteWithExtrasException) ioe).unwrapRemoteException() instanceof NotServingRegionException)) {
                // no need to retry again
                return;
            }
            LOG.warn("Exception when retrieving regioninfo from: " + region.getRegionNameAsString(), ioe);
        }
        Thread.sleep(1000);
    }
    throw new IOException("Region " + region + " failed to close within" + " timeout " + timeout);
}
Also used : AsyncRegionServerAdmin(org.apache.hadoop.hbase.client.AsyncRegionServerAdmin) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) RemoteWithExtrasException(org.apache.hadoop.hbase.ipc.RemoteWithExtrasException)

Example 22 with NotServingRegionException

use of org.apache.hadoop.hbase.NotServingRegionException in project hbase by apache.

the class TestRpcMetrics method testSourceMethods.

/**
 * Test to make sure that all the actively called method on MetricsHBaseServer work.
 */
@Test
public void testSourceMethods() {
    MetricsHBaseServer mrpc = new MetricsHBaseServer("HMaster", new MetricsHBaseServerWrapperStub());
    MetricsHBaseServerSource serverSource = mrpc.getMetricsSource();
    for (int i = 0; i < 12; i++) {
        mrpc.authenticationFailure();
    }
    for (int i = 0; i < 13; i++) {
        mrpc.authenticationSuccess();
    }
    HELPER.assertCounter("authenticationFailures", 12, serverSource);
    HELPER.assertCounter("authenticationSuccesses", 13, serverSource);
    for (int i = 0; i < 14; i++) {
        mrpc.authorizationSuccess();
    }
    for (int i = 0; i < 15; i++) {
        mrpc.authorizationFailure();
    }
    HELPER.assertCounter("authorizationSuccesses", 14, serverSource);
    HELPER.assertCounter("authorizationFailures", 15, serverSource);
    mrpc.dequeuedCall(100);
    mrpc.processedCall(101);
    mrpc.totalCall(102);
    HELPER.assertCounter("queueCallTime_NumOps", 1, serverSource);
    HELPER.assertCounter("processCallTime_NumOps", 1, serverSource);
    HELPER.assertCounter("totalCallTime_NumOps", 1, serverSource);
    mrpc.sentBytes(103);
    mrpc.sentBytes(103);
    mrpc.sentBytes(103);
    mrpc.receivedBytes(104);
    mrpc.receivedBytes(104);
    HELPER.assertCounter("sentBytes", 309, serverSource);
    HELPER.assertCounter("receivedBytes", 208, serverSource);
    mrpc.receivedRequest(105);
    mrpc.sentResponse(106);
    HELPER.assertCounter("requestSize_NumOps", 1, serverSource);
    HELPER.assertCounter("responseSize_NumOps", 1, serverSource);
    mrpc.exception(null);
    HELPER.assertCounter("exceptions", 1, serverSource);
    mrpc.exception(new RegionMovedException(ServerName.parseServerName("localhost:60020"), 100));
    mrpc.exception(new RegionTooBusyException("Some region"));
    mrpc.exception(new OutOfOrderScannerNextException());
    mrpc.exception(new NotServingRegionException());
    mrpc.exception(new CallDroppedException());
    HELPER.assertCounter("exceptions.RegionMovedException", 1, serverSource);
    HELPER.assertCounter("exceptions.RegionTooBusyException", 1, serverSource);
    HELPER.assertCounter("exceptions.OutOfOrderScannerNextException", 1, serverSource);
    HELPER.assertCounter("exceptions.NotServingRegionException", 1, serverSource);
    HELPER.assertCounter("exceptions.callDropped", 1, serverSource);
    HELPER.assertCounter("exceptions", 6, serverSource);
}
Also used : RegionTooBusyException(org.apache.hadoop.hbase.RegionTooBusyException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) RegionMovedException(org.apache.hadoop.hbase.exceptions.RegionMovedException) CallDroppedException(org.apache.hadoop.hbase.CallDroppedException) OutOfOrderScannerNextException(org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException) Test(org.junit.Test)

Aggregations

NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)22 IOException (java.io.IOException)11 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)7 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)5 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)5 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)4 ServerName (org.apache.hadoop.hbase.ServerName)4 Test (org.junit.Test)4 InterruptedIOException (java.io.InterruptedIOException)3 UncheckedIOException (java.io.UncheckedIOException)3 TableName (org.apache.hadoop.hbase.TableName)3 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)3 Pair (org.apache.hadoop.hbase.util.Pair)3 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)3 FileNotFoundException (java.io.FileNotFoundException)2 List (java.util.List)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 CellScanner (org.apache.hadoop.hbase.CellScanner)2