// This method never throws - possible exception already handled inside. private bool GenerateMessageSafe() { bool quitLifeCycle = false; try { State = WorkerState.Busy; bool completed = GenerateMessageNetTimed(); WorkerStatistics.Send(); if (completed) { Tracer.Info("First worker {0} reports completion!", WorkerId); State = WorkerState.Completed; quitLifeCycle = true; } } catch (Exception ex) { ex.Trace().Swallow(); ProblemReport problemReport = new ProblemReport(WorkerId, WorkerStage.WorkerStep, ex); problemReport.SendProblemReport(ReportPipe); quitLifeCycle = true; // Worker which caused unhandled exception should quit rather than try to process more messages } return(quitLifeCycle); }
public void StartWithWorkerId(string workerId) { var managerCoreServicesClient = new ManagerCoreServicesClient(); var managerCoreServicesProxy = managerCoreServicesClient.ManagerCoreServicesProxy; ManagerCoreServicesProxy = managerCoreServicesProxy; WorkAssignment = ManagerCoreServicesProxy.GetWorkAssignment(workerId); Init(); State = WorkerState.Starting; try { BeginWork(); } catch (Exception ex) { ProblemReport problemReport = new ProblemReport(WorkerId, WorkerStage.BeginWork, ex); problemReport.SendProblemReport(ReportPipe); ex.Trace().Swallow(); Tracer.Debug("WorkerBase: Worker {0} is cleaning and quitting now", WorkerId); CleanAndQuit(); return; } State = WorkerState.Started; RunWorker(); CleanAndQuit(); }
private void ProcessProblemReport(ProblemReport problemReport) { PipelineStatus.ProblemReports.Add(problemReport); Tracer.Error("Pipeline received problem report from worker {0} {1}: {2}", problemReport.WorkerId, problemReport.WorkerStage.ToString(), problemReport.ExceptionString); PipelineStatus.PipelineState = PipelineState.ProblemReported; }
protected bool CheckPipelineForCompletion() { if (PipelineStatus.GetMostRecentState() != PipelineState.FirstWorkerCompleted) { return(false); } // Debugging //foreach (var pipelineSection in PipelineSections) //{ // if (pipelineSection.DataPipeName != null /*&& pipelineSection.DataPipeName.Count > 0*/) // { // Tracer.Debug("Pipeline section {0} contains {1} messages.", pipelineSection.Name, pipelineSection.DataPipeName.Count); // } //} // When in the Running state we can check all data pipes sequentially and if they all are empty this means we are done if (PipelineSections.Any(pipelineSection => pipelineSection.DataPipeName != null && pipelineSection.DataPipeName.Count > 0)) { return(false); } Tracer.Info("Pipeline detected that there are no more messages in the pipes."); try { if (!Completed()) { Tracer.Info("Custom Pipeline completion handler requested continuation of pipeline operation."); return(false); } } catch (Exception ex) { ex.Trace(); ProblemReport problemReport = new ProblemReport("Pipeline completion", WorkerStage.EndWork, ex); PipelineStatus.ProblemReports.Add(problemReport); } if (PipelineStatus.ProblemReports.Any()) { Tracer.Warning("Pipeline detected job completion WITH ERRORS in {0:0.##} seconds.", _runTime.Elapsed.TotalSeconds); PipelineStatus.PipelineState = PipelineState.ProblemReported; return(true); } Tracer.Warning("Pipeline detected job completion without errors in {0:0.##} seconds.", _runTime.Elapsed.TotalSeconds); PipelineStatus.PipelineState = PipelineState.Completed; return(true); }
public RoleSlotToken GetFreeSlot() { try { PipeMessageEnvelope envelope = HiringPipe.Receive(hiringPipeTimeout); if (envelope != null) { object message = envelope.Body; RoleSlotToken roleSlot = message as RoleSlotToken; Debug.Assert(null != roleSlot); return roleSlot; } // Debugging //if (SectionName == "S1") //{ // throw new EVException().AddDbgMsg("Test"); //} } catch (Exception ex) { MessageQueueException messageQueueException = ex as MessageQueueException; if (messageQueueException != null && (uint)messageQueueException.ErrorCode == 0x80004005) { Tracer.Debug("Cannot find hiring pipe {0}.{1}, so skip processing it.", WorkRequest.HiringPipeName.SectionName, WorkRequest.PipelineId); } else { ProblemReport problemReport = new ProblemReport(WorkRequest.SectionName, WorkerStage.Unknown, ex); using (Pipe reportPipe = new Pipe(WorkRequest.ReportPipeName)) { try { reportPipe.Open(); problemReport.SendProblemReport(reportPipe); } catch (Exception innerEx) { innerEx.Trace().Swallow(); } } } throw; } return null; }
public RoleSlotToken GetFreeSlot() { try { PipeMessageEnvelope envelope = HiringPipe.Receive(hiringPipeTimeout); if (envelope != null) { object message = envelope.Body; RoleSlotToken roleSlot = message as RoleSlotToken; Debug.Assert(null != roleSlot); return(roleSlot); } // Debugging //if (SectionName == "S1") //{ // throw new EVException().AddDbgMsg("Test"); //} } catch (Exception ex) { MessageQueueException messageQueueException = ex as MessageQueueException; if (messageQueueException != null && (uint)messageQueueException.ErrorCode == 0x80004005) { Tracer.Debug("Cannot find hiring pipe {0}.{1}, so skip processing it.", WorkRequest.HiringPipeName.SectionName, WorkRequest.PipelineId); } else { ProblemReport problemReport = new ProblemReport(WorkRequest.SectionName, WorkerStage.Unknown, ex); using (Pipe reportPipe = new Pipe(WorkRequest.ReportPipeName)) { try { reportPipe.Open(); problemReport.SendProblemReport(reportPipe); } catch (Exception innerEx) { innerEx.Trace().Swallow(); } } } throw; } return(null); }
private void CleanAndQuit() { State = WorkerState.CleaningUp; try { EndWork(); } catch (Exception ex) { ProblemReport problemReport = new ProblemReport(WorkerId, WorkerStage.EndWork, ex); problemReport.SendProblemReport(ReportPipe); ex.Trace().Swallow(); } State = WorkerState.Quit; //Tracer.Trace("Worker {0} reports Quit", WorkerId); }
private void ProcessReport(PipeMessageEnvelope envelope) { if (_reportPipeMessageCounter++ == 0) { _timeSinceTheFirstReportReceived.Start(); } object message = envelope.Body; WorkerStateChangedMessage workerStateChangedMessage = message as WorkerStateChangedMessage; if (workerStateChangedMessage != null) { ProcessWorkerStateChangeReports(workerStateChangedMessage); } WorkerStatistics workerStatistics = message as WorkerStatistics; if (workerStatistics != null) { ProcessWorkerStatistics(workerStatistics); } WorkerMessage workerMessage = message as WorkerMessage; if (workerMessage != null) { ProcessWorkerMessage(workerMessage); } ProblemReport problemReport = message as ProblemReport; if (problemReport != null) { ProcessProblemReport(problemReport); } }
// This method never throws - possible exception already handled inside. private bool ProcessMessageSafe() { bool quitLifeCycle = false; try { #if RECEIVE_WAITS PipeMessageEnvelope message = InputDataPipe.Receive(InputDataPipeReceiveTimeout); #else PipeMessageEnvelope message = InputDataPipe.Receive(_zeroWait); #endif if (null != message) { State = WorkerState.Busy; SlowDownPostbacks(message); ProcessMessageNoTrans(message); } else { State = WorkerState.Idle; #if RECEIVE_WAITS WorkerStatistics.RecordIdleTime(InputDataPipeReceiveTimeout); #else Thread.Sleep(InputDataPipeReceiveTimeout); #endif } WorkerStatistics.Send(); } catch (Exception ex) { ex.Trace().Swallow(); ProblemReport problemReport = new ProblemReport(WorkerId, WorkerStage.WorkerStep, ex); problemReport.SendProblemReport(ReportPipe); quitLifeCycle = true; // Worker which caused unhandled exception should quit rather than try to process more messages } return(quitLifeCycle); }
// This method never throws - possible exception already handled inside. private bool ProcessMessageSafe() { bool quitLifeCycle = false; try { #if RECEIVE_WAITS PipeMessageEnvelope message = InputDataPipe.Receive(InputDataPipeReceiveTimeout); #else PipeMessageEnvelope message = InputDataPipe.Receive(_zeroWait); #endif if (null != message) { State = WorkerState.Busy; SlowDownPostbacks(message); ProcessMessageNoTrans(message); } else { State = WorkerState.Idle; #if RECEIVE_WAITS WorkerStatistics.RecordIdleTime(InputDataPipeReceiveTimeout); #else Thread.Sleep(InputDataPipeReceiveTimeout); #endif } WorkerStatistics.Send(); } catch (Exception ex) { ex.Trace().Swallow(); ProblemReport problemReport = new ProblemReport(WorkerId, WorkerStage.WorkerStep, ex); problemReport.SendProblemReport(ReportPipe); quitLifeCycle = true; // Worker which caused unhandled exception should quit rather than try to process more messages } return quitLifeCycle; }
// This method never throws - possible exception already handled inside. private bool GenerateMessageSafe() { bool quitLifeCycle = false; try { State = WorkerState.Busy; bool completed = GenerateMessageNetTimed(); WorkerStatistics.Send(); if (completed) { Tracer.Info("First worker {0} reports completion!", WorkerId); State = WorkerState.Completed; quitLifeCycle = true; } } catch (Exception ex) { ex.Trace().Swallow(); ProblemReport problemReport = new ProblemReport(WorkerId, WorkerStage.WorkerStep, ex); problemReport.SendProblemReport(ReportPipe); quitLifeCycle = true; // Worker which caused unhandled exception should quit rather than try to process more messages } return quitLifeCycle; }