Ejemplo n.º 1
0
        public JobInfo StartNew(JobSpecification spec)
        {
            var info = new JobInfo(spec);

            info = this._jobs.GetOrAdd(info.Id, id => info);

            //Try create a simulator to see if the spec contains any errors, to report them in the creating thread
            spec.CreateSimulator();

            var batchSize = (int)Math.Floor(info.Specification.VisitorCount / (double)this.Threads);

            for (var i = 0; i < this.Threads; i++)
            {
                var count = i == this.Threads - 1 ? info.Specification.VisitorCount - i * batchSize : batchSize;

                if (count > 0)
                {
                    var segment = new JobSegment(info)
                    {
                        TargetVisitors = count
                    };
                    info.Segments.Add(segment);

                    this.StartJob(info, segment);

                    if (i == 0)
                    {
                        // Fix for concurrent creating of Contacts.
                        Thread.Sleep(this.WarmUpInterval);
                    }
                }
            }

            return(info);
        }
Ejemplo n.º 2
0
        public JobInfo StartNew(JobSpecification spec)
        {
            var info = new JobInfo(spec);

            info = _jobs.GetOrAdd(info.Id, id => info);

            //Try create a simulator to see if the spec contains any errors, to report them in the creating thread
            spec.CreateSimulator();

            var segment = new JobSegment(info)
            {
                TargetVisitors = info.Specification.VisitorCount
            };

            info.Segments.Add(segment);

            StartJob(info, segment);

            return(info);
        }
Ejemplo n.º 3
0
 public JobInfo(JobSpecification specification)
 {
     Id            = Guid.NewGuid();
     Specification = specification;
     Segments      = new List <JobSegment>();
 }