Ejemplo n.º 1
0
        public void StartWizard(Experiment experimentToBeBenchmarked)
        {
            if (experimentToBeBenchmarked == null)
            {
                throw new InvalidOperationException("Benchmark cannot be run with null experiment.");
            }

            //if webservice is set access webservice, and load benchmarks from there... on OnRetrieveListOfBenchmarksCallCompleted will load load also local benchmarks
            //and discover those that are online contests
            if (m_settings.WebserviceAddress != null)
            {
                m_webService = new WebserviceAccessor(m_settings.WebserviceAddress, true);

                if (m_webService != null)
                {
                    var listOfContestsCallback = new Callback <ListOfContestsResponse>();
                    listOfContestsCallback.CallCompleted += OnRetrieveListOfBenchmarksCallCompleted;
                    m_webService.RetrieveListOfContests(listOfContestsCallback);
                }
                else
                {
                    //load only local benchmarks
                    Benchmarks = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory);
                }
            }
            else
            {
                //load only local benchmarks
                Benchmarks = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory);
            }
            ExperimentToBeBenchmarked = experimentToBeBenchmarked;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when [retrieve list of benchmarks call has been completed].
        /// It adds online contests to the list of Benchmarks.
        /// The contests that has been already downloaded and thus were loaded from local directery
        /// get their link to website updated and are marked as the online contests (so that user can compete in them)
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="responseArgs">The <see cref="TraceLab.Core.WebserviceAccess.CallCompletedEventArgs&lt;TraceLab.Core.WebserviceAccess.ListOfContestsResponse&gt;"/> instance containing the event data.</param>
        private void OnRetrieveListOfBenchmarksCallCompleted(object sender, CallCompletedEventArgs <ListOfContestsResponse> responseArgs)
        {
            //local Benchmarks has been loaded already
            var localBenchmarks     = BenchmarkLoader.LoadBenchmarksInfo(BenchmarksDirectory);;
            var newOnlineBenchmarks = new List <Benchmark>();

            if (responseArgs.Response.Status == ResponseStatus.STATUS_SUCCESS)
            {
                List <Contest> contests = responseArgs.Response.ListOfContests;

                foreach (Contest contest in contests)
                {
                    //assuming the joomla com_jtracelab components is used, determine the link to contest website
                    string joomlaSiteRootUrl = m_settings.WebserviceAddress.Substring(0, m_settings.WebserviceAddress.IndexOf("administrator"));
                    string linkToContest     = JoomlaLinks.GetContestWebpageLink(joomlaSiteRootUrl, contest.ContestIndex);

                    //check if there is already local benchmark with the same guid
                    var benchmark = localBenchmarks.Find((b) => { return(b.BenchmarkInfo.Id.Equals(contest.ContestGUID)); });
                    if (benchmark == null)
                    {
                        //if benchmark has not been found create new benchmark (note, its template component is empty at this moment)
                        var newOnlineBenchmark = new Benchmark(contest, linkToContest, BenchmarksDirectory);
                        newOnlineBenchmarks.Add(newOnlineBenchmark);
                    }
                    else
                    {
                        //if found, only update the link to website
                        benchmark.BenchmarkInfo.WebPageLink = new Uri(linkToContest);
                        //mark it as online contest so that wizard now if it should give option to user to publish results
                        benchmark.IsOnlineContest = true;
                    }
                }

                //all new benchmarks add to total list of benchmarks
                localBenchmarks.AddRange(newOnlineBenchmarks);
            }
            else
            {
                //log the error, and continue
                string error = String.Format(Messages.RetrievingListOfContestsFailedWarning, responseArgs.Response.ErrorMessage);
                NLog.LogManager.GetCurrentClassLogger().Warn(error);
                ErrorMessage = error;
            }

            Benchmarks = localBenchmarks;
        }
Ejemplo n.º 3
0
        internal void OnContestPackageDownloadCompleted(object sender, CallCompletedEventArgs <ContestPackageResponse> responseArgs)
        {
            BenchmarkDownloadCallback callback = sender as BenchmarkDownloadCallback;
            var benchmark = callback.Benchmark;

            if (responseArgs.Response.Status == ResponseStatus.STATUS_SUCCESS)
            {
                //do error handling of file writing and deserialization
                try
                {
                    //save the file to benchmark directory into its filepath
                    File.WriteAllBytes(benchmark.BenchmarkInfo.FilePath, Convert.FromBase64String(responseArgs.Response.ContestPackage));

                    //load benchmark info to update its experiment results unitname
                    string resultsUnitname = BenchmarkLoader.ReadExperimentResultsUnitname(benchmark.BenchmarkInfo.FilePath);
                    if (resultsUnitname != null)
                    {
                        benchmark.BenchmarkInfo.ExperimentResultsUnitname = resultsUnitname;

                        //read the file to determine ComponentTemplate
                        ComponentTemplateMetadata template = BenchmarkLoader.FindTemplateComponentMetadata(benchmark.BenchmarkInfo.FilePath);

                        //set the benchmark
                        if (template != null)
                        {
                            benchmark.ComponentTemplate = template;
                        }
                        else
                        {
                            callback.Progress.Reset();
                            callback.Progress.SetError(true);
                            callback.Progress.CurrentStatus = "Error!";
                            benchmark.ErrorMessage          = Messages.ComponentTemplateNotFoundInContestError;
                        }
                    }
                    else
                    {
                        callback.Progress.Reset();
                        callback.Progress.SetError(true);
                        callback.Progress.CurrentStatus = "Error!";
                        benchmark.ErrorMessage          = Messages.ExperimentResultsUnitnameNotDefined;
                    }
                }
                catch (System.Xml.XmlException)
                {
                    callback.Progress.Reset();
                    callback.Progress.SetError(true);
                    callback.Progress.CurrentStatus = "Error!";
                    benchmark.ErrorMessage          = Messages.ContestFileDeserializationError;
                }
                catch (UnauthorizedAccessException ex)
                {
                    callback.Progress.Reset();
                    callback.Progress.SetError(true);
                    callback.Progress.CurrentStatus = "Error!";
                    benchmark.ErrorMessage          = String.Format(Messages.ContestFileSaveError, ex.Message);
                }
                catch (IOException ex)
                {
                    callback.Progress.Reset();
                    callback.Progress.SetError(true);
                    callback.Progress.CurrentStatus = "Error!";
                    benchmark.ErrorMessage          = String.Format(Messages.ContestFileSaveError, ex.Message);
                }
                catch (System.Security.SecurityException ex)
                {
                    callback.Progress.Reset();
                    callback.Progress.SetError(true);
                    callback.Progress.CurrentStatus = "Error!";
                    benchmark.ErrorMessage          = String.Format(Messages.ContestFileSaveError, ex.Message);
                }
                catch (System.Exception ex)
                {
                    callback.Progress.Reset();
                    callback.Progress.SetError(true);
                    callback.Progress.CurrentStatus = "Error!";
                    benchmark.ErrorMessage          = String.Format(Messages.ContestDownloadError, ex.Message);
                }
            }
            else //response status different than SUCCESS
            {
                //propagate error from the response args
                callback.Progress.Reset();
                callback.Progress.SetError(true);
                callback.Progress.CurrentStatus = "Error!";
                benchmark.ErrorMessage          = responseArgs.Response.ErrorMessage;
            }
        }
Ejemplo n.º 4
0
        public TLExperimentResults LoadBaseline()
        {
            TLExperimentResults baseline = BenchmarkLoader.ReadBaseline(BenchmarkInfo.FilePath);

            return(baseline);
        }