SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
randomize based on self address
Chris Lu6230eb28a61e
diff --git a/weed/server/raft_server.go b/weed/server/raft_server.goindex ca1792ac6d..17b1f51b22 100644--- a/weed/server/raft_server.go+++ b/weed/server/raft_server.go@@ -14,6 +14,7 @@ import ("github.com/chrislusf/raft""github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/topology"+ "github.com/chrislusf/seaweedfs/weed/util""github.com/gorilla/mux")@@ -71,6 +72,7 @@ func NewRaftServer(r *mux.Router, peers []string, httpAddr string, dataDir strinfor _, peer := range s.peers {s.raftServer.AddPeer(peer, "http://"+peer)}+ rand.Seed(util.HashBytesToInt64([]byte(httpAddr)))time.Sleep(time.Duration(1000+rand.Int31n(3000)) * time.Millisecond)if s.raftServer.IsLogEmpty() {// Initialize the server by joining itself.diff --git a/weed/util/randomizer.go b/weed/util/randomizer.gonew file mode 100644index 0000000000..e5ccd3fb32--- /dev/null+++ b/weed/util/randomizer.go@@ -0,0 +1,9 @@+package util++import "hash/fnv"++func HashBytesToInt64(x []byte) int64 {+ hash := fnv.New64()+ hash.Write(x)+ return int64(hash.Sum64())+}