예제 #1
0
        private void CreateJobs(List <BaseAggConfig> aggConfigs)
        {
            int failed = 0;

            foreach (var config in aggConfigs)
            {
                try
                {
                    JobInfo info = new JobInfo
                    {
                        ConsumerService = AggResultConsumerService.Instance(),
                        DataPool        = DataPoolFactory.GetDataPool(config),
                        Process         = ProcessFactory.GetAggProcess(config.Way)
                    };
                    IJobDetail job = this.CreateNewJob(config.Key.ToString(), info, config.TimingMode);
                    TaskInfo.Add(config.Key, info);
                    AllJobs.Add(config.Key, job);
                }
                catch (Exception e)
                {
                    log.WarnFormat("job create failed,key:{0},error:{1}", config.Key.ToString(), e.Message);
                    failed++;
                    continue;
                }
            }
            log.InfoFormat("create {0} jobs finished,successful:{1},failed:{2}", aggConfigs.Count, aggConfigs.Count - failed, failed);
        }
예제 #2
0
        public void WeekDataPoolTester()
        {
            BaseAggConfig config = CreateCommonConfig(AggType.Week);

            config.TimeRange = new AggTimeRange {
                DataBeginHour = 1, DataEndHour = 2, DateBegin = 1, DateEnd = 1
            };

            DataPoolFactory.Init();
            IDataPool dataPool = DataPoolFactory.GetDataPool(config);

            Assert.IsNotNull(dataPool);

            DateTime   time  = new DateTime(2015, 2, 15);
            AggRawData data  = dataPool.GetAggRawData(time);
            int        count = 0;

            foreach (var tmp in data.Datas)
            {
                count += tmp.Values.Count;
            }
            Console.WriteLine(string.Format("共读取{0}条数据", count));
            Assert.IsTrue(data.TimeTag == "2015W7");
            Assert.IsTrue(data.FactorId == config.FactorId);
            Assert.IsTrue(data.Datas.Count > 0);
            //Assert.IsTrue(data.LastAggDatas != null);
        }
예제 #3
0
        public void MonthDataPoolTester()
        {
            BaseAggConfig config = CreateCommonConfig(AggType.Month);

            config.TimeRange = new AggTimeRange {
                DataBeginHour = 1, DataEndHour = 3, DateBegin = 1, DateEnd = 1
            };

            DataPoolFactory.Init();
            IDataPool dataPool = DataPoolFactory.GetDataPool(config);

            Assert.IsNotNull(dataPool);

            DateTime  time = new DateTime(2015, 2, 15);
            Stopwatch sw   = new Stopwatch();

            sw.Start();
            AggRawData data = dataPool.GetAggRawData(time);

            sw.Stop();
            Console.WriteLine(string.Format("MonthDataPoolTester 耗时:{0}ms", sw.ElapsedMilliseconds));
            int count = 0;

            foreach (var tmp in data.Datas)
            {
                count += tmp.Values.Count;
            }
            Console.WriteLine(string.Format("共读取{0}条数据", count));
            Assert.IsTrue(data.TimeTag == "201502");
            Assert.IsTrue(data.FactorId == config.FactorId);
            Assert.IsTrue(data.Datas.Count > 0);
            //Assert.IsTrue(data.LastAggDatas != null);
        }
예제 #4
0
        public void CreateDataPoolTester()
        {
            BaseAggConfig config = CreateCommonConfig(AggType.Day);

            config.TimeRange = new AggTimeRange {
                DataBeginHour = 1, DataEndHour = 2, DateBegin = 0, DateEnd = 0
            };
            DataPoolFactory.Init();
            IDataPool dataPool = DataPoolFactory.GetDataPool(config);

            Assert.IsNotNull(dataPool);

            config   = CreateCommonConfig(AggType.Week);
            dataPool = DataPoolFactory.GetDataPool(config);
            Assert.IsNotNull(dataPool);

            config   = CreateCommonConfig(AggType.Month);
            dataPool = DataPoolFactory.GetDataPool(config);
            Assert.IsNotNull(dataPool);
        }