Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/10 19:58:01 (13 years ago)
Author:
ascheibe
Message:

#1233

  • more tests for the hive slave
  • implemented a better way to write tests for the slave
  • get rid of MessageTypes for core and executor
  • various improvements in core and executor (better communication, bugfixes,...)
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources

    • Property svn:ignore
      •  

        old new  
         1*.suo
        12HeuristicLab.Hive-3.4.suo
        23TestResults
        3 HeuristicLab.Hive 3.4.suo
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r5106 r5137  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Clients.Hive.Slave;
    2426using HeuristicLab.Common;
    2527using HeuristicLab.Core;
    26 using HeuristicLab.Services.Hive.Common;
    2728using HeuristicLab.Hive;
     29using HeuristicLab.PluginInfrastructure;
    2830using HeuristicLab.Services.Hive.Common.DataTransfer;
    29 using System.Collections.Generic;
    30 using HeuristicLab.Clients.Hive.Slave;
    31 using HeuristicLab.PluginInfrastructure;
    32 
    33                                              
     31
     32
    3433namespace HeuristicLab.Clients.Hive.Salve {
    3534  public class Executor : MarshalByRefObject, IDisposable {
    3635    public Guid JobId { get; set; }
    3736    public IJob Job { get; set; }
    38     public MessageContainer.MessageType CurrentMessage { get; set; }
    39     public Core core { get; set; }   
    40        
     37    private bool wasJobAborted = false;
     38    public Core core { get; set; }
     39
    4140    private Exception currentException;
    4241    public String CurrentException {
     
    4948      }
    5049    }
    51    
     50
    5251    public ExecutionState ExecutionState {
    5352      get {
     
    7372        RegisterJobEvents();
    7473
    75         if (Job.CollectChildJobs) {         
     74        if (Job.CollectChildJobs) {
    7675          IEnumerable<JobData> childjobs = WcfService.Instance.GetChildJobs(JobId);
    7776          Job.Resume(childjobs.Select(j => PersistenceUtil.Deserialize<IJob>(j.Data)));
     
    8281      }
    8382      catch (Exception e) {
    84         this.currentException = e;       
     83        this.currentException = e;
    8584      }
    8685    }
     
    9190      }
    9291      catch (Exception e) {
    93         this.currentException = e;       
     92        this.currentException = e;
    9493      }
    9594    }
    9695
    9796    public void Abort() {
    98       CurrentMessage = MessageContainer.MessageType.AbortJob;
     97      wasJobAborted = true;
    9998      if ((ExecutionState == ExecutionState.Started) || (ExecutionState == ExecutionState.Paused)) {
    10099        Job.Stop();
     
    105104
    106105    private void RegisterJobEvents() {
    107       //TODO: warum gibt es jobStopped und jobfailed nicht mehr?
    108106      Job.JobStopped += new EventHandler(Job_JobStopped);
    109107      Job.JobFailed += new EventHandler(Job_JobFailed);
     
    123121    private List<Guid> FindPluginsNeeded(IJob obj) {
    124122      List<Guid> guids = new List<Guid>();
    125       foreach(IPluginDescription desc in PluginUtil.GetDeclaringPlugins(obj)) {       
     123      foreach (IPluginDescription desc in PluginUtil.GetDeclaringPlugins(obj)) {
    126124      }
    127125      throw new NotImplementedException("FindPluginsNeeded for Job_NewChildJob");
     
    147145      // Pause the job and send it back to the hive. The server will awake it when all child-jobs are finished
    148146      this.Job.CollectChildJobs = true;
    149      
     147
    150148      JobData jdata = new JobData();
    151149      jdata.Data = PersistenceUtil.Serialize(Job);
    152150      jdata.JobId = this.JobId;
    153      
     151
    154152      core.PauseJob(jdata);
    155153    }
     
    167165
    168166    private void Job_JobStopped(object sender, EventArgs e) {
    169      if (CurrentMessage == MessageContainer.MessageType.AbortJob) {
    170        core.KillAppDomain(JobId);
     167      if (wasJobAborted) {
     168        core.KillAppDomain(JobId);
    171169      } else {
    172170        core.SendFinishedJob(JobId);
     
    176174    public JobData GetFinishedJob() {
    177175      if (Job == null) {
    178         throw new InvalidStateException("Job is null"); 
    179       }             
     176        throw new InvalidStateException("Job is null");
     177      }
    180178
    181179      if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) {
     
    185183
    186184      if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) {
    187         throw new InvalidStateException("Job is still running"); 
     185        throw new InvalidStateException("Job is still running");
    188186      } else {
    189187        JobData jdata = new JobData();
     
    192190        return jdata;
    193191      }
    194     }   
    195    
     192    }
     193
    196194    public Executor() {
    197       // CurrentMessage = MessageContainer.MessageType.NoMessage; [chn] check usage of 'CurrentMessage'
    198195    }
    199196
     
    201198      if (Job != null)
    202199        DeregisterJobEvents();
    203       //Queue = null;
    204200      Job = null;
    205201    }
Note: See TracChangeset for help on using the changeset viewer.