mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-08 04:14:29 +08:00
release local topic partition if no publisher and subscribers
This commit is contained in:
@@ -109,3 +109,11 @@ func (p *LocalPartition) WaitUntilNoPublishers() {
|
||||
time.Sleep(113 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
|
||||
if p.Publishers.IsEmpty() && p.Subscribers.IsEmpty() {
|
||||
p.logBuffer.ShutdownLogBuffer()
|
||||
hasShutdown = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -47,3 +47,10 @@ func (p *LocalPartitionSubscribers) SignalShutdown() {
|
||||
Subscriber.SignalShutdown()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *LocalPartitionSubscribers) IsEmpty() bool {
|
||||
p.SubscribersLock.RLock()
|
||||
defer p.SubscribersLock.RUnlock()
|
||||
|
||||
return len(p.Subscribers) == 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user