fix(peer_server): set store and registry when setting raft server

New raft server needs new store and registry.
This commit is contained in:
Yicheng Qin
2014-05-20 13:12:12 -07:00
parent ad27aa0f70
commit 934c28d498
3 changed files with 24 additions and 0 deletions

View File

@ -327,6 +327,14 @@ func (e *Etcd) runServer() {
e.StandbyServer.SyncCluster(peerURLs)
e.setMode(StandbyMode)
} else {
// Create etcd key-value store and registry.
e.Store = store.New()
e.Registry = server.NewRegistry(e.Store)
e.PeerServer.SetStore(e.Store)
e.PeerServer.SetRegistry(e.Registry)
e.Server.SetStore(e.Store)
e.Server.SetRegistry(e.Registry)
// Generate new peer server here.
// TODO(yichengq): raft server cannot be started after stopped.
// It should be removed when raft restart is implemented.

View File

@ -146,6 +146,14 @@ func (s *PeerServer) SetRaftServer(raftServer raft.Server, snapshot bool) {
}
}
func (s *PeerServer) SetRegistry(registry *Registry) {
s.registry = registry
}
func (s *PeerServer) SetStore(store store.Store) {
s.store = store
}
// Try all possible ways to find clusters to join
// Include log data in -data-dir, -discovery and -peers
//

View File

@ -99,6 +99,14 @@ func (s *Server) Store() store.Store {
return s.store
}
func (s *Server) SetRegistry(registry *Registry) {
s.registry = registry
}
func (s *Server) SetStore(store store.Store) {
s.store = store
}
func (s *Server) installV1(r *mux.Router) {
s.handleFuncV1(r, "/v1/keys/{key:.*}", v1.GetKeyHandler).Methods("GET", "HEAD")
s.handleFuncV1(r, "/v1/keys/{key:.*}", v1.SetKeyHandler).Methods("POST", "PUT")