mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
This commit is contained in:
parent
7de112943b
commit
31d2f77ceb
|
@ -104,9 +104,27 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||
return err
|
||||
}
|
||||
|
||||
if ms.Topo.IsLeader() {
|
||||
ms.Topo.Sequence.SetMax(heartbeat.MaxFileKey)
|
||||
if !ms.Topo.IsLeader() {
|
||||
// tell the volume servers about the leader
|
||||
newLeader, err := ms.Topo.Leader()
|
||||
if err != nil {
|
||||
glog.Warningf("SendHeartbeat find leader: %v", err)
|
||||
return err
|
||||
}
|
||||
if err := stream.Send(&master_pb.HeartbeatResponse{
|
||||
Leader: string(newLeader),
|
||||
}); err != nil {
|
||||
if dn != nil {
|
||||
glog.Warningf("SendHeartbeat.Send response to %s:%d %v", dn.Ip, dn.Port, err)
|
||||
} else {
|
||||
glog.Warningf("SendHeartbeat.Send response %v", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
ms.Topo.Sequence.SetMax(heartbeat.MaxFileKey)
|
||||
if dn == nil {
|
||||
dcName, rackName := ms.Topo.Configuration.Locate(heartbeat.Ip, heartbeat.DataCenter, heartbeat.Rack)
|
||||
dc := ms.Topo.GetOrCreateDataCenter(dcName)
|
||||
|
@ -218,24 +236,6 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||
ms.broadcastToClients(&master_pb.KeepConnectedResponse{VolumeLocation: message})
|
||||
}
|
||||
}
|
||||
|
||||
// tell the volume servers about the leader
|
||||
newLeader, err := ms.Topo.Leader()
|
||||
if err != nil {
|
||||
glog.Warningf("SendHeartbeat find leader: %v", err)
|
||||
return err
|
||||
}
|
||||
if err := stream.Send(&master_pb.HeartbeatResponse{
|
||||
Leader: string(newLeader),
|
||||
}); err != nil {
|
||||
if dn != nil {
|
||||
glog.Warningf("SendHeartbeat.Send response to %s:%d %v", dn.Ip, dn.Port, err)
|
||||
} else {
|
||||
glog.Warningf("SendHeartbeat.Send response %v", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// KeepConnected keep a stream gRPC call to the master. Used by clients to know the master is up.
|
||||
|
|
Loading…
Reference in a new issue