Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/07/10 10:22:27 (14 years ago)
Author:
cneumuel
Message:
  • created HiveClient which shows an overview over all submitted HiveExperiments
  • its possible to download all submitted HiveExperiments including results
  • Experiments are now sent as a whole to the Hive and the Hive-Slaves take care of creating child-jobs (if necessary). The parent job is then paused and will be reactivated when all child-jobs are finished
  • WcfService-Clients are now consistently managed by WcfServicePool which allows to use IDisposable-Pattern and always keeps exactly one proxy-object until all callers disposed them.
  • created ProgressView which is able to lock a View and display progress of an action. It also allows to simulate progress if no progress-information is available so that users don't get too nervous while waiting.
Location:
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.ExecutionEngine/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.ExecutionEngine/3.3/Executor.cs

    r4285 r4368  
    3030using System.IO;
    3131using HeuristicLab.Core;
     32using HeuristicLab.Hive.Contracts.BusinessObjects;
     33using System.Collections.Generic;
     34using System.Linq;
    3235
    3336namespace HeuristicLab.Hive.Slave.ExecutionEngine {
     
    5760    public void Start(byte[] serializedJob) {
    5861      CreationTime = DateTime.Now;
    59       Job = XmlParser.Deserialize<IJob>(new MemoryStream(serializedJob));
     62      Job = DeserializeJobObject(serializedJob);
    6063
    6164      Job.JobStopped += new EventHandler(Job_JobStopped);
    6265      Job.JobFailed += new EventHandler(Job_JobFailed);
    63       Job.Prepare();
    64       Job.Start();
     66      Job.NewChildJob += new EventHandler<EventArgs<IJob>>(Job_NewChildJob);
     67      Job.WaitForChildJobs += new EventHandler(Job_WaitForChildJobs);
     68
     69      if (Job.ExecutionState == Core.ExecutionState.Paused) {
     70        Queue.AddMessage(new MessageContainerWithCallback<SerializedJobList>(MessageContainer.MessageType.GetChildJobs, JobId,
     71          (childjobs) => {
     72            Job.Resume(childjobs.Select(j => DeserializeJobObject(j.SerializedJobData)));
     73          }
     74        ));
     75      } else {
     76        Job.Prepare();
     77        Job.Start();
     78      }
     79    }
     80
     81    void Job_NewChildJob(object sender, EventArgs<IJob> e) {
     82      byte[] jobByteArray = SerializeJobObject(e.Value);
     83
     84      SerializedJob serializedJob = new SerializedJob() {
     85        JobInfo = new JobDto() {
     86          State = JobState.Offline,
     87          CoresNeeded = e.Value.CoresNeeded,
     88          MemoryNeeded = e.Value.MemoryNeeded,
     89          PluginsNeeded = HivePluginInfoDto.FindPluginsNeeded(e.Value.GetType()),
     90        },
     91        SerializedJobData = jobByteArray
     92      };
     93
     94      Queue.AddMessage(new MessageContainerWithJob(MessageContainer.MessageType.AddChildJob, this.JobId, serializedJob));
     95    }
     96
     97    void Job_WaitForChildJobs(object sender, EventArgs e) {
     98      // Pause the job and send it back to the hive. The server will awake it when all child-jobs are finished
     99      byte[] jobByteArray = SerializeJobObject(Job);
     100
     101      SerializedJob serializedJob = new SerializedJob() {
     102        JobInfo = new JobDto() {
     103          Id = JobId,
     104          State = JobState.WaitForChildJobs
     105        },
     106        SerializedJobData = jobByteArray
     107      };
     108
     109      JobIsFinished = true;
     110      Queue.AddMessage(new MessageContainerWithJob(MessageContainer.MessageType.PauseJob, this.JobId, serializedJob));
    65111    }
    66112
     
    101147        CurrentMessage = MessageContainer.MessageType.NoMessage;
    102148        // Pack the whole job inside an xml document
    103         byte[] job = SerializeJobObject();
     149        byte[] job = SerializeJobObject(Job);
    104150        // Restart the job
    105151        // Return the Snapshot
     
    113159        throw new InvalidStateException("Job is still running");
    114160      } else {
    115         byte[] jobArr = SerializeJobObject();
     161        byte[] jobArr = SerializeJobObject(Job);
    116162        return jobArr;
    117163      }
     
    123169    }
    124170
    125     private byte[] SerializeJobObject() {
    126       MemoryStream stream = new MemoryStream();
    127       XmlGenerator.Serialize(Job, stream);
    128       return stream.ToArray();
     171    private byte[] SerializeJobObject(IJob job) {
     172      MemoryStream memStream = new MemoryStream();
     173      XmlGenerator.Serialize(job, memStream);
     174      byte[] jobByteArray = memStream.ToArray();
     175      memStream.Dispose();
     176      return jobByteArray;
     177    }
     178
     179    private IJob DeserializeJobObject(byte[] sjob) {
     180      MemoryStream memStream = new MemoryStream(sjob);
     181      IJob job = XmlParser.Deserialize<IJob>(memStream);
     182      memStream.Dispose();
     183      return job;
    129184    }
    130185
    131186    private void RestoreJobObject(byte[] sjob) {
    132       Job = XmlParser.Deserialize<IJob>(new MemoryStream(sjob));
     187      Job = DeserializeJobObject(sjob);
    133188    }
    134189
  • branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.ExecutionEngine/3.3/HeuristicLab.Hive.Slave.ExecutionEngine-3.3.csproj

    r4296 r4368  
    7676  </PropertyGroup>
    7777  <ItemGroup>
     78    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    7879    <Reference Include="HeuristicLab.Common-3.3">
    7980      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    8081    </Reference>
    81     <Reference Include="HeuristicLab.Core-3.3" >
     82    <Reference Include="HeuristicLab.Core-3.3">
    8283      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
    8384    </Reference>
     85    <Reference Include="HeuristicLab.DataAccess-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    8486    <Reference Include="HeuristicLab.Persistence-3.3">
    8587      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
Note: See TracChangeset for help on using the changeset viewer.