update raft

This commit is contained in:
chrislu
2023-05-07 13:33:44 -07:00
parent 6fdff0bb18
commit 4511edc871
3 changed files with 7 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package weed_server
import (
"encoding/json"
transport "github.com/Jille/raft-grpc-transport"
"github.com/seaweedfs/raft/protobuf"
"io"
"math/rand"
"os"
@@ -33,6 +34,8 @@ type RaftServerOption struct {
}
type RaftServer struct {
protobuf.UnimplementedRaftServer
raftGrpcServer *raft.GrpcServer
peers map[string]pb.ServerAddress // initial peers to join with
raftServer raft.Server
RaftHashicorp *hashicorpRaft.Raft
@@ -40,7 +43,6 @@ type RaftServer struct {
dataDir string
serverAddr pb.ServerAddress
topo *topology.Topology
*raft.GrpcServer
}
type StateMachine struct {
@@ -162,7 +164,7 @@ func NewRaftServer(option *RaftServerOption) (*RaftServer, error) {
}
}
s.GrpcServer = raft.NewGrpcServer(s.raftServer)
s.raftGrpcServer = raft.NewGrpcServer(s.raftServer)
glog.V(0).Infof("current cluster leader: %v", s.raftServer.Leader())