mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
randomize raft server startup
also some go fmt
This commit is contained in:
parent
eca4b928d2
commit
75d63db60d
|
@ -2,6 +2,7 @@ package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
@ -19,7 +20,6 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/security"
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
"context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BenchmarkOptions struct {
|
type BenchmarkOptions struct {
|
||||||
|
|
|
@ -132,7 +132,7 @@ func checkPeers(masterIp string, masterPort int, peers string) (masterAddress st
|
||||||
if !hasSelf {
|
if !hasSelf {
|
||||||
peerCount += 1
|
peerCount += 1
|
||||||
}
|
}
|
||||||
if peerCount %2 == 0 {
|
if peerCount%2 == 0 {
|
||||||
glog.Fatalf("Only odd number of masters are supported!")
|
glog.Fatalf("Only odd number of masters are supported!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package master_ui
|
package master_ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"html/template"
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
"html/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
var funcMap = template.FuncMap{
|
var funcMap = template.FuncMap{
|
||||||
|
|
|
@ -3,6 +3,7 @@ package weed_server
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -68,7 +69,7 @@ func NewRaftServer(r *mux.Router, peers []string, httpAddr string, dataDir strin
|
||||||
for _, peer := range s.peers {
|
for _, peer := range s.peers {
|
||||||
s.raftServer.AddPeer(peer, "http://"+peer)
|
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() {
|
if s.raftServer.IsLogEmpty() {
|
||||||
// Initialize the server by joining itself.
|
// Initialize the server by joining itself.
|
||||||
glog.V(0).Infoln("Initializing new cluster")
|
glog.V(0).Infoln("Initializing new cluster")
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NeedleIdSize = 16
|
NeedleIdSize = 16
|
||||||
NeedleIdEmpty = ""
|
NeedleIdEmpty = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
type NeedleId uint64
|
type NeedleId uint64
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NeedleIdSize = 8
|
NeedleIdSize = 8
|
||||||
NeedleIdEmpty = 0
|
NeedleIdEmpty = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue