Пример #1
0
        public rrd4n.DataAccess.Data.FetchData GetData(rrd4n.DataAccess.Data.FetchRequest request)
        {
            RrdDb rrdDb = null;

            try
            {
                string dataPath;
                if (DataPath.Contains("${APPDATA}"))
                {
                    dataPath  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                    dataPath += DataPath.Substring(10);
                }
                else
                {
                    dataPath = DataPath;
                }


                rrdDb = new RrdDb(dataPath + request.DatabasePath);
                FetchRequest coreRequest   = new FetchRequest(rrdDb.getPath(), request.ConsolidateFunctionName, request.FetchStart, request.FetchEnd, request.Resolution);
                FetchData    coreFetchData = rrdDb.fetchData(coreRequest);

                return(new rrd4n.DataAccess.Data.FetchData(coreFetchData.getArcStep(), coreFetchData.getArcEndTime(), coreFetchData.getDsNames())
                {
                    Values = coreFetchData.getValues(),
                    Timestamps = coreFetchData.getTimestamps()
                });
            }
            finally
            {
                if (rrdDb != null)
                {
                    rrdDb.close();
                }
            }
        }
Пример #2
0
      private void fetchRrdData()
      {
         long tEndFixed = (tEnd == 0) ? Util.getTimestamp() : tEnd;
         for (int i = 0; i < defSources.Length; i++)
         {
            if (!defSources[i].isLoaded())
            {
               // not fetched yet
               List<String> dsNames = new List<String>();
               dsNames.Add(defSources[i].getDsName());
               // look for all other datasources with the same path and the same consolidation function
               for (int j = i + 1; j < defSources.Length; j++)
               {
                  if (defSources[i].isCompatibleWith(defSources[j]))
                  {
                     dsNames.Add(defSources[j].getDsName());
                  }
               }
               // now we have everything
               FetchRequest req = null;
               if (defSources[i].StartTime == long.MinValue)
                  req = new FetchRequest(defSources[i].getPath(), defSources[i].getConsolFun().Name, tStart, tEndFixed, FetchRequestResolution);
               else
               {
                  long step = Math.Max(1, defSources[i].Step);
                  string reduceFunctionName = defSources[i].ReduceCfName;

                  if (string.IsNullOrEmpty(reduceFunctionName))
                     reduceFunctionName = defSources[i].getConsolFun().Name;

                  req = new FetchRequest(defSources[i].getPath(), reduceFunctionName, defSources[i].StartTime, defSources[i].EndTime, step);
               }
               req.setFilter(dsNames);
               FetchData data = DbAccessInterface.GetData(req);

               defSources[i].setFetchData(data);
               for (int j = i + 1; j < defSources.Length; j++)
               {
                  if (defSources[i].isCompatibleWith(defSources[j]))
                     defSources[j].setFetchData(data);
               }
            }
         }
      }