Refine search
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (WatchGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new WatchFileDescriptorSupplier()) .addMethod(METHOD_WATCH) .build(); } } } return result; } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { return new io.grpc.ServiceDescriptor(SERVICE_NAME, METHOD_GET_FEATURE, METHOD_LIST_FEATURES, METHOD_RECORD_ROUTE, METHOD_ROUTE_CHAT); }
Builder addService(ServerServiceDefinition service) { services.put(service.getServiceDescriptor().getName(), service); return this; }
for (ServerServiceDefinition service : grpcService.services()) { map.computeIfAbsent( service.getServiceDescriptor().getName(), s -> { final FileDescriptor fileDescriptor = ((ProtoFileDescriptorSupplier) service.getServiceDescriptor().getSchemaDescriptor()).getFileDescriptor(); final ServiceDescriptor serviceDescriptor = fileDescriptor.getServices().stream() .filter(sd -> sd.getFullName().equals( service.getServiceDescriptor().getName())) .findFirst() .orElseThrow(IllegalStateException::new); final String serviceName = service.getServiceDescriptor().getName(); map.get(serviceName).endpoint( new EndpointInfoBuilder(serviceConfig.virtualHost().hostnamePattern(),
private static List<MethodDescriptor<?, ?>> stubMethods(Class<?> stubClass) { final Method getServiceDescriptorMethod; try { getServiceDescriptorMethod = stubClass.getDeclaredMethod("getServiceDescriptor"); } catch (NoSuchMethodException e) { throw new IllegalStateException("Could not find getServiceDescriptor on gRPC client stub."); } final ServiceDescriptor descriptor; try { descriptor = (ServiceDescriptor) getServiceDescriptorMethod.invoke(stubClass); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Could not invoke getServiceDescriptor on a gRPC client stub."); } return ImmutableList.copyOf(descriptor.getMethods()); }
@SuppressWarnings({"unchecked", "rawtypes"}) public static ServerServiceDefinition getServiceDefByAnnotation(Class<?> clazz) throws Exception { ServiceDescriptor serviceDesc = getServiceDesc(getGrpcClassName(clazz)); io.grpc.ServerServiceDefinition.Builder builder = io.grpc.ServerServiceDefinition.builder(serviceDesc); for (MethodDescriptor<?, ?> methodDesc : serviceDesc.getMethods()) { builder.addMethod(methodDesc, new MotanServerCallHandler()); } return builder.build(); }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (MetaMasterConfigurationServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new MetaMasterConfigurationServiceFileDescriptorSupplier()) .addMethod(getGetConfigurationMethod()) .build(); } } } return result; } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { return new io.grpc.ServiceDescriptor(SERVICE_NAME, METHOD_GET_FUNCTION_STATUS, METHOD_GET_AND_RESET_METRICS, METHOD_RESET_METRICS, METHOD_GET_METRICS, METHOD_HEALTH_CHECK); }
@Override public void destroy() throws Exception { log.info("Shutting down gRPC server ..."); server.getServices().forEach(def->healthStatusManager.clearStatus(def.getServiceDescriptor().getName())); Optional.ofNullable(server).ifPresent(Server::shutdown); log.info("gRPC server stopped."); }
@SuppressWarnings("rawtypes") public static HashMap<String, MethodDescriptor> getMethodDescriptorByAnnotation(Class<?> clazz, String serialization) throws Exception { String clazzName = getGrpcClassName(clazz); HashMap<String, MethodDescriptor> result = serviceMap.get(clazzName); if (result == null) { synchronized (serviceMap) { if (!serviceMap.containsKey(clazzName)) { ServiceDescriptor serviceDesc = getServiceDesc(getGrpcClassName(clazz)); HashMap<String, MethodDescriptor> methodMap = new HashMap<String, MethodDescriptor>(); for (MethodDescriptor<?, ?> methodDesc : serviceDesc.getMethods()) { Method interfaceMethod = getMethod(methodDesc.getFullMethodName(), clazz); if(JSON_CODEC.equals(serialization)){ methodDesc = convertJsonDescriptor(methodDesc, interfaceMethod.getParameterTypes()[0], interfaceMethod.getReturnType()); } methodMap.put(interfaceMethod.getName(), methodDesc); } serviceMap.put(clazzName, methodMap); } result = serviceMap.get(clazzName); } } return result; }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (MetricsMasterClientServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new MetricsMasterClientServiceFileDescriptorSupplier()) .addMethod(getMetricsHeartbeatMethod()) .build(); } } } return result; } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { return new io.grpc.ServiceDescriptor(SERVICE_NAME, METHOD_GET_FEATURE, METHOD_LIST_FEATURES, METHOD_RECORD_ROUTE, METHOD_ROUTE_CHAT); }
@Override public void run(String... args) throws Exception { log.info("Starting gRPC Server ..."); Collection<ServerInterceptor> globalInterceptors = getBeanNamesByTypeWithAnnotation(GRpcGlobalInterceptor.class, ServerInterceptor.class) .map(name -> applicationContext.getBeanFactory().getBean(name, ServerInterceptor.class)) .collect(Collectors.toList()); // Adding health service serverBuilder.addService(healthStatusManager.getHealthService()); // find and register all GRpcService-enabled beans getBeanNamesByTypeWithAnnotation(GRpcService.class, BindableService.class) .forEach(name -> { BindableService srv = applicationContext.getBeanFactory().getBean(name, BindableService.class); ServerServiceDefinition serviceDefinition = srv.bindService(); GRpcService gRpcServiceAnn = applicationContext.findAnnotationOnBean(name, GRpcService.class); serviceDefinition = bindInterceptors(serviceDefinition, gRpcServiceAnn, globalInterceptors); serverBuilder.addService(serviceDefinition); String serviceName = serviceDefinition.getServiceDescriptor().getName(); healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); log.info("'{}' service has been registered.", srv.getClass().getName()); }); if (gRpcServerProperties.isEnableReflection()) { serverBuilder.addService(ProtoReflectionService.newInstance()); log.info("'{}' service has been registered.", ProtoReflectionService.class.getName()); } configurer.configure(serverBuilder); server = serverBuilder.build().start(); applicationContext.publishEvent(new GRpcServerInitializedEvent(server)); log.info("gRPC Server started, listening on port {}.", server.getPort()); startDaemonAwaitThread(); }
/** * Removes all access predicates for the all methods of the given service. After that, the default will be used for * those methods. * * @param service The service to protect with only the default. * @return This instance for chaining. * @see #setDefault(AccessPredicate) */ public ManualGrpcSecurityMetadataSource remove(final ServiceDescriptor service) { requireNonNull(service, "service"); for (final MethodDescriptor<?, ?> method : service.getMethods()) { this.accessMap.remove(method); } return this; }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (SaslAuthenticationServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new SaslAuthenticationServiceFileDescriptorSupplier()) .addMethod(getAuthenticateMethod()) .build(); } } } return result; } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { return new io.grpc.ServiceDescriptor(SERVICE_NAME, METHOD_SAY_HELLO); }
@Test public void testHealthCheck() throws ExecutionException, InterruptedException { final HealthCheckRequest healthCheckRequest = HealthCheckRequest.newBuilder().setService(GreeterGrpc.getServiceDescriptor().getName()).build(); final HealthGrpc.HealthFutureStub healthFutureStub = HealthGrpc.newFutureStub(channel); final HealthCheckResponse.ServingStatus servingStatus = healthFutureStub.check(healthCheckRequest).get().getStatus(); assertNotNull(servingStatus); assertEquals(servingStatus, HealthCheckResponse.ServingStatus.SERVING); } }
/** * Pre-registers the all methods provided by the given service. This will initialize all default counters and timers * for those methods. * * @param service The service to initialize the meters for. * @see #preregisterMethod(MethodDescriptor) */ public void preregisterService(final ServiceDescriptor service) { for (final MethodDescriptor<?, ?> method : service.getMethods()) { preregisterMethod(method); } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { io.grpc.ServiceDescriptor result = serviceDescriptor; if (result == null) { synchronized (ServiceVersionClientServiceGrpc.class) { result = serviceDescriptor; if (result == null) { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new ServiceVersionClientServiceFileDescriptorSupplier()) .addMethod(getGetServiceVersionMethod()) .build(); } } } return result; } }
public static io.grpc.ServiceDescriptor getServiceDescriptor() { return new io.grpc.ServiceDescriptor(SERVICE_NAME, METHOD_GET_GENE, METHOD_GET_TRANSCRIPT, METHOD_GET_VARIATION, METHOD_GET_SEQUENCE, METHOD_GET_REGULATORY_REGION, METHOD_GET_TFBS); }