コード例 #1
0
        public void update_multi_archive()
        {
            var retention_schema = new List <ArchiveInfo>()
            {
                new ArchiveInfo(1, 60), new ArchiveInfo(60, 60)
            };
            var data = update(schema: retention_schema);

            var fetch       = Whipser.Fetch(db, DateTime.UtcNow.ToUnixTime() - 25, now: DateTime.UtcNow.ToUnixTime() + 5).Value;
            var fetchedData = fetch.ValueList;

            foreach (var item in data)
            {
                Debug.WriteLine("wrote point ({0},{1})", item.Timestamp, item.value);
            }
            foreach (var item in fetchedData)
            {
                Debug.WriteLine("read point ({0},{1})", item.Timestamp, item.value);
            }

            // in future
            Assert.Throws <TimestampNotCoveredException>(() => Whipser.Update(db, 1.337, DateTime.UtcNow.ToUnixTime() + 1, now));

            // before the past
            Assert.Throws <TimestampNotCoveredException>(() => Whipser.Update(db, 1.337, DateTime.UtcNow.ToUnixTime() - retention_schema[1].Retention - 1, now));

            RemoveDb();
        }
コード例 #2
0
ファイル: PerfMonFile.cs プロジェクト: jdaigle/nsysmon
        public void Publish(string host, DateTime timestamp, string category, string counter, string instance, float value)
        {
            var counterId = this.counterDictionary.GetCounterIdOrNew(host, category, counter, instance);
            var path      = string.Format(@"c:\temp\counters\{0}.dat", counterId);

            ValidateCounterExists(path);
            try
            {
                Whipser.Update(path, Convert.ToDouble(value), timestamp: timestamp.ToUniversalTime().ToUnixTime());
            }
            catch (Exception e)
            {
                e.ToString();
                throw;
            }
        }
コード例 #3
0
        public void update_single_archive()
        {
            var retention_schema = new List <ArchiveInfo>()
            {
                new ArchiveInfo(1, 20)
            };
            var data = update(schema: retention_schema);

            var fetch       = Whipser.Fetch(db, 0).Value;
            var fetchedData = fetch.ValueList;

            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i].value, fetchedData[i].value);
            }

            // in future
            Assert.Throws <TimestampNotCoveredException>(() => Whipser.Update(db, 1.337, now + 1, now));

            // before the past
            Assert.Throws <TimestampNotCoveredException>(() => Whipser.Update(db, 1.337, now - retention_schema[0].Retention - 1, now));

            RemoveDb();
        }
コード例 #4
0
        private PointPair[] update(string wsp = null, List <ArchiveInfo> schema = null)
        {
            wsp    = wsp ?? db;
            schema = schema ?? new List <ArchiveInfo>()
            {
                new ArchiveInfo(1, 20)
            };

            var numDataPoints = schema[0].Points;

            Whipser.Create(wsp, schema);

            var tn   = DateTime.UtcNow.ToUnixTime() - numDataPoints;
            var data = new PointPair[numDataPoints];

            for (int i = 0; i < numDataPoints; i++)
            {
                //data[i] = new PointPair(tn + 1 + i, i * 10);
                data[i] = new PointPair(tn + 1 + i, random.Next(1000) * 10);
            }

            //Whipser.Update(wsp, data[0].value, data[0].Timestamp);
            //Whipser.UpdateMany(wsp, data);
            foreach (var item in data)
            {
                Whipser.Update(wsp, item.value, item.Timestamp);
            }

            // add more fake data
            Thread.Sleep(1000);
            Whipser.Update(wsp, random.Next(1000) * 10);
            Thread.Sleep(1000);
            Whipser.Update(wsp, random.Next(1000) * 10);

            return(data);
        }