Ejemplo n.º 1
0
        public void ProcessTimeEvent(long timeEventTime)
        {
            if (!specification.IsEnableMetricsReporting) {
                return;
            }

            schedule.CurrentTime = timeEventTime;
            if (!isScheduled) {
                if (executionContext != null) {
                    ScheduleExecutions();
                    isScheduled = true;
                }
                else {
                    return; // not initialized yet, race condition and must wait till initialized
                }
            }

            // fast evaluation against nearest scheduled time
            var nearestTime = schedule.NearestTime;
            if (nearestTime == null || nearestTime > timeEventTime) {
                return;
            }

            // get executions
            IList<MetricExec> executions = new List<MetricExec>(2);
            schedule.Evaluate(executions);
            if (executions.IsEmpty()) {
                return;
            }

            // execute
            if (executionContext == null) {
                log.Debug(".processTimeEvent No execution context");
                return;
            }

            foreach (var execution in executions) {
                metricsExecutor.Execute(execution, executionContext);
            }
        }