### Question:
ThriftLoadBalancer implements Closeable, Balancer<NodeStatus<I, C>> { @Override public void reBalance() { synchronized (updateStatusLock) { try { List<ThriftDcBalancer<I, C>> dcCopy = nodesHolder.getDcList(); for (ThriftDcBalancer<I, C> dc : dcCopy) { boolean preferred = dc.getDcName().equals(config.getPreferredDc()); dc.getLoadAccumulator().setPreferred(preferred); dc.reBalance(); } List<ThriftDcBalancer<I, C>> balancerList = dcCopy.stream() .filter(ThriftDcBalancer::isWorking) .collect(Collectors.toList()); if (balancerList.isEmpty()) { balancerList = dcCopy.stream() .filter(ThriftDcBalancer::canProcessRequests) .collect(Collectors.toList()); } balancer = new LoadBasedBalancer<>( balancerList, ThriftDcBalancer::getLoadAccumulator, ThriftDcBalancer::getLoad, config.getDcLoadFilterFactor(), config.getDcLoadPredictFactor(), config.getDcWeightFilterFactor() ); } catch (Exception ex) { log.error("Unable to update ring status. Service {}", serviceName, ex); } } } protected  ThriftLoadBalancer(
            String serviceName,
            ThriftBalancerConfig config,
            ScheduledExecutorService reBalanceScheduler,
            ScheduledExecutorService reloadScheduler,
            NodesHolder<I, C> nodesHolder
    ); void reconfigure(ThriftBalancerConfig newConfig); @Override void reBalance(); void evict(); @Override Optional<NodeStatus<I, C>> get(); Optional<NodeStatus<I, C>> getWorking(); @Override Stream<NodeStatus<I, C>> nodes(); Stream<ThriftDcBalancer<I, C>> dcList(); double getLoad(); int getUsedConnections(); int getOpenConnections(); Stream<ThriftClientAddress> getFailedNodes(); long getFailedNodesCount(); @Override void close(); String getServiceName(); void scheduleConfigReload(
            ThriftBalancerConfig.UntypedBuilder<?> builder,
            Consumer<ThriftBalancerConfig> toReconfigure
    ); static final Duration CONFIG_RELOAD_PERIOD; }### Answer:
@Test(groups = "unit") public void reBalance() throws Exception { assertTrue(dc2.getLoadAccumulator().getLoad() > 320.0); verify(dc1).reBalance(); verify(dc2).reBalance(); assertFalse(dc1.getLoadAccumulator().isPreferred()); assertFalse(dc2.getLoadAccumulator().isPreferred()); when(config.getPreferredDc()).thenReturn("dc1"); balancer.reBalance(); assertTrue(dc1.getLoadAccumulator().isPreferred()); assertFalse(dc2.getLoadAccumulator().isPreferred()); assertEquals(balancer.get().get(), status1); }