Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/10 16:52:55 (13 years ago)
Author:
cneumuel
Message:

#1233

  • made MockJob to execute asynchronously with the option to spinWait
  • added methods to IHiveService
  • implemented methods for Slave handling in HiveService
  • added more tests for server
  • changed db-schema of slaves and slavegroups
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/Mocks/MockJob.cs

    r5104 r5106  
    99using System.Drawing;
    1010using System.Threading;
     11using System.Diagnostics;
    1112
    1213namespace HeuristicLab.Clients.Hive.Slave.Tests {
     
    4546
    4647    private int ms = 1000; //ms
    47     public MockJob(int ms) {
     48    private bool spinWait;
     49    public MockJob(int ms, bool spinWait) {
    4850      this.ms = ms;
     51      this.spinWait = spinWait;
    4952    }
    5053    public MockJob() { }
    5154    [StorableConstructor]
    5255    protected MockJob(bool deserializing) { }
    53     protected MockJob(MockJob original, Cloner cloner) : base(original, cloner) {
     56    protected MockJob(MockJob original, Cloner cloner)
     57      : base(original, cloner) {
    5458      this.ComputeInParallel = original.ComputeInParallel;
    5559      this.IndexInParentOptimizerList = original.IndexInParentOptimizerList;
     
    9296
    9397    public virtual void Start() {
    94       DateTime start = DateTime.Now;
    95       do {
    96         Thread.SpinWait(1000);
    97         this.ExecutionTime = DateTime.Now - start;
    98       } while (ExecutionTime.TotalMilliseconds < ms);
    99       Stop();
    100       OnJobStopped();
     98      new Thread(Run).Start();
     99    }
     100
     101    private void Run() {
     102      try {
     103        if (spinWait) {
     104          Stopwatch watch = new Stopwatch();
     105          watch.Start();
     106          do {
     107            Thread.SpinWait(1000);
     108          } while (watch.ElapsedMilliseconds < ms);
     109          watch.Stop();
     110        } else {
     111          Thread.Sleep(ms);
     112        }
     113        Stop();
     114        OnJobStopped();
     115      }
     116      catch (Exception e) {
     117        this.ExecutionState = Core.ExecutionState.Stopped;
     118        OnJobFailed();
     119      }
    101120    }
    102121
Note: See TracChangeset for help on using the changeset viewer.