aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-08-12 14:27:14 -0700
committerChris Lu <chris.lu@gmail.com>2018-08-12 14:27:14 -0700
commit75d63db60d1677f2e3350c3ee2b9dbecf931ec1a (patch)
tree939d170c6c2e076395b219fcbd91eac0a743c71e
parenteca4b928d2b14fa940233eba3458df52077a9ede (diff)
downloadseaweedfs-75d63db60d1677f2e3350c3ee2b9dbecf931ec1a.tar.xz
seaweedfs-75d63db60d1677f2e3350c3ee2b9dbecf931ec1a.zip
randomize raft server startup
also some go fmt
-rw-r--r--weed/command/benchmark.go2
-rw-r--r--weed/command/master.go2
-rw-r--r--weed/server/filer_ui/templates.go2
-rw-r--r--weed/server/raft_server.go3
-rw-r--r--weed/storage/types/needle_id_128bit.go2
-rw-r--r--weed/storage/types/needle_id_type.go2
6 files changed, 7 insertions, 6 deletions
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go
index 4ba00dc98..8b65c8663 100644
--- a/weed/command/benchmark.go
+++ b/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 {
diff --git a/weed/command/master.go b/weed/command/master.go
index ac5902b60..34f467bd2 100644
--- a/weed/command/master.go
+++ b/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
diff --git a/weed/server/filer_ui/templates.go b/weed/server/filer_ui/templates.go
index e53d5caa7..c2d69156e 100644
--- a/weed/server/filer_ui/templates.go
+++ b/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{
diff --git a/weed/server/raft_server.go b/weed/server/raft_server.go
index e2a091e83..01ca41aac 100644
--- a/weed/server/raft_server.go
+++ b/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")
diff --git a/weed/storage/types/needle_id_128bit.go b/weed/storage/types/needle_id_128bit.go
index 8f1c50a29..3af0b7285 100644
--- a/weed/storage/types/needle_id_128bit.go
+++ b/weed/storage/types/needle_id_128bit.go
@@ -7,7 +7,7 @@ import (
)
const (
- NeedleIdSize = 16
+ NeedleIdSize = 16
NeedleIdEmpty = ""
)
diff --git a/weed/storage/types/needle_id_type.go b/weed/storage/types/needle_id_type.go
index 78a493b94..efb22190d 100644
--- a/weed/storage/types/needle_id_type.go
+++ b/weed/storage/types/needle_id_type.go
@@ -11,7 +11,7 @@ import (
type NeedleId uint64
const (
- NeedleIdSize = 8
+ NeedleIdSize = 8
NeedleIdEmpty = 0
)