Inheritance: ICache
 public void Should_expire_after_construction()
 {
     var log = MockRepository.GenerateMock<ILog>();
     var t = new TimeSpan(0, 0, 0, 0, 500);
     var cache = new Cache(t, log);
     Assert.That(cache.HasExpired(), Is.EqualTo(true));
 }
 public void Should_expire_after_One_second()
 {
     var log = MockRepository.GenerateMock<ILog>();
     var t = new TimeSpan(0, 0, 0, 0, 500);
     var cache = new Cache(t, log);
     cache.ResetCache();
     Assert.That(cache.HasExpired(), Is.EqualTo(false));
     Thread.Sleep(1000);
     Assert.That(cache.HasExpired(), Is.EqualTo(true));
 }
Example #3
0
 public static TaskManager CreateTaskManager(SqlToGraphiteSection configuration)
 {
     var cacheLength = new TimeSpan(0, configuration.ConfigCacheLengthMinutes, 0);
     var stop = new Stop();
     IDataClientFactory dataClientFactory = new DataClientFactory(log);
     IGraphiteClientFactory graphiteClientFactory = new GraphiteClientFactory(log);
     var configMapper = new ConfigMapper(configuration.Hostname, stop, dataClientFactory, graphiteClientFactory, log);
     var configReader = new ConfigReader(configuration.ConfigUri,configuration.ConfigUsername,configuration.ConfigPassword);
     var cache = new Cache(cacheLength, log);
     var sleeper = new Sleeper();
     var knownGraphiteClients = new KnownGraphiteClients();
     var cr = new ConfigRepository(configReader, knownGraphiteClients, cache, sleeper, log, configuration.MinutesBetweenRetryToGetConfigOnError);
     var configController = new ConfigController(configMapper, log, cr);
     return new TaskManager(log, configController, configuration.ConfigUri, stop, sleeper, configuration.CheckConfigUpdatedEveryMinutes);
 }
        public static TaskManager CreateTaskManager(SqlToGraphiteSection configuration)
        {
            var cacheLength = new TimeSpan(0, configuration.ConfigCacheLengthMinutes, 0);
            var stop = new Stop();
            var directoryImpl = new DirectoryImpl();
            var assemblyResolver = new AssemblyResolver(directoryImpl, log);
            IEncryption encryption = new Encryption();
            IDataClientFactory dataClientFactory = new DataClientFactory(log, assemblyResolver, encryption);
            IGraphiteClientFactory graphiteClientFactory = new GraphiteClientFactory(log);

            var configReader = new ConfigHttpReader(configuration.ConfigUri, configuration.ConfigUsername, configuration.ConfigPassword);
            var cache = new Cache(cacheLength, log);
            var sleeper = new Sleeper();
            var genericSer = new GenericSerializer(Global.GetNameSpace());
            var cr = new ConfigRepository(configReader, cache, sleeper, log, configuration.MinutesBetweenRetryToGetConfigOnError, genericSer);
            var configMapper = new ConfigMapper(configuration.Hostname, stop, dataClientFactory, graphiteClientFactory, log, cr);
            var roleConfigFactory = new RoleConfigFactory();
            var environment = new Environment();
            var taskSetBuilder = new TaskSetBuilder();
            var configController = new ConfigController(configMapper, log, cr, roleConfigFactory, environment, taskSetBuilder);
            return new TaskManager(log, configController, configuration.ConfigUri, stop, sleeper, configuration.CheckConfigUpdatedEveryMinutes);
        }
        public void Initialise(string path)
        {
            log = LogManager.GetLogger("log");
            log4net.Config.XmlConfigurator.Configure();

            var sleepTime = 0;
            assemblyResolver = new AssemblyResolver(new DirectoryImpl(), log);
            var config = new SqlToGraphiteConfig(assemblyResolver, log);
            encryption = new Encryption();
            var reader = new ConfigHttpReader(path, "", "");
            var cache = new Cache(new TimeSpan(0, 0, 1, 0), log);
            var sleep = new Sleeper();
            var genericSerializer = new GenericSerializer(Global.GetNameSpace());
            var configPersister = new ConfigPersister(new ConfigFileWriter(path), genericSerializer);

            repository = new ConfigRepository(reader, cache, sleep, this.log, sleepTime, configPersister, genericSerializer);
        }