Code Review: Swap ordering of watermark getting.

A test for Julius.
This commit is contained in:
Matt T. Proud 2013-06-21 18:34:08 +02:00
parent ee840904d2
commit 5daa0a09ea

View file

@ -311,6 +311,16 @@ func (t *TieredStorage) seriesTooOld(f *model.Fingerprint, i time.Time) (bool, e
wm, cacheHit := t.wmCache.Get(f)
if !cacheHit {
if t.memoryArena.HasFingerprint(f) {
samples := t.memoryArena.CloneSamples(f)
if len(samples) > 0 {
newest := samples[0].Timestamp
t.wmCache.Set(f, &Watermarks{High: newest})
return newest.Before(i), nil
}
}
value := &dto.MetricHighWatermark{}
diskHit, err := t.DiskStorage.MetricHighWatermarks.Get(f.ToDTO(), value)
if err != nil {
@ -320,21 +330,10 @@ func (t *TieredStorage) seriesTooOld(f *model.Fingerprint, i time.Time) (bool, e
if diskHit {
wmTime := time.Unix(*value.Timestamp, 0).UTC()
t.wmCache.Set(f, &Watermarks{High: wmTime})
return wmTime.Before(i), nil
}
if !t.memoryArena.HasFingerprint(f) {
return true, nil
}
samples := t.memoryArena.CloneSamples(f)
if len(samples) == 0 {
return true, nil
}
newest := samples[0].Timestamp
t.wmCache.Set(f, &Watermarks{High: newest})
return false, nil
}