Exemplo n.º 1
0
        public override RFProcessingResult Process()
        {
            var interval = InstanceParams.Interval;
            var result   = new RFProcessingResult();

            foreach (var configFunc in mConfigFunc)
            {
                var config = configFunc(Context);
                if (config.ShouldTrigger(interval))
                {
                    var key = config.TriggerKey;
                    if (config.GraphInstance != null)
                    {
                        key = key.CreateForInstance(config.GraphInstance(interval));
                        Context.SaveEntry(RFDocument.Create(key, new RFGraphProcessorTrigger {
                            TriggerStatus = true, TriggerTime = interval.IntervalEnd
                        }));
                    }
                    else
                    {
                        Context.SaveEntry(RFDocument.Create(key, new RFScheduleTrigger {
                            LastTriggerTime = interval.IntervalEnd
                        }));
                    }
                    result.WorkDone = true;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 protected void LogProcessingStat(RFEngineProcess process, RFProcessInstruction i, Stopwatch sw, DateTimeOffset startTime)
 {
     try
     {
         RFGraphInstance graphInstance = null;
         if (i is RFGraphProcessInstruction)
         {
             return; // these are logged by graph stats
             //graphInstance = (i as RFGraphProcessInstruction).Instance;
         }
         var statsKey      = RFEngineStatsKey.Create(_config.KeyDomain, graphInstance);
         var statsDocument = _context.Catalog.LoadItem(statsKey, 0) as RFDocument;
         if (statsDocument == null)
         {
             statsDocument = RFDocument.Create(statsKey,
                                               new RFEngineStats
             {
                 GraphInstance = graphInstance,
                 Stats         = new Dictionary <string, RFEngineStat>()
             });
         }
         var stat = new RFEngineStat
         {
             ProcessName  = process.Name,
             LastDuration = sw.ElapsedMilliseconds,
             LastRun      = startTime
         };
         var statsItem = statsDocument.GetContent <RFEngineStats>();
         if (!statsItem.Stats.ContainsKey(process.Name))
         {
             statsItem.Stats.Add(process.Name, stat);
         }
         else
         {
             statsItem.Stats[process.Name] = stat;
         }
         statsDocument.UpdateTime = DateTimeOffset.Now;
         _context.Catalog.SaveItem(statsDocument, true); // don't keep versions
     }
     catch (Exception ex)
     {
         Log.Warning(this, "Error saving processing stats for process {0}: {1}", process.Name, ex.Message);
     }
 }
Exemplo n.º 3
0
 protected void LogGraphStat(RFGraphProcessorStatus status)
 {
     try
     {
         var statsKey      = RFGraphStatsKey.Create(KeyDomain, Config.GraphName, GraphInstance);
         var statsDocument = Context.LoadEntry(statsKey) as RFDocument;
         if (statsDocument == null)
         {
             statsDocument = RFDocument.Create(statsKey,
                                               new RFGraphStats
             {
                 GraphInstance = GraphInstance,
                 GraphName     = Config.GraphName,
                 Stats         = new Dictionary <string, RFGraphStat>()
             });
         }
         var stat = new RFGraphStat
         {
             ProcessName   = Config.Name,
             LastRun       = status?.Updated ?? DateTimeOffset.MinValue,
             CalculationOK = status?.CalculationOK ?? false,
             Message       = status?.Message ?? "n/a"
         };
         var statsItem = statsDocument.GetContent <RFGraphStats>();
         if (!statsItem.Stats.ContainsKey(Config.Name))
         {
             statsItem.Stats.Add(Config.Name, stat);
         }
         else
         {
             statsItem.Stats[Config.Name] = stat;
         }
         statsDocument.UpdateTime = DateTimeOffset.Now;
         Context.SaveEntry(statsDocument, false, true); // don't keep versions
     }
     catch (Exception ex)
     {
         Context.SystemLog.Exception(this, ex, "Error saving graph stats for process {0}", Config.Name);
     }
 }
Exemplo n.º 4
0
        public override void Start()
        {
            _context.SystemLog.Debug(this, "Scheduler Service starting");
            while (!IsExiting())
            {
                Thread.Sleep(1000 - DateTime.Now.Millisecond);

                if (IsExiting())
                {
                    return;
                }

                var now      = DateTime.Now;
                var interval = new RFInterval(_lastTrigger, now);
                lock (_sync)
                {
                    foreach (var config in _configs)
                    {
                        if (config.ShouldTrigger(interval))
                        {
                            var key = config.TriggerKey;
                            if (config.GraphInstance != null)
                            {
                                key = key.CreateForInstance(config.GraphInstance(interval));
                                _context.SaveEntry(RFDocument.Create(key, new RFGraphProcessorTrigger {
                                    TriggerStatus = true, TriggerTime = interval.IntervalEnd
                                }));
                            }
                            else
                            {
                                _context.SaveEntry(RFDocument.Create(key, new RFScheduleTrigger {
                                    LastTriggerTime = interval.IntervalEnd
                                }));
                            }
                        }
                    }
                    _lastTrigger = now;
                }
            }
        }
Exemplo n.º 5
0
 public void SaveDocument(RFCatalogKey key, object content, bool raiseEvent = true)
 {
     SaveEntry(RFDocument.Create(key, content), raiseEvent);
 }