当前位置: 首页>>代码示例>>Java>>正文


Java BlockingService.callBlockingMethod方法代码示例

本文整理汇总了Java中com.google.protobuf.BlockingService.callBlockingMethod方法的典型用法代码示例。如果您正苦于以下问题:Java BlockingService.callBlockingMethod方法的具体用法?Java BlockingService.callBlockingMethod怎么用?Java BlockingService.callBlockingMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.BlockingService的用法示例。


在下文中一共展示了BlockingService.callBlockingMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import com.google.protobuf.BlockingService; //导入方法依赖的package包/类
/**
 * 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(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    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);
    }
    long requestSize = param.getSerializedSize();
    long responseSize = result.getSerializedSize();
    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(new Object[]{param},
          md.getName(), md.getName() + "(" + param.getClass().getName() + ")",
          (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result, controller.cellScanner());
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) 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);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:66,代码来源:RpcServer.java

示例2: call

import com.google.protobuf.BlockingService; //导入方法依赖的package包/类
/**
 * 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(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    int processingTime = (int) (System.currentTimeMillis() - startTime);
    int qTime = (int) (startTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime);
    }
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    long responseSize = result.getSerializedSize();
    // 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(new Object[]{param},
          md.getName(), md.getName() + "(" + param.getClass().getName() + ")",
          (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result, controller.cellScanner());
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();
    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);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:55,代码来源:RpcServer.java

示例3: call

import com.google.protobuf.BlockingService; //导入方法依赖的package包/类
/**
 * 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.
 */
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    int processingTime = (int) (System.currentTimeMillis() - startTime);
    int qTime = (int) (startTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime);
    }
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    long responseSize = result.getSerializedSize();
    // 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.
      StringBuilder buffer = new StringBuilder(256);
      buffer.append(md.getName());
      buffer.append("(");
      buffer.append(param.getClass().getName());
      buffer.append(")");
      logResponse(new Object[]{param},
          md.getName(), buffer.toString(), (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result,
      controller != null? controller.cellScanner(): null);
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();
    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);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:59,代码来源:RpcServer.java

示例4: call

import com.google.protobuf.BlockingService; //导入方法依赖的package包/类
/**
 * 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.
 */
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    int processingTime = (int) (System.currentTimeMillis() - startTime);
    int qTime = (int) (startTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime);
    }
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    long responseSize = result.getSerializedSize();
    // 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.
      StringBuilder buffer = new StringBuilder(256);
      buffer.append(md.getName());
      buffer.append("(");
      buffer.append(param.getClass().getName());
      buffer.append(")");
      logResponse(new Object[]{param},
          md.getName(), buffer.toString(), (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result, controller.cellScanner());
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();
    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);
  }
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:58,代码来源:RpcServer.java

示例5: call

import com.google.protobuf.BlockingService; //导入方法依赖的package包/类
/**
 * 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.
 */
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    int processingTime = (int) (System.currentTimeMillis() - startTime);
    int qTime = (int) (startTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime);
    }
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    long responseSize = result.getSerializedSize();
    // 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.
      StringBuilder buffer = new StringBuilder(256);
      buffer.append(md.getName());
      buffer.append("(");
      buffer.append(param.getClass().getName());
      buffer.append(")");
      logResponse(new Object[]{param},
          md.getName(), buffer.toString(), (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result,
      controller != null? controller.cellScanner(): null);
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();
    if (e instanceof IOException) throw (IOException)e;
    LOG.error("Unexpected throwable object ", e);
    throw new IOException(e.getMessage(), e);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:58,代码来源:RpcServer.java


注:本文中的com.google.protobuf.BlockingService.callBlockingMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。