From 1ab8232b55e4572a4b456f02854640f74acbceef Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 28 Jul 2018 01:30:03 -0700 Subject: [PATCH] filer only talk to the master leader --- weed/server/master_grpc_server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)