Browse Source

MaybeShutdownLocalPartition refactor

mq-subscribe
chrislu 9 months ago
parent
commit
f249f831b1
  1. 20
      weed/mq/topic/local_partition.go

20
weed/mq/topic/local_partition.go

@ -179,7 +179,14 @@ func (p *LocalPartition) MaybeConnectToFollowers(initMessage *mq_pb.PublishMessa
}
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
if p.canShutdownLocalPartition() {
if !p.Publishers.IsEmpty() {
return
}
if !p.Subscribers.IsEmpty() {
return
}
p.LogBuffer.ShutdownLogBuffer()
if p.FollowerStream != nil {
// send close to the follower
if followErr := p.FollowerStream.Send(&mq_pb.PublishFollowMeRequest{
@ -189,18 +196,11 @@ func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
}); followErr != nil {
glog.Errorf("Error closing follower stream: %v", followErr)
}
println("closing grpcConnection to follower")
glog.V(4).Infof("closing grpcConnection to follower")
p.FollowerGrpcConnection.Close()
}
}
return
p.FollowerStream = nil
}
func (p *LocalPartition) canShutdownLocalPartition() (hasShutdown bool) {
if p.Publishers.IsEmpty() && p.Subscribers.IsEmpty() {
p.LogBuffer.ShutdownLogBuffer()
hasShutdown = true
}
return
}

Loading…
Cancel
Save