change response HTTP header to StatusServiceUnavailable when the server is not leader

This commit is contained in:
Xiang Li 2013-06-20 17:46:12 -07:00
parent ef59a03fbb
commit 1228694383
2 changed files with 3 additions and 2 deletions

View File

@ -144,7 +144,8 @@ func excute(c Command, w *http.ResponseWriter) {
}
} else {
// tell the client where is the leader
(*w).WriteHeader(http.StatusTemporaryRedirect)
debug("Redirect to the leader %s", server.Leader())
(*w).WriteHeader(http.StatusServiceUnavailable)
(*w).Write([]byte(server.Leader()))
return
}

View File

@ -379,7 +379,7 @@ func Join(s *raft.Server, serverName string) error {
if resp.StatusCode == http.StatusOK {
return nil
}
if resp.StatusCode == http.StatusTemporaryRedirect {
if resp.StatusCode == http.StatusServiceUnavailable {
address, err := ioutil.ReadAll(resp.Body)
if err != nil {
warn("Cannot Read Leader info: %v", err)