filer only talk to the master leader

This commit is contained in:
Chris Lu 2018-07-28 01:30:03 -07:00
parent e8d4be579d
commit 1ab8232b55

View File

@ -9,6 +9,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/topology" "github.com/chrislusf/seaweedfs/weed/topology"
"google.golang.org/grpc/peer" "google.golang.org/grpc/peer"
"fmt" "fmt"
"github.com/chrislusf/raft"
) )
func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServer) error { 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 { func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServer) error {
req, err := stream.Recv() req, err := stream.Recv()
@ -113,6 +115,10 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
return err return err
} }
if !ms.Topo.IsLeader() {
return raft.NotLeaderError
}
// remember client address // remember client address
ctx := stream.Context() ctx := stream.Context()
// fmt.Printf("FromContext %+v\n", ctx) // fmt.Printf("FromContext %+v\n", ctx)