Ejemplo n.º 1
0
        public void ReturnsAllUsableIntervalTypes()
        {
            var results = IntervalService.GetIntervalFriendlyNames();

            Assert.Equal(3, results.Count());
            Assert.True(results.All(x => !string.IsNullOrEmpty(x)));
        }
Ejemplo n.º 2
0
        public Statsd(StatsdnetConfiguration config)
            : this(config.Name)
        {
            _log.Info("statsd.net loading config.");
            var systemMetrics = TinyIoCContainer.Current.Resolve <ISystemMetricsService>();

            systemMetrics.HideSystemStats = config.HideSystemStats;

            LoadBackends(config, systemMetrics);

            // Load Aggregators
            var intervalServices = new List <IIntervalService>();
            var intervalService  = new IntervalService(config.FlushInterval,
                                                       _tokenSource.Token);

            intervalServices.Add(intervalService);
            LoadAggregators(config,
                            intervalService,
                            _messageBroadcaster,
                            systemMetrics);
            // Load Listeners
            LoadListeners(config, _tokenSource.Token, systemMetrics);

            // Now start the interval service
            intervalServices.ForEach(p => p.Start());

            // Announce that we've started
            systemMetrics.LogCount("started");
        }
Ejemplo n.º 3
0
        public MSSQLRelayListener(string connectionString,
                                  TimeSpan pollInterval,
                                  CancellationToken cancellationToken,
                                  int batchSize,
                                  bool deleteAfterSend,
                                  ISystemMetricsService metrics)
        {
            _connectionString  = connectionString;
            _intervalService   = new IntervalService(pollInterval, cancellationToken);
            _cancellationToken = cancellationToken;
            _batchSize         = batchSize;
            _deleteAfterSend   = deleteAfterSend;
            _metrics           = metrics;

            var stopwatch = new Stopwatch();

            _intervalService.Elapsed += (sender, e) =>
            {
                if (IsListening)
                {
                    _intervalService.Cancel(true);
                    stopwatch.Restart();
                    ReadAndFeed();
                    stopwatch.Stop();
                    metrics.LogCount("listeners.mssql-relay.feedTimeSeconds", Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));

                    // Only continue the interval service if cancellation
                    // isn't in progress
                    if (!cancellationToken.IsCancellationRequested)
                    {
                        _intervalService.Start();
                    }
                }
            };
        }
Ejemplo n.º 4
0
        public void TestService()
        {
            IntervalService service = new IntervalService();
            Interval interval = new Interval();
            interval.Description = "Hello World";

            //service.Insert(interval);
        }
Ejemplo n.º 5
0
        public void TestSortIntervalsShouldSortByLowerBoundValue()
        {
            var sut      = new IntervalService();
            var actual   = sut.sortIntervals(MockData.exampleInput);
            var expected = MockData.exampleSortedExpected;

            Assert.True(checkEquality(expected, actual));
        }
Ejemplo n.º 6
0
        public void TestMergeIntervalsLargeValues()
        {
            var sut      = new IntervalService();
            var actual   = sut.sortIntervals(sut.mergeIntervals(MockData.exampleInput));
            var expected = MockData.exampleExpected;

            Assert.True(checkEquality(expected, actual));
        }
Ejemplo n.º 7
0
        private static Interval ThemisMap(ChoreFormViewModel model)
        {
            var result = IntervalService.CreateNew(model.IntervalType);

            result.Duration    = (uint)model.Duration;
            result.StartDay    = model.StartDay.Value; // MUST have a valid StartDay here!
            result.StartOfWeek = model.StartOfWeek;
            return(result);
        }
Ejemplo n.º 8
0
        public void GetIntervals()
        {
            var intervalService = new IntervalService();
            var intervals       = intervalService.GetIntervals();

            Assert.Equal(13, intervals.Count());

            var perfectFifth = intervals.First(i => i.Symbol == "5");

            Assert.Equal(7, perfectFifth.DistanceInSemiTones);
        }
Ejemplo n.º 9
0
        public void IntervalTest()
        {
            var noteService         = new NoteService();
            var intervalService     = new IntervalService();
            var noteIntervalService = new NoteIntervalService(noteService, intervalService);

            var intervals    = noteIntervalService.GetNoteIntervals("A");
            var perfectFifth = intervals.First(t => t.Interval.DistanceInSemiTones == 7);

            Assert.Equal("E", perfectFifth.Note.Name);
            Assert.Equal("A", intervals.Last().Note.Name);
            Assert.Equal(Intervals.Octave, intervals.Last().Interval.Type);
        }
Ejemplo n.º 10
0
        private async Task OnIntervalTemplateChangeAsync(IntervalTemplate item)
        {
            if (item.IsNew)
            {
                var id = await IntervalService.AddItemAsync(Mapper.Map <IntervalTemplateDto>(item));

                item.Id = id;
                IntervalTemplates.Insert(0, item);
            }
            else
            {
                await IntervalService.UpdateItemAsync(Mapper.Map <IntervalTemplateDto>(item));
            }
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            var intervalService = new IntervalService();
            var mergeResult     = intervalService.mergeIntervals(MockData.exampleInput);

            foreach (var value in MockData.exampleInput)
            {
                Console.WriteLine($"Input interval: {value.ToString()}");
            }
            Console.WriteLine("========================");
            foreach (var result in mergeResult)
            {
                Console.WriteLine($"Result interval: {result.ToString()}");
            }
        }
Ejemplo n.º 12
0
        public void AMajorChord()
        {
            var noteService         = new NoteService();
            var intervalService     = new IntervalService();
            var noteIntervalService = new NoteIntervalService(noteService, intervalService);
            var chordService        = new ChordService(noteIntervalService, noteService);
            var aMajorChord         = chordService.GetChord("A", Core.Chords.Major);

            Assert.NotNull(aMajorChord);
            Assert.Equal("A", aMajorChord.Key.Name);

            // notes.
            Assert.Equal("A", aMajorChord.Notes[0].Name);
            Assert.Equal("C#", aMajorChord.Notes[1].Name);
            Assert.Equal("E", aMajorChord.Notes[2].Name);
        }
Ejemplo n.º 13
0
        private async Task DeleteTemplateAsync(object obj)
        {
            if (obj is IntervalTemplate item)
            {
                if (Device.RuntimePlatform != Device.UWP &&
                    !(await DialogService.DisplayAlertAsync("Delete", $"You are about to delete template '{item.Name}', are you sure?", "Ok", "Cancel")))
                {
                    return;
                }

                if (await IntervalService.DeleteItemAsync(item.Id))
                {
                    IntervalTemplates.Remove(item);
                }
            }
        }
Ejemplo n.º 14
0
        public void NextNote()
        {
            var noteService         = new NoteService();
            var intervalService     = new IntervalService();
            var noteIntervalService = new NoteIntervalService(noteService, intervalService);

            var notes  = noteService.GetNotes();
            var a      = noteService.GetNoteByName("A");
            var asharp = noteIntervalService.NextNote(notes, a);

            Assert.Equal("A#", asharp.Name); // semi tone higher.
            var b = noteIntervalService.NextNote(notes, a, 2);

            Assert.Equal("B", b.Name); // tone.
            var nextA = noteIntervalService.NextNote(notes, a, 12);

            Assert.Equal(a, nextA); // octave
        }
Ejemplo n.º 15
0
        public async Task InitializeAsync(INavigationParameters parameters)
        {
            foreach (var template in await IntervalService.GetItemsAsync())
            {
                var map = Mapper.Map <IntervalTemplate>(template);

                foreach (var interval in template.Intervals)
                {
                    map.Intervals.Add(Mapper.Map <Interval>(interval));
                }

                foreach (var history in template.History)
                {
                    map.History.Add(Mapper.Map <History>(history));
                }

                IntervalTemplates.Add(map);
            }
        }
Ejemplo n.º 16
0
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            base.FinishedLaunching(app, options);

            IntervalService service = new IntervalService();
            service.InitData();

            //SoundService sservice = new SoundService();
            //sservice.PlayCountDown();

            AudioSession.Initialize();
            AudioSession.Category = AudioSessionCategory.MediaPlayback;
            AudioSession.SetActive(true);

            window.AddSubview (navigationController.View);
            window.MakeKeyAndVisible ();

            return true;
        }
Ejemplo n.º 17
0
        public void AllIntervals()
        {
            IntervalService service = new IntervalService();

            Interval interval = new Interval();

            //	service.Insert(interval);

            //	List<Interval> intervals = service.FindAll();

            /*	var conn = new SqliteConnection("Data Source=intervals;Version=3;Legacy Format=True;");

              			using (var cmd = conn.CreateCommand())

            {

              				conn.Open();

              			//	cmd.CommandText ="SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;";

            */
        }
Ejemplo n.º 18
0
        private static Chore MapFromDb(DbChore dbChore)
        {
            var interval = IntervalService.CreateNew(dbChore.IntervalType);

            interval.Duration    = dbChore.Duration;
            interval.StartDay    = dbChore.StartDay;
            interval.StartOfWeek = dbChore.StartOfWeek;

            string[] assis = { };
            if (!string.IsNullOrEmpty(dbChore.AssignedUsers))
            {
                assis = dbChore.AssignedUsers.Split(";");
            }

            return(new Chore
            {
                Title = dbChore.Title,
                Description = dbChore.Description,
                AssignedUsers = assis,
                Interval = interval
            });
        }
 public IntervalService_AddShould()
 {
     this.intervalService = new IntervalService();
 }
Ejemplo n.º 20
0
 public void SetUp()
 {
     _intervalService = new IntervalService();
 }
Ejemplo n.º 21
0
 public RootViewController(IntPtr handle)
     : base(handle)
 {
     Service = new IntervalService();
 }
Ejemplo n.º 22
0
        public Statsd(dynamic config)
            : this((string)config.general.name)
        {
            _log.Info("statsd.net loading config.");
            var systemMetrics = SuperCheapIOC.Resolve <ISystemMetricsService>();

            // Load backends
            if (config.backends.console.enabled)
            {
                AddBackend(new ConsoleBackend(), "console");
            }
            if (config.backends.graphite.enabled)
            {
                AddBackend(new GraphiteBackend(config.backends.graphite.host, (int)config.backends.graphite.port, systemMetrics), "graphite");
            }
            if (config.backends.sqlserver.enabled)
            {
                AddBackend(new SqlServerBackend(
                               config.backends.sqlserver.connectionString,
                               config.general.name,
                               systemMetrics,
                               batchSize: (int)config.backends.sqlserver.writeBatchSize),
                           "sqlserver");
            }

            // Load Aggregators
            var intervalServices = new List <IIntervalService>();
            var intervalService  = new IntervalService(( int )config.calc.flushIntervalSeconds);

            intervalServices.Add(intervalService);
            AddAggregator(MessageType.Counter,
                          TimedCounterAggregatorBlockFactory.CreateBlock(_messageBroadcaster, config.calc.countersNamespace, intervalService, _log));
            AddAggregator(MessageType.Gauge,
                          TimedGaugeAggregatorBlockFactory.CreateBlock(_messageBroadcaster, config.calc.gaugesNamespace, config.calc.deleteGaugesOnFlush, intervalService, _log));
            AddAggregator(MessageType.Set,
                          TimedSetAggregatorBlockFactory.CreateBlock(_messageBroadcaster, config.calc.setsNamespace, intervalService, _log));
            AddAggregator(MessageType.Timing,
                          TimedLatencyAggregatorBlockFactory.CreateBlock(_messageBroadcaster, config.calc.timersNamespace, intervalService, _log));

            // Load Latency Percentile Aggregators
            foreach (var percentile in (IDictionary <string, object>)config.calc.percentiles)
            {
                dynamic thePercentile = percentile.Value;
                intervalService = new IntervalService((int)thePercentile.flushIntervalSeconds);
                AddAggregator(MessageType.Timing,
                              TimedLatencyPercentileAggregatorBlockFactory.CreateBlock(_messageBroadcaster, config.calc.timersNamespace,
                                                                                       intervalService,
                                                                                       (int)thePercentile.percentile,
                                                                                       percentile.Key,
                                                                                       _log));
                intervalServices.Add(intervalService);
            }

            // Load listeners - done last and once the rest of the chain is in place
            if (config.listeners.udp.enabled)
            {
                AddListener(new UdpStatsListener((int)config.listeners.udp.port, systemMetrics));
            }
            if (config.listeners.tcp.enabled)
            {
                AddListener(new TcpStatsListener((int)config.listeners.tcp.port, systemMetrics));
            }
            if (config.listeners.http.enabled)
            {
                AddListener(new HttpStatsListener((int)config.listeners.http.port, systemMetrics));
            }

            // Now start the interval service
            intervalServices.ForEach(p => p.Start());
        }
Ejemplo n.º 23
0
        private void LoadAggregators(StatsdnetConfiguration config,
                                     IntervalService intervalService,
                                     BroadcastBlock <Bucket> messageBroadcaster,
                                     ISystemMetricsService systemMetrics)
        {
            foreach (var aggregator in config.Aggregators)
            {
                switch (aggregator.Key)
                {
                case "counters":
                    var counter = aggregator.Value as CounterAggregationConfig;
                    AddAggregator(MessageType.Counter,
                                  TimedCounterAggregatorBlockFactory.CreateBlock(messageBroadcaster,
                                                                                 counter.Namespace,
                                                                                 intervalService),
                                  systemMetrics);
                    break;

                case "gauges":
                    var gauge = aggregator.Value as GaugeAggregatorConfig;
                    AddAggregator(MessageType.Gauge,
                                  TimedGaugeAggregatorBlockFactory.CreateBlock(messageBroadcaster,
                                                                               gauge.Namespace,
                                                                               gauge.RemoveZeroGauges,
                                                                               intervalService),
                                  systemMetrics);
                    break;

                case "calendargrams":
                    var calendargram = aggregator.Value as CalendargramAggregationConfig;
                    AddAggregator(MessageType.Calendargram,
                                  TimedCalendargramAggregatorBlockFactory.CreateBlock(messageBroadcaster,
                                                                                      calendargram.Namespace,
                                                                                      intervalService,
                                                                                      new TimeWindowService()),
                                  systemMetrics);
                    break;

                case "timers":
                    var timer = aggregator.Value as TimersAggregationConfig;
                    AddAggregator(MessageType.Timing,
                                  TimedLatencyAggregatorBlockFactory.CreateBlock(messageBroadcaster,
                                                                                 timer.Namespace,
                                                                                 intervalService,
                                                                                 timer.CalculateSumSquares),
                                  systemMetrics);
                    // Add Percentiles
                    foreach (var percentile in timer.Percentiles)
                    {
                        AddAggregator(MessageType.Timing,
                                      TimedLatencyPercentileAggregatorBlockFactory.CreateBlock(messageBroadcaster,
                                                                                               timer.Namespace,
                                                                                               intervalService,
                                                                                               percentile.Threshold,
                                                                                               percentile.Name),
                                      systemMetrics);
                    }
                    break;
                }
            }
            // Add the Raw (pass-through) aggregator
            AddAggregator(MessageType.Raw,
                          PassThroughBlockFactory.CreateBlock(messageBroadcaster, intervalService),
                          systemMetrics);
        }
 void Initialize()
 {
     IntervalSevice = new IntervalService();
     SoundService = new SoundService();
 }
Ejemplo n.º 25
0
 public void InitTest()
 {
     intervalService = new IntervalService();
 }