ConfigurableWeightLoadBalance extends ActiveWeightLoadBalance<T> { @Override protected void doSelectToHolder(Request request, List<Referer<T>> refersHolder) { if (holder == emptyHolder) { return; } RefererListCacheHolder<T> h = this.holder; int i = 0, j = 0; while (i++ < getReferers().size()) { Referer<T> r = h.next(); if (r.isAvailable()) { refersHolder.add(r); if (++j == MAX_REFERER_COUNT) { return; } } } if (refersHolder.isEmpty()) { noAvailableReferer(); } }  @SuppressWarnings("unchecked") @Override void onRefresh(List<Referer<T>> referers); @Override void setWeightString(String weightString);  }
@Test public void testDoSelectToHolder() { generate(3, new int[] {2, 3, 5}, new int[] {3, 4, 5}); List<Referer<IHello>> list = new ArrayList<Referer<IHello>>(); balance.doSelectToHolder(new DefaultRequest(), list); assertTrue(list.size() > 0 && list.size() <= ConfigurableWeightLoadBalance.MAX_REFERER_COUNT); }