Пример #1
0
 private void InitializeDataSet(DataCompactionConfiguration compactionConfig)
 {
     compactionConfig = compactionConfig ?? this.customCompaction;
     var mockSharedProperties = new MockSharedDataSetProperties
                                {
                                    CompactionConfiguration = compactionConfig,
                                    SealTime = compactionConfig.Default.Interval,
                                };
     this.dataSet =
         new DataSet<InternalHitCount>(CounterName, storagePath, this.dimensionSet,
                                                                  mockSharedProperties);
     dataSet.LoadStoredData();
 }
Пример #2
0
        public void GetEarliestTimestampsPerBucketProducesCorrectSegments()
        {
            var config =
                new DataCompactionConfiguration(new[]
                                         {
                                             new DataIntervalConfiguration(TimeSpan.FromMinutes(1),
                                                                  TimeSpan.FromHours(2)),
                                             new DataIntervalConfiguration(TimeSpan.FromMinutes(5),
                                                                  TimeSpan.FromHours(46)),
                                             new DataIntervalConfiguration(TimeSpan.FromMinutes(10),
                                                                  TimeSpan.FromDays(12)),
                                             new DataIntervalConfiguration(TimeSpan.FromHours(1), TimeSpan.MaxValue),
                                         });

            // Take a last time of ~2014/07/04 18:35:00
            // Expect: 2+ hrs of one minute buckets (from 2014/07/04 16:35 forward)
            //         46 hrs of 5 minute buckets (from 2014/07/02 16:30 forward)
            //         12 days of 10 minute buckets (from 2014/06/22 16:30 forward)
            var firstBucketTime = new DateTime(2014, 7, 4, 16, 35, 0, DateTimeKind.Utc);
            var secondBucketTime = new DateTime(2014, 7, 2, 18, 30, 0, DateTimeKind.Utc);
            var thirdBucketTime = new DateTime(2014, 6, 20, 18, 0, 0, DateTimeKind.Utc);

            foreach (var latestTime in new[]
                                       {
                                           new DateTime(2014, 7, 4, 18, 35, 0, DateTimeKind.Utc),
                                           new DateTime(2014, 7, 4, 18, 38, 21, DateTimeKind.Utc),
                                       })
            {
                var stamps = config.GetEarliestTimestampsPerBucket(latestTime);

                Assert.AreEqual(config.Intervals.Count, stamps.Count);
                Assert.AreEqual(firstBucketTime, stamps.Keys[0]);
                Assert.AreSame(config.Default, stamps.Values[0]);
                Assert.AreEqual(secondBucketTime, stamps.Keys[1]);
                Assert.AreSame(config.Intervals.ElementAt(1), stamps.Values[1]);
                Assert.AreEqual(thirdBucketTime, stamps.Keys[2]);
                Assert.AreSame(config.Intervals.ElementAt(2), stamps.Values[2]);
                Assert.AreEqual(DateTime.MinValue, stamps.Keys[3]);
                Assert.AreSame(config.Intervals.ElementAt(3), stamps.Values[3]);
            }
        }