Exemple #1
0
        public WebsocketManager(ILogDatabase log, IJobDatabase jobDatabase, IJobControl jobControl)
        {
            _serSettings = new Newtonsoft.Json.JsonSerializerSettings();
            _serSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
            _serSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();

            if (log != null)
            {
                log.NewLogEntry += (e, foreignId) =>
                                   Send(new ServerEvent()
                {
                    LogEntry = e
                });
            }

            if (jobDatabase != null)
            {
                jobDatabase.OnNewJobs += (jobs) =>
                                         Send(new ServerEvent()
                {
                    NewJobs = jobs
                });
            }

            if (jobControl != null)
            {
                jobControl.OnNewCurrentStatus += (status) =>
                                                 Send(new ServerEvent()
                {
                    NewCurrentStatus = status
                });
            }
        }
Exemple #2
0
 public void CheckStatus(IJobDatabase database)
 {
     for (int i = 0; i < criteria.Count;)
     {
         if (database.Jobs.Where(j => j.ID == criteria[i].Item1).Select(j => j.Status).First() >= criteria[i].Item2)
         {
             criteria.RemoveAt(i);
         }
         else
         {
             i++;
         }
     }
 }
Exemple #3
0
        public void Schedule(IJobDatabase database)
        {
            var node = database.Nodes.First();

            // Schedule all new system jobs
            foreach (var jr in database.Jobs.Where(j => j.Priority >= JobPriority.System && j.Status == JobStatus.WaitingToRun).OrderBy(j => j.SubmitTime))
            {
                database.StartJob(jr.ID, node.ID);
            }

            int runningCount = database.Jobs.Count(j => j.Status >= JobStatus.Running || j.Status < Int32.MaxValue);

            if (runningCount < 2)
            {
                // Schedule some number of privileged jobs
                foreach (var jr in database.Jobs.Where(j => j.Priority == JobPriority.Privileged && j.Status == JobStatus.WaitingToRun).OrderBy(j => j.SubmitTime))
                {
                    database.StartJob(jr.ID, node.ID);
                    if (++runningCount > 2)
                    {
                        break;
                    }
                }
                if (runningCount < 2)
                {
                    int privilegedCount = database.Jobs.Count(j => j.Priority == JobPriority.Privileged || j.Priority == JobPriority.SystemPrivileged);
                    if (privilegedCount == 0)
                    {
                        // Schedule some number of privileged jobs
                        foreach (var jr in database.Jobs.Where(j => j.Priority == JobPriority.Regular && j.Status == JobStatus.WaitingToRun).OrderBy(j => j.SubmitTime))
                        {
                            database.StartJob(jr.ID, node.ID);
                            if (++runningCount > 2)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        public NodeJobManager(int nodeID, IJobDatabase database, IScheduler scheduler)
        {
            this.nodeID    = nodeID;
            this.database  = database;
            this.scheduler = scheduler;

            if (nodeID >= 0)
            {
                database.JobStarted.ObserveOn(interleaver).Subscribe(jr => OnJobStarted(jr));
            }
            database.JobStatusChanged.ObserveOn(interleaver).Subscribe(jr => OnJobStatusChanged(jr));

            jobStarted.ObserveOn(interleaver).Subscribe(r => OnJobStarted(r));
            statusChanged.ObserveOn(interleaver).Subscribe(r => OnJobStatusChanged(r));
            waitRequested.ObserveOn(interleaver).Subscribe(r => OnWaitRequested(r));
            ioRequested.ObserveOn(interleaver).Subscribe(r => OnIORequested(r));
            ioCompleted.ObserveOn(interleaver).Subscribe(r => OnIOCompleted(r));
            externalWaitRequested.ObserveOn(interleaver).Subscribe(r => OnExternalWaitRequested(r));
            if (nodeID >= 0)
            {
                scheduleRequested.ObserveOn(interleaver).Subscribe(dummy => scheduler.Schedule(database));
            }
        }
Exemple #5
0
 private Job(IJobRecord record, IJobDatabase database, bool needDispose)
 {
     this.record   = record;
     this.database = database;
 }
Exemple #6
0
 public Job(IJobRecord record, IJobDatabase database) : this(record, database, true)
 {
 }
Exemple #7
0
 public jobsController(IFMSBackend backend)
 {
     _db      = backend.JobDatabase();
     _control = backend.JobControl();
 }