/// <summary> /// Add a job based on the file name, and arguments /// contained in the DataReceivedEventArgs /// </summary> /// <param name="job"> job to add</param> /// <param name="proxyId">who the job is for</param> public void AddJob(JobRef job, int proxyId) { lock (_jobLock) { //JobRef j = new JobRef(job, id++, proxy_id); // debug job.JobId = _id++; job.ProxyId = proxyId; _manager.Logger.Log("Adding job: " + job); // add the job to the queue _jobQueue.Enqueue(job); // keep track of users and their job(s) // if a user has already submitted a job before if (_jobs.ContainsKey(job.Username)) { // add this job to their list _jobs[job.Username].Add(job); } else { var jl = new List <JobRef> { job }; _jobs.Add(job.Username, jl); } JobCount++; } }
/// <summary> /// Send back the job results to the user /// </summary> /// <param name="data"></param> public void SendJobResults(DataReceivedEventArgs data) { JobRef j = Scheduler.GetJob(int.Parse(data.Args[1])); foreach (Proxy p in Connections) { if (p.Id == j.ProxyId) { p.QueueDataEvent(new NodeManagerComm("results|" + data.Args[2])); } } }
/// <summary> /// Send out the message that a job is available /// </summary> /// <param name="job"></param> public void SendJobOut(JobRef job) { lock (_nodeLock) { var sectionId = 0; var reqNodes = job.RequestedNodes; foreach (var node in ConnectedNodes.Values) { if (reqNodes == 0) { break; } Logger.Log("Enqueing for Node"); job.SectionId = sectionId; job.TotalNodes = ConnectedNodes.Values.Count; node.QueueDataEvent(new NodeManagerComm("file|" + JsonConvert.SerializeObject(job))); node.Busy = true; reqNodes--; sectionId++; } } }