Browse Source

allow pervious machine to rejoin to the cluster without pervious log

Xiang Li 12 years ago
parent
commit
9b8c5b0527
1 changed files with 7 additions and 0 deletions
  1. 7 0
      command.go

+ 7 - 0
command.go

@@ -120,6 +120,13 @@ func (c *JoinCommand) CommandName() string {
 // Join a server to the cluster
 func (c *JoinCommand) Apply(raftServer *raft.Server) (interface{}, error) {
 
+	// check if the join command is from a previous machine, who lost all its previous log.
+	response, _ := etcdStore.RawGet(path.Join("_etcd/machines", c.Name))
+
+	if response != nil {
+		return []byte("join success"), nil
+	}
+
 	// check machine number in the cluster
 	num := machineNum()
 	if num == maxClusterSize {