Skip to content

Commit

Permalink
Get current holder by reading from statestore
Browse files Browse the repository at this point in the history
  • Loading branch information
shaleman committed Feb 5, 2016
1 parent c03ba09 commit 0840303
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion etcdLock.go
Expand Up @@ -124,7 +124,17 @@ func (ep *Lock) IsAcquired() bool {
func (ep *Lock) GetHolder() string {
ep.mutex.Lock()
defer ep.mutex.Unlock()
return ep.holderID

keyName := "/contiv.io/lock/" + ep.name

// Get the current value
resp, err := ep.client.Get(keyName, false, false)
if err != nil {
log.Warnf("Could not get current holder for lock %s", ep.name)
return ""
}

return resp.Node.Value
}

// *********************** Internal functions *************
Expand Down

0 comments on commit 0840303

Please sign in to comment.