incremental ETAs
This commit is contained in:
parent
90d557be9e
commit
fba9741821
@ -684,8 +684,9 @@ func (this *Migrator) printMigrationStatusHint(writers ...io.Writer) {
|
|||||||
*this.inspector.connectionConfig.ImpliedKey,
|
*this.inspector.connectionConfig.ImpliedKey,
|
||||||
this.migrationContext.Hostname,
|
this.migrationContext.Hostname,
|
||||||
))
|
))
|
||||||
fmt.Fprintln(w, fmt.Sprintf("# Migration started at %+v",
|
fmt.Fprintln(w, fmt.Sprintf("# Migration started at %+v; time now is %+v",
|
||||||
this.migrationContext.StartTime.Format(time.RubyDate),
|
this.migrationContext.StartTime.Format(time.RubyDate),
|
||||||
|
time.Now().Format(time.RubyDate),
|
||||||
))
|
))
|
||||||
maxLoad := this.migrationContext.GetMaxLoad()
|
maxLoad := this.migrationContext.GetMaxLoad()
|
||||||
criticalLoad := this.migrationContext.GetCriticalLoad()
|
criticalLoad := this.migrationContext.GetCriticalLoad()
|
||||||
@ -793,7 +794,9 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
|
|||||||
etaDuration := etaTime.Sub(time.Now())
|
etaDuration := etaTime.Sub(time.Now())
|
||||||
eta = base.PrettifyDurationOutput(etaDuration)
|
eta = base.PrettifyDurationOutput(etaDuration)
|
||||||
etaSeconds = etaDuration.Seconds()
|
etaSeconds = etaDuration.Seconds()
|
||||||
|
log.Errorf("==== etaTime: %+v, eta=%+v, etaSeonds=%+v", etaTime, eta, etaSeconds)
|
||||||
}
|
}
|
||||||
|
log.Errorf("===1 etaTime: %+v, eta=%+v, etaSeonds=%+v", "na", eta, etaSeconds)
|
||||||
|
|
||||||
if etaSeconds < 0 {
|
if etaSeconds < 0 {
|
||||||
eta = "due"
|
eta = "due"
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/github/gh-ost/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxHistoryDuration time.Duration = time.Hour
|
const maxHistoryDuration time.Duration = time.Minute * 61
|
||||||
|
|
||||||
type ProgressState struct {
|
type ProgressState struct {
|
||||||
mark time.Time
|
mark time.Time
|
||||||
@ -50,6 +50,15 @@ func (this *ProgressHistory) oldestState() *ProgressState {
|
|||||||
return this.history[0]
|
return this.history[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ProgressHistory) firstStateSince(since time.Time) *ProgressState {
|
||||||
|
for _, state := range this.history {
|
||||||
|
if !state.mark.Before(since) {
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *ProgressHistory) newestState() *ProgressState {
|
func (this *ProgressHistory) newestState() *ProgressState {
|
||||||
if len(this.history) == 0 {
|
if len(this.history) == 0 {
|
||||||
return nil
|
return nil
|
||||||
@ -98,12 +107,12 @@ func (this *ProgressHistory) hasEnoughData() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ProgressHistory) getETA() (eta time.Time) {
|
func (this *ProgressHistory) getETABasedOnRange(basedOnRange time.Duration) (eta time.Time) {
|
||||||
if !this.hasEnoughData() {
|
if !this.hasEnoughData() {
|
||||||
return eta
|
return eta
|
||||||
}
|
}
|
||||||
|
|
||||||
oldest := this.oldestState()
|
oldest := this.firstStateSince(time.Now().Add(-basedOnRange))
|
||||||
newest := this.newestState()
|
newest := this.newestState()
|
||||||
rowsEstimate := atomic.LoadInt64(&this.migrationContext.RowsEstimate) + atomic.LoadInt64(&this.migrationContext.RowsDeltaEstimate)
|
rowsEstimate := atomic.LoadInt64(&this.migrationContext.RowsEstimate) + atomic.LoadInt64(&this.migrationContext.RowsDeltaEstimate)
|
||||||
ratio := float64(rowsEstimate-oldest.rowsCopied) / float64(newest.rowsCopied-oldest.rowsCopied)
|
ratio := float64(rowsEstimate-oldest.rowsCopied) / float64(newest.rowsCopied-oldest.rowsCopied)
|
||||||
@ -113,3 +122,22 @@ func (this *ProgressHistory) getETA() (eta time.Time) {
|
|||||||
|
|
||||||
return eta
|
return eta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ProgressHistory) getETA() (eta time.Time) {
|
||||||
|
if eta = this.getETABasedOnRange(time.Minute * 1); !eta.IsZero() {
|
||||||
|
return eta
|
||||||
|
}
|
||||||
|
if eta = this.getETABasedOnRange(time.Minute * 5); !eta.IsZero() {
|
||||||
|
return eta
|
||||||
|
}
|
||||||
|
if eta = this.getETABasedOnRange(time.Minute * 10); !eta.IsZero() {
|
||||||
|
return eta
|
||||||
|
}
|
||||||
|
if eta = this.getETABasedOnRange(time.Minute * 30); !eta.IsZero() {
|
||||||
|
return eta
|
||||||
|
}
|
||||||
|
if eta = this.getETABasedOnRange(time.Minute * 60); !eta.IsZero() {
|
||||||
|
return eta
|
||||||
|
}
|
||||||
|
return eta
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user