@GET @Timed @ApiOperation(value = "List current status of ServiceManager") @Produces(MediaType.APPLICATION_JSON) public Map<Service, Long> list() { return serviceManager.startupTimes(); } }
public void testServiceStartupTimes() { Service a = new NoOpDelayedService(150); Service b = new NoOpDelayedService(353); ServiceManager serviceManager = new ServiceManager(asList(a, b)); serviceManager.startAsync().awaitHealthy(); ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes(); assertEquals(2, startupTimes.size()); // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150); assertTrue(startupTimes.get(a) >= 150); // TODO(kak): Use assertThat(startupTimes.get(b)).isAtLeast(353); assertTrue(startupTimes.get(b) >= 353); }
System.exit(-1); LOG.info("Services started, startup times in ms: {}", serviceManager.startupTimes());
ServiceManager serviceManager = new ServiceManager(asList(a, b)); serviceManager.startAsync().awaitHealthy(); ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes(); assertEquals(2, startupTimes.size());
assertTrue(manager.startupTimes().isEmpty()); Formatter logFormatter = new Formatter() {
@GET @Timed @ApiOperation(value = "List current status of ServiceManager") @Produces(MediaType.APPLICATION_JSON) public Map<Service, Long> list() { return serviceManager.startupTimes(); } }
ImmutableMap<Service, Long> serviceStartupTimeMap = this.serviceManager.startupTimes();
System.exit(-1); LOG.info("Services started, startup times in ms: {}", serviceManager.startupTimes());
public void testServiceStartupTimes() { Service a = new NoOpDelayedService(150); Service b = new NoOpDelayedService(353); ServiceManager serviceManager = new ServiceManager(asList(a, b)); serviceManager.startAsync().awaitHealthy(); ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes(); assertEquals(2, startupTimes.size()); // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150); assertTrue(startupTimes.get(a) >= 150); // TODO(kak): Use assertThat(startupTimes.get(b)).isAtLeast(353); assertTrue(startupTimes.get(b) >= 353); }
public void testServiceStartupTimes_selfStartingServices() { // This tests to ensure that: // 1. service times are accurate when the service is started by the manager // 2. service times are recorded when the service is not started by the manager (but they may // not be accurate). final Service b = new NoOpDelayedService(353) { @Override protected void doStart() { super.doStart(); // This will delay service listener execution at least 150 milliseconds Uninterruptibles.sleepUninterruptibly(150, TimeUnit.MILLISECONDS); } }; Service a = new NoOpDelayedService(150) { @Override protected void doStart() { b.startAsync(); super.doStart(); } }; ServiceManager serviceManager = new ServiceManager(asList(a, b)); serviceManager.startAsync().awaitHealthy(); ImmutableMap<Service, Long> startupTimes = serviceManager.startupTimes(); assertEquals(2, startupTimes.size()); // TODO(kak): Use assertThat(startupTimes.get(a)).isAtLeast(150); assertTrue(startupTimes.get(a) >= 150); // Service b startup takes at least 353 millis, but starting the timer is delayed by at least // 150 milliseconds. so in a perfect world the timing would be 353-150=203ms, but since either // of our sleep calls can be arbitrarily delayed we should just assert that there is a time // recorded. assertThat(startupTimes.get(b)).isNotNull(); }
assertTrue(manager.startupTimes().isEmpty()); Formatter logFormatter = new Formatter() { @Override public String format(LogRecord record) {