Free cookie consent management tool by TermsFeed Policy Generator

Changeset 768


Ignore:
Timestamp:
11/16/08 16:47:43 (16 years ago)
Author:
kgrading
Message:

Implemented the Execution Engine, modified some parts of the JobBase (#358)

Location:
trunk/sources
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Common/HeuristicLab.Hive.Client.Common.csproj

    r742 r768  
    7474  </ItemGroup>
    7575  <ItemGroup>
     76    <ProjectReference Include="..\HeuristicLab.Core\HeuristicLab.Core.csproj">
     77      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
     78      <Name>HeuristicLab.Core</Name>
     79    </ProjectReference>
    7680    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    7781      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
  • trunk/sources/HeuristicLab.Hive.Client.Common/JobBase.cs

    r749 r768  
    44using System.Text;
    55using System.Threading;
     6using System.Xml;
     7using HeuristicLab.Core;
    68
    79namespace HeuristicLab.Hive.Client.Common {
    810
    9   public delegate void Callback();
    10 
    1111  abstract public class JobBase {
    12 
    13     public event Callback JobAborted;
    1412
    1513    private Thread thread = null;
    1614   
    1715    public int Progress { get; set; }
    18     private bool abort = false;
    19     private bool running = false;
     16   
     17    protected bool abort = false;
     18    public bool Running { get; set; }
     19
     20    public event EventHandler JobStopped;
    2021
    2122    abstract public void Run();
     
    2425      thread = new Thread(new ThreadStart(Run));
    2526      thread.Start();
    26       running = true;
     27      Running = true;
    2728    }
    2829
     
    3132    }
    3233
     34    protected void OnJobStopped() {
     35      Console.WriteLine("Job has finished");
     36      Running = false;
     37      if (JobStopped != null)
     38        JobStopped(this, new EventArgs());
     39    }
     40
     41    public XmlNode GetXmlNode() {
     42      XmlDocument doc = PersistenceManager.CreateXmlDocument();
     43      return doc.CreateNode(XmlNodeType.Element, "testnode", null);     
     44    }
     45
    3346    public JobBase() {   
    3447    }
  • trunk/sources/HeuristicLab.Hive.Client.Common/MessageContainer.cs

    r739 r768  
    3232  public class MessageContainer {
    3333
    34     public enum MessageType { FetchJob, AbortJob, RequestSnapshot, FinishedJob };
     34    public enum MessageType { FetchJob, AbortJob, JobAborted, RequestSnapshot, FinishedJob, NoMessage, SnapshotReady };
    3535
    3636    public MessageType Message { get; set; }
    37     public int JobId { get; set; }
     37    public long JobId { get; set; }
    3838
    3939    public MessageContainer(MessageType message) {
     
    4141      JobId = 0;
    4242    }
    43     public MessageContainer(MessageType message, int jobId) {
     43    public MessageContainer(MessageType message, long jobId) {
    4444      Message = message;
    4545      JobId = jobId;
  • trunk/sources/HeuristicLab.Hive.Client.Common/TestJob.cs

    r742 r768  
    77  public class TestJob: JobBase {
    88    public override void Run() {
    9       Console.WriteLine("The Job Thread is running!");
     9      for (int x = 0; x < 10; x++) {
     10        for (int y = 0; y < Int32.MaxValue; y++) ;
     11        if (abort == true) {
     12          Logging.getInstance().Info(this.ToString(), "Job Processing aborted");
     13          //Console.WriteLine("Job Abort Processing");
     14          break;
     15        }
     16        Logging.getInstance().Info(this.ToString(), "Iteration " + x + " done");
     17        //Console.WriteLine("Iteration " + x + " done");
     18      }     
     19      OnJobStopped();
    1020    }
    1121  }
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r749 r768  
    2424using System.Linq;
    2525using System.Text;
     26using HeuristicLab.Hive.Client.ExecutionEngine;
    2627using HeuristicLab.Hive.Client.Common;
     28using System.Threading;
     29
    2730
    2831namespace HeuristicLab.Hive.Client.Core {
    2932  public class Core {
     33
     34    Dictionary<long, Executor> engines = new Dictionary<long, Executor>();
     35   
    3036    public void Start() {
    3137      Logging.getInstance().Info(this.ToString(), "Info Message");
    32       Logging.getInstance().Error(this.ToString(), "Error Message");
    33       Logging.getInstance().Error(this.ToString(), "Exception Message", new Exception("Exception"));     
     38      //Logging.getInstance().Error(this.ToString(), "Error Message");
     39      //Logging.getInstance().Error(this.ToString(), "Exception Message", new Exception("Exception"));     
    3440
    3541      Heartbeat beat = new Heartbeat();
    36       beat.Interval = 1000;
     42      beat.Interval = 5000;
    3743      beat.StartHeartbeat();
    38       ConfigurationManager.GetInstance().Connect(Guid.Empty);
    39       TestJob job = new TestJob();
    40       job.Start();
    41          
     44
    4245      MessageQueue queue = MessageQueue.GetInstance();
     46     
     47      JobBase job = new TestJob();
     48     
     49      ExecutionEngine.Executor engine = new ExecutionEngine.Executor();
     50      engine.Job = job;
     51      engine.JobId = 1L;
     52      engine.Queue = queue;     
     53      engine.Start();
     54      engines.Add(engine.JobId, engine);
    4355
     56      Thread.Sleep(15000);
     57      engine.RequestSnapshot();
    4458      while (true) {
    4559        MessageContainer container = queue.GetMessage();
    46         Console.WriteLine(container.Message.ToString());
     60        Logging.getInstance().Info(this.ToString(), container.Message.ToString());
     61        DetermineAction(container);
     62
     63       
    4764      }
    4865    }
     66
     67    private void DetermineAction(MessageContainer container) {
     68      if(container.Message == MessageContainer.MessageType.AbortJob)
     69        engines[container.JobId].Abort();
     70      else if (container.Message == MessageContainer.MessageType.JobAborted)
     71        //kill appdomain
     72        Console.WriteLine("tmp");
     73      else if (container.Message == MessageContainer.MessageType.RequestSnapshot)
     74        engines[container.JobId].RequestSnapshot();
     75      else if (container.Message == MessageContainer.MessageType.SnapshotReady)
     76        // must be async!
     77        engines[container.JobId].GetSnapshot();
     78    }       
    4979  }
    5080}
  • trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs

    r739 r768  
    6161    void heartbeatTimer_Elapsed(object sender, ElapsedEventArgs e) {
    6262      Console.WriteLine("tick");
    63       MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.FetchJob);
     63      //MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.FetchJob);
    6464    }
    6565
  • trunk/sources/HeuristicLab.Hive.Client.Core/HeuristicLab.Hive.Client.Core.csproj

    r742 r768  
    8686      <Name>HeuristicLab.Hive.Client.Common</Name>
    8787    </ProjectReference>
     88    <ProjectReference Include="..\HeuristicLab.Hive.Client.ExecutionEngine\HeuristicLab.Hive.Client.ExecutionEngine.csproj">
     89      <Project>{1605256A-1CB3-44AB-AAFF-577093EE5789}</Project>
     90      <Name>HeuristicLab.Hive.Client.ExecutionEngine</Name>
     91    </ProjectReference>
    8892    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    8993      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
  • trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/HeuristicLab.Hive.Client.ExecutionEngine.csproj

    r749 r768  
    4848  </ItemGroup>
    4949  <ItemGroup>
     50    <Compile Include="Executor.cs" />
    5051    <Compile Include="ExecutionEnginePlugin.cs" />
    5152    <Compile Include="Properties\AssemblyInfo.cs" />
     
    5657  </ItemGroup>
    5758  <ItemGroup>
     59    <ProjectReference Include="..\HeuristicLab.Hive.Client.Common\HeuristicLab.Hive.Client.Common.csproj">
     60      <Project>{89F4BC52-C174-481E-9BD2-3814171020E8}</Project>
     61      <Name>HeuristicLab.Hive.Client.Common</Name>
     62    </ProjectReference>
    5863    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    5964      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
Note: See TracChangeset for help on using the changeset viewer.