MaybeShutdownLocalPartition refactor
This commit is contained in:
@@ -179,7 +179,14 @@ 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() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !p.Subscribers.IsEmpty() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.LogBuffer.ShutdownLogBuffer()
|
||||||
|
|
||||||
if p.FollowerStream != nil {
|
if p.FollowerStream != nil {
|
||||||
// send close to the follower
|
// send close to the follower
|
||||||
if followErr := p.FollowerStream.Send(&mq_pb.PublishFollowMeRequest{
|
if followErr := p.FollowerStream.Send(&mq_pb.PublishFollowMeRequest{
|
||||||
@@ -189,18 +196,11 @@ func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
|||||||
}); followErr != nil {
|
}); followErr != nil {
|
||||||
glog.Errorf("Error closing follower stream: %v", followErr)
|
glog.Errorf("Error closing follower stream: %v", followErr)
|
||||||
}
|
}
|
||||||
println("closing grpcConnection to follower")
|
glog.V(4).Infof("closing grpcConnection to follower")
|
||||||
p.FollowerGrpcConnection.Close()
|
p.FollowerGrpcConnection.Close()
|
||||||
}
|
p.FollowerStream = nil
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LocalPartition) canShutdownLocalPartition() (hasShutdown bool) {
|
|
||||||
if p.Publishers.IsEmpty() && p.Subscribers.IsEmpty() {
|
|
||||||
p.LogBuffer.ShutdownLogBuffer()
|
|
||||||
hasShutdown = true
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user