simplify
This commit is contained in:
@@ -125,7 +125,7 @@ func (p *LocalPartition) closeSubscribers() {
|
|||||||
|
|
||||||
func (p *LocalPartition) WaitUntilNoPublishers() {
|
func (p *LocalPartition) WaitUntilNoPublishers() {
|
||||||
for {
|
for {
|
||||||
if p.Publishers.IsEmpty() {
|
if p.Publishers.Size() == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(113 * time.Millisecond)
|
time.Sleep(113 * time.Millisecond)
|
||||||
@@ -183,7 +183,7 @@ func (p *LocalPartition) MaybeConnectToFollowers(initMessage *mq_pb.PublishMessa
|
|||||||
|
|
||||||
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
||||||
|
|
||||||
if p.Publishers.IsEmpty() {
|
if p.Publishers.Size() == 0 {
|
||||||
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{
|
||||||
@@ -196,10 +196,11 @@ func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
|||||||
glog.V(4).Infof("closing grpcConnection to follower")
|
glog.V(4).Infof("closing grpcConnection to follower")
|
||||||
p.followerGrpcConnection.Close()
|
p.followerGrpcConnection.Close()
|
||||||
p.followerStream = nil
|
p.followerStream = nil
|
||||||
|
p.follower = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Publishers.IsEmpty() && p.Subscribers.IsEmpty() {
|
if p.Publishers.Size() == 0 && p.Subscribers.Size() == 0 {
|
||||||
p.LogBuffer.ShutdownLogBuffer()
|
p.LogBuffer.ShutdownLogBuffer()
|
||||||
hasShutdown = true
|
hasShutdown = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,6 @@ func (p *LocalPartitionPublishers) SignalShutdown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LocalPartitionPublishers) IsEmpty() bool {
|
|
||||||
p.publishersLock.RLock()
|
|
||||||
defer p.publishersLock.RUnlock()
|
|
||||||
|
|
||||||
return len(p.publishers) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *LocalPartitionPublishers) Size() int {
|
func (p *LocalPartitionPublishers) Size() int {
|
||||||
p.publishersLock.RLock()
|
p.publishersLock.RLock()
|
||||||
defer p.publishersLock.RUnlock()
|
defer p.publishersLock.RUnlock()
|
||||||
|
|||||||
@@ -48,13 +48,6 @@ func (p *LocalPartitionSubscribers) SignalShutdown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *LocalPartitionSubscribers) IsEmpty() bool {
|
|
||||||
p.SubscribersLock.RLock()
|
|
||||||
defer p.SubscribersLock.RUnlock()
|
|
||||||
|
|
||||||
return len(p.Subscribers) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *LocalPartitionSubscribers) Size() int {
|
func (p *LocalPartitionSubscribers) Size() int {
|
||||||
p.SubscribersLock.RLock()
|
p.SubscribersLock.RLock()
|
||||||
defer p.SubscribersLock.RUnlock()
|
defer p.SubscribersLock.RUnlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user