@Test public void testCheckInOk() throws Exception { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicBoolean result = new AtomicBoolean(); healthService.register("foo", 1, TimeUnit.SECONDS); healthService.checkInOk("foo"); healthService.findHealthyNodes(names -> { result.set(names.stream().anyMatch(s -> s.equals("foo"))); countDownLatch.countDown(); } ); countDownLatch.await(10, TimeUnit.SECONDS); assertTrue("foo is in healthy list", result.get()); }
private void check() { now = timer.now(); long duration = now - lastCheckTime; if (duration > checkInIntervalMS) { lastCheckTime = now; final boolean failing = healthManager.isFailing(); if (!failing) { healthServiceAsync.checkInOk(serviceName); } else { healthServiceAsync.checkIn(serviceName, HealthStatus.FAIL); } healthServiceAsync.clientProxyFlush(); } }
@Before public void setUp() throws Exception { adminBuilder = AdminBuilder.adminBuilder(); int port = adminBuilder.getPort(); port = PortUtils.findOpenPortStartAt(port); adminBuilder.setPort(port); adminBuilder.getHealthService().register("foo", 1, TimeUnit.SECONDS); adminBuilder.getHealthService().register("bar", 1, TimeUnit.SECONDS); adminBuilder.getHealthService().register("baz", 1, TimeUnit.SECONDS); adminBuilder.getHealthService().checkInOk("foo"); adminBuilder.getHealthService().checkInOk("bar"); adminBuilder.getHealthService().checkInOk("baz"); serviceEndpointServer = adminBuilder.build().startServer(); httpClient = HttpClientBuilder.httpClientBuilder().setPort(adminBuilder.getPort()).build().startClient(); }
private void check() { now = timer.now(); long duration = now - lastCheckTime; if (duration > checkInIntervalMS) { lastCheckTime = now; final boolean failing = healthManager.isFailing(); if (!failing) { healthServiceAsync.checkInOk(serviceName); } else { healthServiceAsync.checkIn(serviceName, HealthStatus.FAIL); } healthServiceAsync.clientProxyFlush(); } }
private void check() { now = timer.now(); long duration = now - lastCheckTime; if (duration > checkInIntervalMS) { lastCheckTime = now; final ServiceQueue serviceQueue = ServiceContext.serviceContext().currentService(); boolean failing = serviceQueue.failing(); if (!failing) { healthServiceAsync.checkInOk(serviceName); } else { healthServiceAsync.checkIn(serviceName, HealthStatus.FAIL); } healthServiceAsync.clientProxyFlush(); } }