public void ShouldBeAbleToPullExistingConfigFromCache() { var monitorInfoDictionary = new ConcurrentDictionary<string, MonitorInfo>(); var reduceLevel = new ReduceLevel(); var monitorConfig = new MonitorConfig(); monitorConfig.MonitorReductionType = MonitorReductionType.DefaultAccumulate; monitorConfig.ReduceLevels = new List<ReduceLevel> { reduceLevel }; var monitorConfigsDictionary = new ConcurrentDictionary<string, MonitorConfig>(); monitorConfigsDictionary.TryAdd("Test", monitorConfig); var cache = new Mock<IDataCache>(); cache.SetupGet(x => x.MonitorInfo).Returns(monitorInfoDictionary); cache.SetupGet(x => x.MonitorConfigs).Returns(monitorConfigsDictionary); var settings = BuildSettings(); var seeder = new ConfigSeed(cache.Object, settings.Object); var result = seeder.Seed("Test", MonitorReductionType.DefaultAccumulate); Assert.NotNull(result); Assert.Same(monitorConfig, result.MonitorConfig); Assert.Same(reduceLevel, result.FirstReduceLevel); }
public void ShouldBeAbleToPullExistingInfoFromCache() { var monitorInfo = new MonitorInfo(); var monitorInfoDictionary = new ConcurrentDictionary<string, MonitorInfo>(); monitorInfoDictionary.TryAdd("Test", monitorInfo); var cache = new Mock<IDataCache>(); cache.SetupGet(x => x.MonitorInfo).Returns(monitorInfoDictionary); var settings = BuildSettings(); var seeder = new ConfigSeed(cache.Object, settings.Object); var result = seeder.Seed("Test", MonitorReductionType.DefaultAccumulate); Assert.NotNull(result); Assert.Same(monitorInfo, result); }
public void ShouldCreatConfigWhenNotRecordExists() { var monitorInfoDictionary = new ConcurrentDictionary<string, MonitorInfo>(); var monitorConfigsDictionary = new ConcurrentDictionary<string, MonitorConfig>(); var cache = new Mock<IDataCache>(); cache.SetupGet(x => x.MonitorInfo).Returns(monitorInfoDictionary); cache.SetupGet(x => x.MonitorConfigs).Returns(monitorConfigsDictionary); var reduceMethodProvider = new Mock<IReduceMethodProvider>(); reduceMethodProvider.Setup(x => x.Retrieve(It.IsAny<string>())).Returns(new Mock<IReduceMethod<double>>().Object); var settings = BuildSettings(); settings.SetupGet(x => x.ReduceMethodProvider).Returns(reduceMethodProvider.Object); var seeder = new ConfigSeed(cache.Object, settings.Object); var result = seeder.Seed("Test", MonitorReductionType.DefaultAccumulate); Assert.NotNull(result); Assert.Equal(4, result.MonitorConfig.ReduceLevels.Count); }
public void Initialize(SettingsExtensionOptions settingsExtensionOptions) { //Need to setup the logger first LoggerProvider = settingsExtensionOptions.LoggerProvider ?? new SystemLoggerProvider(this); var storageFactory = settingsExtensionOptions.StorageFactory; if (settingsExtensionOptions.StorageFactory == null) { var storageFactoryProvider = new StorageFactoryProvider(); storageFactory = storageFactoryProvider.CreateProvider(); } var storageCommands = settingsExtensionOptions.StorageCommands ?? new StorageCommands(storageFactory, this); var storageCommandsSetup = settingsExtensionOptions.StorageCommandsSetup ?? new StorageCommandsSetup(); var cache = new DataCache(); var flusherUpdate = new RecordFlushUpdate(cache, storageCommands); var reduceStatus = new RecordReduceStatus(new RecordReduceStatusSourceProviderFile(this)); var reduceAggregate = new RecordReduceAggregate(); var compare = new RecordCompare(storageCommands, this); var setupSystemTables = new SetupSystemTables(cache, storageCommandsSetup, this); var setupSystemData = new SetupSystemData(cache, storageCommandsSetup, this); var setupSystem = new SetupSystem(setupSystemTables, setupSystemData, storageFactory); var defineDefaults = new SetupMonitorConfig(storageCommands, setupSystemTables, cache, storageFactory, this); ConfigSeed = new ConfigSeed(cache, this); Recorder = new Recorder(cache, this); RecordFlush = new RecordFlush(defineDefaults, cache, storageCommands, flusherUpdate, storageFactory, this); RecordReduce = new RecordReduce(reduceStatus, reduceAggregate, cache, compare, storageCommands, storageFactory, this); ReduceMethodProvider = new ReduceMethodProvider(); ReduceMethodProvider.Register(new ReduceMethodAccumulate()); ReduceMethodProvider.Register(new ReduceMethodAverage()); ProcessingInstructionProvider = new ProcessingInstructionProvider(); ProcessingInstructionProvider.Register(new ProcessingInstructionAccumulate(storageCommands)); ProcessingInstructionProvider.Register(new ProcessingInstructionAverage()); //Run system setup setupSystem.Initialize(); }