Esempio n. 1
0
 /// <summary>Set the priority of the job, defaulting to NORMAL.</summary>
 /// <param name="jp">new job priority</param>
 public virtual void SetJobPriority(JobPriority jp)
 {
     lock (this)
     {
         base.SetPriority(JobPriority.ValueOf(jp.ToString()));
     }
 }
Esempio n. 2
0
 /// <summary>Create a job status object for a given jobid.</summary>
 /// <param name="jobid">The jobid of the job</param>
 /// <param name="setupProgress">The progress made on the setup</param>
 /// <param name="mapProgress">The progress made on the maps</param>
 /// <param name="reduceProgress">The progress made on the reduces</param>
 /// <param name="cleanupProgress">The progress made on the cleanup</param>
 /// <param name="runState">The current state of the job</param>
 /// <param name="jp">Priority of the job.</param>
 /// <param name="user">userid of the person who submitted the job.</param>
 /// <param name="jobName">user-specified job name.</param>
 /// <param name="queue">job queue name.</param>
 /// <param name="jobFile">job configuration file.</param>
 /// <param name="trackingUrl">link to the web-ui for details of the job.</param>
 /// <param name="isUber">Whether job running in uber mode</param>
 public JobStatus(JobID jobid, float setupProgress, float mapProgress, float reduceProgress
                  , float cleanupProgress, int runState, JobPriority jp, string user, string jobName
                  , string queue, string jobFile, string trackingUrl, bool isUber)
     : base(jobid, setupProgress, mapProgress, reduceProgress, cleanupProgress, GetEnum
                (runState), JobPriority.ValueOf(jp.ToString()), user, jobName, queue, jobFile, trackingUrl
            , isUber)
 {
 }
 /// <summary>Generate an event to record changes in Job priority</summary>
 /// <param name="id">Job Id</param>
 /// <param name="priority">The new priority of the job</param>
 public JobPriorityChangeEvent(JobID id, JobPriority priority)
 {
     datum.jobid    = new Utf8(id.ToString());
     datum.priority = new Utf8(priority.ToString());
 }
Esempio n. 4
0
        public void TriggerJobsWithGroupingAndPriority(string dicomTag, JobPriority jobPriority)
        {
            var grouping = DicomTag.Parse(dicomTag);

            _jobStore.Setup(p => p.Add(It.IsAny <InferenceJob>()));
            var countdownEvent = new CountdownEvent(_instances.Count);

            _cleanupQueue.Setup(p => p.QueueInstance(It.IsAny <string>())).Callback((string path) =>
            {
                countdownEvent.Signal();
            });

            _configuration.AeTitle = _aeTitle;
            _configuration.ProcessorSettings.Add("timeout", "1");
            _configuration.ProcessorSettings.Add("groupBy", grouping.ToString());
            _configuration.ProcessorSettings.Add("priority", jobPriority.ToString());
            _configuration.ProcessorSettings.Add("pipeline-first", "PIPELINE1");
            _configuration.ProcessorSettings.Add("pipeline-second", "PIPELINE2");

            var processor = new AeTitleJobProcessor(_configuration, _notificationService, _loggerFactory.Object, _jobStore.Object, _cleanupQueue.Object, _dicomToolkit.Object, _cancellationTokenSource.Token);

            foreach (var instance in _instances)
            {
                _notificationService.NewInstanceStored(instance);
            }

            countdownEvent.Wait(System.TimeSpan.FromSeconds(60));

            // Verify configuration
            _logger.VerifyLogging($"AE Title AET1 Processor Setting: timeout={AeTitleJobProcessor.DEFAULT_TIMEOUT_SECONDS}s", LogLevel.Information, Times.Once());
            _logger.VerifyLogging($"AE Title AET1 Processor Setting: priority={jobPriority.ToString()}", LogLevel.Information, Times.Once());
            _logger.VerifyLogging($"AE Title AET1 Processor Setting: groupBy={grouping}", LogLevel.Information, Times.Once());
            _logger.VerifyLogging($"Pipeline first=PIPELINE1 added for AE Title {_aeTitle}", LogLevel.Information, Times.Once());
            _logger.VerifyLogging($"Pipeline second=PIPELINE2 added for AE Title {_aeTitle}", LogLevel.Information, Times.Once());

            // Verify notified instances
            switch (dicomTag)
            {
            case "00100020":
                _logger.VerifyLogging($"Instance received and added with key {_patient1}", LogLevel.Debug, Times.Exactly(3));
                _logger.VerifyLogging($"Instance received and added with key {_patient2}", LogLevel.Debug, Times.Exactly(1));
                break;

            case "0020000D":
                _logger.VerifyLogging($"Instance received and added with key {_study1.UID}", LogLevel.Debug, Times.Exactly(2));
                _logger.VerifyLogging($"Instance received and added with key {_study2.UID}", LogLevel.Debug, Times.Exactly(1));
                _logger.VerifyLogging($"Instance received and added with key {_study3.UID}", LogLevel.Debug, Times.Exactly(1));
                break;

            case "0020000E":
                _logger.VerifyLogging($"Instance received and added with key {_series1.UID}", LogLevel.Debug, Times.Exactly(1));
                _logger.VerifyLogging($"Instance received and added with key {_series2.UID}", LogLevel.Debug, Times.Exactly(1));
                _logger.VerifyLogging($"Instance received and added with key {_series3.UID}", LogLevel.Debug, Times.Exactly(1));
                _logger.VerifyLogging($"Instance received and added with key {_series4.UID}", LogLevel.Debug, Times.Exactly(1));
                break;
            }

            // Verify timer events
            switch (dicomTag)
            {
            case "00100020":
                _logger.VerifyLogging($"New collection created for {_patient1}", LogLevel.Debug, Times.Once());
                _logger.VerifyLogging($"New collection created for {_patient2}", LogLevel.Debug, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_patient1}", LogLevel.Information, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_patient2}", LogLevel.Information, Times.Once());
                break;

            case "0020000D":
                _logger.VerifyLogging($"New collection created for {_study1.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLogging($"New collection created for {_study2.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLogging($"New collection created for {_study3.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_study1.UID}", LogLevel.Information, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_study2.UID}", LogLevel.Information, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_study3.UID}", LogLevel.Information, Times.Once());
                break;

            case "0020000E":
                _logger.VerifyLogging($"New collection created for {_series1.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLogging($"New collection created for {_series2.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLogging($"New collection created for {_series3.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLogging($"New collection created for {_series4.UID}", LogLevel.Debug, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_series1.UID}", LogLevel.Information, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_series2.UID}", LogLevel.Information, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_series3.UID}", LogLevel.Information, Times.Once());
                _logger.VerifyLoggingMessageBeginsWith($"Timeout elapsed waiting for {grouping} {_series4.UID}", LogLevel.Information, Times.Once());
                break;
            }

            // Verify jobs generated
            switch (dicomTag)
            {
            case "00100020":
                _logger.VerifyLogging($"Job generated {_aeTitle}-first-{_patient1} for pipeline PIPELINE1", LogLevel.Information, Times.Once());
                _logger.VerifyLogging($"Job generated {_aeTitle}-second-{_patient1} for pipeline PIPELINE2", LogLevel.Information, Times.Once());
                _logger.VerifyLogging($"Job generated {_aeTitle}-first-{_patient2} for pipeline PIPELINE1", LogLevel.Information, Times.Once());
                _logger.VerifyLogging($"Job generated {_aeTitle}-second-{_patient2} for pipeline PIPELINE2", LogLevel.Information, Times.Once());
                break;

            case "0020000D":
                _logger.VerifyLogging($"Job generated {_aeTitle}-first-{_patient1} for pipeline PIPELINE1", LogLevel.Information, Times.Exactly(2));
                _logger.VerifyLogging($"Job generated {_aeTitle}-second-{_patient1} for pipeline PIPELINE2", LogLevel.Information, Times.Exactly(2));
                _logger.VerifyLogging($"Job generated {_aeTitle}-first-{_patient2} for pipeline PIPELINE1", LogLevel.Information, Times.Exactly(1));
                _logger.VerifyLogging($"Job generated {_aeTitle}-second-{_patient2} for pipeline PIPELINE2", LogLevel.Information, Times.Exactly(1));

                break;

            case "0020000E":
                _logger.VerifyLogging($"Job generated {_aeTitle}-first-{_patient1} for pipeline PIPELINE1", LogLevel.Information, Times.Exactly(3));
                _logger.VerifyLogging($"Job generated {_aeTitle}-second-{_patient1} for pipeline PIPELINE2", LogLevel.Information, Times.Exactly(3));
                _logger.VerifyLogging($"Job generated {_aeTitle}-first-{_patient2} for pipeline PIPELINE1", LogLevel.Information, Times.Exactly(1));
                _logger.VerifyLogging($"Job generated {_aeTitle}-second-{_patient2} for pipeline PIPELINE2", LogLevel.Information, Times.Exactly(1));
                break;
            }

            // Verify new pipeline job events
            switch (dicomTag)
            {
            case "00100020":
                _logger.VerifyLoggingMessageBeginsWith($"Submitting a new job", LogLevel.Information, Times.Exactly(4));
                _logger.VerifyLogging($"Uploading 3 instances", LogLevel.Information, Times.Exactly(2));
                _logger.VerifyLogging($"Uploading 1 instances", LogLevel.Information, Times.Exactly(2));
                _logger.VerifyLogging($"Upload to payload completed", LogLevel.Information, Times.Exactly(4));
                _jobStore.Verify(p => p.Add(It.IsAny <InferenceJob>()), Times.Exactly(4));
                break;

            case "0020000D":
                _logger.VerifyLoggingMessageBeginsWith($"Submitting a new job", LogLevel.Information, Times.Exactly(6));
                _logger.VerifyLogging($"Uploading 2 instances", LogLevel.Information, Times.Exactly(2));
                _logger.VerifyLogging($"Uploading 1 instances", LogLevel.Information, Times.Exactly(4));
                _logger.VerifyLogging($"Upload to payload completed", LogLevel.Information, Times.Exactly(6));
                _jobStore.Verify(p => p.Add(It.IsAny <InferenceJob>()), Times.Exactly(6));
                break;

            case "0020000E":
                _logger.VerifyLoggingMessageBeginsWith($"Submitting a new job", LogLevel.Information, Times.Exactly(8));
                _logger.VerifyLogging($"Uploading 1 instances", LogLevel.Information, Times.Exactly(8));
                _logger.VerifyLogging($"Upload to payload completed", LogLevel.Information, Times.Exactly(8));
                _jobStore.Verify(p => p.Add(It.IsAny <InferenceJob>()), Times.Exactly(8));
                break;
            }

            // Verify cleanups
            switch (dicomTag)
            {
            case "00100020":
                _logger.VerifyLoggingMessageBeginsWith($"Notifying Disk Reclaimer to delete", LogLevel.Debug, Times.Exactly(2));
                _logger.VerifyLoggingMessageBeginsWith($"Notified Disk Reclaimer to delete", LogLevel.Information, Times.Exactly(2));
                break;

            case "0020000D":
                _logger.VerifyLoggingMessageBeginsWith($"Notifying Disk Reclaimer to delete", LogLevel.Debug, Times.Exactly(3));
                _logger.VerifyLoggingMessageBeginsWith($"Notified Disk Reclaimer to delete", LogLevel.Information, Times.Exactly(3));
                break;

            case "0020000E":
                _logger.VerifyLoggingMessageBeginsWith($"Notifying Disk Reclaimer to delete", LogLevel.Debug, Times.Exactly(4));
                _logger.VerifyLoggingMessageBeginsWith($"Notified Disk Reclaimer to delete", LogLevel.Information, Times.Exactly(4));
                break;
            }

            foreach (var instance in _instances)
            {
                _cleanupQueue.Verify(p => p.QueueInstance(instance.InstanceStorageFullPath), Times.Once());
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateJobPriorityRequest"/> class.
 /// </summary>
 /// <param name="jobId">The job identifier.</param>
 /// <param name="priority">The new job priority</param>
 public UpdateJobPriorityRequest(Guid jobId, JobPriority priority)
 {
     JobId = jobId;
     AddQueryParam("priority", priority.ToString().ToUpper());
 }
Esempio n. 6
0
        /// <summary>Submit a job to the job server in the background, with a particular priority</summary>
        /// <example>
        /// <code>
        /// </code>
        /// </example>
        public string submitJobInBackground(string callback, byte[] data, JobPriority priority)
        {
            try {
                Connection c = null;

                string jobid = System.Guid.NewGuid().ToString();

                SubmitJob p = new SubmitJob(callback, jobid, data, true, priority);

                Packet result;

                while (true)
                {
                    // Simple round-robin submission for now
                    c = managers[connectionIndex++ % managers.Count];

                    c.sendPacket(p);

                    Log.DebugFormat("Sent background job request to {0}...", c);

                    // We need to get back a JOB_CREATED packet
                    result = c.getNextPacket();

                    // If we get back a JOB_CREATED packet, we can continue,
                    // otherwise try the next job manager
                    if (result.Type == PacketType.JOB_CREATED)
                    {
                        Log.DebugFormat("Created background job {0}, with priority {1}", ((JobCreated)result).jobhandle, priority.ToString());
                        return(((JobCreated)result).jobhandle);
                    }
                }
            } catch (Exception e) {
                Log.DebugFormat("Error submitting job: {0}", e.ToString());
                return(null);
            }
        }
Esempio n. 7
0
 /// <returns>the priority of this job</returns>
 public virtual string GetPriority()
 {
     return(priority.ToString());
 }