|
|
@ -135,5 +135,29 @@ func (s *NodeSync) Unlock(where string, iam string) (err error) { |
|
|
|
|
|
|
|
|
|
|
|
err = s.Zk.Delete(path.Join(workingPath, iam), 0) |
|
|
|
err = s.Zk.Delete(path.Join(workingPath, iam), 0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WaitEmpty implements a barrier synchronisation mechanism by waiting for empty node.
|
|
|
|
|
|
|
|
func (s *NodeSync) WaitEmpty(where string) (err error) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workingPath := path.Join(s.rootPath, where) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
var children []string |
|
|
|
|
|
|
|
var ev <-chan zk.Event |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children, _, ev, err = s.Zk.ChildrenW(workingPath) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(children) == 0 { |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<-ev |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |