com.google.protobuf.Service Java Examples
The following examples show how to use
com.google.protobuf.Service.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RpcForwarder.java From protobuf-socket-rpc with MIT License | 6 votes |
/** * 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); }
Example #2
Source File: RpcForwarder.java From protobuf-socket-rpc with MIT License | 6 votes |
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); } }
Example #3
Source File: AsyncRpcServer.java From incubator-tajo with Apache License 2.0 | 6 votes |
public AsyncRpcServer(final Class<?> protocol, final Object instance, final InetSocketAddress bindAddress, final int workerNum) throws Exception { super(protocol.getSimpleName(), bindAddress); String serviceClassName = protocol.getName() + "$" + protocol.getSimpleName() + "Service"; Class<?> serviceClass = Class.forName(serviceClassName); Class<?> interfaceClass = Class.forName(serviceClassName + "$Interface"); Method method = serviceClass.getMethod("newReflectiveService", interfaceClass); this.service = (Service) method.invoke(null, instance); ServerHandler handler = new ServerHandler(); this.pipeline = new ProtoPipelineFactory(handler, RpcRequest.getDefaultInstance()); super.init(this.pipeline, workerNum); }
Example #4
Source File: RaftService.java From TakinRPC with Apache License 2.0 | 6 votes |
@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); } }
Example #5
Source File: GameContext.java From gameserver with Apache License 2.0 | 6 votes |
/** * Register a remote RPC service to system. * @param service */ public void registerRpcService(Service service) { String serviceName = service.getDescriptorForType().getFullName(); rpcServiceMap.put(serviceName, service); // List<MethodDescriptor> methods = service.getDescriptorForType().getMethods(); if ( logger.isInfoEnabled() ) { logger.info("register remote service: {}", serviceName); } // for ( MethodDescriptor method : methods ) { // String methodName = method.getName(); // String remoteServiceName = StringUtil.concat(serviceName, DOT, methodName); // rpcServiceMap.put(remoteServiceName, service); // if ( log.isInfoEnabled() ) { // log.info("register remote service: " + remoteServiceName ); // } // } }
Example #6
Source File: AsyncRpcServer.java From tajo with Apache License 2.0 | 6 votes |
public AsyncRpcServer(final Class<?> protocol, final Object instance, final InetSocketAddress bindAddress, final int threads) throws Exception { super(protocol.getSimpleName(), bindAddress); String serviceClassName = protocol.getName() + "$" + protocol.getSimpleName() + "Service"; Class<?> serviceClass = Class.forName(serviceClassName); Class<?> interfaceClass = Class.forName(serviceClassName + "$Interface"); Method method = serviceClass.getMethod("newReflectiveService", interfaceClass); this.service = (Service) method.invoke(null, instance); this.initializer = new ProtoServerChannelInitializer(new ServerHandler(), RpcRequest.getDefaultInstance()); super.init(this.initializer, threads); }
Example #7
Source File: ServerRpcProvider.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * 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)); } } }
Example #8
Source File: MockHTable.java From hgraphdb with Apache License 2.0 | 5 votes |
/** * {@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."); }
Example #9
Source File: MockHTable.java From hgraphdb with Apache License 2.0 | 5 votes |
/** * {@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."); }
Example #10
Source File: DelegateHTable.java From phoenix with Apache License 2.0 | 5 votes |
@Override public <T extends Service, R> void coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Call<T, R> callable, Callback<R> callback) throws ServiceException, Throwable { delegate.coprocessorService(service, startKey, endKey, callable, callback); }
Example #11
Source File: RangerAuthorizationCoprocessor.java From ranger with Apache License 2.0 | 5 votes |
@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(ctx, "invoke(" + service.getDescriptorForType().getName() + "." + methodName + ")", getTableName(ctx.getEnvironment()), null, null, Action.EXEC); } return request; }
Example #12
Source File: AdapterPartition.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public <T extends Service,V> Map<byte[],V> coprocessorExec( Class<T> serviceClass, byte[] startKey, byte[] endKey, final Batch.Call<T,V> callable) throws Throwable { return delegate.coprocessorExec(serviceClass, startKey, endKey, callable); }
Example #13
Source File: ServerRpcProvider.java From swellrt with Apache License 2.0 | 5 votes |
/** * 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)); } } }
Example #14
Source File: ClientPartition.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public <T extends Service,V> Map<byte[],V> coprocessorExec( Class<T> serviceClass, byte[] startKey, byte[] endKey, Batch.Call<T,V> call) throws Throwable{ return table.coprocessorService(serviceClass, startKey, endKey, call); }
Example #15
Source File: SpliceRSRpcServices.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public Iterable<Service> getServices() { List<Service> services = Lists.newArrayList(); services.add(this); return services; }
Example #16
Source File: IIEndpoint.java From Kylin with Apache License 2.0 | 4 votes |
@Override public Service getService() { return this; }
Example #17
Source File: TxnLifecycleEndpoint.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public Iterable<Service> getServices() { List<Service> services = Lists.newArrayList(); services.add(this); return services; }
Example #18
Source File: ServerRpcProvider.java From incubator-retired-wave with Apache License 2.0 | 4 votes |
RegisteredServiceMethod(Service service, MethodDescriptor method) { this.service = service; this.method = method; }
Example #19
Source File: AdapterPartition.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public <T extends Service,V> Map<byte[],V> coprocessorExec(Class<T> serviceClass,Batch.Call<T,V> call) throws Throwable{ return delegate.coprocessorExec(serviceClass,call); }
Example #20
Source File: SkeletonHBaseClientPartition.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public abstract <T extends Service,V> Map<byte[],V> coprocessorExec( Class<T> serviceClass, byte[] startKey, byte[] endKey, final Batch.Call<T,V> callable) throws Throwable;
Example #21
Source File: SpliceIndexEndpoint.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public Iterable<Service> getServices() { List<Service> services = Lists.newArrayList(); services.add(this); return services; }
Example #22
Source File: BlockingProbeEndpoint.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public Service getService() { return this; }
Example #23
Source File: HTableMultiCluster.java From HBase.MCC with Apache License 2.0 | 4 votes |
public <T extends Service, R> void coprocessorService(Class<T> service, byte[] startKey, byte[] endKey,Call<T, R> callable, Callback<R> callback) throws ServiceException, Throwable { // TODO Auto-generated method stub }
Example #24
Source File: RegionSizeEndpoint.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public Iterable<Service> getServices() { List<Service> services = Lists.newArrayList(); services.add(this); return services; }
Example #25
Source File: OmidTransactionTable.java From phoenix with Apache License 2.0 | 4 votes |
@Override public <T extends Service, R> void coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Call<T, R> callable, Callback<R> callback) throws ServiceException, Throwable { throw new UnsupportedOperationException(); }
Example #26
Source File: RangerAuthorizationCoprocessor.java From ranger with Apache License 2.0 | 4 votes |
@Override public Iterable<Service> getServices() { return Collections.singleton(AccessControlProtos.AccessControlService.newReflectiveService(this)); }
Example #27
Source File: RangerAuthorizationCoprocessor.java From ranger with Apache License 2.0 | 4 votes |
@Override public Iterable<Service> getServices() { return Collections.singleton(AccessControlService.newReflectiveService(this)); }
Example #28
Source File: ServerRpcProvider.java From swellrt with Apache License 2.0 | 4 votes |
RegisteredServiceMethod(Service service, MethodDescriptor method) { this.service = service; this.method = method; }
Example #29
Source File: QueryEndpoint.java From yuzhouwan with Apache License 2.0 | 4 votes |
@Override public Service getService() { return this; }
Example #30
Source File: MockHTable.java From kylin with Apache License 2.0 | 4 votes |
@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 { throw new NotImplementedException(); }