|
@@ -249,7 +249,7 @@ func startRaft(securityType int) {
|
|
|
|
|
|
|
|
err = joinCluster(raftServer, machine)
|
|
err = joinCluster(raftServer, machine)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- debug("cannot join to cluster via machine %s", machine)
|
|
|
|
|
|
|
+ debug("cannot join to cluster via machine %s %s", machine, err)
|
|
|
} else {
|
|
} else {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
@@ -267,7 +267,7 @@ func startRaft(securityType int) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// open the snapshot
|
|
// open the snapshot
|
|
|
- // go server.Snapshot()
|
|
|
|
|
|
|
+ go raftServer.Snapshot()
|
|
|
|
|
|
|
|
// start to response to raft requests
|
|
// start to response to raft requests
|
|
|
go startRaftTransport(info.RaftPort, securityType)
|
|
go startRaftTransport(info.RaftPort, securityType)
|
|
@@ -332,6 +332,7 @@ func startRaftTransport(port int, st int) {
|
|
|
http.HandleFunc("/log", GetLogHttpHandler)
|
|
http.HandleFunc("/log", GetLogHttpHandler)
|
|
|
http.HandleFunc("/log/append", AppendEntriesHttpHandler)
|
|
http.HandleFunc("/log/append", AppendEntriesHttpHandler)
|
|
|
http.HandleFunc("/snapshot", SnapshotHttpHandler)
|
|
http.HandleFunc("/snapshot", SnapshotHttpHandler)
|
|
|
|
|
+ http.HandleFunc("/snapshotRecovery", SnapshotRecoveryHttpHandler)
|
|
|
http.HandleFunc("/client", ClientHttpHandler)
|
|
http.HandleFunc("/client", ClientHttpHandler)
|
|
|
|
|
|
|
|
switch st {
|
|
switch st {
|
|
@@ -566,6 +567,9 @@ func joinCluster(s *raft.Server, serverName string) error {
|
|
|
json.NewEncoder(&b).Encode(command)
|
|
json.NewEncoder(&b).Encode(command)
|
|
|
resp, err = t.Post(fmt.Sprintf("%s/join", address), &b)
|
|
resp, err = t.Post(fmt.Sprintf("%s/join", address), &b)
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ b, _ := ioutil.ReadAll(resp.Body)
|
|
|
|
|
+ fmt.Println(string(b))
|
|
|
|
|
+ resp.Body.Close()
|
|
|
return fmt.Errorf("Unable to join")
|
|
return fmt.Errorf("Unable to join")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|