private void ReturnResults() { System.Diagnostics.Trace.TraceInformation("[ServerRole] ReturnResults() JobID={0}", jobData.JobID); KMeansJobResult jobResult = new KMeansJobResult(jobData, Centroids.Uri); jobResult.Points = Points.Uri; AzureHelper.EnqueueMessage(AzureHelper.ServerResponseQueue, jobResult); // TODO: Delete this KMeansJob from the list of jobs in ServerRole }
/// <summary> /// Enqueues M messages into a queue. Each message is an instruction to a worker to process a partition of the k-means data. /// </summary> public void EnqueueTasks(IEnumerable <Worker> workers) { AzureHelper.LogPerformance(() => { int workerNumber = 0; // Loop through the known workers and give them each a chunk of the points. // Note: This loop must execute in the same order every time, otherwise caching will not work -- the workers will get a different workerNumber each time and therefore a different chunk of the points. // We use OrderBy on the PartitionKey to guarantee stable ordering. foreach (Worker worker in workers.OrderBy(worker => worker.PartitionKey)) { KMeansTaskData taskData = new KMeansTaskData(jobData, Guid.NewGuid(), workerNumber++, workers.Count(), Centroids.Uri, DateTime.UtcNow, IterationCount, worker.BuddyGroupID); taskData.Points = Points.Uri; tasks.Add(new KMeansTask(taskData)); AzureHelper.EnqueueMessage(AzureHelper.GetWorkerRequestQueue(worker.PartitionKey), taskData, true); } }, jobData.JobID.ToString(), methodName: "EnqueueTasks", iterationCount: IterationCount, points: Points.Uri.ToString(), centroids: Centroids.Uri.ToString(), machineID: MachineID); }