Java 类com.google.protobuf.Service 实例源码

项目:TakinRPC    文件:RaftService.java   
@Override
protected void doStart() {

    try {

        log.load();

        RaftServiceEndpoint endpoint = new RaftServiceEndpoint(ctx);
        Service replicaService = RaftProto.RaftService.newReflectiveService(endpoint);
        rpcServer.registerService(replicaService);
        rpcServer.startAsync().addListener(new Listener() {
            @Override
            public void running() {
                ctx.setState(RaftStateContext.StateType.FOLLOWER);
            }
        }, MoreExecutors.sameThreadExecutor());
        rpcServer.awaitRunning();

        notifyStarted();

    } catch (Exception e) {
        notifyFailed(e);
    }

}
项目:ditb    文件:HMaster.java   
@Override
public boolean registerService(Service instance) {
  /*
   * No stacking of instances is allowed for a single service name
   */
  Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
  if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
    LOG.error("Coprocessor service "+serviceDesc.getFullName()+
        " already registered, rejecting request from "+instance
    );
    return false;
  }

  coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Registered master coprocessor service: service="+serviceDesc.getFullName());
  }
  return true;
}
项目:ditb    文件:HRegionServer.java   
@Override public boolean registerService(Service instance) {
  /*
   * No stacking of instances is allowed for a single service name
   */
  Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
  if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
    LOG.error("Coprocessor service " + serviceDesc.getFullName()
        + " already registered, rejecting request from " + instance);
    return false;
  }

  coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
  if (LOG.isDebugEnabled()) {
    LOG.debug(
        "Registered regionserver coprocessor service: service=" + serviceDesc.getFullName());
  }
  return true;
}
项目:ditb    文件:HRegion.java   
@Override public boolean registerService(Service instance) {
  /*
   * No stacking of instances is allowed for a single service name
   */
  Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
  if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
    LOG.error("Coprocessor service " + serviceDesc.getFullName()
        + " already registered, rejecting request from " + instance);
    return false;
  }

  coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Registered coprocessor service: region=" + Bytes
        .toStringBinary(getRegionInfo().getRegionName()) + " service=" + serviceDesc
        .getFullName());
  }
  return true;
}
项目:ditb    文件:HTable.java   
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
    byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
    throws ServiceException, Throwable {
  final Map<byte[],R> results =  Collections.synchronizedMap(
      new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
  coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
    @Override
    public void update(byte[] region, byte[] row, R value) {
      if (region != null) {
        results.put(region, value);
      }
    }
  });
  return results;
}
项目:protobuf-socket-rpc    文件:RpcForwarder.java   
/**
 * Handle the blocking RPC request by forwarding it to the correct
 * service/method.
 *
 * @throws RpcException If there was some error executing the RPC.
 */
public SocketRpcProtos.Response doBlockingRpc(
    SocketRpcProtos.Request rpcRequest) throws RpcException {
  // Get the service, first try BlockingService
  BlockingService blockingService = blockingServiceMap.get(
      rpcRequest.getServiceName());
  if (blockingService != null) {
    return forwardToBlockingService(rpcRequest, blockingService);
  }

  // Now try Service
  Service service = serviceMap.get(rpcRequest.getServiceName());
  if (service == null) {
    throw new RpcException(ErrorReason.SERVICE_NOT_FOUND,
        "Could not find service: " + rpcRequest.getServiceName(), null);
  }

  // Call service using an instant callback
  Callback<Message> callback = new Callback<Message>();
  SocketRpcController socketController = new SocketRpcController();
  forwardToService(rpcRequest, callback, service, socketController);

  // Build and return response (callback invocation is optional)
  return createRpcResponse(callback.response, callback.invoked,
      socketController);
}
项目:protobuf-socket-rpc    文件:RpcForwarder.java   
private void forwardToService(SocketRpcProtos.Request rpcRequest,
    RpcCallback<Message> callback, Service service,
    RpcController socketController) throws RpcException {
  // Get matching method
  MethodDescriptor method = getMethod(rpcRequest,
      service.getDescriptorForType());

  // Create request for method
  Message request = getRequestProto(rpcRequest,
      service.getRequestPrototype(method));

  // Call method
  try {
    service.callMethod(method, socketController, request, callback);
  } catch (RuntimeException e) {
    throw new RpcException(ErrorReason.RPC_ERROR,
        "Error running method " + method.getFullName(), e);
  }
}
项目:pbase    文件:HMaster.java   
@Override
public boolean registerService(Service instance) {
/*
 * No stacking of instances is allowed for a single service name
 */
    Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
    if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
        LOG.error("Coprocessor service " + serviceDesc.getFullName() +
                        " already registered, rejecting request from " + instance
        );
        return false;
    }

    coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Registered master coprocessor service: service=" + serviceDesc.getFullName());
    }
    return true;
}
项目:pbase    文件:HRegionServer.java   
@Override
public boolean registerService(Service instance) {
/*
 * No stacking of instances is allowed for a single service name
 */
    Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
    if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
        LOG.error("Coprocessor service " + serviceDesc.getFullName()
                + " already registered, rejecting request from " + instance);
        return false;
    }

    coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Registered regionserver coprocessor service: service=" + serviceDesc.getFullName());
    }
    return true;
}
项目:pbase    文件:HRegion.java   
/**
 * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to
 * be available for handling
 * {@link HRegion#execService(com.google.protobuf.RpcController,
 * org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall)}} calls.
 * <p/>
 * <p>
 * Only a single instance may be registered per region for a given {@link Service} subclass (the
 * instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}.
 * After the first registration, subsequent calls with the same service name will fail with
 * a return value of {@code false}.
 * </p>
 *
 * @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
 * @return {@code true} if the registration was successful, {@code false}
 * otherwise
 */
public boolean registerService(Service instance) {
/*
 * No stacking of instances is allowed for a single service name
 */
    Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
    if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
        LOG.error("Coprocessor service " + serviceDesc.getFullName() +
                        " already registered, rejecting request from " + instance
        );
        return false;
    }

    coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Registered coprocessor service: region=" +
                Bytes.toStringBinary(getRegionName()) + " service=" + serviceDesc.getFullName());
    }
    return true;
}
项目:pbase    文件:HTable.java   
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
    byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
    throws ServiceException, Throwable {
  final Map<byte[],R> results =  Collections.synchronizedMap(
      new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
  coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
    @Override
    public void update(byte[] region, byte[] row, R value) {
      if (region != null) {
        results.put(region, value);
      }
    }
  });
  return results;
}
项目:HIndex    文件:HMaster.java   
@Override
public boolean registerService(Service instance) {
  /*
   * No stacking of instances is allowed for a single service name
   */
  Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
  if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
    LOG.error("Coprocessor service "+serviceDesc.getFullName()+
        " already registered, rejecting request from "+instance
    );
    return false;
  }

  coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Registered master coprocessor service: service="+serviceDesc.getFullName());
  }
  return true;
}
项目:HIndex    文件:HRegion.java   
/**
 * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to
 * be available for handling
 * {@link HRegion#execService(com.google.protobuf.RpcController,
 *    org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall)}} calls.
 *
 * <p>
 * Only a single instance may be registered per region for a given {@link Service} subclass (the
 * instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}.
 * After the first registration, subsequent calls with the same service name will fail with
 * a return value of {@code false}.
 * </p>
 * @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
 * @return {@code true} if the registration was successful, {@code false}
 * otherwise
 */
public boolean registerService(Service instance) {
  /*
   * No stacking of instances is allowed for a single service name
   */
  Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType();
  if (coprocessorServiceHandlers.containsKey(serviceDesc.getFullName())) {
    LOG.error("Coprocessor service "+serviceDesc.getFullName()+
        " already registered, rejecting request from "+instance
    );
    return false;
  }

  coprocessorServiceHandlers.put(serviceDesc.getFullName(), instance);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Registered coprocessor service: region="+
        Bytes.toStringBinary(getRegionName())+" service="+serviceDesc.getFullName());
  }
  return true;
}
项目:HIndex    文件:RegionCoprocessorHost.java   
public Message preEndpointInvocation(final Service service, final String methodName,
    Message request) throws IOException {
  ObserverContext<RegionCoprocessorEnvironment> ctx = null;
  for (RegionEnvironment env : coprocessors) {
    if (env.getInstance() instanceof EndpointObserver) {
      ctx = ObserverContext.createAndPrepare(env, ctx);
      Thread currentThread = Thread.currentThread();
      ClassLoader cl = currentThread.getContextClassLoader();
      try {
        currentThread.setContextClassLoader(env.getClassLoader());
        request = ((EndpointObserver) env.getInstance()).preEndpointInvocation(ctx, service,
          methodName, request);
      } catch (Throwable e) {
        handleCoprocessorThrowable(env, e);
      } finally {
        currentThread.setContextClassLoader(cl);
      }
      if (ctx.shouldComplete()) {
        break;
      }
    }
  }
  return request;
}
项目:HIndex    文件:RegionCoprocessorHost.java   
public void postEndpointInvocation(final Service service, final String methodName,
    final Message request, final Message.Builder responseBuilder) throws IOException {
  ObserverContext<RegionCoprocessorEnvironment> ctx = null;
  for (RegionEnvironment env : coprocessors) {
    if (env.getInstance() instanceof EndpointObserver) {
      ctx = ObserverContext.createAndPrepare(env, ctx);
      Thread currentThread = Thread.currentThread();
      ClassLoader cl = currentThread.getContextClassLoader();
      try {
        currentThread.setContextClassLoader(env.getClassLoader());
        ((EndpointObserver) env.getInstance()).postEndpointInvocation(ctx, service,
          methodName, request, responseBuilder);
      } catch (Throwable e) {
        handleCoprocessorThrowable(env, e);
      } finally {
        currentThread.setContextClassLoader(cl);
      }
      if (ctx.shouldComplete()) {
        break;
      }
    }
  }
}
项目:HIndex    文件:HTable.java   
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
    byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
    throws ServiceException, Throwable {
  final Map<byte[],R> results =  Collections.synchronizedMap(
      new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
  coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
    public void update(byte[] region, byte[] row, R value) {
      if (region != null) {
        results.put(region, value);
      }
    }
  });
  return results;
}
项目:sstore-soft    文件:ServiceRegistry.java   
public void register(Service service) {
    // TODO: Support registering multiple local services? Needs "local 2PC" effectively. Yuck.
    Descriptors.ServiceDescriptor descriptor = service.getDescriptorForType();
    for (MethodDescriptor i : descriptor.getMethods()) {
        if (methods.containsKey(i.getFullName())) {
            throw new IllegalStateException(
                    "method " + i.getFullName() + " is already registered");
        }
        methods.put(i.getFullName(), new ProtoMethodInvoker(service, i));
    }
}
项目:s-store    文件:ServiceRegistry.java   
public void register(Service service) {
    // TODO: Support registering multiple local services? Needs "local 2PC" effectively. Yuck.
    Descriptors.ServiceDescriptor descriptor = service.getDescriptorForType();
    for (MethodDescriptor i : descriptor.getMethods()) {
        if (methods.containsKey(i.getFullName())) {
            throw new IllegalStateException(
                    "method " + i.getFullName() + " is already registered");
        }
        methods.put(i.getFullName(), new ProtoMethodInvoker(service, i));
    }
}
项目:JavaNRPC    文件:NrpcServiceRegistry.java   
public Service queryService(String serviceFullName) throws ServiceNotFoundException {
    Service service = serviceMap.get(serviceFullName);
    if (service == null) {
        throw new ServiceNotFoundException("Not foud service : " + serviceFullName);
    }
    return service;
}
项目:ditb    文件:AccessController.java   
@Override
public Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx,
    Service service, String methodName, Message request) throws IOException {
  // Don't intercept calls to our own AccessControlService, we check for
  // appropriate permissions in the service handlers
  if (shouldCheckExecPermission && !(service instanceof AccessControlService)) {
    requirePermission("invoke(" + service.getDescriptorForType().getName() + "." +
      methodName + ")",
      getTableName(ctx.getEnvironment()), null, null,
      Action.EXEC);
  }
  return request;
}
项目:ditb    文件:RegionCoprocessorHost.java   
public Message preEndpointInvocation(final Service service, final String methodName,
    Message request) throws IOException {
  return execOperationWithResult(request,
      coprocessors.isEmpty() ? null : new EndpointOperationWithResult<Message>() {
    @Override
    public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
        throws IOException {
      setResult(oserver.preEndpointInvocation(ctx, service, methodName, getResult()));
    }
  });
}
项目:ditb    文件:RegionCoprocessorHost.java   
public void postEndpointInvocation(final Service service, final String methodName,
    final Message request, final Message.Builder responseBuilder) throws IOException {
  execOperation(coprocessors.isEmpty() ? null : new EndpointOperation() {
    @Override
    public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
        throws IOException {
      oserver.postEndpointInvocation(ctx, service, methodName, request, responseBuilder);
    }
  });
}
项目:ditb    文件:HTablePool.java   
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
    throws ServiceException, Throwable {
  checkState();
  return table.coprocessorService(service, startKey, endKey, callable);
}
项目:ditb    文件:HTablePool.java   
@Override
public <T extends Service, R> void coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable, Callback<R> callback)
    throws ServiceException, Throwable {
  checkState();
  table.coprocessorService(service, startKey, endKey, callable, callback);
}
项目:hgraphdb    文件:MockHTable.java   
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(final Class<T> service,
                                                                byte[] startKey, byte[] endKey, final Batch.Call<T, R> callable)
        throws ServiceException {
    throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
项目:hgraphdb    文件:MockHTable.java   
/**
 * {@inheritDoc}
 */
@Override
public <T extends Service, R> void coprocessorService(final Class<T> service,
                                                      byte[] startKey, byte[] endKey, final Batch.Call<T, R> callable,
                                                      final Batch.Callback<R> callback) throws ServiceException {
    throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
项目:AbacusUtil    文件:AsyncHBaseExecutor.java   
<T extends Service, R> CompletableFuture<Map<byte[], R>> coprocessorService(final String tableName, final Class<T> service, final Object startRowKey,
        final Object endRowKey, final Batch.Call<T, R> callable) throws Exception {
    return asyncExecutor.execute(new Callable<Map<byte[], R>>() {
        @Override
        public Map<byte[], R> call() throws Exception {
            return hbaseExecutor.coprocessorService(tableName, service, startRowKey, endRowKey, callable);
        }
    });
}
项目:AbacusUtil    文件:AsyncHBaseExecutor.java   
<T extends Service, R> CompletableFuture<Void> coprocessorService(final String tableName, final Class<T> service, final Object startRowKey,
        final Object endRowKey, final Batch.Call<T, R> callable, final Batch.Callback<R> callback) throws Exception {
    return asyncExecutor.execute(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            hbaseExecutor.coprocessorService(tableName, service, startRowKey, endRowKey, callable, callback);

            return null;
        }
    });
}
项目:Wiab.pro    文件:ServerRpcProvider.java   
/**
 * Register all methods provided by the given service type.
 */
public void registerService(Service service) {
  synchronized (registeredServices) {
    for (MethodDescriptor methodDescriptor : service.getDescriptorForType().getMethods()) {
      registeredServices.put(methodDescriptor.getInputType(),
          new RegisteredServiceMethod(service, methodDescriptor));
    }
  }
}
项目:cloud-bigtable-client    文件:BigtableTable.java   
@Override
public <T extends Service, R> void coprocessorService(Class<T> service, byte[] startKey,
    byte[] endKey, Batch.Call<T, R> callable, Batch.Callback<R> callback)
    throws ServiceException, Throwable {
  LOG.error("Unsupported coprocessorService("
      + "Class, byte[], byte[], Batch.Call, Batch.Callback) called.");
  throw new UnsupportedOperationException();  // TODO
}
项目:pbase    文件:AccessController.java   
@Override
public Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx,
    Service service, String methodName, Message request) throws IOException {
  // Don't intercept calls to our own AccessControlService, we check for
  // appropriate permissions in the service handlers
  if (shouldCheckExecPermission && !(service instanceof AccessControlService)) {
    requirePermission("invoke(" + service.getDescriptorForType().getName() + "." +
      methodName + ")",
      getTableName(ctx.getEnvironment()), null, null,
      Action.EXEC);
  }
  return request;
}
项目:pbase    文件:RegionCoprocessorHost.java   
public Message preEndpointInvocation(final Service service, final String methodName,
    Message request) throws IOException {
  return execOperationWithResult(request,
      coprocessors.isEmpty() ? null : new EndpointOperationWithResult<Message>() {
    @Override
    public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
        throws IOException {
      setResult(oserver.preEndpointInvocation(ctx, service, methodName, getResult()));
    }
  });
}
项目:pbase    文件:RegionCoprocessorHost.java   
public void postEndpointInvocation(final Service service, final String methodName,
    final Message request, final Message.Builder responseBuilder) throws IOException {
  execOperation(coprocessors.isEmpty() ? null : new EndpointOperation() {
    @Override
    public void call(EndpointObserver oserver, ObserverContext<RegionCoprocessorEnvironment> ctx)
        throws IOException {
      oserver.postEndpointInvocation(ctx, service, methodName, request, responseBuilder);
    }
  });
}
项目:pbase    文件:HTablePool.java   
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
    throws ServiceException, Throwable {
  checkState();
  return table.coprocessorService(service, startKey, endKey, callable);
}
项目:pbase    文件:HTablePool.java   
@Override
public <T extends Service, R> void coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable, Callback<R> callback)
    throws ServiceException, Throwable {
  checkState();
  table.coprocessorService(service, startKey, endKey, callable, callback);
}
项目:HIndex    文件:AccessController.java   
@Override
public Message preEndpointInvocation(ObserverContext<RegionCoprocessorEnvironment> ctx,
    Service service, String methodName, Message request) throws IOException {
  // Don't intercept calls to our own AccessControlService, we check for
  // appropriate permissions in the service handlers
  if (shouldCheckExecPermission && !(service instanceof AccessControlService)) {
    requirePermission("invoke(" + service.getDescriptorForType().getName() + "." +
      methodName + ")",
      getTableName(ctx.getEnvironment()), null, null,
      Action.EXEC);
  }
  return request;
}
项目:HIndex    文件:HTablePool.java   
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
    throws ServiceException, Throwable {
  checkState();
  return table.coprocessorService(service, startKey, endKey, callable);
}
项目:HIndex    文件:HTablePool.java   
@Override
public <T extends Service, R> void coprocessorService(Class<T> service,
    byte[] startKey, byte[] endKey, Batch.Call<T, R> callable, Callback<R> callback)
    throws ServiceException, Throwable {
  checkState();
  table.coprocessorService(service, startKey, endKey, callable, callback);
}
项目:aliyun-cupid-sdk    文件:CupidRpcChannelProxyTest.java   
public CupidRpcChannelProxyTest(Service service) {
    this.service = service;
}
项目:sstore-soft    文件:ProtoMethodInvoker.java   
public ProtoMethodInvoker(Service service, MethodDescriptor method) {
    this.service = service;
    this.method = method;
    requestPrototype = service.getRequestPrototype(method);
}