private void ProcessBackgroundWorkItems() { BackgroundWorkItem workItem = null; do { workItem = null; lock (_backgroundWorkItems) { if (_backgroundWorkItems.Count > 0) { workItem = _backgroundWorkItems.Dequeue(); } } if (workItem != null) { try { workItem.finishedCallback(workItem.exception); } catch (Exception ex) { Log.Debug("Exception when processing finished callback for background work item: {0}", ex); } } }while (workItem != null); }
public void doWork(string workKey, BackgroundWorkItem item) { try { using (TransactionScope tx = SCUtility.getTransactionScope()) { bool can_block_pass = true; bool can_hid_pass = true; bool isSuccess = false; SCApplication scApp = SCApplication.getInstance(); //BCFApplication bcfApp, AVEHICLE eqpt, EventType eventType, int seqNum, string req_block_id, string req_hid_secid //Node node = item.Param[0] as Node; BCFApplication bcfApp = item.Param[0] as BCFApplication; AVEHICLE eqpt = item.Param[1] as AVEHICLE; EventType eventType = (EventType)item.Param[2]; int seqNum = (int)item.Param[3]; string req_block_id = item.Param[4] as string; string req_hid_secid = item.Param[5] as string; can_block_pass = scApp.VehicleService.ProcessBlockReqNewNew(bcfApp, eqpt, req_block_id); isSuccess = scApp.VehicleService.replyTranEventReport(bcfApp, eventType, eqpt, seqNum, canBlockPass: can_block_pass, canHIDPass: can_hid_pass); if (isSuccess) { tx.Complete(); } } } catch (Exception ex) { logger.Error(ex, "Exception"); } }
/// <summary> /// Does the work. /// </summary> /// <param name="workKey">The work key.</param> /// <param name="item">The item.</param> public void doWork(string workKey, BackgroundWorkItem item) { //Do something. Service.VehicleService.ReceiveProcessor vehicle_service_receive_proc = item.Param[0] as Service.VehicleService.ReceiveProcessor; AVEHICLE vh = item.Param[1] as AVEHICLE; ProtocolFormat.OHTMessage.ID_134_TRANS_EVENT_REP receiveStr = item.Param[2] as ProtocolFormat.OHTMessage.ID_134_TRANS_EVENT_REP; vehicle_service_receive_proc.doPositionUpdate(vh, receiveStr); }
/// <summary> /// Diagnose the failures of the selected jobs. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void diagnoseToolStripMenuItem_Click(object sender, EventArgs e) { IEnumerable <ClusterJobInformation> todo = this.SelectedJobs(); IEnumerable <DryadLinqJobSummary> jobs = todo.Select(j => j.DiscoverDryadLinqJob(this.clusterStatus, this.Status)).Where(j => j != null); var item = new BackgroundWorkItem <List <DiagnosisLog> >( m => ClusterWork.DiagnoseJobs(jobs, this.clusterStatus.Config, m), DiagnosisResult.ShowDiagnosisResult, "cancel"); this.Queue(item); }
public void doWork(string workKey, BackgroundWorkItem item) { try { byte[] bytes = item.Param[1] as byte[]; WindownApplication app = item.Param[0] as WindownApplication; sc.ProtocolFormat.OHTMessage.VEHICLE_INFO vh_info = sc.BLL.VehicleBLL.Convert2Object_VehicleInfo(bytes); app.ObjCacheManager.PutVehicle(vh_info); } catch (Exception ex) { logger.Error(ex, "Exception"); } }
/// <summary> /// User intends to terminate the selected job. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void terminateToolStripMenuItem_Click(object sender, EventArgs e) { var todo = this.SelectedJobs().ToList(); if (todo.Count() != 1) { this.Status("You have to select exactly one job to terminate", StatusKind.Error); return; } IEnumerable <DryadLinqJobSummary> jobs = todo.Select(j => j.DiscoverDryadLinqJob(this.clusterStatus, this.Status)).Where(j => j != null); var item = new BackgroundWorkItem <bool>( m => ClusterWork.CancelJobs(jobs, this.clusterStatus, m), (c, b) => { }, "cancel"); this.Queue(item); }
/// <summary> /// Query the cluster again for the list of jobs. /// </summary> /// <returns>True if the cluster could be found.</returns> private void RefreshClusterJobList() { if (this.cluster == null) { return; } string clus = this.cluster; if (!string.IsNullOrEmpty(this.SelectedVirtualCluster)) { clus += "/" + this.SelectedVirtualCluster; } this.Status("Querying cluster " + clus, StatusKind.LongOp); try { this.openFromURLToolStripMenuItem.Visible = false; if ( this.Configuration is CacheClusterConfiguration) { this.filteredDataGridView.DataGridView.Columns["VirtualCluster"].Visible = true; } else { this.filteredDataGridView.DataGridView.Columns["VirtualCluster"].Visible = false; } this.clusterStatus = this.Configuration.CreateClusterStatus(); this.toolStripMenuItem_job.Enabled = true; var item = new BackgroundWorkItem <List <ClusterJobInformation> >( m => BuildClusterJobList(m, this.clusterStatus, this.SelectedVirtualCluster), this.JobListRetrieved, "getJobs"); this.Queue(item); } catch (Exception ex) { this.Status("Cannot retrieve information from cluster " + cluster + ": " + ex.Message, StatusKind.Error); Trace.TraceInformation(ex.ToString()); this.comboBox_virtualCluster.Text = ""; } }
/// <summary> /// Query the cluster again for the list of jobs. /// </summary> /// <returns>True if the cluster could be found.</returns> private void RefreshClusterJobList() { if (this.cluster == null) return; string clus = this.cluster; if (!string.IsNullOrEmpty(this.SelectedVirtualCluster)) clus += "/" + this.SelectedVirtualCluster; this.Status("Querying cluster " + clus, StatusKind.LongOp); try { this.openFromURLToolStripMenuItem.Visible = false; if ( this.Configuration is CacheClusterConfiguration) { this.filteredDataGridView.DataGridView.Columns["VirtualCluster"].Visible = true; } else { this.filteredDataGridView.DataGridView.Columns["VirtualCluster"].Visible = false; } this.clusterStatus = this.Configuration.CreateClusterStatus(); this.toolStripMenuItem_job.Enabled = true; var item = new BackgroundWorkItem<List<ClusterJobInformation>>( m => BuildClusterJobList(m, this.clusterStatus, this.SelectedVirtualCluster), this.JobListRetrieved, "getJobs"); this.Queue(item); } catch (Exception ex) { this.Status("Cannot retrieve information from cluster " + cluster + ": " + ex.Message, StatusKind.Error); Trace.TraceInformation(ex.ToString()); this.comboBox_virtualCluster.Text = ""; } }
/// <summary> /// Refresh and redisplay the query plan. /// </summary> public void RefreshQueryPlan() { this.richTextBox_file.Text = ""; var item = new BackgroundWorkItem<DryadJobStaticPlan>( m => JobObjectModel.DryadJobStaticPlan.CreatePlan(this.Job, m), this.PlanComputed, "refresh plan"); this.Queue(item); }
/// <summary> /// Add the log files (and other important files) for all displayed vertices to the cache. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void cacheLogsForAllVerticesToolStripMenuItem_Click(object sender, EventArgs e) { if (this.ShowingStageOrTable != KindOfStageShown.Stage) { this.Status("No vertices are currently displayed", StatusKind.Error); return; } List<ExecutedVertexInstance> vertices = this.stageData.ToList(); var item = new BackgroundWorkItem<bool>( m => CacheAllVertices(this.Job.ClusterConfiguration, this.Job.Summary, vertices, m), (c, b) => { }, "cacheAll"); this.Queue(item); }
/// <summary> /// Find mentions of the current vertex in the JM stdout. /// </summary> private void FindJMStdoutMentions() { LogViewer lv = new LogViewer(true, "JM on " + this.currentVertex); lv.Show(); var item = new BackgroundWorkItem<bool>( m => ScanJMStdout(this.currentVertex, this.Job.ManagerVertex.StdoutFile, lv), (c, b) => { }, "findStdout"); this.Queue(item); }
/// <summary> /// Refresh the job details. /// </summary> private void RefreshJob() { DryadLinqJobInfo job = this.Job; DateTime start = DateTime.Now; var item = new BackgroundWorkItem<TimeSpan>( m => { job.CollectEssentialInformation(m); return DateTime.Now - start; }, this.JobInfoLoaded, "refreshJob"); this.Queue(item); }
/// <summary> /// Display the contents of a cluster resident object. /// </summary> /// <param name="path">Object reference.</param> /// <param name="pattern">Pattern to match for its childen.</param> /// <returns>True if the display succeeded.</returns> private void DisplayContents1(IClusterResidentObject path, string pattern) { var item = new BackgroundWorkItem<FileContents>( m => GetContents(m, path, pattern), this.ShowContents, "Read file"); this.Queue(item); }
/// <summary> /// Does the work. /// </summary> /// <param name="workKey">The work key.</param> /// <param name="item">The item.</param> public void doWork(string workKey, BackgroundWorkItem item) { //Do something. //Console.WriteLine(value); }
/// <summary> /// User intends to terminate the selected job. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void terminateToolStripMenuItem_Click(object sender, EventArgs e) { var todo = this.SelectedJobs().ToList(); if (todo.Count() != 1) { this.Status("You have to select exactly one job to terminate", StatusKind.Error); return; } IEnumerable<DryadLinqJobSummary> jobs = todo.Select(j => j.DiscoverDryadLinqJob(this.clusterStatus, this.Status)).Where(j => j != null); var item = new BackgroundWorkItem<bool>( m => ClusterWork.CancelJobs(jobs, this.clusterStatus, m), (c, b) => { }, "cancel"); this.Queue(item); }
/// <summary> /// Diagnose the failures of the selected jobs. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void diagnoseToolStripMenuItem_Click(object sender, EventArgs e) { IEnumerable<ClusterJobInformation> todo = this.SelectedJobs(); IEnumerable<DryadLinqJobSummary> jobs = todo.Select(j => j.DiscoverDryadLinqJob(this.clusterStatus, this.Status)).Where(j => j != null); var item = new BackgroundWorkItem<List<DiagnosisLog>>( m => ClusterWork.DiagnoseJobs(jobs, this.clusterStatus.Config, m), DiagnosisResult.ShowDiagnosisResult, "cancel"); this.Queue(item); }
/// <summary> /// User selected to terminate the job. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void toolStripMenuItem_terminate_Click(object sender, EventArgs e) { List<DryadLinqJobSummary> job = new List<DryadLinqJobSummary>(); job.Add(this.Job.Summary); ClusterStatus clusterStatus = this.Job.ClusterConfiguration.CreateClusterStatus(); var item = new BackgroundWorkItem<bool>( m => ClusterWork.CancelJobs(job, clusterStatus, m), (c, b) => { }, "cancel"); this.Queue(item); }