类org.apache.hadoop.hbase.ipc.RpcCall源码实例Demo

下面列出了怎么用org.apache.hadoop.hbase.ipc.RpcCall的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hbase   文件: RegionProcedureStore.java
/**
 * 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);
  }
}
 
源代码2 项目: hbase   文件: RpcLogDetails.java
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;
}
 
源代码3 项目: hbase   文件: LogEventHandler.java
/**
 * 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);
    }
  }
}
 
源代码4 项目: hbase   文件: RpcLogDetails.java
public RpcCall getRpcCall() {
  return rpcCall;
}
 
源代码5 项目: hbase   文件: TestSlowLogRecorder.java
static RpcLogDetails getRpcLogDetails(String userName, String clientAddress, String className) {
  RpcCall rpcCall = getRpcCall(userName);
  return new RpcLogDetails(rpcCall, rpcCall.getParam(), clientAddress, 0, className, true, true);
}
 
源代码6 项目: hbase   文件: TestSlowLogRecorder.java
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);
}
 
源代码7 项目: spliceengine   文件: RegionServerControl.java
private static RpcCallContext getRpcCallContext() {
    Optional<RpcCall> rpcCall = RpcServer.getCurrentCall();
    return rpcCall.isPresent() ? rpcCall.get() : null;
}
 
 类所在包
 类方法
 同包方法