io.grpc.health.v1.HealthGrpc Java Examples
The following examples show how to use
io.grpc.health.v1.HealthGrpc.
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: GRPCServerProvider.java From conductor with Apache License 2.0 | 6 votes |
@Inject public GRPCServerProvider( GRPCServerConfiguration grpcServerConfiguration, HealthGrpc.HealthImplBase healthServiceImpl, EventServiceGrpc.EventServiceImplBase eventServiceImpl, MetadataServiceGrpc.MetadataServiceImplBase metadataServiceImpl, TaskServiceGrpc.TaskServiceImplBase taskServiceImpl, WorkflowServiceGrpc.WorkflowServiceImplBase workflowServiceImpl ) { this.configuration = grpcServerConfiguration; this.healthServiceImpl = healthServiceImpl; this.eventServiceImpl = eventServiceImpl; this.metadataServiceImpl = metadataServiceImpl; this.taskServiceImpl = taskServiceImpl; this.workflowServiceImpl = workflowServiceImpl; }
Example #2
Source File: HealthServiceImplTest.java From conductor with Apache License 2.0 | 6 votes |
@Test public void healthServing() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); HealthCheckStatus hcs = mock(HealthCheckStatus.class); when(hcs.isHealthy()).thenReturn(true); when(hcsf.get()).thenReturn(hcs); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build()); assertEquals(HealthCheckResponse.ServingStatus.SERVING, reply.getStatus()); }
Example #3
Source File: HealthServiceImplTest.java From conductor with Apache License 2.0 | 6 votes |
@Test public void healthNotServing() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); HealthCheckStatus hcs = mock(HealthCheckStatus.class); when(hcs.isHealthy()).thenReturn(false); when(hcsf.get()).thenReturn(hcs); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build()); assertEquals(HealthCheckResponse.ServingStatus.NOT_SERVING, reply.getStatus()); }
Example #4
Source File: HealthServiceImplTest.java From conductor with Apache License 2.0 | 6 votes |
@Test public void healthException() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); when(hcsf.get()).thenThrow(InterruptedException.class); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); thrown.expect(StatusRuntimeException.class); thrown.expect(hasProperty("status", is(Status.INTERNAL))); blockingStub.check(HealthCheckRequest.newBuilder().build()); }
Example #5
Source File: HealthCheckClient.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
public HealthCheckClient() { String target = "zookeeper:///grpc.health.v1.Health"; channel = ManagedChannelBuilder.forTarget(target) .usePlaintext() .build(); blockingStub = HealthGrpc.newBlockingStub(channel); }
Example #6
Source File: GrpcHealthIndicator.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@Override public Health health() { HealthGrpc.HealthImplBase healthService = (HealthGrpc.HealthImplBase) healthStatusManager .getHealthService(); HealthCheckRequest healthcheckRequest = HealthCheckRequest.newBuilder().setService(serviceName).build(); HealthStreamObserver healthStreamObserver = new HealthStreamObserver(); healthService.check(healthcheckRequest, healthStreamObserver); return healthStreamObserver.getHealth(); }
Example #7
Source File: Tiller.java From microbean-helm with Apache License 2.0 | 5 votes |
public HealthBlockingStub getHealthBlockingStub() { HealthBlockingStub returnValue = null; if (this.channel != null) { returnValue = MetadataUtils.attachHeaders(HealthGrpc.newBlockingStub(this.channel), metadata); } return returnValue; }
Example #8
Source File: Tiller.java From microbean-helm with Apache License 2.0 | 5 votes |
public HealthFutureStub getHealthFutureStub() { HealthFutureStub returnValue = null; if (this.channel != null) { returnValue = MetadataUtils.attachHeaders(HealthGrpc.newFutureStub(this.channel), metadata); } return returnValue; }
Example #9
Source File: Tiller.java From microbean-helm with Apache License 2.0 | 5 votes |
public HealthStub getHealthStub() { HealthStub returnValue = null; if (this.channel != null) { returnValue = MetadataUtils.attachHeaders(HealthGrpc.newStub(this.channel), metadata); } return returnValue; }
Example #10
Source File: GRPCModule.java From conductor with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(HealthGrpc.HealthImplBase.class).to(HealthServiceImpl.class); bind(EventServiceGrpc.EventServiceImplBase.class).to(EventServiceImpl.class); bind(MetadataServiceGrpc.MetadataServiceImplBase.class).to(MetadataServiceImpl.class); bind(TaskServiceGrpc.TaskServiceImplBase.class).to(TaskServiceImpl.class); bind(WorkflowServiceGrpc.WorkflowServiceImplBase.class).to(WorkflowServiceImpl.class); bind(GRPCServerConfiguration.class).to(GRPCServerSystemConfiguration.class); bind(GRPCServerProvider.class); }
Example #11
Source File: DemoAppTest.java From grpc-spring-boot-starter with Apache License 2.0 | 5 votes |
@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); }
Example #12
Source File: HealthCheckingLoadBalancerFactory.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
HcStream() { callCreationNanos = time.currentTimeNanos(); callServiceName = serviceName; call = subchannel.asChannel().newCall(HealthGrpc.getWatchMethod(), CallOptions.DEFAULT); }
Example #13
Source File: HealthStatusManagerTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Before public void setup() { grpcServerRule.getServiceRegistry().addService(service); stub = HealthGrpc.newStub(grpcServerRule.getChannel()); blockingStub = HealthGrpc.newBlockingStub(grpcServerRule.getChannel()); }
Example #14
Source File: HealthCheckingLoadBalancerFactory.java From grpc-java with Apache License 2.0 | 4 votes |
HcStream() { stopwatch = stopwatchSupplier.get().start(); callServiceName = serviceName; call = subchannel.asChannel().newCall(HealthGrpc.getWatchMethod(), CallOptions.DEFAULT); }
Example #15
Source File: HealthStatusManagerTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Before public void setup() { grpcServerRule.getServiceRegistry().addService(service); stub = HealthGrpc.newStub(grpcServerRule.getChannel()); blockingStub = HealthGrpc.newBlockingStub(grpcServerRule.getChannel()); }