func (p *Backend) queryGetData(param *specs.RrdQuery, resp *specs.RrdResp, e *cacheEntry) (rrds, caches []*specs.RRDData, err error) { flag := atomic.LoadUint32(&e.flag) caches, _ = e._getData(uint32(e.e.commitId), uint32(e.e.dataId)) if !p.Migrate.Disabled && flag&RRD_F_MISS != 0 { node, _ := p.storageMigrateConsistent.Get(param.Id()) done := make(chan error, 1) res := &specs.RrdRespCsum{} p.storageNetTaskCh[node] <- &netTask{ Method: NET_TASK_M_QUERY, Done: done, Args: param, Reply: res, } <-done // fetch data from remote rrds = res.Values } else { // read data from local rrd file rrds, _ = p.taskRrdFetch(e.hashkey(), param.ConsolFun, param.Start, param.End, int(e.e.step)) } // larger than rra1point range, skip merge now := p.timeNow() if param.Start < now-now%int64(e.e.step)-RRA1PointCnt*int64(e.e.step) { resp.Vs = rrds return nil, nil, errors.New("skip merge") } // no cached caches, do not merge if len(caches) < 1 { resp.Vs = rrds return nil, nil, errors.New("no caches") } return rrds, caches, nil }
func (p *Backend) queryGetCacheEntry(param *specs.RrdQuery, resp *specs.RrdResp) (*cacheEntry, error) { // form empty response resp.Vs = []*specs.RRDData{} resp.Host = param.Host resp.Name = param.Name e := p.cache.get(param.Csum()) if e == nil { return nil, specs.ErrNoent } resp.Type = e.typ() resp.Step = int(e.e.step) param.Start = param.Start - param.Start%int64(resp.Step) param.End = param.End - param.End%int64(resp.Step) + int64(resp.Step) if param.End-param.Start-int64(resp.Step) < 1 { return nil, specs.ErrParam } return e, nil }