From a3a0eeeaddf7707873085b8e75d3fd5a3c0428ff Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 25 Mar 2016 14:00:05 -0700 Subject: [PATCH] Trim residual complexity from server join notifications Now that serf node join events are decoupled from rebalancing activities completely, remove the complixity of draining the channel and ensuring only one go routine was rebalancing the server list. Now that we're no longer initializing a notification channel, we can remove the config load/save from `Start()` --- consul/server_manager/server_manager.go | 27 ++----------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/consul/server_manager/server_manager.go b/consul/server_manager/server_manager.go index bb4d4fad1c..504c5ce2bf 100644 --- a/consul/server_manager/server_manager.go +++ b/consul/server_manager/server_manager.go @@ -295,36 +295,13 @@ func (sm *ServerManager) refreshServerRebalanceTimer(timer *time.Timer) time.Dur // distribute load across all known and available consul servers. func (sm *ServerManager) Start() { var rebalanceTimer *time.Timer = time.NewTimer(clientRPCMinReuseDuration) - var rebalanceTaskDispatched int32 - - func() { - sm.serverConfigLock.Lock() - defer sm.serverConfigLock.Unlock() - - serverCfgPtr := sm.serverConfigValue.Load() - if serverCfgPtr == nil { - panic("server config has not been initialized") - } - var serverCfg serverConfig - serverCfg = serverCfgPtr.(serverConfig) - sm.saveServerConfig(serverCfg) - }() for { select { case <-rebalanceTimer.C: - sm.logger.Printf("[INFO] server manager: server rebalance timeout") + sm.logger.Printf("[INFO] server manager: Rebalancing server connections") sm.RebalanceServers() - - // Only run one rebalance task at a time, but do - // allow for the channel to be drained - if atomic.CompareAndSwapInt32(&rebalanceTaskDispatched, 0, 1) { - sm.logger.Printf("[INFO] server manager: Launching rebalance duration task") - go func() { - defer atomic.StoreInt32(&rebalanceTaskDispatched, 0) - sm.refreshServerRebalanceTimer(rebalanceTimer) - }() - } + sm.refreshServerRebalanceTimer(rebalanceTimer) case <-sm.shutdownCh: sm.logger.Printf("[INFO] server manager: shutting down")