|
@ -1,6 +1,7 @@ |
|
|
package lock_manager |
|
|
package lock_manager |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
"github.com/seaweedfs/seaweedfs/weed/util" |
|
|
"github.com/seaweedfs/seaweedfs/weed/util" |
|
|
"sort" |
|
|
"sort" |
|
@ -39,9 +40,11 @@ func (r *LockRing) SetTakeSnapshotCallback(onTakeSnapshot func(snapshot []pb.Ser |
|
|
// AddServer adds a server to the ring
|
|
|
// AddServer adds a server to the ring
|
|
|
// if the previous snapshot passed the snapshot interval, create a new snapshot
|
|
|
// if the previous snapshot passed the snapshot interval, create a new snapshot
|
|
|
func (r *LockRing) AddServer(server pb.ServerAddress) { |
|
|
func (r *LockRing) AddServer(server pb.ServerAddress) { |
|
|
|
|
|
glog.V(0).Infof("add server %v", server) |
|
|
r.Lock() |
|
|
r.Lock() |
|
|
|
|
|
|
|
|
if _, found := r.candidateServers[server]; found { |
|
|
if _, found := r.candidateServers[server]; found { |
|
|
|
|
|
glog.V(0).Infof("add server: already exists %v", server) |
|
|
r.Unlock() |
|
|
r.Unlock() |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
@ -53,6 +56,8 @@ func (r *LockRing) AddServer(server pb.ServerAddress) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (r *LockRing) RemoveServer(server pb.ServerAddress) { |
|
|
func (r *LockRing) RemoveServer(server pb.ServerAddress) { |
|
|
|
|
|
glog.V(0).Infof("remove server %v", server) |
|
|
|
|
|
|
|
|
r.Lock() |
|
|
r.Lock() |
|
|
|
|
|
|
|
|
if _, found := r.candidateServers[server]; !found { |
|
|
if _, found := r.candidateServers[server]; !found { |
|
|