Java 类org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse 实例源码

项目:ditb    文件:RSRpcServices.java   
@Override
public CoprocessorServiceResponse execService(final RpcController controller,
    final CoprocessorServiceRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    Region region = getRegion(request.getRegion());
    Message result = execServiceOnRegion(region, request.getCall());
    CoprocessorServiceResponse.Builder builder =
      CoprocessorServiceResponse.newBuilder();
    builder.setRegion(RequestConverter.buildRegionSpecifier(
      RegionSpecifierType.REGION_NAME, region.getRegionInfo().getRegionName()));
    builder.setValue(
      builder.getValueBuilder().setName(result.getClass().getName())
        .setValue(result.toByteString()));
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:ditb    文件:ProtobufUtil.java   
/**
 * Make a region server endpoint call
 * @param client
 * @param call
 * @return CoprocessorServiceResponse
 * @throws IOException
 */
public static CoprocessorServiceResponse execRegionServerService(
    final RpcController controller, final ClientService.BlockingInterface client,
    final CoprocessorServiceCall call)
    throws IOException {
  CoprocessorServiceRequest request =
      CoprocessorServiceRequest
          .newBuilder()
          .setCall(call)
          .setRegion(
            RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY))
          .build();
  try {
    CoprocessorServiceResponse response = client.execRegionServerService(controller, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:pbase    文件:RSRpcServices.java   
@Override
public CoprocessorServiceResponse execService(final RpcController controller,
                                              final CoprocessorServiceRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        HRegion region = getRegion(request.getRegion());
        Message result = execServiceOnRegion(region, request.getCall());
        CoprocessorServiceResponse.Builder builder =
                CoprocessorServiceResponse.newBuilder();
        builder.setRegion(RequestConverter.buildRegionSpecifier(
                RegionSpecifierType.REGION_NAME, region.getRegionName()));
        builder.setValue(
                builder.getValueBuilder().setName(result.getClass().getName())
                        .setValue(result.toByteString()));
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
项目:pbase    文件:ProtobufUtil.java   
/**
 * Make a region server endpoint call
 * @param client
 * @param call
 * @return CoprocessorServiceResponse
 * @throws IOException
 */
public static CoprocessorServiceResponse execRegionServerService(
    final ClientService.BlockingInterface client, final CoprocessorServiceCall call)
    throws IOException {
  CoprocessorServiceRequest request =
      CoprocessorServiceRequest
          .newBuilder()
          .setCall(call)
          .setRegion(
            RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY))
          .build();
  try {
    CoprocessorServiceResponse response = client.execRegionServerService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:pbase    文件:RegionServerCoprocessorRpcChannel.java   
@Override
protected Message callExecService(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();
  CoprocessorServiceResponse result =
      ProtobufUtil.execRegionServerService(connection.getClient(serverName), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    response =
        responsePrototype.newBuilderForType().mergeFrom(result.getValue().getValue()).build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Result is value=" + response);
  }
  return response;
}
项目:HIndex    文件:HRegionServer.java   
@Override
public CoprocessorServiceResponse execService(final RpcController controller,
    final CoprocessorServiceRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    Message result = execServiceOnRegion(region, request.getCall());
    CoprocessorServiceResponse.Builder builder =
        CoprocessorServiceResponse.newBuilder();
    builder.setRegion(RequestConverter.buildRegionSpecifier(
        RegionSpecifierType.REGION_NAME, region.getRegionName()));
    builder.setValue(
        builder.getValueBuilder().setName(result.getClass().getName())
            .setValue(result.toByteString()));
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:PyroDB    文件:RSRpcServices.java   
@Override
public CoprocessorServiceResponse execService(final RpcController controller,
    final CoprocessorServiceRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    Message result = execServiceOnRegion(region, request.getCall());
    CoprocessorServiceResponse.Builder builder =
      CoprocessorServiceResponse.newBuilder();
    builder.setRegion(RequestConverter.buildRegionSpecifier(
      RegionSpecifierType.REGION_NAME, region.getRegionName()));
    builder.setValue(
      builder.getValueBuilder().setName(result.getClass().getName())
        .setValue(result.toByteString()));
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:c5    文件:HRegionServer.java   
@Override
public CoprocessorServiceResponse execService(final RpcController controller,
    final CoprocessorServiceRequest request) throws ServiceException {
  try {
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    // ignore the passed in controller (from the serialized call)
    ServerRpcController execController = new ServerRpcController();
    Message result = region.execService(execController, request.getCall());
    if (execController.getFailedOn() != null) {
      throw execController.getFailedOn();
    }
    CoprocessorServiceResponse.Builder builder =
        CoprocessorServiceResponse.newBuilder();
    builder.setRegion(RequestConverter.buildRegionSpecifier(
        RegionSpecifierType.REGION_NAME, region.getRegionName()));
    builder.setValue(
        builder.getValueBuilder().setName(result.getClass().getName())
            .setValue(result.toByteString()));
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:DominoHBase    文件:HRegionServer.java   
@Override
public CoprocessorServiceResponse execService(final RpcController controller,
    final CoprocessorServiceRequest request) throws ServiceException {
  try {
    requestCount.increment();
    HRegion region = getRegion(request.getRegion());
    // ignore the passed in controller (from the serialized call)
    ServerRpcController execController = new ServerRpcController();
    Message result = region.execService(execController, request.getCall());
    if (execController.getFailedOn() != null) {
      throw execController.getFailedOn();
    }
    CoprocessorServiceResponse.Builder builder =
        CoprocessorServiceResponse.newBuilder();
    builder.setRegion(RequestConverter.buildRegionSpecifier(
        RegionSpecifierType.REGION_NAME, region.getRegionName()));
    builder.setValue(
        builder.getValueBuilder().setName(result.getClass().getName())
            .setValue(result.toByteString()));
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:ditb    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final RpcController controller,
    final ClientService.BlockingInterface client, final CoprocessorServiceCall call,
    final byte[] regionName) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build();
  try {
    CoprocessorServiceResponse response =
        client.execService(controller, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:ditb    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final RpcController controller,
  final MasterService.BlockingInterface client, final CoprocessorServiceCall call)
throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build();
  try {
    CoprocessorServiceResponse response =
        client.execMasterService(controller, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:ditb    文件:MasterCoprocessorRpcChannel.java   
@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;
}
项目:ditb    文件:RegionServerCoprocessorRpcChannel.java   
@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;
}
项目:pbase    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final ClientService.BlockingInterface client,
    final CoprocessorServiceCall call, final byte[] regionName) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build();
  try {
    CoprocessorServiceResponse response =
        client.execService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:pbase    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(
  final MasterService.BlockingInterface client, final CoprocessorServiceCall call)
throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build();
  try {
    CoprocessorServiceResponse response =
        client.execMasterService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:pbase    文件:MasterCoprocessorRpcChannel.java   
@Override
protected Message callExecService(Descriptors.MethodDescriptor method,
                                Message request, Message responsePrototype)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("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();
  CoprocessorServiceResponse result = ProtobufUtil.execService(connection.getMaster(), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Master Result is value=" + response);
  }
  return response;
}
项目:pbase    文件:RegionCoprocessorRpcChannel.java   
@Override
protected Message callExecService(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 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) {
        public CoprocessorServiceResponse call(int callTimeout) throws Exception {
          byte[] regionName = getLocation().getRegionInfo().getRegionName();
          return ProtobufUtil.execService(getStub(), call, regionName);
        }
      };
  CoprocessorServiceResponse result = rpcFactory.<CoprocessorServiceResponse> newCaller()
      .callWithRetries(callable, operationTimeout);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).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;
}
项目:HIndex    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(
    final ClientService.BlockingInterface client, final CoprocessorServiceCall call,
    final byte[] regionName, PayloadCarryingRpcController controller) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build();
  try {
    CoprocessorServiceResponse response =
        client.execService(controller, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:HIndex    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(
  final MasterService.BlockingInterface client, final CoprocessorServiceCall call)
throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build();
  try {
    CoprocessorServiceResponse response =
        client.execMasterService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:HIndex    文件:MasterCoprocessorRpcChannel.java   
@Override
protected Message callExecService(Descriptors.MethodDescriptor method,
                                Message request, Message responsePrototype)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Call: "+method.getName()+", "+request.toString());
  }

  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(HBaseZeroCopyByteString.wrap(HConstants.EMPTY_BYTE_ARRAY))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  CoprocessorServiceResponse result = ProtobufUtil.execService(connection.getMaster(), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Master Result is value=" + response);
  }
  return response;
}
项目:PyroDB    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final ClientService.BlockingInterface client,
    final CoprocessorServiceCall call, final byte[] regionName) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build();
  try {
    CoprocessorServiceResponse response =
        client.execService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:PyroDB    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(
  final MasterService.BlockingInterface client, final CoprocessorServiceCall call)
throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build();
  try {
    CoprocessorServiceResponse response =
        client.execMasterService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:PyroDB    文件:MasterCoprocessorRpcChannel.java   
@Override
protected Message callExecService(Descriptors.MethodDescriptor method,
                                Message request, Message responsePrototype)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Call: "+method.getName()+", "+request.toString());
  }

  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(HBaseZeroCopyByteString.wrap(HConstants.EMPTY_BYTE_ARRAY))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  CoprocessorServiceResponse result = ProtobufUtil.execService(connection.getMaster(), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Master Result is value=" + response);
  }
  return response;
}
项目:PyroDB    文件:RegionCoprocessorRpcChannel.java   
@Override
protected Message callExecService(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 ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(HBaseZeroCopyByteString.wrap(row))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  RegionServerCallable<CoprocessorServiceResponse> callable =
      new RegionServerCallable<CoprocessorServiceResponse>(connection, table, row) {
        public CoprocessorServiceResponse call(int callTimeout) throws Exception {
          byte[] regionName = getLocation().getRegionInfo().getRegionName();
          return ProtobufUtil.execService(getStub(), call, regionName);
        }
      };
  CoprocessorServiceResponse result = rpcFactory.<CoprocessorServiceResponse> newCaller()
      .callWithRetries(callable, operationTimeout);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).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;
}
项目:c5    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final ClientService.BlockingInterface client,
    final CoprocessorServiceCall call, final byte[] regionName) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build();
  try {
    CoprocessorServiceResponse response =
        client.execService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:c5    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(
  final MasterService.BlockingInterface client, final CoprocessorServiceCall call)
throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build();
  try {
    CoprocessorServiceResponse response =
        client.execMasterService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:c5    文件:MasterCoprocessorRpcChannel.java   
@Override
protected Message callExecService(Descriptors.MethodDescriptor method,
                                Message request, Message responsePrototype)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Call: "+method.getName()+", "+request.toString());
  }

  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(ZeroCopyLiteralByteString.wrap(HConstants.EMPTY_BYTE_ARRAY))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  CoprocessorServiceResponse result = ProtobufUtil.execService(connection.getMaster(), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Master Result is value=" + response);
  }
  return response;
}
项目:c5    文件:RegionCoprocessorRpcChannel.java   
@Override
protected Message callExecService(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 ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(ZeroCopyLiteralByteString.wrap(row))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  RegionServerCallable<CoprocessorServiceResponse> callable =
      new RegionServerCallable<CoprocessorServiceResponse>(connection, table, row) {
        public CoprocessorServiceResponse call() throws Exception {
          byte[] regionName = getLocation().getRegionInfo().getRegionName();
          return ProtobufUtil.execService(getStub(), call, regionName);
        }
      };
  CoprocessorServiceResponse result = rpcFactory.<CoprocessorServiceResponse> newCaller()
      .callWithRetries(callable);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).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;
}
项目:DominoHBase    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final ClientProtocol client,
    final CoprocessorServiceCall call, final byte[] regionName) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build();
  try {
    CoprocessorServiceResponse response =
        client.execService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:DominoHBase    文件:ProtobufUtil.java   
public static CoprocessorServiceResponse execService(final MasterAdminProtocol client,
    final CoprocessorServiceCall call) throws IOException {
  CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder()
      .setCall(call).setRegion(
          RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build();
  try {
    CoprocessorServiceResponse response =
        client.execMasterService(null, request);
    return response;
  } catch (ServiceException se) {
    throw getRemoteException(se);
  }
}
项目:DominoHBase    文件:MasterCoprocessorRpcChannel.java   
@Override
protected Message callExecService(Descriptors.MethodDescriptor method,
                                Message request, Message responsePrototype)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Call: "+method.getName()+", "+request.toString());
  }

  final ClientProtos.CoprocessorServiceCall call =
      ClientProtos.CoprocessorServiceCall.newBuilder()
          .setRow(ByteString.copyFrom(HConstants.EMPTY_BYTE_ARRAY))
          .setServiceName(method.getService().getFullName())
          .setMethodName(method.getName())
          .setRequest(request.toByteString()).build();
  CoprocessorServiceResponse result = ProtobufUtil.execService(connection.getMasterAdmin(), call);
  Message response = null;
  if (result.getValue().hasValue()) {
    response = responsePrototype.newBuilderForType()
        .mergeFrom(result.getValue().getValue()).build();
  } else {
    response = responsePrototype.getDefaultInstanceForType();
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace("Master Result is value=" + response);
  }
  return response;
}
项目:ditb    文件:HRegionServer.java   
public CoprocessorServiceResponse execRegionServerService(
    @SuppressWarnings("UnusedParameters") final RpcController controller,
    final CoprocessorServiceRequest serviceRequest) throws ServiceException {
  try {
    ServerRpcController serviceController = new ServerRpcController();
    CoprocessorServiceCall call = serviceRequest.getCall();
    String serviceName = call.getServiceName();
    String methodName = call.getMethodName();
    if (!coprocessorServiceHandlers.containsKey(serviceName)) {
      throw new UnknownProtocolException(null,
          "No registered coprocessor service found for name " + serviceName);
    }
    Service service = coprocessorServiceHandlers.get(serviceName);
    Descriptors.ServiceDescriptor serviceDesc = service.getDescriptorForType();
    Descriptors.MethodDescriptor methodDesc = serviceDesc.findMethodByName(methodName);
    if (methodDesc == null) {
      throw new UnknownProtocolException(service.getClass(),
          "Unknown method " + methodName + " called on service " + serviceName);
    }
    Message.Builder builderForType = service.getRequestPrototype(methodDesc).newBuilderForType();
    ProtobufUtil.mergeFrom(builderForType, call.getRequest());
    Message request = builderForType.build();
    final Message.Builder responseBuilder =
        service.getResponsePrototype(methodDesc).newBuilderForType();
    service.callMethod(methodDesc, serviceController, request, new RpcCallback<Message>() {
      @Override public void run(Message message) {
        if (message != null) {
          responseBuilder.mergeFrom(message);
        }
      }
    });
    IOException exception = ResponseConverter.getControllerException(serviceController);
    if (exception != null) {
      throw exception;
    }
    Message execResult = responseBuilder.build();
    ClientProtos.CoprocessorServiceResponse.Builder builder =
        ClientProtos.CoprocessorServiceResponse.newBuilder();
    builder.setRegion(RequestConverter
        .buildRegionSpecifier(RegionSpecifierType.REGION_NAME, HConstants.EMPTY_BYTE_ARRAY));
    builder.setValue(builder.getValueBuilder().setName(execResult.getClass().getName())
        .setValue(execResult.toByteString()));
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
项目:ditb    文件:RSRpcServices.java   
@Override
public CoprocessorServiceResponse execRegionServerService(RpcController controller,
    CoprocessorServiceRequest request) throws ServiceException {
  return regionServer.execRegionServerService(controller, request);
}
项目:ditb    文件:MockRegionServer.java   
@Override
public ClientProtos.CoprocessorServiceResponse execService(RpcController controller,
    ClientProtos.CoprocessorServiceRequest request) throws ServiceException {
  return null;
}
项目:ditb    文件:MockRegionServer.java   
@Override
public CoprocessorServiceResponse execRegionServerService(RpcController controller,
    CoprocessorServiceRequest request) throws ServiceException {
  // TODO Auto-generated method stub
  return null;
}
项目:ditb    文件:RegionCoprocessorRpcChannel.java   
@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;
}
项目:ditb    文件:TestClientNoCluster.java   
@Override
public CoprocessorServiceResponse execService(
    RpcController controller, CoprocessorServiceRequest request)
    throws ServiceException {
  throw new NotImplementedException();
}
项目:ditb    文件:TestClientNoCluster.java   
@Override
public CoprocessorServiceResponse execRegionServerService(RpcController controller,
    CoprocessorServiceRequest request) throws ServiceException {
  throw new NotImplementedException();
}
项目:pbase    文件:HRegionServer.java   
public CoprocessorServiceResponse execRegionServerService(final RpcController controller,
                                                          final CoprocessorServiceRequest serviceRequest) throws ServiceException {
    try {
        ServerRpcController execController = new ServerRpcController();
        CoprocessorServiceCall call = serviceRequest.getCall();
        String serviceName = call.getServiceName();
        String methodName = call.getMethodName();
        if (!coprocessorServiceHandlers.containsKey(serviceName)) {
            throw new UnknownProtocolException(null,
                    "No registered coprocessor service found for name " + serviceName);
        }
        Service service = coprocessorServiceHandlers.get(serviceName);
        Descriptors.ServiceDescriptor serviceDesc = service.getDescriptorForType();
        Descriptors.MethodDescriptor methodDesc = serviceDesc.findMethodByName(methodName);
        if (methodDesc == null) {
            throw new UnknownProtocolException(service.getClass(), "Unknown method " + methodName
                    + " called on service " + serviceName);
        }
        Message request =
                service.getRequestPrototype(methodDesc).newBuilderForType().mergeFrom(call.getRequest())
                        .build();
        final Message.Builder responseBuilder =
                service.getResponsePrototype(methodDesc).newBuilderForType();
        service.callMethod(methodDesc, controller, request, new RpcCallback<Message>() {
            @Override
            public void run(Message message) {
                if (message != null) {
                    responseBuilder.mergeFrom(message);
                }
            }
        });
        Message execResult = responseBuilder.build();
        if (execController.getFailedOn() != null) {
            throw execController.getFailedOn();
        }
        ClientProtos.CoprocessorServiceResponse.Builder builder =
                ClientProtos.CoprocessorServiceResponse.newBuilder();
        builder.setRegion(RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME,
                HConstants.EMPTY_BYTE_ARRAY));
        builder.setValue(builder.getValueBuilder().setName(execResult.getClass().getName())
                .setValue(execResult.toByteString()));
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
项目:pbase    文件:RSRpcServices.java   
@Override
public CoprocessorServiceResponse execRegionServerService(RpcController controller,
                                                          CoprocessorServiceRequest request) throws ServiceException {
    return regionServer.execRegionServerService(controller, request);
}