Search in sources :

Example 6 with RegionMovedException

use of org.apache.hadoop.hbase.exceptions.RegionMovedException in project hbase by apache.

the class ServerCall method setExceptionResponse.

static void setExceptionResponse(Throwable t, String errorMsg, ResponseHeader.Builder headerBuilder) {
    ExceptionResponse.Builder exceptionBuilder = ExceptionResponse.newBuilder();
    exceptionBuilder.setExceptionClassName(t.getClass().getName());
    exceptionBuilder.setStackTrace(errorMsg);
    exceptionBuilder.setDoNotRetry(t instanceof DoNotRetryIOException);
    if (t instanceof RegionMovedException) {
        // Special casing for this exception.  This is only one carrying a payload.
        // Do this instead of build a generic system for allowing exceptions carry
        // any kind of payload.
        RegionMovedException rme = (RegionMovedException) t;
        exceptionBuilder.setHostname(rme.getHostname());
        exceptionBuilder.setPort(rme.getPort());
    }
    // Set the exception as the result of the method invocation.
    headerBuilder.setException(exceptionBuilder.build());
}
Also used : ExceptionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ExceptionResponse) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RegionMovedException(org.apache.hadoop.hbase.exceptions.RegionMovedException)

Example 7 with RegionMovedException

use of org.apache.hadoop.hbase.exceptions.RegionMovedException 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

RegionMovedException (org.apache.hadoop.hbase.exceptions.RegionMovedException)7 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)4 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)2 RegionLocations (org.apache.hadoop.hbase.RegionLocations)2 Test (org.junit.Test)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Configuration (org.apache.hadoop.conf.Configuration)1 CallDroppedException (org.apache.hadoop.hbase.CallDroppedException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 RegionTooBusyException (org.apache.hadoop.hbase.RegionTooBusyException)1 ServerName (org.apache.hadoop.hbase.ServerName)1 OutOfOrderScannerNextException (org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException)1 RegionOpeningException (org.apache.hadoop.hbase.exceptions.RegionOpeningException)1 HMaster (org.apache.hadoop.hbase.master.HMaster)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 ExceptionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ExceptionResponse)1