public void EnqueueMessagePollForMessageTest() { string queueName = Guid.NewGuid().ToString(); KMeansJobData message = new KMeansJobData(Guid.NewGuid(), 1, null, 2, 10, DateTime.Now); bool async = false; AzureHelper.EnqueueMessage(queueName, message, async); KMeansJobData foundMessage = null; AzureHelper.ExponentialBackoff(() => AzureHelper.PollForMessage <KMeansJobData>(queueName, msg => { foundMessage = msg; return(true); }), firstDelayMilliseconds: 100, backoffFactor: 2, maxDelay: 1000, retryLimit: 5 ); Assert.AreNotEqual(null, foundMessage); Assert.AreEqual(message.JobID, foundMessage.JobID); Assert.AreEqual(message.K, foundMessage.K); }
private void InitializeToServer() { // Give ourselves a machine ID this.machineID = Guid.NewGuid().ToString(); // Find our fault domain int faultDomain = RoleEnvironment.IsAvailable ? RoleEnvironment.CurrentRoleInstance.FaultDomain : 1; Trace.TraceInformation("[WorkerRole] Machine ID: {0}, Fault Domain: {1}", machineID, faultDomain); // Announce ourselves to the server AzureHelper.EnqueueMessage(AzureHelper.ServerControlQueue, new ServerControlMessage(machineID, faultDomain)); }
protected void Run_Click(object sender, EventArgs e) { FreezeUI(); ClearIndicators(); Guid jobID = Guid.NewGuid(); Status.Text = string.Format("Running job {0}.", jobID); DownloadLog.NavigateUrl = string.Format("Log.aspx?JobID={0}", jobID); DownloadLog.Enabled = true; Session["jobID"] = jobID; Session["lastLogRefreshTime"] = DateTime.MinValue; Session["allLogs"] = new List <PerformanceLog>(); Uri pointsBlobUri = null; if (PointsFile.HasFile) { CloudBlob pointsBlob = AzureHelper.CreateBlob(jobID.ToString(), AzureHelper.PointsBlob); using (BlobStream stream = pointsBlob.OpenWrite()) { PointsFile.FileContent.CopyTo(stream); } pointsBlobUri = pointsBlob.Uri; } else if (!string.IsNullOrEmpty(PointsBlob.Text)) { CloudBlob pointsBlob = AzureHelper.CreateBlob(jobID.ToString(), AzureHelper.PointsBlob); pointsBlob.CopyFromBlob(AzureHelper.GetBlob(new Uri(PointsBlob.Text))); pointsBlobUri = pointsBlob.Uri; } int nInt = 0, kInt = 0, maxIterationCountInt = 0; int.TryParse(N.Text, out nInt); int.TryParse(K.Text, out kInt); int.TryParse(MaxIterationCount.Text, out maxIterationCountInt); KMeansJobData jobData = new KMeansJobData(jobID, nInt, pointsBlobUri, kInt, maxIterationCountInt, DateTime.Now) { ProgressEmail = ProgressEmail.Text }; AzureHelper.EnqueueMessage(AzureHelper.ServerRequestQueue, jobData); WaitForResults(); }
private bool ProcessNewTask(KMeansTaskData task) { System.Diagnostics.Trace.TraceInformation("[WorkerRole] ProcessNewTask(jobID={1}, taskID={0})", task.TaskID, task.JobID); UpdateBuddyGroup(task); AzureHelper.LogPerformance(() => { // Process the taskData KMeansTaskProcessor taskProcessor = new KMeansTaskProcessor(task); taskProcessor.Run(); // Send the result back taskProcessor.TaskResult.SavePointsProcessedDataByCentroid(); AzureHelper.EnqueueMessage(AzureHelper.WorkerResponseQueue, taskProcessor.TaskResult); }, jobID: task.JobID.ToString(), methodName: "ProcessNewTask", iterationCount: task.Iteration, points: task.Points.ToString(), centroids: task.Centroids.ToString(), machineID: machineID); return(true); }