Browse Source

randomize raft server startup

also some go fmt
pull/719/head
Chris Lu 7 years ago
parent
commit
75d63db60d
  1. 2
      weed/command/benchmark.go
  2. 2
      weed/command/master.go
  3. 2
      weed/server/filer_ui/templates.go
  4. 3
      weed/server/raft_server.go
  5. 2
      weed/storage/types/needle_id_128bit.go
  6. 2
      weed/storage/types/needle_id_type.go

2
weed/command/benchmark.go

@ -2,6 +2,7 @@ package command
import (
"bufio"
"context"
"fmt"
"io"
"math"
@ -19,7 +20,6 @@ import (
"github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/wdclient"
"context"
)
type BenchmarkOptions struct {

2
weed/command/master.go

@ -132,7 +132,7 @@ func checkPeers(masterIp string, masterPort int, peers string) (masterAddress st
if !hasSelf {
peerCount += 1
}
if peerCount %2 == 0 {
if peerCount%2 == 0 {
glog.Fatalf("Only odd number of masters are supported!")
}
return

2
weed/server/filer_ui/templates.go

@ -1,8 +1,8 @@
package master_ui
import (
"html/template"
"github.com/dustin/go-humanize"
"html/template"
)
var funcMap = template.FuncMap{

3
weed/server/raft_server.go

@ -3,6 +3,7 @@ package weed_server
import (
"encoding/json"
"io/ioutil"
"math/rand"
"os"
"path"
"reflect"
@ -68,7 +69,7 @@ func NewRaftServer(r *mux.Router, peers []string, httpAddr string, dataDir strin
for _, peer := range s.peers {
s.raftServer.AddPeer(peer, "http://"+peer)
}
time.Sleep(2 * time.Second)
time.Sleep(time.Duration(1000+rand.Int31n(3000)) * time.Millisecond)
if s.raftServer.IsLogEmpty() {
// Initialize the server by joining itself.
glog.V(0).Infoln("Initializing new cluster")

2
weed/storage/types/needle_id_128bit.go

@ -7,7 +7,7 @@ import (
)
const (
NeedleIdSize = 16
NeedleIdSize = 16
NeedleIdEmpty = ""
)

2
weed/storage/types/needle_id_type.go

@ -11,7 +11,7 @@ import (
type NeedleId uint64
const (
NeedleIdSize = 8
NeedleIdSize = 8
NeedleIdEmpty = 0
)

Loading…
Cancel
Save