Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/07/09 16:50:07 (15 years ago)
Author:
gkronber
Message:
  • Reimplemented method to read a list of already executed algorithms and configurations from the results DB
  • Fixed a bug in the GridExecuter
  • Added a button in the dispatcher view to speed up configuration of input variables

#712

File:
1 edited

Legend:

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

    r2223 r2258  
    4444
    4545    private TimeSpan StartJobInterval {
    46       get { return TimeSpan.FromMilliseconds(500); }
     46      get { return TimeSpan.FromMilliseconds(3000); }
    4747    }
    4848
     
    5151    }
    5252
    53     private TimeSpan WaitForNewJobsInterval {
    54       get { return TimeSpan.FromSeconds(3); }
    55     }
    56 
    57     public GridExecuter(IDispatcher dispatcher,  IGridServer server, IModelingDatabase databaseService)
     53    public GridExecuter(IDispatcher dispatcher, IGridServer server, IModelingDatabase databaseService)
    5854      : base(dispatcher, databaseService) {
    5955      this.jobManager = new JobManager(server);
     
    6460    protected override void StartJobs() {
    6561      Dictionary<WaitHandle, AsyncGridResult> asyncResults = new Dictionary<WaitHandle, AsyncGridResult>();
     62      // inifinite loop:
     63      // 1. try to dispatch one algo
     64      // 2. when at least one run is dispatched try to get the result
     65      // 3. sleep
    6666      while (true) {
    6767        try {
    68           // start new jobs as long as there are less than MaxActiveJobs
    69           while (asyncResults.Count < MaxActiveJobs) {
    70             Thread.Sleep(StartJobInterval);
     68          // if allowed then try to dispatch another run
     69          if (asyncResults.Count < MaxActiveJobs) {
    7170            // get an execution from the dispatcher and execute in grid via job-manager
    7271            HeuristicLab.Modeling.IAlgorithm algorithm = Dispatcher.GetNextJob();
     
    8584            }
    8685          }
     86          // when there are active runs
    8787          if (asyncResults.Count > 0) {
    8888            WaitHandle[] whArr = asyncResults.Keys.ToArray();
    8989            int readyHandleIndex = WaitAny(whArr, WaitForFinishedJobsTimeout);
     90            // if the wait didn't timeout, a new result is ready
    9091            if (readyHandleIndex != WaitHandle.WaitTimeout) {
     92              // request the finished run and clean up
    9193              WaitHandle readyHandle = whArr[readyHandleIndex];
     94              AsyncGridResult finishedResult = asyncResults[readyHandle];
     95              asyncResults.Remove(readyHandle);
    9296              HeuristicLab.Modeling.IAlgorithm finishedAlgorithm = null;
    93               AsyncGridResult finishedResult = null;
    9497              lock (activeAlgorithms) {
    95                 finishedResult = asyncResults[readyHandle];
    9698                finishedAlgorithm = activeAlgorithms[finishedResult];
    9799                activeAlgorithms.Remove(finishedResult);
    98                 asyncResults.Remove(readyHandle);
    99100              }
    100101              OnChanged();
     
    105106              }
    106107              catch (Exception badEx) {
    107                 HeuristicLab.Tracing.Logger.Error("CEDMA Executer: Exception in job execution thread. " + badEx.Message+Environment.NewLine+badEx.StackTrace);
     108                HeuristicLab.Tracing.Logger.Error("CEDMA Executer: Exception in job execution thread. " + badEx.Message + Environment.NewLine + badEx.StackTrace);
    108109              }
    109110            }
    110           } else {
    111             Thread.Sleep(WaitForNewJobsInterval);
    112111          }
     112          // when there are no active runs then sleep until we try to start a new run (to prevent excessive looping)
     113          Thread.Sleep(StartJobInterval);
    113114        }
    114 
    115115        catch (Exception ex) {
    116116          HeuristicLab.Tracing.Logger.Warn("CEDMA Executer: Exception in job-management thread. " + ex.Message + Environment.NewLine + ex.StackTrace);
    117117        }
    118       }
     118      } // end while(true)
    119119    }
    120120
Note: See TracChangeset for help on using the changeset viewer.