Package org.apache.hadoop.hbase.ipc

Examples of org.apache.hadoop.hbase.ipc.ServerRpcController


        TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
    final Map<byte[], String> results = Collections.synchronizedMap(
        new TreeMap<byte[], String>(Bytes.BYTES_COMPARATOR));
    try {
      // scan: for all regions
      final RpcController controller = new ServerRpcController();
      table.coprocessorService(TestRpcServiceProtos.TestProtobufRpcProto.class,
          ROWS[0], ROWS[ROWS.length - 1],
          new Batch.Call<TestRpcServiceProtos.TestProtobufRpcProto, TestProtos.EchoResponseProto>() {
            public TestProtos.EchoResponseProto call(TestRpcServiceProtos.TestProtobufRpcProto instance)
                throws IOException {
View Full Code Here


    final TestProtos.EchoRequestProto request =
        TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
    try {
      // scan: for all regions
      final RpcController controller = new ServerRpcController();
      // test that null results are supported
      Map<byte[], String> results = table.coprocessorService(TestRpcServiceProtos.TestProtobufRpcProto.class,
          ROWS[0], ROWS[ROWS.length - 1],
          new Batch.Call<TestRpcServiceProtos.TestProtobufRpcProto, String>() {
            public String call(TestRpcServiceProtos.TestProtobufRpcProto instance)
View Full Code Here

  @Override
  public ClientProtos.CoprocessorServiceResponse execMasterService(final RpcController controller,
      final ClientProtos.CoprocessorServiceRequest request) throws ServiceException {
    try {
      ServerRpcController execController = new ServerRpcController();

      ClientProtos.CoprocessorServiceCall call = request.getCall();
      String serviceName = call.getServiceName();
      String methodName = call.getMethodName();
      if (!coprocessorServiceHandlers.containsKey(serviceName)) {
        throw new UnknownProtocolException(null,
            "No registered master 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 master service "+serviceName);
      }

      //invoke the method
      Message execRequest = service.getRequestPrototype(methodDesc).newBuilderForType()
          .mergeFrom(call.getRequest()).build();
      final Message.Builder responseBuilder =
          service.getResponsePrototype(methodDesc).newBuilderForType();
      service.callMethod(methodDesc, execController, execRequest, 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));
View Full Code Here

          EMPTY_START_ROW,
          LAST_ROW,
          new Batch.Call<SecureBulkLoadProtos.SecureBulkLoadService,String>() {
            @Override
            public String call(SecureBulkLoadProtos.SecureBulkLoadService instance) throws IOException {
              ServerRpcController controller = new ServerRpcController();

              BlockingRpcCallback<SecureBulkLoadProtos.PrepareBulkLoadResponse> rpcCallback =
                  new BlockingRpcCallback<SecureBulkLoadProtos.PrepareBulkLoadResponse>();

              SecureBulkLoadProtos.PrepareBulkLoadRequest request =
                  SecureBulkLoadProtos.PrepareBulkLoadRequest.newBuilder()
                  .setTableName(ProtobufUtil.toProtoTableName(tableName)).build();

              instance.prepareBulkLoad(controller,
                  request,
                  rpcCallback);

              SecureBulkLoadProtos.PrepareBulkLoadResponse response = rpcCallback.get();
              if (controller.failedOnException()) {
                throw controller.getFailedOn();
              }
              return response.getBulkToken();
            }
          }).entrySet().iterator().next().getValue();
    } catch (Throwable throwable) {
View Full Code Here

            LAST_ROW,
            new Batch.Call<SecureBulkLoadProtos.SecureBulkLoadService, String>() {

              @Override
              public String call(SecureBulkLoadProtos.SecureBulkLoadService instance) throws IOException {
                ServerRpcController controller = new ServerRpcController();

                BlockingRpcCallback<SecureBulkLoadProtos.CleanupBulkLoadResponse> rpcCallback =
                    new BlockingRpcCallback<SecureBulkLoadProtos.CleanupBulkLoadResponse>();

                SecureBulkLoadProtos.CleanupBulkLoadRequest request =
                    SecureBulkLoadProtos.CleanupBulkLoadRequest.newBuilder()
                        .setBulkToken(bulkToken).build();

                instance.cleanupBulkLoad(controller,
                    request,
                    rpcCallback);

                if (controller.failedOnException()) {
                  throw controller.getFailedOn();
                }
                return null;
              }
            });
    } catch (Throwable throwable) {
View Full Code Here

          SecureBulkLoadProtos.SecureBulkLoadHFilesRequest.newBuilder()
            .setFsToken(protoDT)
            .addAllFamilyPath(protoFamilyPaths)
            .setBulkToken(bulkToken).build();

      ServerRpcController controller = new ServerRpcController();
      BlockingRpcCallback<SecureBulkLoadProtos.SecureBulkLoadHFilesResponse> rpcCallback =
          new BlockingRpcCallback<SecureBulkLoadProtos.SecureBulkLoadHFilesResponse>();
      instance.secureBulkLoadHFiles(controller,
        request,
        rpcCallback);

      SecureBulkLoadProtos.SecureBulkLoadHFilesResponse response = rpcCallback.get();
      if (controller.failedOnException()) {
        throw controller.getFailedOn();
      }
      return response.getLoaded();
    } catch (Throwable throwable) {
      throw new IOException(throwable);
    }
View Full Code Here

  @Override
  public ClientProtos.CoprocessorServiceResponse execMasterService(final RpcController controller,
      final ClientProtos.CoprocessorServiceRequest request) throws ServiceException {
    try {
      ServerRpcController execController = new ServerRpcController();

      ClientProtos.CoprocessorServiceCall call = request.getCall();
      String serviceName = call.getServiceName();
      String methodName = call.getMethodName();
      if (!coprocessorServiceHandlers.containsKey(serviceName)) {
        throw new UnknownProtocolException(null,
            "No registered master 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 master service "+serviceName);
      }

      //invoke the method
      Message execRequest = service.getRequestPrototype(methodDesc).newBuilderForType()
          .mergeFrom(call.getRequest()).build();
      final Message.Builder responseBuilder =
          service.getResponsePrototype(methodDesc).newBuilderForType();
      service.callMethod(methodDesc, execController, execRequest, 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));
View Full Code Here

  }

  private Message execServiceOnRegion(HRegion region,
      final ClientProtos.CoprocessorServiceCall serviceCall) throws IOException {
    // ignore the passed in controller (from the serialized call)
    ServerRpcController execController = new ServerRpcController();
    Message result = region.execService(execController, serviceCall);
    if (execController.getFailedOn() != null) {
      throw execController.getFailedOn();
    }
    return result;
  }
View Full Code Here

    MaxCallBack aMaxCallBack = new MaxCallBack();
    table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
        new Batch.Call<AggregateService, R>() {
          @Override
          public R call(AggregateService instance) throws IOException {
            ServerRpcController controller = new ServerRpcController();
            BlockingRpcCallback<AggregateResponse> rpcCallback =
                new BlockingRpcCallback<AggregateResponse>();
            instance.getMax(controller, requestArg, rpcCallback);
            AggregateResponse response = rpcCallback.get();
            if (controller.failedOnException()) {
              throw controller.getFailedOn();
            }
            if (response.getFirstPartCount() > 0) {
              ByteString b = response.getFirstPart(0);
              Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
              return ci.getCellValueFromProto(q);
View Full Code Here

    table.coprocessorService(AggregateService.class, scan.getStartRow(), scan.getStopRow(),
        new Batch.Call<AggregateService, R>() {

          @Override
          public R call(AggregateService instance) throws IOException {
            ServerRpcController controller = new ServerRpcController();
            BlockingRpcCallback<AggregateResponse> rpcCallback =
                new BlockingRpcCallback<AggregateResponse>();
            instance.getMin(controller, requestArg, rpcCallback);
            AggregateResponse response = rpcCallback.get();
            if (controller.failedOnException()) {
              throw controller.getFailedOn();
            }
            if (response.getFirstPartCount() > 0) {
              ByteString b = response.getFirstPart(0);
              Q q = ProtobufUtil.getParsedGenericInstance(ci.getClass(), 3, b);
              return ci.getCellValueFromProto(q);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.ipc.ServerRpcController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.