io.grpc.health.v1.HealthCheckResponse.ServingStatus Java Examples

The following examples show how to use io.grpc.health.v1.HealthCheckResponse.ServingStatus. 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: HealthServiceImpl.java    From modeldb with Apache License 2.0 6 votes vote down vote up
@Override
public void check(
    HealthCheckRequest request, StreamObserver<HealthCheckResponse> responseObserver) {
  ServingStatus globalStatus;
  if (!request.getService().equals("")) {
    globalStatus = getStatus("");
    if (request.getService().equals("ready")) {
      if (globalStatus == ServingStatus.SERVING) {
        setStatus("ready", ModelDBHibernateUtil.checkReady());
      }
    } else if (request.getService().equals("live")) {
      setStatus("live", ModelDBHibernateUtil.checkLive());
    }
  }
  ServingStatus status = getStatus(request.getService());
  if (status == null) {
    responseObserver.onError(
        new StatusException(
            Status.NOT_FOUND.withDescription("unknown service " + request.getService())));
  } else {
    HealthCheckResponse response = HealthCheckResponse.newBuilder().setStatus(status).build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
  }
}
 
Example #2
Source File: HealthStatusManagerTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Test
public void checkValidStatus() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.NOT_SERVING);
  manager.setStatus(SERVICE2, ServingStatus.SERVING);
  HealthCheckRequest request = HealthCheckRequest.newBuilder().setService(SERVICE1).build();
  HealthCheckResponse response =
      blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
  assertThat(response).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.NOT_SERVING).build());

  request = HealthCheckRequest.newBuilder().setService(SERVICE2).build();
  response = blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
  assertThat(response).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVING).build());
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(0);
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(0);
}
 
Example #3
Source File: HealthCheckingLoadBalancerFactory.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
void handleResponse(HealthCheckResponse response) {
  callHasResponded = true;
  backoffPolicy = null;
  ServingStatus status = response.getStatus();
  // running == true means the Subchannel's state (rawState) is READY
  if (Objects.equal(status, ServingStatus.SERVING)) {
    subchannelLogger.log(ChannelLogLevel.INFO, "READY: health-check responded SERVING");
    gotoState(ConnectivityStateInfo.forNonError(READY));
  } else {
    subchannelLogger.log(
        ChannelLogLevel.INFO, "TRANSIENT_FAILURE: health-check responded {0}", status);
    gotoState(
        ConnectivityStateInfo.forTransientFailure(
            Status.UNAVAILABLE.withDescription(
                "Health-check service responded "
                + status + " for '" + callServiceName + "'")));
  }
  call.request(1);
}
 
Example #4
Source File: HealthCheckingLoadBalancerFactory.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
void handleResponse(HealthCheckResponse response) {
  callHasResponded = true;
  backoffPolicy = null;
  ServingStatus status = response.getStatus();
  // running == true means the Subchannel's state (rawState) is READY
  if (Objects.equal(status, ServingStatus.SERVING)) {
    subchannelLogger.log(ChannelLogLevel.INFO, "READY: health-check responded SERVING");
    gotoState(ConnectivityStateInfo.forNonError(READY));
  } else {
    subchannelLogger.log(
        ChannelLogLevel.INFO, "TRANSIENT_FAILURE: health-check responded {0}", status);
    gotoState(
        ConnectivityStateInfo.forTransientFailure(
            Status.UNAVAILABLE.withDescription(
                "Health-check service responded "
                + status + " for '" + callServiceName + "'")));
  }
  call.request(1);
}
 
Example #5
Source File: HealthStatusManagerTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
@Test
public void checkValidStatus() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.NOT_SERVING);
  manager.setStatus(SERVICE2, ServingStatus.SERVING);
  HealthCheckRequest request = HealthCheckRequest.newBuilder().setService(SERVICE1).build();
  HealthCheckResponse response =
      blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
  assertThat(response).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.NOT_SERVING).build());

  request = HealthCheckRequest.newBuilder().setService(SERVICE2).build();
  response = blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
  assertThat(response).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVING).build());
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(0);
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(0);
}
 
Example #6
Source File: HealthServiceImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
void enterTerminalState() {
  synchronized (watchLock) {
    if (terminal) {
      logger.log(Level.WARNING, "Already terminating", new RuntimeException());
      return;
    }
    terminal = true;
    for (String service : statusMap.keySet()) {
      setStatusInternal(service, ServingStatus.NOT_SERVING);
    }
  }
}
 
Example #7
Source File: HealthServiceImpl.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Override
public void check(HealthCheckRequest request,
    StreamObserver<HealthCheckResponse> responseObserver) {
  ServingStatus status = statusMap.get(request.getService());
  if (status == null) {
    responseObserver.onError(new StatusException(
        Status.NOT_FOUND.withDescription("unknown service " + request.getService())));
  } else {
    HealthCheckResponse response = HealthCheckResponse.newBuilder().setStatus(status).build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
  }
}
 
Example #8
Source File: XdsTestServer.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setServing(
    EmptyProtos.Empty req, StreamObserver<EmptyProtos.Empty> responseObserver) {
  health.setStatus("", ServingStatus.SERVING);
  responseObserver.onNext(EmptyProtos.Empty.getDefaultInstance());
  responseObserver.onCompleted();
}
 
Example #9
Source File: XdsTestServer.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setNotServing(
    EmptyProtos.Empty req, StreamObserver<EmptyProtos.Empty> responseObserver) {
  health.setStatus("", ServingStatus.NOT_SERVING);
  responseObserver.onNext(EmptyProtos.Empty.getDefaultInstance());
  responseObserver.onCompleted();
}
 
Example #10
Source File: HealthServiceImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public void check(HealthCheckRequest request,
    StreamObserver<HealthCheckResponse> responseObserver) {
  ServingStatus status = statusMap.get(request.getService());
  if (status == null) {
    responseObserver.onError(new StatusException(
        Status.NOT_FOUND.withDescription("unknown service " + request.getService())));
  } else {
    HealthCheckResponse response = HealthCheckResponse.newBuilder().setStatus(status).build();
    responseObserver.onNext(response);
    responseObserver.onCompleted();
  }
}
 
Example #11
Source File: HealthServiceImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
void setStatus(String service, ServingStatus status) {
  synchronized (watchLock) {
    if (terminal) {
      logger.log(Level.FINE, "Ignoring status {} for {}", new Object[]{status, service});
      return;
    }
    setStatusInternal(service, status);
  }
}
 
Example #12
Source File: HealthServiceImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@GuardedBy("watchLock")
private void setStatusInternal(String service, ServingStatus status) {
  ServingStatus prevStatus = statusMap.put(service, status);
  if (prevStatus != status) {
    notifyWatchers(service, status);
  }
}
 
Example #13
Source File: HealthServiceImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
void clearStatus(String service) {
  synchronized (watchLock) {
    if (terminal) {
      logger.log(Level.FINE, "Ignoring status clearing for {}", new Object[]{service});
      return;
    }
    ServingStatus prevStatus = statusMap.remove(service);
    if (prevStatus != null) {
      notifyWatchers(service, null);
    }
  }
}
 
Example #14
Source File: XdsTestServer.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
private void start() throws Exception {
  health = new HealthStatusManager();
  server =
      NettyServerBuilder.forPort(port)
          .addService(new TestServiceImpl(serverId))
          .addService(new XdsUpdateHealthServiceImpl(health))
          .addService(health.getHealthService())
          .addService(ProtoReflectionService.newInstance())
          .build()
          .start();
  health.setStatus("", ServingStatus.SERVING);
}
 
Example #15
Source File: HealthServiceImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@GuardedBy("watchLock")
private void notifyWatchers(String service, @Nullable ServingStatus status) {
  HealthCheckResponse response = getResponseForWatch(status);
  IdentityHashMap<StreamObserver<HealthCheckResponse>, Boolean> serviceWatchers =
      watchers.get(service);
  if (serviceWatchers != null) {
    for (StreamObserver<HealthCheckResponse> responseObserver : serviceWatchers.keySet()) {
      responseObserver.onNext(response);
    }
  }
}
 
Example #16
Source File: HealthStatusManagerTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void defaultIsServing() throws Exception {
  HealthCheckRequest request =
      HealthCheckRequest.newBuilder().setService(HealthStatusManager.SERVICE_NAME_ALL_SERVICES)
          .build();

  HealthCheckResponse response =
      blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);

  assertThat(response).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVING).build());
}
 
Example #17
Source File: HealthStatusManagerTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void checkStatusNotFound() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.SERVING);
  // SERVICE2's status is not set
  HealthCheckRequest request
      = HealthCheckRequest.newBuilder().setService(SERVICE2).build();
  try {
    blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
    fail("Should've failed");
  } catch (StatusRuntimeException e) {
    assertThat(e.getStatus().getCode()).isEqualTo(Status.Code.NOT_FOUND);
  }
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(0);
}
 
Example #18
Source File: HealthStatusManagerTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void notFoundForClearedStatus() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.SERVING);
  manager.clearStatus(SERVICE1);
  HealthCheckRequest request
      = HealthCheckRequest.newBuilder().setService(SERVICE1).build();
  try {
    blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
    fail("Should've failed");
  } catch (StatusRuntimeException e) {
    assertThat(e.getStatus().getCode()).isEqualTo(Status.Code.NOT_FOUND);
  }
}
 
Example #19
Source File: HealthStatusManagerTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void watchRemovedWhenClientCloses() throws Exception {
  CancellableContext withCancellation = Context.current().withCancellation();
  Context prevCtx = withCancellation.attach();
  RespObserver respObs1 = new RespObserver();
  try {
    assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(0);
    stub.watch(HealthCheckRequest.newBuilder().setService(SERVICE1).build(), respObs1);
  } finally {
    withCancellation.detach(prevCtx);
  }
  RespObserver respObs1b = new RespObserver();
  stub.watch(HealthCheckRequest.newBuilder().setService(SERVICE1).build(), respObs1b);
  RespObserver respObs2 = new RespObserver();
  stub.watch(HealthCheckRequest.newBuilder().setService(SERVICE2).build(), respObs2);

  assertThat(respObs1.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVICE_UNKNOWN).build());
  assertThat(respObs1b.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVICE_UNKNOWN).build());
  assertThat(respObs2.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVICE_UNKNOWN).build());
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(2);
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(1);
  assertThat(respObs1.responses).isEmpty();
  assertThat(respObs1b.responses).isEmpty();
  assertThat(respObs2.responses).isEmpty();

  // This will cancel the RPC with respObs1
  withCancellation.close();

  assertThat(respObs1.responses.poll()).isInstanceOf(Throwable.class);
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(1);
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(1);
  assertThat(respObs1.responses).isEmpty();
  assertThat(respObs1b.responses).isEmpty();
  assertThat(respObs2.responses).isEmpty();
}
 
Example #20
Source File: BuildFarmServer.java    From bazel-buildfarm with Apache License 2.0 5 votes vote down vote up
public void start() throws IOException {
  actionCacheRequestCounter.start();
  instances.start();
  server.start();
  healthStatusManager.setStatus(
      HealthStatusManager.SERVICE_NAME_ALL_SERVICES, ServingStatus.SERVING);
}
 
Example #21
Source File: HealthServiceImpl.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
void setStatus(String service, ServingStatus status) {
  synchronized (watchLock) {
    ServingStatus prevStatus = statusMap.put(service, status);
    if (prevStatus != status) {
      notifyWatchers(service, status);
    }
  }
}
 
Example #22
Source File: HealthServiceImpl.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
void clearStatus(String service) {
  synchronized (watchLock) {
    ServingStatus prevStatus = statusMap.remove(service);
    if (prevStatus != null) {
      notifyWatchers(service, null);
    }
  }
}
 
Example #23
Source File: HealthServiceImpl.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@GuardedBy("watchLock")
private void notifyWatchers(String service, @Nullable ServingStatus status) {
  HealthCheckResponse response = getResponseForWatch(status);
  IdentityHashMap<StreamObserver<HealthCheckResponse>, Boolean> serviceWatchers =
      watchers.get(service);
  if (serviceWatchers != null) {
    for (StreamObserver<HealthCheckResponse> responseObserver : serviceWatchers.keySet()) {
      responseObserver.onNext(response);
    }
  }
}
 
Example #24
Source File: HealthStatusManagerTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void checkStatusNotFound() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.SERVING);
  // SERVICE2's status is not set
  HealthCheckRequest request
      = HealthCheckRequest.newBuilder().setService(SERVICE2).build();
  try {
    blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
    fail("Should've failed");
  } catch (StatusRuntimeException e) {
    assertThat(e.getStatus().getCode()).isEqualTo(Status.Code.NOT_FOUND);
  }
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(0);
}
 
Example #25
Source File: HealthStatusManagerTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void notFoundForClearedStatus() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.SERVING);
  manager.clearStatus(SERVICE1);
  HealthCheckRequest request
      = HealthCheckRequest.newBuilder().setService(SERVICE1).build();
  try {
    blockingStub.withDeadlineAfter(5, TimeUnit.SECONDS).check(request);
    fail("Should've failed");
  } catch (StatusRuntimeException e) {
    assertThat(e.getStatus().getCode()).isEqualTo(Status.Code.NOT_FOUND);
  }
}
 
Example #26
Source File: BuildFarmServer.java    From bazel-buildfarm with Apache License 2.0 5 votes vote down vote up
public void stop() {
  synchronized (this) {
    if (stopping) {
      return;
    }
    stopping = true;
  }
  healthStatusManager.setStatus(
      HealthStatusManager.SERVICE_NAME_ALL_SERVICES, ServingStatus.NOT_SERVING);
  try {
    if (server != null) {
      server.shutdown();
    }
    instances.stop();
    server.awaitTermination(10, TimeUnit.SECONDS);
  } catch (InterruptedException e) {
    if (server != null) {
      server.shutdownNow();
    }
  }
  if (!shutdownAndAwaitTermination(keepaliveScheduler, 10, TimeUnit.SECONDS)) {
    logger.log(Level.WARNING, "could not shut down keepalive scheduler");
  }
  if (!actionCacheRequestCounter.stop()) {
    logger.log(Level.WARNING, "count not shut down action cache request counter");
  }
}
 
Example #27
Source File: HealthCheckingLoadBalancerFactoryTest.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckDisabledWhenServiceNotImplemented() {
  Attributes resolutionAttrs = attrsWithHealthCheckService("BarService");
  ResolvedAddresses result = ResolvedAddresses.newBuilder()
      .setAddresses(resolvedAddressList)
      .setAttributes(resolutionAttrs)
      .build();
  hcLbEventDelivery.handleResolvedAddresses(result);

  verify(origLb).handleResolvedAddresses(result);
  verifyNoMoreInteractions(origLb);

  // We create 2 Subchannels. One of them connects to a server that doesn't implement health check
  for (int i = 0; i < 2; i++) {
    createSubchannel(i, Attributes.EMPTY);
  }

  InOrder inOrder = inOrder(mockStateListeners[0], mockStateListeners[1]);

  for (int i = 0; i < 2; i++) {
    deliverSubchannelState(i, ConnectivityStateInfo.forNonError(READY));
    assertThat(healthImpls[i].calls).hasSize(1);
    inOrder.verify(mockStateListeners[i]).onSubchannelState(
        eq(ConnectivityStateInfo.forNonError(CONNECTING)));
  }

  ServerSideCall serverCall0 = healthImpls[0].calls.poll();
  ServerSideCall serverCall1 = healthImpls[1].calls.poll();

  subchannels[0].logs.clear();
  // subchannels[0] gets UNIMPLEMENTED for health checking, which will disable health
  // checking and it'll use the original state, which is currently READY.
  // In reality UNIMPLEMENTED is generated by GRPC server library, but the client can't tell
  // whether it's the server library or the service implementation that returned this status.
  serverCall0.responseObserver.onError(Status.UNIMPLEMENTED.asException());
  inOrder.verify(mockStateListeners[0]).onSubchannelState(
      eq(ConnectivityStateInfo.forNonError(READY)));
  assertThat(subchannels[0].logs).containsExactly(
      "ERROR: Health-check disabled: " + Status.UNIMPLEMENTED,
      "INFO: READY (no health-check)").inOrder();

  // subchannels[1] has normal health checking
  serverCall1.responseObserver.onNext(makeResponse(ServingStatus.NOT_SERVING));
  inOrder.verify(mockStateListeners[1]).onSubchannelState(
      unavailableStateWithMsg("Health-check service responded NOT_SERVING for 'BarService'"));

  // Without health checking, states from underlying Subchannel are delivered directly to the mock
  // listeners.
  deliverSubchannelState(0, ConnectivityStateInfo.forNonError(IDLE));
  inOrder.verify(mockStateListeners[0]).onSubchannelState(
      eq(ConnectivityStateInfo.forNonError(IDLE)));

  // Re-connecting on a Subchannel will reset the "disabled" flag.
  assertThat(healthImpls[0].calls).hasSize(0);
  deliverSubchannelState(0, ConnectivityStateInfo.forNonError(READY));
  assertThat(healthImpls[0].calls).hasSize(1);
  serverCall0 = healthImpls[0].calls.poll();
  inOrder.verify(mockStateListeners[0]).onSubchannelState(
      eq(ConnectivityStateInfo.forNonError(CONNECTING)));

  // Health check now works as normal
  serverCall0.responseObserver.onNext(makeResponse(ServingStatus.SERVICE_UNKNOWN));
  inOrder.verify(mockStateListeners[0]).onSubchannelState(
      unavailableStateWithMsg("Health-check service responded SERVICE_UNKNOWN for 'BarService'"));

  verifyNoMoreInteractions(origLb, mockStateListeners[0], mockStateListeners[1]);
  verifyZeroInteractions(backoffPolicyProvider);
}
 
Example #28
Source File: HealthStatusManagerTest.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
@Test
public void watch() throws Exception {
  manager.setStatus(SERVICE1, ServingStatus.UNKNOWN);

  // Start a watch on SERVICE1
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(0);
  RespObserver respObs1 = new RespObserver();
  stub.watch(HealthCheckRequest.newBuilder().setService(SERVICE1).build(), respObs1);
  // Will get the current status
  assertThat(respObs1.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.UNKNOWN).build());        
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(1);

  // Status change is notified of to the RPC
  manager.setStatus(SERVICE1, ServingStatus.SERVING);
  assertThat(respObs1.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVING).build());        

  // Start another watch on SERVICE1
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(1);
  RespObserver respObs1b = new RespObserver();
  stub.watch(HealthCheckRequest.newBuilder().setService(SERVICE1).build(), respObs1b);
  assertThat(service.numWatchersForTest(SERVICE1)).isEqualTo(2);
  // Will get the current status
  assertThat(respObs1b.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVING).build());

  // Start a watch on SERVICE2, which is not known yet
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(0);
  RespObserver respObs2 = new RespObserver();
  stub.watch(HealthCheckRequest.newBuilder().setService(SERVICE2).build(), respObs2);
  assertThat(service.numWatchersForTest(SERVICE2)).isEqualTo(1);
  // Current status is SERVICE_UNKNOWN
  assertThat(respObs2.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVICE_UNKNOWN).build());

  // Set status for SERVICE2, which will be notified of
  manager.setStatus(SERVICE2, ServingStatus.NOT_SERVING);
  assertThat(respObs2.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.NOT_SERVING).build());

  // Clear the status for SERVICE1, which will be notified of
  manager.clearStatus(SERVICE1);
  assertThat(respObs1.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVICE_UNKNOWN).build());
  assertThat(respObs1b.responses.poll()).isEqualTo(
      HealthCheckResponse.newBuilder().setStatus(ServingStatus.SERVICE_UNKNOWN).build());

  // All responses have been accounted for
  assertThat(respObs1.responses).isEmpty();
  assertThat(respObs1b.responses).isEmpty();
  assertThat(respObs2.responses).isEmpty();
}
 
Example #29
Source File: HealthServiceImpl.java    From modeldb with Apache License 2.0 4 votes vote down vote up
void setStatus(String service, ServingStatus status) {
  statusMap.put(service, status);
}
 
Example #30
Source File: HealthServiceImpl.java    From modeldb with Apache License 2.0 4 votes vote down vote up
@Nullable
private ServingStatus getStatus(String service) {
  return statusMap.get(service);
}