Rename listLock to activatedListLock
This commit is contained in:
parent
4c9067310b
commit
03846fb754
|
@ -88,8 +88,8 @@ type serverList struct {
|
||||||
type RPCProxy struct {
|
type RPCProxy struct {
|
||||||
// activatedList manages the list of Nomad Servers that are eligible
|
// activatedList manages the list of Nomad Servers that are eligible
|
||||||
// to be queried by the Client agent.
|
// to be queried by the Client agent.
|
||||||
activatedList atomic.Value
|
activatedList atomic.Value
|
||||||
listLock sync.Mutex
|
activatedListLock sync.Mutex
|
||||||
|
|
||||||
// primaryServers is a list of servers found in the last heartbeat.
|
// primaryServers is a list of servers found in the last heartbeat.
|
||||||
// primaryServers are periodically reshuffled. Covered by
|
// primaryServers are periodically reshuffled. Covered by
|
||||||
|
@ -202,8 +202,8 @@ func (p *RPCProxy) SetBackupServers(addrs []string) error {
|
||||||
p.backupServers.L = l
|
p.backupServers.L = l
|
||||||
p.serverListLock.Unlock()
|
p.serverListLock.Unlock()
|
||||||
|
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
for _, s := range l {
|
for _, s := range l {
|
||||||
p.activateEndpoint(s)
|
p.activateEndpoint(s)
|
||||||
}
|
}
|
||||||
|
@ -229,9 +229,9 @@ func (p *RPCProxy) AddPrimaryServer(rpcAddr string) *ServerEndpoint {
|
||||||
p.primaryServers.L = append(p.primaryServers.L, s)
|
p.primaryServers.L = append(p.primaryServers.L, s)
|
||||||
p.serverListLock.Unlock()
|
p.serverListLock.Unlock()
|
||||||
|
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
p.activateEndpoint(s)
|
p.activateEndpoint(s)
|
||||||
p.listLock.Unlock()
|
p.activatedListLock.Unlock()
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
@ -328,8 +328,8 @@ func (p *RPCProxy) saveServerList(l serverList) {
|
||||||
// the Nomad Server for this Nomad Agent is in the minority or the Nomad
|
// the Nomad Server for this Nomad Agent is in the minority or the Nomad
|
||||||
// Servers are in the middle of an election.
|
// Servers are in the middle of an election.
|
||||||
func (p *RPCProxy) LeaderAddr() string {
|
func (p *RPCProxy) LeaderAddr() string {
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
return p.leaderAddr
|
return p.leaderAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,8 +347,8 @@ func (p *RPCProxy) NotifyFailedServer(s *ServerEndpoint) {
|
||||||
if len(l.L) > 1 && l.L[0] == s {
|
if len(l.L) > 1 && l.L[0] == s {
|
||||||
// Grab a lock, retest, and take the hit of cycling the first
|
// Grab a lock, retest, and take the hit of cycling the first
|
||||||
// server to the end.
|
// server to the end.
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
l = p.getServerList()
|
l = p.getServerList()
|
||||||
|
|
||||||
if len(l.L) > 1 && l.L[0] == s {
|
if len(l.L) > 1 && l.L[0] == s {
|
||||||
|
@ -496,8 +496,8 @@ func (p *RPCProxy) RebalanceServers() {
|
||||||
// servers are appended to the list and other missing servers are removed
|
// servers are appended to the list and other missing servers are removed
|
||||||
// from the list.
|
// from the list.
|
||||||
func (p *RPCProxy) reconcileServerList(l *serverList) bool {
|
func (p *RPCProxy) reconcileServerList(l *serverList) bool {
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
|
|
||||||
// newServerList is a serverList that has been kept up-to-date with
|
// newServerList is a serverList that has been kept up-to-date with
|
||||||
// join and leave events.
|
// join and leave events.
|
||||||
|
@ -564,8 +564,8 @@ func (p *RPCProxy) RemoveServer(s *ServerEndpoint) {
|
||||||
p.serverListLock.Lock()
|
p.serverListLock.Lock()
|
||||||
defer p.serverListLock.Unlock()
|
defer p.serverListLock.Unlock()
|
||||||
|
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
l := p.getServerList()
|
l := p.getServerList()
|
||||||
|
|
||||||
k := s.Key()
|
k := s.Key()
|
||||||
|
@ -596,8 +596,8 @@ func (p *RPCProxy) refreshServerRebalanceTimer() time.Duration {
|
||||||
// ResetRebalanceTimer resets the rebalance timer. This method exists for
|
// ResetRebalanceTimer resets the rebalance timer. This method exists for
|
||||||
// testing and should not be used directly.
|
// testing and should not be used directly.
|
||||||
func (p *RPCProxy) ResetRebalanceTimer() {
|
func (p *RPCProxy) ResetRebalanceTimer() {
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
p.rebalanceTimer.Reset(clientRPCMinReuseDuration)
|
p.rebalanceTimer.Reset(clientRPCMinReuseDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,8 +723,8 @@ func (p *RPCProxy) RefreshServerLists(servers []*structs.NodeServerInfo, numNode
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
p.listLock.Lock()
|
p.activatedListLock.Lock()
|
||||||
defer p.listLock.Unlock()
|
defer p.activatedListLock.Unlock()
|
||||||
newServerCfg := p.getServerList()
|
newServerCfg := p.getServerList()
|
||||||
for k, v := range mergedPrimaryMap {
|
for k, v := range mergedPrimaryMap {
|
||||||
switch v.state {
|
switch v.state {
|
||||||
|
|
Loading…
Reference in a new issue