MaybeShutdownLocalPartition refactor
This commit is contained in:
@@ -179,28 +179,28 @@ func (p *LocalPartition) MaybeConnectToFollowers(initMessage *mq_pb.PublishMessa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
||||||
if p.canShutdownLocalPartition() {
|
if !p.Publishers.IsEmpty() {
|
||||||
if p.FollowerStream != nil {
|
return
|
||||||
// send close to the follower
|
|
||||||
if followErr := p.FollowerStream.Send(&mq_pb.PublishFollowMeRequest{
|
|
||||||
Message: &mq_pb.PublishFollowMeRequest_Close{
|
|
||||||
Close: &mq_pb.PublishFollowMeRequest_CloseMessage{},
|
|
||||||
},
|
|
||||||
}); followErr != nil {
|
|
||||||
glog.Errorf("Error closing follower stream: %v", followErr)
|
|
||||||
}
|
|
||||||
println("closing grpcConnection to follower")
|
|
||||||
p.FollowerGrpcConnection.Close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
if !p.Subscribers.IsEmpty() {
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
p.LogBuffer.ShutdownLogBuffer()
|
||||||
|
|
||||||
func (p *LocalPartition) canShutdownLocalPartition() (hasShutdown bool) {
|
if p.FollowerStream != nil {
|
||||||
if p.Publishers.IsEmpty() && p.Subscribers.IsEmpty() {
|
// send close to the follower
|
||||||
p.LogBuffer.ShutdownLogBuffer()
|
if followErr := p.FollowerStream.Send(&mq_pb.PublishFollowMeRequest{
|
||||||
hasShutdown = true
|
Message: &mq_pb.PublishFollowMeRequest_Close{
|
||||||
|
Close: &mq_pb.PublishFollowMeRequest_CloseMessage{},
|
||||||
|
},
|
||||||
|
}); followErr != nil {
|
||||||
|
glog.Errorf("Error closing follower stream: %v", followErr)
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("closing grpcConnection to follower")
|
||||||
|
p.FollowerGrpcConnection.Close()
|
||||||
|
p.FollowerStream = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user