@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); } }
/** * 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); } }
@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); } }
/** * 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); } }
@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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
@Override public CoprocessorServiceResponse execRegionServerService(RpcController controller, CoprocessorServiceRequest request) throws ServiceException { return regionServer.execRegionServerService(controller, request); }
@Override public ClientProtos.CoprocessorServiceResponse execService(RpcController controller, ClientProtos.CoprocessorServiceRequest request) throws ServiceException { return null; }
@Override public CoprocessorServiceResponse execRegionServerService(RpcController controller, CoprocessorServiceRequest request) throws ServiceException { // TODO Auto-generated method stub return null; }
@Override public CoprocessorServiceResponse execService( RpcController controller, CoprocessorServiceRequest request) throws ServiceException { throw new NotImplementedException(); }
@Override public CoprocessorServiceResponse execRegionServerService(RpcController controller, CoprocessorServiceRequest request) throws ServiceException { throw new NotImplementedException(); }
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); } }