Browse Source

filer only talk to the master leader

pull/702/head
Chris Lu 7 years ago
parent
commit
1ab8232b55
  1. 8
      weed/server/master_grpc_server.go

8
weed/server/master_grpc_server.go

@ -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)

Loading…
Cancel
Save