Recreate channel observer irrespective of probe success/fail. (#1778)
This commit is contained in:
@@ -39,7 +39,7 @@ type ProbeController struct {
|
|||||||
probeTrendObserved bool
|
probeTrendObserved bool
|
||||||
probeEndTime time.Time
|
probeEndTime time.Time
|
||||||
|
|
||||||
onProbeSuccess func()
|
onProbeDone func(isSuccessful bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProbeController(params ProbeControllerParams) *ProbeController {
|
func NewProbeController(params ProbeControllerParams) *ProbeController {
|
||||||
@@ -51,11 +51,11 @@ func NewProbeController(params ProbeControllerParams) *ProbeController {
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProbeController) OnProbeSuccess(f func()) {
|
func (p *ProbeController) OnProbeDone(f func(isSuccessful bool)) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|
||||||
p.onProbeSuccess = f
|
p.onProbeDone = f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProbeController) Reset() {
|
func (p *ProbeController) Reset() {
|
||||||
@@ -79,15 +79,11 @@ func (p *ProbeController) ProbeClusterDone(info ProbeClusterInfo, lowestEstimate
|
|||||||
if p.abortedProbeClusterId == ProbeClusterIdInvalid {
|
if p.abortedProbeClusterId == ProbeClusterIdInvalid {
|
||||||
// successful probe, finalize
|
// successful probe, finalize
|
||||||
isSuccessful := p.finalizeProbeLocked()
|
isSuccessful := p.finalizeProbeLocked()
|
||||||
|
onProbeDone := p.onProbeDone
|
||||||
var onProbeSuccess func()
|
|
||||||
if isSuccessful {
|
|
||||||
onProbeSuccess = p.onProbeSuccess
|
|
||||||
}
|
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
|
|
||||||
if onProbeSuccess != nil {
|
if onProbeDone != nil {
|
||||||
onProbeSuccess()
|
onProbeDone(isSuccessful)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -145,19 +141,16 @@ func (p *ProbeController) CheckProbe(trend ChannelTrend, highestEstimate int64)
|
|||||||
|
|
||||||
func (p *ProbeController) MaybeFinalizeProbe() {
|
func (p *ProbeController) MaybeFinalizeProbe() {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
|
var onProbeDone func(bool)
|
||||||
isSuccessful := false
|
isSuccessful := false
|
||||||
if p.isInProbeLocked() && !p.probeEndTime.IsZero() && time.Now().After(p.probeEndTime) {
|
if p.isInProbeLocked() && !p.probeEndTime.IsZero() && time.Now().After(p.probeEndTime) {
|
||||||
isSuccessful = p.finalizeProbeLocked()
|
isSuccessful = p.finalizeProbeLocked()
|
||||||
}
|
onProbeDone = p.onProbeDone
|
||||||
|
|
||||||
var onProbeSuccess func()
|
|
||||||
if isSuccessful {
|
|
||||||
onProbeSuccess = p.onProbeSuccess
|
|
||||||
}
|
}
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
|
|
||||||
if onProbeSuccess != nil {
|
if onProbeDone != nil {
|
||||||
onProbeSuccess()
|
onProbeDone(isSuccessful)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ func NewStreamAllocator(params StreamAllocatorParams) *StreamAllocator {
|
|||||||
Prober: s.prober,
|
Prober: s.prober,
|
||||||
Logger: params.Logger,
|
Logger: params.Logger,
|
||||||
})
|
})
|
||||||
s.probeController.OnProbeSuccess(s.onProbeSuccess)
|
s.probeController.OnProbeDone(s.onProbeDone)
|
||||||
|
|
||||||
s.resetState()
|
s.resetState()
|
||||||
|
|
||||||
@@ -916,7 +916,7 @@ func (s *StreamAllocator) allocateTrack(track *Track) {
|
|||||||
s.adjustState()
|
s.adjustState()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StreamAllocator) onProbeSuccess() {
|
func (s *StreamAllocator) onProbeDone(isSuccessful bool) {
|
||||||
highestEstimateInProbe := s.channelObserver.GetHighestEstimate()
|
highestEstimateInProbe := s.channelObserver.GetHighestEstimate()
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -931,6 +931,9 @@ func (s *StreamAllocator) onProbeSuccess() {
|
|||||||
// the send side is in full control of bandwidth estimation.
|
// the send side is in full control of bandwidth estimation.
|
||||||
//
|
//
|
||||||
s.channelObserver = s.newChannelObserverNonProbe()
|
s.channelObserver = s.newChannelObserverNonProbe()
|
||||||
|
if !isSuccessful {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// probe estimate is same or higher, commit it and try to allocate deficient tracks
|
// probe estimate is same or higher, commit it and try to allocate deficient tracks
|
||||||
s.params.Logger.Infow(
|
s.params.Logger.Infow(
|
||||||
|
|||||||
Reference in New Issue
Block a user