Пример #1
0
        public void AddPollingJobCopy()
        {
            ITaskProcessorRuntimeInfo processorInfo = new FakeTaskProcessorRuntimeInfo()
            {
                TaskProcessorId = Guid.NewGuid(),
                Configuration   = new FakeTaskProcessorConfiguration()
            };

            this.Repository.Add(processorInfo);

            processorInfo = this.Repository.GetById(processorInfo.TaskProcessorId);

            processorInfo.Configuration.PollingJobs.AddCopy(new FakePollingJobConfiguration()
            {
                ImplementationType = typeof(FakePollingJob),
                PollInterval       = TimeSpan.FromMinutes(1),
                IsMaster           = true,
                IsActive           = true
            });

            IPollingJobConfiguration result = processorInfo.Configuration.PollingJobs[typeof(FakePollingJob)];

            Assert.AreEqual(typeof(FakePollingJob), result.ImplementationType);
            Assert.AreEqual(TimeSpan.FromMinutes(1), result.PollInterval);
            Assert.IsTrue(result.IsMaster);
            Assert.IsTrue(result.IsActive);
        }
Пример #2
0
        public void PollingJobs()
        {
            ITaskProcessorConfiguration configuration = AppConfigConfigurationUnitTests.GetTaskProcessorConfiguration("PollingJobs");

            Assert.AreEqual(3, configuration.PollingJobs.Count());

            IPollingJobConfiguration config = configuration.PollingJobs.First();

            Assert.AreEqual(typeof(FakePollingJob), config.ImplementationType);
            Assert.AreEqual(TimeSpan.FromMinutes(1), config.PollInterval);
            Assert.IsTrue(config.IsMaster);
            Assert.IsFalse(config.IsActive);
            Assert.IsFalse(config.IsConcurrent);

            config = configuration.PollingJobs.Skip(1).First();

            Assert.AreEqual(typeof(FakePollingJob2), config.ImplementationType);
            Assert.AreEqual(TimeSpan.FromMinutes(2), config.PollInterval);
            Assert.IsFalse(config.IsMaster);
            Assert.IsTrue(config.IsActive);
            Assert.IsFalse(config.IsConcurrent);

            config = configuration.PollingJobs.Skip(2).First();

            Assert.AreEqual(typeof(FakePollingJob3), config.ImplementationType);
            Assert.AreEqual(TimeSpan.FromMinutes(3), config.PollInterval);
            Assert.IsFalse(config.IsMaster);
            Assert.IsTrue(config.IsActive);
            Assert.IsTrue(config.IsConcurrent);
        }
Пример #3
0
        public void PollingJobsConfiguration()
        {
            FakeTaskProcessorRuntimeInfo processorInfo1 = new FakeTaskProcessorRuntimeInfo()
            {
                TaskProcessorId = Guid.NewGuid(),

                Configuration = new FakeTaskProcessorConfiguration()
            };

            processorInfo1.Configuration.PollingJobs.Add(new FakePollingJobConfiguration()
            {
                ImplementationType = typeof(FakePollingJob),
                PollInterval       = TimeSpan.FromMinutes(1),
                IsMaster           = true
            });

            processorInfo1.Configuration.PollingJobs.Add(new FakePollingJobConfiguration()
            {
                ImplementationType = typeof(FakePollingJob2),
                PollInterval       = TimeSpan.FromMinutes(2),
                IsActive           = true
            });

            processorInfo1.Configuration.PollingJobs.Add(new FakePollingJobConfiguration()
            {
                ImplementationType = typeof(FakePollingJob3),
                PollInterval       = TimeSpan.FromMinutes(3),
                IsConcurrent       = true
            });

            this.Repository.Add(processorInfo1);

            ITaskProcessorRuntimeInfo processorInfo2 = this.Repository.GetById(processorInfo1.TaskProcessorId);

            Assert.AreEqual(3, processorInfo2.Configuration.PollingJobs.Count());

            IPollingJobConfiguration queue1 = processorInfo2.Configuration.PollingJobs.First(q => q.ImplementationType == typeof(FakePollingJob));

            Assert.AreEqual(TimeSpan.FromMinutes(1), queue1.PollInterval);
            Assert.IsTrue(queue1.IsMaster);
            Assert.IsFalse(queue1.IsActive);
            Assert.IsFalse(queue1.IsConcurrent);

            IPollingJobConfiguration queue2 = processorInfo2.Configuration.PollingJobs.First(q => q.ImplementationType == typeof(FakePollingJob2));

            Assert.AreEqual(TimeSpan.FromMinutes(2), queue2.PollInterval);
            Assert.IsFalse(queue2.IsMaster);
            Assert.IsTrue(queue2.IsActive);
            Assert.IsFalse(queue2.IsConcurrent);

            IPollingJobConfiguration queue3 = processorInfo2.Configuration.PollingJobs.First(q => q.ImplementationType == typeof(FakePollingJob3));

            Assert.AreEqual(TimeSpan.FromMinutes(3), queue3.PollInterval);
            Assert.IsFalse(queue3.IsMaster);
            Assert.IsFalse(queue3.IsActive);
            Assert.IsTrue(queue3.IsConcurrent);
        }
Пример #4
0
        /// <inheritdoc />
        public void AddCopy(IPollingJobConfiguration source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            RepositoryExtensions.ValidatePollingJobImplementationType(source.ImplementationType);

            this.queues.Add(source.ImplementationType, new RedisPollingJobConfiguration(source));
        }
        private static void Deserialize(IReadOnlyDictionary <string, string> values, IPollingJobsConfiguration result, string prefix)
        {
            if (!string.IsNullOrEmpty(prefix) && !prefix.EndsWith(".", StringComparison.Ordinal))
            {
                prefix = prefix + ".";
            }

            foreach (KeyValuePair <string, string> pair in values.Where(v => v.Key.StartsWith(prefix, StringComparison.Ordinal) && v.Key.EndsWith(".Type", StringComparison.Ordinal)))
            {
                Type implementationType = RedisConverter.ParseType(pair.Value);

                IPollingJobConfiguration config = result.Add(implementationType);

                RedisTaskProcessorConfigurationRepository.Deserialize(values, config, prefix + implementationType.Name);
            }
        }
Пример #6
0
        public void AddPollingJob()
        {
            ITaskProcessorRuntimeInfo processorInfo = new FakeTaskProcessorRuntimeInfo()
            {
                TaskProcessorId = Guid.NewGuid(),
                Configuration   = new FakeTaskProcessorConfiguration()
            };

            this.Repository.Add(processorInfo);

            processorInfo = this.Repository.GetById(processorInfo.TaskProcessorId);

            IPollingJobConfiguration result = processorInfo.Configuration.PollingJobs.Add(typeof(FakePollingJob));

            Assert.AreEqual(typeof(FakePollingJob), result.ImplementationType);

            result = processorInfo.Configuration.PollingJobs[typeof(FakePollingJob)];

            Assert.AreEqual(typeof(FakePollingJob), result.ImplementationType);
        }
Пример #7
0
        private void InvalidPollingJobInterval(TimeSpan interval)
        {
            FakeTaskProcessorRuntimeInfo processorInfo1 = new FakeTaskProcessorRuntimeInfo()
            {
                TaskProcessorId = Guid.NewGuid(),
                Configuration   = new FakeTaskProcessorConfiguration()
            };

            processorInfo1.Configuration.PollingJobs.Add(new FakePollingJobConfiguration()
            {
                ImplementationType = typeof(FakePollingJob),
                PollInterval       = TimeSpan.FromMinutes(1)
            });

            this.Repository.Add(processorInfo1);

            ITaskProcessorRuntimeInfo processorInfo2 = this.Repository.GetById(processorInfo1.TaskProcessorId);

            IPollingJobConfiguration queue1 = processorInfo2.Configuration.PollingJobs.First(q => q.ImplementationType == typeof(FakePollingJob));

            queue1.PollInterval = interval;
        }
 /// <inheritdoc />
 void IPollingJobsConfiguration.AddCopy(IPollingJobConfiguration source)
 {
     throw new NotSupportedException();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisPollingJobConfiguration"/> class by copying the properties of another instance.
 /// </summary>
 /// <param name="source">The instance whose properties to copy.</param>
 internal RedisPollingJobConfiguration(IPollingJobConfiguration source)
     : base(source)
 {
     this.implementationType = source.ImplementationType;
 }
 public void AddCopy(IPollingJobConfiguration source)
 {
     this.jobs.Add(new FakePollingJobConfiguration(source));
 }