public OverseenWorker(WorkerService service, System.Timers.Timer lifeproofTimer) { this.WorkerId = service.Id; this.Service = service; this.LifeproofTimer = lifeproofTimer; this.Assignment = null; }
/// <summary> /// The assignJobs method takes the list of job /// tasks to be done, looks at the number of /// available workers, and calculates the list /// of tasks each worker has to do. /// </summary> /// <returns>listJobAssignments: a list of workers and their assigned splits</returns> private IList <JobAssignment> assignJobs() { IList <JobAssignment> listJobAssignments = new List <JobAssignment>(); int nWorkers = manager.Count + 1; // Counts himself as well int nJobs = jobList.Count; int[] workerJobs = new int[nWorkers - 1]; for (int i = 0; i < nJobs; i++) { workerJobs[i % (nWorkers - 1)] = 1 + workerJobs[i % (nWorkers - 1)]; } int j = 0; for (int i = 0; i < nWorkers - 1; i++) { JobAssignment jobAssignment; List <split> jobs = new List <split>(); //logger.Log("Worker W" + manager.ListWorkers[i].WorkerId + " will do:"); for (int k = 0; k < workerJobs[i]; k++) { jobs.Add(jobList[j]); //logger.Log("--- { " + jobList[j].from + ", " + jobList[j].to + " }"); j++; } jobAssignment = new JobAssignment(manager.ListWorkers[i].WorkerId, jobs); manager.ListWorkers[i].Assignment = jobAssignment; listJobAssignments.Add(jobAssignment); } return(listJobAssignments); }
/// <summary> /// The assignJobs method takes the list of job /// tasks to be done, looks at the number of /// available workers, and calculates the list /// of tasks each worker has to do. /// </summary> /// <returns>listJobAssignments: a list of workers and their assigned splits</returns> private IList<JobAssignment> assignJobs() { IList<JobAssignment> listJobAssignments = new List<JobAssignment>(); int nWorkers = manager.Count + 1; // Counts himself as well int nJobs = jobList.Count; int[] workerJobs = new int[nWorkers - 1]; for (int i = 0; i < nJobs; i++) { workerJobs[i % (nWorkers - 1)] = 1 + workerJobs[i % (nWorkers - 1)]; } int j = 0; for (int i = 0; i < nWorkers - 1; i++) { JobAssignment jobAssignment; List<split> jobs = new List<split>(); //logger.Log("Worker W" + manager.ListWorkers[i].WorkerId + " will do:"); for (int k = 0; k < workerJobs[i]; k++) { jobs.Add(jobList[j]); //logger.Log("--- { " + jobList[j].from + ", " + jobList[j].to + " }"); j++; } jobAssignment = new JobAssignment(manager.ListWorkers[i].WorkerId, jobs); manager.ListWorkers[i].Assignment = jobAssignment; listJobAssignments.Add(jobAssignment); } return listJobAssignments; }