Search in sources :

Example 51 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class RpcRetryingCallerImpl method translateException.

/**
   * Get the good or the remote exception if any, throws the DoNotRetryIOException.
   * @param t the throwable to analyze
   * @return the translated exception, if it's not a DoNotRetryIOException
   * @throws DoNotRetryIOException - if we find it, we throw it instead of translating.
   */
static Throwable translateException(Throwable t) throws DoNotRetryIOException {
    if (t instanceof UndeclaredThrowableException) {
        if (t.getCause() != null) {
            t = t.getCause();
        }
    }
    if (t instanceof RemoteException) {
        t = ((RemoteException) t).unwrapRemoteException();
    }
    if (t instanceof LinkageError) {
        throw new DoNotRetryIOException(t);
    }
    if (t instanceof ServiceException) {
        ServiceException se = (ServiceException) t;
        Throwable cause = se.getCause();
        if (cause != null && cause instanceof DoNotRetryIOException) {
            throw (DoNotRetryIOException) cause;
        }
        // Don't let ServiceException out; its rpc specific.
        t = cause;
        // t could be a RemoteException so go around again.
        translateException(t);
    } else if (t instanceof DoNotRetryIOException) {
        throw (DoNotRetryIOException) t;
    }
    return t;
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) RemoteException(org.apache.hadoop.ipc.RemoteException)

Example 52 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class RpcServer method call.

/**
   * This is a server side method, which is invoked over RPC. On success
   * the return response has protobuf response payload. On failure, the
   * exception name and the stack trace are returned in the protobuf response.
   */
@Override
public Pair<Message, CellScanner> call(RpcCall call, MonitoredRPCHandler status) throws IOException {
    try {
        MethodDescriptor md = call.getMethod();
        Message param = call.getParam();
        status.setRPC(md.getName(), new Object[] { param }, call.getReceiveTime());
        // TODO: Review after we add in encoded data blocks.
        status.setRPCPacket(param);
        status.resume("Servicing call");
        //get an instance of the method arg type
        HBaseRpcController controller = new HBaseRpcControllerImpl(call.getCellScanner());
        controller.setCallTimeout(call.getTimeout());
        Message result = call.getService().callBlockingMethod(md, controller, param);
        long receiveTime = call.getReceiveTime();
        long startTime = call.getStartTime();
        long endTime = System.currentTimeMillis();
        int processingTime = (int) (endTime - startTime);
        int qTime = (int) (startTime - receiveTime);
        int totalTime = (int) (endTime - receiveTime);
        if (LOG.isTraceEnabled()) {
            LOG.trace(CurCall.get().toString() + ", response " + TextFormat.shortDebugString(result) + " queueTime: " + qTime + " processingTime: " + processingTime + " totalTime: " + totalTime);
        }
        // Use the raw request call size for now.
        long requestSize = call.getSize();
        long responseSize = result.getSerializedSize();
        if (call.isClientCellBlockSupported()) {
            // Include the payload size in HBaseRpcController
            responseSize += call.getResponseCellSize();
        }
        metrics.dequeuedCall(qTime);
        metrics.processedCall(processingTime);
        metrics.totalCall(totalTime);
        metrics.receivedRequest(requestSize);
        metrics.sentResponse(responseSize);
        // log any RPC responses that are slower than the configured warn
        // response time or larger than configured warning size
        boolean tooSlow = (processingTime > warnResponseTime && warnResponseTime > -1);
        boolean tooLarge = (responseSize > warnResponseSize && warnResponseSize > -1);
        if (tooSlow || tooLarge) {
            // when tagging, we let TooLarge trump TooSmall to keep output simple
            // note that large responses will often also be slow.
            logResponse(param, md.getName(), md.getName() + "(" + param.getClass().getName() + ")", (tooLarge ? "TooLarge" : "TooSlow"), status.getClient(), startTime, processingTime, qTime, responseSize);
        }
        return new Pair<>(result, controller.cellScanner());
    } catch (Throwable e) {
        // need to pass it over the wire.
        if (e instanceof ServiceException) {
            if (e.getCause() == null) {
                LOG.debug("Caught a ServiceException with null cause", e);
            } else {
                e = e.getCause();
            }
        }
        // increment the number of requests that were exceptions.
        metrics.exception(e);
        if (e instanceof LinkageError)
            throw new DoNotRetryIOException(e);
        if (e instanceof IOException)
            throw (IOException) e;
        LOG.error("Unexpected throwable object ", e);
        throw new IOException(e.getMessage(), e);
    }
}
Also used : Message(org.apache.hadoop.hbase.shaded.com.google.protobuf.Message) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) MethodDescriptor(org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) Pair(org.apache.hadoop.hbase.util.Pair)

Example 53 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class HRegionServer method reportForDuty.

/*
   * Let the master know we're here Run initialization using parameters passed
   * us by the master.
   * @return A Map of key/value configurations we got from the Master else
   * null if we failed to register.
   * @throws IOException
   */
private RegionServerStartupResponse reportForDuty() throws IOException {
    ServerName masterServerName = createRegionServerStatusStub(true);
    if (masterServerName == null)
        return null;
    RegionServerStartupResponse result = null;
    try {
        rpcServices.requestCount.reset();
        rpcServices.rpcGetRequestCount.reset();
        rpcServices.rpcScanRequestCount.reset();
        rpcServices.rpcMultiRequestCount.reset();
        rpcServices.rpcMutateRequestCount.reset();
        LOG.info("reportForDuty to master=" + masterServerName + " with port=" + rpcServices.isa.getPort() + ", startcode=" + this.startcode);
        long now = EnvironmentEdgeManager.currentTime();
        int port = rpcServices.isa.getPort();
        RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();
        if (shouldUseThisHostnameInstead()) {
            request.setUseThisHostnameInstead(useThisHostnameInstead);
        }
        request.setPort(port);
        request.setServerStartCode(this.startcode);
        request.setServerCurrentTime(now);
        result = this.rssStub.regionServerStartup(null, request.build());
    } catch (ServiceException se) {
        IOException ioe = ProtobufUtil.getRemoteException(se);
        if (ioe instanceof ClockOutOfSyncException) {
            LOG.fatal("Master rejected startup because clock is out of sync", ioe);
            // Re-throw IOE will cause RS to abort
            throw ioe;
        } else if (ioe instanceof ServerNotRunningYetException) {
            LOG.debug("Master is not running yet");
        } else {
            LOG.warn("error telling master we are up", se);
        }
        rssStub = null;
    }
    return result;
}
Also used : ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ClockOutOfSyncException(org.apache.hadoop.hbase.ClockOutOfSyncException) ServerName(org.apache.hadoop.hbase.ServerName) RegionServerStartupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) RegionServerStartupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest)

Example 54 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class HRegionServer method tryRegionServerReport.

@VisibleForTesting
protected void tryRegionServerReport(long reportStartTime, long reportEndTime) throws IOException {
    RegionServerStatusService.BlockingInterface rss = rssStub;
    if (rss == null) {
        // the current server could be stopping.
        return;
    }
    ClusterStatusProtos.ServerLoad sl = buildServerLoad(reportStartTime, reportEndTime);
    try {
        RegionServerReportRequest.Builder request = RegionServerReportRequest.newBuilder();
        ServerName sn = ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());
        request.setServer(ProtobufUtil.toServerName(sn));
        request.setLoad(sl);
        rss.regionServerReport(null, request.build());
    } catch (ServiceException se) {
        IOException ioe = ProtobufUtil.getRemoteException(se);
        if (ioe instanceof YouAreDeadException) {
            // This will be caught and handled as a fatal error in run()
            throw ioe;
        }
        if (rssStub == rss) {
            rssStub = null;
        }
        // Couldn't connect to the master, get location from zk and reconnect
        // Method blocks until new master is found or we are stopped
        createRegionServerStatusStub(true);
    }
}
Also used : ClusterStatusProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos) RegionServerReportRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) ServerName(org.apache.hadoop.hbase.ServerName) RegionServerStatusService(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionServerStatusService) YouAreDeadException(org.apache.hadoop.hbase.YouAreDeadException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 55 with ServiceException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException in project hbase by apache.

the class MasterRpcServices method getSecurityCapabilities.

/**
   * Returns the security capabilities in effect on the cluster
   */
@Override
public SecurityCapabilitiesResponse getSecurityCapabilities(RpcController controller, SecurityCapabilitiesRequest request) throws ServiceException {
    SecurityCapabilitiesResponse.Builder response = SecurityCapabilitiesResponse.newBuilder();
    try {
        master.checkInitialized();
        Set<Capability> capabilities = new HashSet<>();
        // Authentication
        if (User.isHBaseSecurityEnabled(master.getConfiguration())) {
            capabilities.add(Capability.SECURE_AUTHENTICATION);
        } else {
            capabilities.add(Capability.SIMPLE_AUTHENTICATION);
        }
        // The AccessController can provide AUTHORIZATION and CELL_AUTHORIZATION
        if (master.cpHost != null && master.cpHost.findCoprocessor(AccessController.class.getName()) != null) {
            if (AccessController.isAuthorizationSupported(master.getConfiguration())) {
                capabilities.add(Capability.AUTHORIZATION);
            }
            if (AccessController.isCellAuthorizationSupported(master.getConfiguration())) {
                capabilities.add(Capability.CELL_AUTHORIZATION);
            }
        }
        // The VisibilityController can provide CELL_VISIBILITY
        if (master.cpHost != null && master.cpHost.findCoprocessor(VisibilityController.class.getName()) != null) {
            if (VisibilityController.isCellAuthorizationSupported(master.getConfiguration())) {
                capabilities.add(Capability.CELL_VISIBILITY);
            }
        }
        response.addAllCapabilities(capabilities);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    return response.build();
}
Also used : AccessController(org.apache.hadoop.hbase.security.access.AccessController) Capability(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse.Capability) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) SecurityCapabilitiesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) VisibilityController(org.apache.hadoop.hbase.security.visibility.VisibilityController) HashSet(java.util.HashSet)

Aggregations

ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)95 IOException (java.io.IOException)76 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)65 InterruptedIOException (java.io.InterruptedIOException)28 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)24 ServerName (org.apache.hadoop.hbase.ServerName)16 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)15 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)14 ArrayList (java.util.ArrayList)12 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)12 TableName (org.apache.hadoop.hbase.TableName)10 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)10 Test (org.junit.Test)9 CellScanner (org.apache.hadoop.hbase.CellScanner)5 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)4 ClusterConnection (org.apache.hadoop.hbase.client.ClusterConnection)4 Result (org.apache.hadoop.hbase.client.Result)4 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)4 RpcCallContext (org.apache.hadoop.hbase.ipc.RpcCallContext)4 OperationQuota (org.apache.hadoop.hbase.quotas.OperationQuota)4