This commit is contained in:
Xiang Li 2013-08-11 09:48:12 -07:00
parent 434b0045db
commit d3649d3254
4 changed files with 11 additions and 11 deletions

View File

@ -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 {

View File

@ -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()))

View File

@ -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 lastWrites uint64
writesThr 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)
} }
} }
} }

View File

@ -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
} }