|
|
@ -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() |
|
|
|
p.FollowerStream = nil |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func (p *LocalPartition) canShutdownLocalPartition() (hasShutdown bool) { |
|
|
|
if p.Publishers.IsEmpty() && p.Subscribers.IsEmpty() { |
|
|
|
p.LogBuffer.ShutdownLogBuffer() |
|
|
|
hasShutdown = true |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|