@Test public void testTwo() { BehaviorSubject<List<Integer>> source = BehaviorSubject.create(); LoadBalancer<Integer> lb = LoadBalancer.fromSnapshotSource(source).build(ChoiceOfTwoLoadBalancer.create(COMPARATOR)); source.onNext(Lists.newArrayList(0,1)); AtomicIntegerArray counts = new AtomicIntegerArray(2); for (int i = 0; i < 100; i++) { counts.incrementAndGet(lb.next()); } Assert.assertEquals(counts.get(0), 0); Assert.assertEquals(counts.get(1), 100); }
public static <T> ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func) { return new ChoiceOfTwoLoadBalancer<T>(func); }
ChoiceOfTwoLoadBalancer implements LoadBalancerStrategy<T> { public static <T> ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func) { return new ChoiceOfTwoLoadBalancer<T>(func); } }
ChoiceOfTwoLoadBalancer implements LoadBalancerStrategy<T> { public static <T> ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func) { return new ChoiceOfTwoLoadBalancer<T>(func); } ChoiceOfTwoLoadBalancer(final Comparator<T> func2); }
ChoiceOfTwoLoadBalancer implements LoadBalancerStrategy<T> { public static <T> ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func) { return new ChoiceOfTwoLoadBalancer<T>(func); } ChoiceOfTwoLoadBalancer(final Comparator<T> func2); static ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func); @Override T choose(List<T> candidates); }
ChoiceOfTwoLoadBalancer implements LoadBalancerStrategy<T> { public static <T> ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func) { return new ChoiceOfTwoLoadBalancer<T>(func); } ChoiceOfTwoLoadBalancer(final Comparator<T> func2); static ChoiceOfTwoLoadBalancer<T> create(final Comparator<T> func); @Override T choose(List<T> candidates);  }