@Test public void failureToLoad() throws Exception { final CountDownLatch latch = new CountDownLatch(1); Map<String, Loader> loaders = new LinkedHashMap<>(); loaders.put("edda", eddaLoader()); loaders.put("eureka", () -> { if (latch.getCount() > 0) { latch.countDown(); throw new RuntimeException(); } return Collections.singletonList(eurekaGroup()); }); GroupService service = new GroupService(new NoopRegistry(), Duration.ZERO, loaders); service.start(); Assert.assertEquals(Collections.singletonList(eddaGroup()), service.getGroups()); service.stop(); }
public List<ServerGroup> getGroups() { List<ServerGroup> groups = merged; if (groups == null) { groups = new ArrayList<>(); for (String k : loaders.keySet()) { List<ServerGroup> otherGroups = cachedData.get(k); if (otherGroups != null && !otherGroups.isEmpty()) { groups = ServerGroup.merge(groups, otherGroups); } } groups = Collections.unmodifiableList(groups); merged = groups; } return groups; }
GroupService extends AbstractService { public List<ServerGroup> getGroups() { List<ServerGroup> groups = merged; if (groups == null) { groups = new ArrayList<>(); for (String k : loaders.keySet()) { List<ServerGroup> otherGroups = cachedData.get(k); if (otherGroups != null && !otherGroups.isEmpty()) { groups = ServerGroup.merge(groups, otherGroups); } } groups = Collections.unmodifiableList(groups); merged = groups; } return groups; } }
GroupService extends AbstractService { public List<ServerGroup> getGroups() { List<ServerGroup> groups = merged; if (groups == null) { groups = new ArrayList<>(); for (String k : loaders.keySet()) { List<ServerGroup> otherGroups = cachedData.get(k); if (otherGroups != null && !otherGroups.isEmpty()) { groups = ServerGroup.merge(groups, otherGroups); } } groups = Collections.unmodifiableList(groups); merged = groups; } return groups; } GroupService(
      Registry registry,
      Duration frequency,
      Map<String, Loader> loaders); }
GroupService extends AbstractService { public List<ServerGroup> getGroups() { List<ServerGroup> groups = merged; if (groups == null) { groups = new ArrayList<>(); for (String k : loaders.keySet()) { List<ServerGroup> otherGroups = cachedData.get(k); if (otherGroups != null && !otherGroups.isEmpty()) { groups = ServerGroup.merge(groups, otherGroups); } } groups = Collections.unmodifiableList(groups); merged = groups; } return groups; } GroupService(
      Registry registry,
      Duration frequency,
      Map<String, Loader> loaders); List<ServerGroup> getGroups(); }
GroupService extends AbstractService { public List<ServerGroup> getGroups() { List<ServerGroup> groups = merged; if (groups == null) { groups = new ArrayList<>(); for (String k : loaders.keySet()) { List<ServerGroup> otherGroups = cachedData.get(k); if (otherGroups != null && !otherGroups.isEmpty()) { groups = ServerGroup.merge(groups, otherGroups); } } groups = Collections.unmodifiableList(groups); merged = groups; } return groups; } GroupService(
      Registry registry,
      Duration frequency,
      Map<String, Loader> loaders); List<ServerGroup> getGroups();  }