Exemple #1
0
        private void timerTask(object source, ElapsedEventArgs e)
        {
            string lPath    = ConfigurationManager.AppSettings["logPath"];
            string lGroupId = ConfigurationManager.AppSettings["serverName"];
            int    lDay     = int.Parse(ConfigurationManager.AppSettings["day"]);

            _logger.Info("**************************************服务已启动**************************************");
            LogFileUtils.ReadContrast(lPath, lGroupId, lDay);
        }
Exemple #2
0
 private static void Execute(string oldEventLogPath, IMessageBus messageBus, ILogger logger)
 {
     if (Directory.Exists(oldEventLogPath))
     {
         var count = LogFileUtils.ResubmitLogs(new LogFileManager(oldEventLogPath), messageBus);
         logger.Info("Migrated {0} events from old to new event log path.", count);
         messageBus.Publish(new InfoEvent {
             Info = "wat?"
         });
         Directory.Delete(oldEventLogPath, true);
     }
 }
Exemple #3
0
        public void ResubmittedEventsDontChange()
        {
            var hashes = _sourceLogFileManager.Logs.SelectMany(l => l.ReadAll()).Select(e => e.GetHashCode()).ToList();

            Assert.AreEqual(6, hashes.Count);
            LogFileUtils.ResubmitLogs(_sourceLogFileManager, _messageBus);
            foreach (var e in _receivedEvents)
            {
                hashes.Remove(e.GetHashCode());
            }
            Assert.AreEqual(0, hashes.Count);
        }
 private static void Execute(IList <string> paths, IMessageBus messageBus, ILogger logger)
 {
     foreach (var path in paths)
     {
         if (Directory.Exists(path))
         {
             logger.Info("Starting to migrate events from an old to a new event log path.");
             var count = LogFileUtils.ResubmitLogs(new LogFileManager(path), messageBus);
             logger.Info("Migrated {0} events from an old to a new event log path.", count);
             // ReSharper disable once AssignNullToNotNullAttribute
             Directory.Delete(path, true);
         }
     }
 }
Exemple #5
0
        public bool Start(HostControl hostControl)
        {
            /** Timer timer = new Timer();
             * timer.Elapsed += new ElapsedEventHandler(timerTask);
             * timer.Interval = 1000*60*60*24;
             * timer.Start();
             * timer.Enabled = true;
             **/

            string lPath     = ConfigurationManager.AppSettings[Constants.LOG_FOLDER_PATH_KEY];
            string lServerId = ConfigurationManager.AppSettings[Constants.SERVER_ID_KEY];
            int    lDay      = int.Parse(ConfigurationManager.AppSettings[Constants.DAYS_KEY]);

            _logger.Info("**************************************服务已启动**************************************");
            LogFileUtils.ReadContrast(lPath, lServerId, lDay);
            return(true);
        }
Exemple #6
0
        /// <summary>
        /// Executes the specified query.
        /// </summary>
        /// <param name="experiments">The list of logged experiments on which the query will be processed</param>
        /// <param name="OnExpUnitProcessed">Callback function called when an exp unit is processed. Used to update the progress</param>
        /// <param name="resultTracks">Output list of track groups</param>
        /// <param name="reports">Output list of reports</param>
        public void Execute(BindableCollection <LoggedExperimentViewModel> experiments
                            , LoadOptions.PerExperimentalUnitFunction OnExpUnitProcessed, out List <TrackGroup> resultTracks, out List <Report> reports)
        {
            TrackGroup resultTrackGroup = null;

            //initialize the output lists
            resultTracks = new List <TrackGroup>();
            reports      = DataTrackUtilities.FromLoggedVariables(VariablesVM);

            //if the in-group selection function requires a variable not selected for the report
            //we add it too to the list of variables read from the log
            if (GroupsEnabled && InGroupSelectionVariable != null && InGroupSelectionVariable != "" &&
                !IsVariableSelected(InGroupSelectionVariable, InGroupSelectionReportType))
            {
                EnumDescriptionConverter conv = new EnumDescriptionConverter();
                ReportType reportType         = (ReportType)((IValueConverter)conv).ConvertBack(InGroupSelectionReportType, typeof(ReportType), null, CultureInfo.CurrentCulture);

                reports.Add(new Report(InGroupSelectionVariable, reportType, GetVariableProcessFunc(InGroupSelectionVariable)));
            }

            //if we use some sorting function to select only some tracks, we need to add the variable
            // to the list too
            if (LimitTracks && !IsVariableSelected(OrderByVariable, OrderByReportType))
            {
                EnumDescriptionConverter conv = new EnumDescriptionConverter();
                ReportType reportType         = (ReportType)((IValueConverter)conv).ConvertBack(OrderByReportType, typeof(ReportType), null, CultureInfo.CurrentCulture);

                reports.Add(new Report(OrderByVariable, reportType, GetVariableProcessFunc(OrderByVariable)));
            }

            //set the data resampling options
            foreach (Report report in reports)
            {
                report.Resample         = ResampleData;
                report.NumSamples       = ResamplingNumPoints;
                report.TimeOffset       = TimeOffset;
                report.MinEpisodeLength = MinEpisodeLength;
            }

            //traverse the experimental units within each experiment
            foreach (LoggedExperimentViewModel exp in experiments)
            {
                foreach (LoggedExperimentalUnitViewModel expUnit in exp.ExperimentalUnits)
                {
                    //take selection into account? is this exp. unit selected?
                    bool expUnitContainsGroupByForks = expUnit.ContainsForks(GroupByForks);
                    if ((!UseForkSelection || (UseForkSelection && expUnit.IsSelected)) &&
                        expUnitContainsGroupByForks)
                    {
                        resultTrackGroup = null;
                        if (GroupByForks.Count != 0)
                        {
                            resultTrackGroup = GetTrackGroup(resultTracks, expUnit.ForkValues, exp.ExperimentName);
                            if (resultTrackGroup != null)
                            {
                                //the track exists and we are using forks to group results
                                Track trackData = LogFileUtils.LoadTrackData(expUnit, reports);
                                if (trackData != null)
                                {
                                    resultTrackGroup.AddTrackData(trackData);
                                }

                                //It is not the first track in the track group, so we consolidate it asap
                                //to avoid using unnecessary amounts of memory
                                //Consolidate selects a single track in each group using the in-group selection function
                                //-max(avg(inGroupSelectionVariable)) or min(avg(inGroupSelectionVariable))
                                //and also names groups depending on the number of tracks in the group
                                resultTrackGroup.Consolidate(InGroupSelectionFunction, InGroupSelectionVariable
                                                             , InGroupSelectionReportType, GroupByForks);
                            }
                        }
                        if (resultTrackGroup == null && expUnitContainsGroupByForks) //New track group
                        {
                            //No groups (each experimental unit is a track) or the track doesn't exist
                            //Either way, we create a new track
                            TrackGroup newResultTrackGroup = new TrackGroup(exp.ExperimentName);

                            if (GroupByForks.Count == 0)
                            {
                                newResultTrackGroup.ForkValues = expUnit.ForkValues;
                            }
                            else
                            {
                                foreach (string forkName in GroupByForks)
                                {
                                    //an experimental unit may not have a fork used to group
                                    if (expUnit.ForkValues.ContainsKey(forkName))
                                    {
                                        newResultTrackGroup.ForkValues[forkName] = expUnit.ForkValues[forkName];
                                    }
                                    else if (forkName == ReportsWindowViewModel.GroupByExperimentId)
                                    {
                                        newResultTrackGroup.ForkValues[forkName] = exp.ExperimentName;
                                    }
                                }
                            }

                            //load data from the log file
                            Track trackData = LogFileUtils.LoadTrackData(expUnit, reports);

                            if (trackData != null)
                            {
                                //for now, we just ignore failed experiments. Maybe we could do something more sophisticated
                                //for example, allow to choose only those parameter variations that lead to failed experiments
                                if (trackData.HasData)
                                {
                                    newResultTrackGroup.AddTrackData(trackData);
                                }

                                //we only consider those tracks with data loaded
                                if (newResultTrackGroup.HasData)
                                {
                                    resultTracks.Add(newResultTrackGroup);
                                }
                            }
                        }
                        //Limit the number of tracks asap
                        //if we are using limitTo/orderBy, we have to select the best tracks/groups according to the given criteria
                        if (LimitTracks)
                        {
                            if (resultTracks.Count > MaxNumTracks)
                            {
                                bool asc       = (OrderByFunction == FunctionMin) || (OrderByFunction == FunctionAscBeauty);
                                bool useBeauty = (OrderByFunction == FunctionDscBeauty) || (OrderByFunction == FunctionAscBeauty);
                                resultTracks.Sort(new TrackGroupComparer(asc, useBeauty, OrderByVariable, OrderByReportType));
                                resultTracks.RemoveRange(MaxNumTracks, resultTracks.Count - MaxNumTracks);
                            }
                        }
                    }
                    OnExpUnitProcessed?.Invoke(expUnit.Model);
                }
            }
        }
Exemple #7
0
        public void AllResubmittedEventsArrive()
        {
            var count = LogFileUtils.ResubmitLogs(_sourceLogFileManager, _messageBus);

            Assert.AreEqual(6, count);
        }