Xiang Li 12 years ago
parent
commit
c39f7712f7
3 changed files with 10 additions and 7 deletions
  1. 6 6
      client_handlers.go
  2. 1 1
      etcd.go
  3. 3 0
      test.go

+ 6 - 6
client_handlers.go

@@ -1,10 +1,10 @@
 package main
 
 import (
+	"fmt"
 	"github.com/coreos/etcd/store"
 	"net/http"
 	"strconv"
-	"fmt"
 	"time"
 )
 
@@ -72,9 +72,9 @@ func SetHttpHandler(w *http.ResponseWriter, req *http.Request) {
 
 	if len(prevValue) != 0 {
 		command := &TestAndSetCommand{
-			Key: key,
-			Value: value,
-			PrevValue: prevValue,
+			Key:        key,
+			Value:      value,
+			PrevValue:  prevValue,
 			ExpireTime: expireTime,
 		}
 
@@ -82,8 +82,8 @@ func SetHttpHandler(w *http.ResponseWriter, req *http.Request) {
 
 	} else {
 		command := &SetCommand{
-			Key: key,
-			Value: value,
+			Key:        key,
+			Value:      value,
 			ExpireTime: expireTime,
 		}
 

+ 1 - 1
etcd.go

@@ -555,7 +555,7 @@ func getInfo(path string) *Info {
 		info := &Info{
 			Hostname: hostname,
 
-			RaftPort: raftPort,
+			RaftPort:   raftPort,
 			ClientPort: clientPort,
 			WebPort:    webPort,
 

+ 3 - 0
test.go

@@ -74,6 +74,9 @@ func createCluster(size int, procAttr *os.ProcAttr) ([][]string, []*os.Process,
 		if err != nil {
 			return nil, nil, err
 		}
+		// we only add machine one to the cluster list
+		// thus we need to make sure other node start after the first one has done set up
+		time.Sleep(time.Millisecond * 200)
 	}
 
 	return argGroup, etcds, nil