diff --git a/weed/server/master_grpc_server.go b/weed/server/master_grpc_server.go index 815bcfba3..53e4b59e1 100644 --- a/weed/server/master_grpc_server.go +++ b/weed/server/master_grpc_server.go @@ -9,6 +9,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/topology" "google.golang.org/grpc/peer" "fmt" + "github.com/chrislusf/raft" ) func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServer) error { @@ -105,7 +106,8 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ } } -// KeepConnected keep a stream gRPC call to the master. Used by filer to know the master is up. +// KeepConnected keep a stream gRPC call to the master. Used by clients to know the master is up. +// And clients gets the up-to-date list of volume locations func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServer) error { req, err := stream.Recv() @@ -113,6 +115,10 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ return err } + if !ms.Topo.IsLeader() { + return raft.NotLeaderError + } + // remember client address ctx := stream.Context() // fmt.Printf("FromContext %+v\n", ctx)