org.apache.hadoop.hbase.ipc.RpcCall Java Examples

The following examples show how to use org.apache.hadoop.hbase.ipc.RpcCall. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegionProcedureStore.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Insert procedure may be called by master's rpc call. There are some check about the rpc call
 * when mutate region. Here unset the current rpc call and set it back in finally block. See
 * HBASE-23895 for more details.
 */
private void runWithoutRpcCall(Runnable runnable) {
  Optional<RpcCall> rpcCall = RpcServer.unsetCurrentCall();
  try {
    runnable.run();
  } finally {
    rpcCall.ifPresent(RpcServer::setCurrentCall);
  }
}
 
Example #2
Source File: RpcLogDetails.java    From hbase with Apache License 2.0 5 votes vote down vote up
public RpcLogDetails(RpcCall rpcCall, Message param, String clientAddress, long responseSize,
    String className, boolean isSlowLog, boolean isLargeLog) {
  this.rpcCall = rpcCall;
  this.param = param;
  this.clientAddress = clientAddress;
  this.responseSize = responseSize;
  this.className = className;
  this.isSlowLog = isSlowLog;
  this.isLargeLog = isLargeLog;
}
 
Example #3
Source File: LogEventHandler.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Called when a publisher has published an event to the {@link RingBuffer}
 *
 * @param event published to the {@link RingBuffer}
 * @param sequence of the event being processed
 * @param endOfBatch flag to indicate if this is the last event in a batch from
 *   the {@link RingBuffer}
 * @throws Exception if the EventHandler would like the exception handled further up the chain
 */
@Override
public void onEvent(RingBufferEnvelope event, long sequence, boolean endOfBatch)
    throws Exception {
  final RpcLogDetails rpcCallDetails = event.getPayload();
  final RpcCall rpcCall = rpcCallDetails.getRpcCall();
  final String clientAddress = rpcCallDetails.getClientAddress();
  final long responseSize = rpcCallDetails.getResponseSize();
  final String className = rpcCallDetails.getClassName();
  final SlowLogPayload.Type type = getLogType(rpcCallDetails);
  if (type == null) {
    return;
  }
  Descriptors.MethodDescriptor methodDescriptor = rpcCall.getMethod();
  Message param = rpcCallDetails.getParam();
  long receiveTime = rpcCall.getReceiveTime();
  long startTime = rpcCall.getStartTime();
  long endTime = System.currentTimeMillis();
  int processingTime = (int) (endTime - startTime);
  int qTime = (int) (startTime - receiveTime);
  final SlowLogParams slowLogParams = ProtobufUtil.getSlowLogParams(param);
  int numGets = 0;
  int numMutations = 0;
  int numServiceCalls = 0;
  if (param instanceof ClientProtos.MultiRequest) {
    ClientProtos.MultiRequest multi = (ClientProtos.MultiRequest) param;
    for (ClientProtos.RegionAction regionAction : multi.getRegionActionList()) {
      for (ClientProtos.Action action : regionAction.getActionList()) {
        if (action.hasMutation()) {
          numMutations++;
        }
        if (action.hasGet()) {
          numGets++;
        }
        if (action.hasServiceCall()) {
          numServiceCalls++;
        }
      }
    }
  }
  final String userName = rpcCall.getRequestUserName().orElse(StringUtils.EMPTY);
  final String methodDescriptorName =
    methodDescriptor != null ? methodDescriptor.getName() : StringUtils.EMPTY;
  SlowLogPayload slowLogPayload = SlowLogPayload.newBuilder()
    .setCallDetails(methodDescriptorName + "(" + param.getClass().getName() + ")")
    .setClientAddress(clientAddress)
    .setMethodName(methodDescriptorName)
    .setMultiGets(numGets)
    .setMultiMutations(numMutations)
    .setMultiServiceCalls(numServiceCalls)
    .setParam(slowLogParams != null ? slowLogParams.getParams() : StringUtils.EMPTY)
    .setProcessingTime(processingTime)
    .setQueueTime(qTime)
    .setRegionName(slowLogParams != null ? slowLogParams.getRegionName() : StringUtils.EMPTY)
    .setResponseSize(responseSize)
    .setServerClass(className)
    .setStartTime(startTime)
    .setType(type)
    .setUserName(userName)
    .build();
  queueForRingBuffer.add(slowLogPayload);
  if (isSlowLogTableEnabled) {
    if (!slowLogPayload.getRegionName().startsWith("hbase:slowlog")) {
      queueForSysTable.add(slowLogPayload);
    }
  }
}
 
Example #4
Source File: RpcLogDetails.java    From hbase with Apache License 2.0 4 votes vote down vote up
public RpcCall getRpcCall() {
  return rpcCall;
}
 
Example #5
Source File: TestSlowLogRecorder.java    From hbase with Apache License 2.0 4 votes vote down vote up
static RpcLogDetails getRpcLogDetails(String userName, String clientAddress, String className) {
  RpcCall rpcCall = getRpcCall(userName);
  return new RpcLogDetails(rpcCall, rpcCall.getParam(), clientAddress, 0, className, true, true);
}
 
Example #6
Source File: TestSlowLogRecorder.java    From hbase with Apache License 2.0 4 votes vote down vote up
private RpcLogDetails getRpcLogDetails(String userName, String clientAddress,
    String className, boolean isSlowLog, boolean isLargeLog) {
  RpcCall rpcCall = getRpcCall(userName);
  return new RpcLogDetails(rpcCall, rpcCall.getParam(), clientAddress, 0, className, isSlowLog,
    isLargeLog);
}
 
Example #7
Source File: RegionServerControl.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
private static RpcCallContext getRpcCallContext() {
    Optional<RpcCall> rpcCall = RpcServer.getCurrentCall();
    return rpcCall.isPresent() ? rpcCall.get() : null;
}