Skip to content

Commit

Permalink
Merge pull request Netflix#225 from motortalk/remove-fixed-server-lis…
Browse files Browse the repository at this point in the history
…t-reload-delay

Remove fixed inital delay for dynamic server list reload
  • Loading branch information
elandau committed May 5, 2015
2 parents 47fecf4 + 6f28f89 commit c8c4dae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public class DynamicServerListLoadBalancer<T extends Server> extends
protected AtomicBoolean serverListUpdateInProgress = new AtomicBoolean(
false);

private static long LISTOFSERVERS_CACHE_UPDATE_DELAY = 1000; // msecs;
private static int LISTOFSERVERS_CACHE_REPEAT_INTERVAL = 30 * 1000; // msecs;
// //
// every
Expand Down Expand Up @@ -250,7 +249,7 @@ private String getIdentifier() {
private void keepServerListUpdated() {
scheduledFuture = _serverListRefreshExecutor.scheduleAtFixedRate(
new ServerListRefreshExecutorThread(),
LISTOFSERVERS_CACHE_UPDATE_DELAY, refeshIntervalMills,
refeshIntervalMills, refeshIntervalMills,
TimeUnit.MILLISECONDS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,22 @@ public void initWithNiwsConfig(IClientConfig clientConfig) {

@Test
public void testDynamicServerListLoadBalancer() throws Exception {
DefaultClientConfigImpl config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
final int refreshIntervalMillis = 50;
final DefaultClientConfigImpl config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
config.setProperty(CommonClientConfigKey.NIWSServerListClassName, MyServerList.class.getName());
config.setProperty(CommonClientConfigKey.NFLoadBalancerClassName, DynamicServerListLoadBalancer.class.getName());
config.setProperty(CommonClientConfigKey.ServerListRefreshInterval, "50");
config.setProperty(CommonClientConfigKey.ServerListRefreshInterval, refreshIntervalMillis);
DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<Server>(config);
try {
assertTrue(MyServerList.latch.await(2, TimeUnit.SECONDS));
assertTrue(MyServerList.latch.await(refreshIntervalMillis * (5 + 1), TimeUnit.MILLISECONDS));
} catch (InterruptedException e) { // NOPMD
}
assertEquals(lb.getServerList(false), MyServerList.list);
lb.stopServerListRefreshing();
Thread.sleep(1000);
Thread.sleep(refreshIntervalMillis * 2);
int count = MyServerList.counter.get();
assertTrue(count >= 5);
Thread.sleep(1000);
Thread.sleep(refreshIntervalMillis * 2);
assertEquals(count, MyServerList.counter.get());

}
Expand Down

0 comments on commit c8c4dae

Please sign in to comment.