@Test public void testMixedNodes() throws Exception { startGroupMonitor(); String nonMemberPath = createNonMember(); assertEquals(ImmutableSet.of(), getGroupMonitor().get()); ServiceInstance member = serviceInstance("member"); String memberPath = createMember(member); assertEquals(ImmutableSet.of(member), getGroupMonitor().get()); deleteChild(memberPath); assertEquals(ImmutableSet.of(), getGroupMonitor().get()); deleteChild(nonMemberPath); assertEquals(ImmutableSet.of(), getGroupMonitor().get()); }
@Override public ImmutableSet<ServiceInstance> get() { return groupCache.getCurrentData().stream() .filter(cd -> memberSelector.test(ZKPaths.getNodeFromPath(cd.getPath()))) .map(this::extractServiceInstance) .filter(Optional::isPresent) .map(Optional::get) .collect(GuavaUtils.toImmutableSet()); }
CuratorServiceGroupMonitor implements ServiceGroupMonitor { @Override public ImmutableSet<ServiceInstance> get() { return groupCache.getCurrentData().stream() .filter(cd -> memberSelector.test(ZKPaths.getNodeFromPath(cd.getPath()))) .map(this::extractServiceInstance) .filter(Optional::isPresent) .map(Optional::get) .collect(GuavaUtils.toImmutableSet()); } }
CuratorServiceGroupMonitor implements ServiceGroupMonitor { @Override public ImmutableSet<ServiceInstance> get() { return groupCache.getCurrentData().stream() .filter(cd -> memberSelector.test(ZKPaths.getNodeFromPath(cd.getPath()))) .map(this::extractServiceInstance) .filter(Optional::isPresent) .map(Optional::get) .collect(GuavaUtils.toImmutableSet()); } CuratorServiceGroupMonitor(
      PathChildrenCache groupCache,
      Predicate<String> memberSelector,
      Codec<ServiceInstance> codec); }
CuratorServiceGroupMonitor implements ServiceGroupMonitor { @Override public ImmutableSet<ServiceInstance> get() { return groupCache.getCurrentData().stream() .filter(cd -> memberSelector.test(ZKPaths.getNodeFromPath(cd.getPath()))) .map(this::extractServiceInstance) .filter(Optional::isPresent) .map(Optional::get) .collect(GuavaUtils.toImmutableSet()); } CuratorServiceGroupMonitor(
      PathChildrenCache groupCache,
      Predicate<String> memberSelector,
      Codec<ServiceInstance> codec); @Override void start(); @Override void close(); @Override ImmutableSet<ServiceInstance> get(); }
CuratorServiceGroupMonitor implements ServiceGroupMonitor { @Override public ImmutableSet<ServiceInstance> get() { return groupCache.getCurrentData().stream() .filter(cd -> memberSelector.test(ZKPaths.getNodeFromPath(cd.getPath()))) .map(this::extractServiceInstance) .filter(Optional::isPresent) .map(Optional::get) .collect(GuavaUtils.toImmutableSet()); } CuratorServiceGroupMonitor(
      PathChildrenCache groupCache,
      Predicate<String> memberSelector,
      Codec<ServiceInstance> codec); @Override void start(); @Override void close(); @Override ImmutableSet<ServiceInstance> get();  }