當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getDefaultInstanceForType方法代碼示例

本文整理匯總了Java中com.google.protobuf.Message.getDefaultInstanceForType方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getDefaultInstanceForType方法的具體用法?Java Message.getDefaultInstanceForType怎麽用?Java Message.getDefaultInstanceForType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.protobuf.Message的用法示例。


在下文中一共展示了Message.getDefaultInstanceForType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: callExecService

import com.google.protobuf.Message; //導入方法依賴的package包/類
@Override
protected Message callExecService(RpcController controller, Descriptors.MethodDescriptor method,
                                Message request, Message responsePrototype)
    throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("Call: "+method.getName()+", "+request.toString());
  }

  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(ByteStringer.wrap(HConstants.EMPTY_BYTE_ARRAY))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();

  // TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
  CoprocessorServiceResponse result = ProtobufUtil.execService(controller,
    connection.getMaster(), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    Message.Builder builder = responsePrototype.newBuilderForType();
    ProtobufUtil.mergeFrom(builder, result.getValue().getValue());
    response = builder.build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Master Result is value=" + response);
  }
  return response;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:MasterCoprocessorRpcChannel.java

示例2: callExecService

import com.google.protobuf.Message; //導入方法依賴的package包/類
@Override
protected Message callExecService(RpcController controller,
    Descriptors.MethodDescriptor method, Message request, Message responsePrototype)
        throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("Call: " + method.getName() + ", " + request.toString());
  }
  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(ByteStringer.wrap(HConstants.EMPTY_BYTE_ARRAY))
          .setServiceName(method.getService().getFullName()).setMethodName(method.getName())
          .setRequest(request.toByteString()).build();

  // TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
  CoprocessorServiceResponse result =
      ProtobufUtil.execRegionServerService(controller, connection.getClient(serverName), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    Message.Builder builder = responsePrototype.newBuilderForType();
    ProtobufUtil.mergeFrom(builder, result.getValue().getValue());
    response = builder.build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Result is value=" + response);
  }
  return response;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:30,代碼來源:RegionServerCoprocessorRpcChannel.java

示例3: callExecService

import com.google.protobuf.Message; //導入方法依賴的package包/類
@Override
protected Message callExecService(RpcController controller,
    Descriptors.MethodDescriptor method, Message request, Message responsePrototype)
        throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("Call: "+method.getName()+", "+request.toString());
  }

  if (row == null) {
    throw new IllegalArgumentException("Missing row property for remote region location");
  }

  final RpcController rpcController = controller == null
      ? rpcControllerFactory.newController() : controller;

  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(ByteStringer.wrap(row))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  RegionServerCallable<CoprocessorServiceResponse> callable =
      new RegionServerCallable<CoprocessorServiceResponse>(connection, table, row) {
    @Override
    public CoprocessorServiceResponse call(int callTimeout) throws Exception {
      if (rpcController instanceof PayloadCarryingRpcController) {
        ((PayloadCarryingRpcController) rpcController).setPriority(tableName);
      }
      if (rpcController instanceof TimeLimitedRpcController) {
        ((TimeLimitedRpcController) rpcController).setCallTimeout(callTimeout);
      }
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      return ProtobufUtil.execService(rpcController, getStub(), call, regionName);
    }
  };
  CoprocessorServiceResponse result = rpcCallerFactory.<CoprocessorServiceResponse> newCaller()
      .callWithRetries(callable, operationTimeout);
  Message response = null;
  if (result.getValue().hasValue()) {
    Message.Builder builder = responsePrototype.newBuilderForType();
    ProtobufUtil.mergeFrom(builder, result.getValue().getValue());
    response = builder.build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  lastRegion = result.getRegion().getValue().toByteArray();
  if (LOG.isTraceEnabled()) {
    LOG.trace("Result is region=" + Bytes.toStringBinary(lastRegion) + ", value=" + response);
  }
  return response;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:52,代碼來源:RegionCoprocessorRpcChannel.java


注:本文中的com.google.protobuf.Message.getDefaultInstanceForType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。