예제 #1
0
        public void CreateOpen()
        {
            var path = Path.GetTempFileName();

            DatapointDatabase.Create(path, 0.5f, DownsamplingMethod.Sum,
                                     new RetentionPolicy {
                { TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(1) },
                { TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(5) },
                { TimeSpan.FromSeconds(20), TimeSpan.FromMinutes(20) }
            });

            var database = DatapointDatabase.Open(path);

            Assert.AreEqual(0.5f, database.DownsamplingFactor);
            Assert.AreEqual(DownsamplingMethod.Sum, database.DownsamplingMethod);

            Assert.AreEqual(3, database.Archives.Count);

            Assert.AreEqual((TimeSpan)database.Archives[0].Retention.Precision, TimeSpan.FromSeconds(1));
            Assert.AreEqual((TimeSpan)database.Archives[0].Retention.History, TimeSpan.FromMinutes(1));

            Assert.AreEqual((TimeSpan)database.Archives[1].Retention.Precision, TimeSpan.FromSeconds(10));
            Assert.AreEqual((TimeSpan)database.Archives[1].Retention.History, TimeSpan.FromMinutes(5));

            Assert.AreEqual((TimeSpan)database.Archives[2].Retention.Precision, TimeSpan.FromSeconds(20));
            Assert.AreEqual((TimeSpan)database.Archives[2].Retention.History, TimeSpan.FromMinutes(20));
        }
예제 #2
0
        public Metric ReadMetric(string metricName, DateTime @from, DateTime until, TimeSpan?precision = null)
        {
            var databaseFilePath = GetDatabaseFiles(metricName).FirstOrDefault();

            if (databaseFilePath == null)
            {
                return(null);
            }

            var database = DatapointDatabase.Open(databaseFilePath.FullName);
            var series   = database.ReadSeries(from, until, precision);

            return(new Metric(metricName, series));
        }