mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-18 20:57:49 +08:00
Merge pull request #1507 from ustuzhanin/raft_remove_peers
Raft remove peers
This commit is contained in:
commit
b597406699
@ -104,7 +104,24 @@ func NewRaftServer(grpcDialOption grpc.DialOption, peers []string, serverAddr, d
|
|||||||
if err := s.raftServer.AddPeer(peer, pb.ServerToGrpcAddress(peer)); err != nil {
|
if err := s.raftServer.AddPeer(peer, pb.ServerToGrpcAddress(peer)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove deleted peers
|
||||||
|
if raftResumeState {
|
||||||
|
for existsPeerName, _ := range s.raftServer.Peers() {
|
||||||
|
exists := false
|
||||||
|
for _, peer := range s.peers {
|
||||||
|
if peer == existsPeerName {
|
||||||
|
exists = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
if err := s.raftServer.RemovePeer(existsPeerName); err != nil {
|
||||||
|
glog.V(0).Infoln(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.GrpcServer = raft.NewGrpcServer(s.raftServer)
|
s.GrpcServer = raft.NewGrpcServer(s.raftServer)
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
package weed_server
|
package weed_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClusterStatusResult struct {
|
type ClusterStatusResult struct {
|
||||||
IsLeader bool `json:"IsLeader,omitempty"`
|
IsLeader bool `json:"IsLeader,omitempty"`
|
||||||
Leader string `json:"Leader,omitempty"`
|
Leader string `json:"Leader,omitempty"`
|
||||||
Peers []string `json:"Peers,omitempty"`
|
Peers []string `json:"Peers,omitempty"`
|
||||||
|
MaxVolumeId needle.VolumeId `json:"MaxVolumeId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RaftServer) StatusHandler(w http.ResponseWriter, r *http.Request) {
|
func (s *RaftServer) StatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
ret := ClusterStatusResult{
|
ret := ClusterStatusResult{
|
||||||
IsLeader: s.topo.IsLeader(),
|
IsLeader: s.topo.IsLeader(),
|
||||||
Peers: s.Peers(),
|
Peers: s.Peers(),
|
||||||
|
MaxVolumeId: s.topo.GetMaxVolumeId(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if leader, e := s.topo.Leader(); e == nil {
|
if leader, e := s.topo.Leader(); e == nil {
|
||||||
ret.Leader = leader
|
ret.Leader = leader
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user