Changeset 378
- Timestamp:
- 07/10/08 12:19:05 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.CEDMA.Server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Server/RunScheduler.cs
r377 r378 36 36 private JobManager jobManager; 37 37 private const int RELEASE_INTERVAL = 5; 38 private object remoteCommLock = new object(); 39 38 40 public RunScheduler(Database database, JobManager jobManager) { 39 41 this.database = database; … … 47 49 } 48 50 private void ReleaseWaitingRuns() { 49 ICollection<RunEntry> runs = database.GetRuns(ProcessStatus.Waiting); 50 jobManager.Reset(); 51 ICollection<RunEntry> runs; 52 lock(remoteCommLock) { 53 runs = database.GetRuns(ProcessStatus.Waiting); 54 } 51 55 foreach(RunEntry entry in runs) { 52 56 IOperatorGraph opGraph = (IOperatorGraph)DbPersistenceManager.Restore(entry.RawData); 53 54 57 Scope scope = new Scope(); 55 58 AtomicOperation op = new AtomicOperation(opGraph.InitialOperator, scope); 56 WaitHandle wHandle = jobManager.BeginExecuteOperation(scope, op); 59 WaitHandle wHandle; 60 lock(remoteCommLock) { 61 wHandle = jobManager.BeginExecuteOperation(scope, op); 62 database.UpdateRunStatus(entry.Id, ProcessStatus.Active); 63 database.UpdateRunStart(entry.Id, DateTime.Now); 64 } 57 65 58 ThreadPool.QueueUserWorkItem(delegate(object state) { 59 wHandle.WaitOne(); 60 jobManager.EndExecuteOperation(op); 61 entry.Status = ProcessStatus.Finished; 62 database.UpdateRunStatus(entry.Id, entry.Status); 63 database.UpdateRunFinished(entry.Id, DateTime.Now); 64 }); 66 ThreadPool.QueueUserWorkItem(WaitForFinishedRun, new object[] {wHandle, op, entry}); 67 } 68 } 65 69 66 entry.Status = ProcessStatus.Active; 67 database.UpdateRunStatus(entry.Id, entry.Status); 68 database.UpdateRunStart(entry.Id, DateTime.Now); 70 private void WaitForFinishedRun(object state) { 71 object[] param = (object[])state; 72 WaitHandle wHandle = (WaitHandle)param[0]; 73 AtomicOperation op = (AtomicOperation)param[1]; 74 RunEntry entry = (RunEntry)param[2]; 75 wHandle.WaitOne(); 76 wHandle.Close(); 77 lock(remoteCommLock) { 78 jobManager.EndExecuteOperation(op); 79 database.UpdateRunStatus(entry.Id, ProcessStatus.Finished); 80 database.UpdateRunFinished(entry.Id, DateTime.Now); 69 81 } 70 82 } -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs
r375 r378 61 61 private void InitRunScheduler() { 62 62 JobManager jobManager = new JobManager(gridAddress.Text); 63 jobManager.Reset(); 63 64 RunScheduler scheduler = new RunScheduler(database, jobManager); 64 65 ThreadPool.QueueUserWorkItem(delegate(object status) { scheduler.Run(); }); … … 100 101 } 101 102 102 private void statusUpdateTimer_Tick(object sender, EventArgs e) {103 }104 105 103 private void startButton_Click(object sender, EventArgs e) { 106 104 Start(); -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.designer.cs
r375 r378 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container();48 47 this.addressTextBox = new System.Windows.Forms.TextBox(); 49 48 this.externalAddressLabel = new System.Windows.Forms.Label(); 50 49 this.activeAgentsLabel = new System.Windows.Forms.Label(); 51 50 this.activeAgentsTextBox = new System.Windows.Forms.TextBox(); 52 this.statusUpdateTimer = new System.Windows.Forms.Timer(this.components);53 51 this.gridAddressLabel = new System.Windows.Forms.Label(); 54 52 this.gridAddress = new System.Windows.Forms.TextBox(); … … 91 89 this.activeAgentsTextBox.Text = "0"; 92 90 this.activeAgentsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; 93 //94 // statusUpdateTimer95 //96 this.statusUpdateTimer.Enabled = true;97 this.statusUpdateTimer.Interval = 1000;98 this.statusUpdateTimer.Tick += new System.EventHandler(this.statusUpdateTimer_Tick);99 91 // 100 92 // gridAddressLabel … … 149 141 private System.Windows.Forms.Label activeAgentsLabel; 150 142 private System.Windows.Forms.TextBox activeAgentsTextBox; 151 private System.Windows.Forms.Timer statusUpdateTimer;152 143 private System.Windows.Forms.Label gridAddressLabel; 153 144 private System.Windows.Forms.TextBox gridAddress; -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.resx
r352 r378 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="statusUpdateTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">121 <value>17, 17</value>122 </metadata>123 120 </root>
Note: See TracChangeset
for help on using the changeset viewer.