Xiang Li 12 years ago
parent
commit
d3649d3254
4 changed files with 11 additions and 11 deletions
  1. 2 2
      etcd.go
  2. 1 1
      etcd_handlers.go
  3. 7 7
      snapshot.go
  4. 1 1
      store/stats.go

+ 2 - 2
etcd.go

@@ -364,7 +364,7 @@ func newTransporter(scheme string, tlsConf tls.Config) transporter {
 	t.scheme = scheme
 	t.scheme = scheme
 
 
 	tr := &http.Transport{
 	tr := &http.Transport{
-		Dial:               dialTimeout,
+		Dial: dialTimeout,
 	}
 	}
 
 
 	if scheme == "https" {
 	if scheme == "https" {
@@ -594,7 +594,7 @@ func joinCluster(s *raft.Server, raftURL string) error {
 	joinURL := url.URL{Host: raftURL, Scheme: raftTransporter.scheme, Path: "/join"}
 	joinURL := url.URL{Host: raftURL, Scheme: raftTransporter.scheme, Path: "/join"}
 
 
 	debugf("Send Join Request to %s", raftURL)
 	debugf("Send Join Request to %s", raftURL)
-	
+
 	resp, err := t.Post(joinURL.String(), &b)
 	resp, err := t.Post(joinURL.String(), &b)
 
 
 	for {
 	for {

+ 1 - 1
etcd_handlers.go

@@ -109,7 +109,7 @@ func DeleteHttpHandler(w *http.ResponseWriter, req *http.Request) {
 func dispatch(c Command, w *http.ResponseWriter, req *http.Request, etcd bool) {
 func dispatch(c Command, w *http.ResponseWriter, req *http.Request, etcd bool) {
 	if raftServer.State() == "leader" {
 	if raftServer.State() == "leader" {
 		if body, err := raftServer.Do(c); err != nil {
 		if body, err := raftServer.Do(c); err != nil {
-			
+
 			if _, ok := err.(store.NotFoundError); ok {
 			if _, ok := err.(store.NotFoundError); ok {
 				(*w).WriteHeader(http.StatusNotFound)
 				(*w).WriteHeader(http.StatusNotFound)
 				(*w).Write(newJsonError(100, err.Error()))
 				(*w).Write(newJsonError(100, err.Error()))

+ 7 - 7
snapshot.go

@@ -1,25 +1,25 @@
 package main
 package main
 
 
 import (
 import (
-	"time"
 	"fmt"
 	"fmt"
+	"time"
 )
 )
 
 
 type snapshotConf struct {
 type snapshotConf struct {
-	// basic 
+	// basic
 	checkingInterval time.Duration
 	checkingInterval time.Duration
-	lastWrites uint64
-	writesThr uint64
+	lastWrites       uint64
+	writesThr        uint64
 }
 }
 
 
 var snapConf *snapshotConf
 var snapConf *snapshotConf
 
 
 func newSnapshotConf() *snapshotConf {
 func newSnapshotConf() *snapshotConf {
-	return &snapshotConf {time.Second*3, etcdStore.TotalWrites(), 20*1000}
+	return &snapshotConf{time.Second * 3, etcdStore.TotalWrites(), 20 * 1000}
 }
 }
 
 
 func monitorSnapshot() {
 func monitorSnapshot() {
-	for {	
+	for {
 		time.Sleep(snapConf.checkingInterval)
 		time.Sleep(snapConf.checkingInterval)
 		currentWrites := etcdStore.TotalWrites() - snapConf.lastWrites
 		currentWrites := etcdStore.TotalWrites() - snapConf.lastWrites
 
 
@@ -31,4 +31,4 @@ func monitorSnapshot() {
 			fmt.Println(currentWrites)
 			fmt.Println(currentWrites)
 		}
 		}
 	}
 	}
-}
+}

+ 1 - 1
store/stats.go

@@ -30,4 +30,4 @@ func (s *Store) TotalWrites() uint64 {
 	bs := s.BasicStats
 	bs := s.BasicStats
 
 
 	return bs.Deletes + bs.Sets + bs.TestAndSets
 	return bs.Deletes + bs.Sets + bs.TestAndSets
-}
+}