Changeset 378


Ignore:
Timestamp:
07/10/08 12:19:05 (14 years ago)
Author:
gkronber
Message:

worked on #189

Location:
trunk/sources/HeuristicLab.CEDMA.Server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Server/RunScheduler.cs

    r377 r378  
    3636    private JobManager jobManager;
    3737    private const int RELEASE_INTERVAL = 5;
     38    private object remoteCommLock = new object();
     39
    3840    public RunScheduler(Database database, JobManager jobManager) {
    3941      this.database = database;
     
    4749    }
    4850    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      }
    5155      foreach(RunEntry entry in runs) {
    5256        IOperatorGraph opGraph = (IOperatorGraph)DbPersistenceManager.Restore(entry.RawData);
    53 
    5457        Scope scope = new Scope();
    5558        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        }
    5765
    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    }
    6569
    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);
    6981      }
    7082    }
  • trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs

    r375 r378  
    6161    private void InitRunScheduler() {
    6262      JobManager jobManager = new JobManager(gridAddress.Text);
     63      jobManager.Reset();
    6364      RunScheduler scheduler = new RunScheduler(database, jobManager);
    6465      ThreadPool.QueueUserWorkItem(delegate(object status) { scheduler.Run(); });
     
    100101    }
    101102
    102     private void statusUpdateTimer_Tick(object sender, EventArgs e) {
    103     }
    104 
    105103    private void startButton_Click(object sender, EventArgs e) {
    106104      Start();
  • trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.designer.cs

    r375 r378  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.components = new System.ComponentModel.Container();
    4847      this.addressTextBox = new System.Windows.Forms.TextBox();
    4948      this.externalAddressLabel = new System.Windows.Forms.Label();
    5049      this.activeAgentsLabel = new System.Windows.Forms.Label();
    5150      this.activeAgentsTextBox = new System.Windows.Forms.TextBox();
    52       this.statusUpdateTimer = new System.Windows.Forms.Timer(this.components);
    5351      this.gridAddressLabel = new System.Windows.Forms.Label();
    5452      this.gridAddress = new System.Windows.Forms.TextBox();
     
    9189      this.activeAgentsTextBox.Text = "0";
    9290      this.activeAgentsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
    93       //
    94       // statusUpdateTimer
    95       //
    96       this.statusUpdateTimer.Enabled = true;
    97       this.statusUpdateTimer.Interval = 1000;
    98       this.statusUpdateTimer.Tick += new System.EventHandler(this.statusUpdateTimer_Tick);
    9991      //
    10092      // gridAddressLabel
     
    149141    private System.Windows.Forms.Label activeAgentsLabel;
    150142    private System.Windows.Forms.TextBox activeAgentsTextBox;
    151     private System.Windows.Forms.Timer statusUpdateTimer;
    152143    private System.Windows.Forms.Label gridAddressLabel;
    153144    private System.Windows.Forms.TextBox gridAddress;
  • trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.resx

    r352 r378  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </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>
    123120</root>
Note: See TracChangeset for help on using the changeset viewer.