Changeset 768
- Timestamp:
- 11/16/08 16:47:43 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Common/HeuristicLab.Hive.Client.Common.csproj
r742 r768 74 74 </ItemGroup> 75 75 <ItemGroup> 76 <ProjectReference Include="..\HeuristicLab.Core\HeuristicLab.Core.csproj"> 77 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 78 <Name>HeuristicLab.Core</Name> 79 </ProjectReference> 76 80 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 77 81 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
trunk/sources/HeuristicLab.Hive.Client.Common/JobBase.cs
r749 r768 4 4 using System.Text; 5 5 using System.Threading; 6 using System.Xml; 7 using HeuristicLab.Core; 6 8 7 9 namespace HeuristicLab.Hive.Client.Common { 8 10 9 public delegate void Callback();10 11 11 abstract public class JobBase { 12 13 public event Callback JobAborted;14 12 15 13 private Thread thread = null; 16 14 17 15 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; 20 21 21 22 abstract public void Run(); … … 24 25 thread = new Thread(new ThreadStart(Run)); 25 26 thread.Start(); 26 running = true;27 Running = true; 27 28 } 28 29 … … 31 32 } 32 33 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 33 46 public JobBase() { 34 47 } -
trunk/sources/HeuristicLab.Hive.Client.Common/MessageContainer.cs
r739 r768 32 32 public class MessageContainer { 33 33 34 public enum MessageType { FetchJob, AbortJob, RequestSnapshot, FinishedJob};34 public enum MessageType { FetchJob, AbortJob, JobAborted, RequestSnapshot, FinishedJob, NoMessage, SnapshotReady }; 35 35 36 36 public MessageType Message { get; set; } 37 public intJobId { get; set; }37 public long JobId { get; set; } 38 38 39 39 public MessageContainer(MessageType message) { … … 41 41 JobId = 0; 42 42 } 43 public MessageContainer(MessageType message, intjobId) {43 public MessageContainer(MessageType message, long jobId) { 44 44 Message = message; 45 45 JobId = jobId; -
trunk/sources/HeuristicLab.Hive.Client.Common/TestJob.cs
r742 r768 7 7 public class TestJob: JobBase { 8 8 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(); 10 20 } 11 21 } -
trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs
r749 r768 24 24 using System.Linq; 25 25 using System.Text; 26 using HeuristicLab.Hive.Client.ExecutionEngine; 26 27 using HeuristicLab.Hive.Client.Common; 28 using System.Threading; 29 27 30 28 31 namespace HeuristicLab.Hive.Client.Core { 29 32 public class Core { 33 34 Dictionary<long, Executor> engines = new Dictionary<long, Executor>(); 35 30 36 public void Start() { 31 37 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")); 34 40 35 41 Heartbeat beat = new Heartbeat(); 36 beat.Interval = 1000;42 beat.Interval = 5000; 37 43 beat.StartHeartbeat(); 38 ConfigurationManager.GetInstance().Connect(Guid.Empty); 39 TestJob job = new TestJob(); 40 job.Start(); 41 44 42 45 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); 43 55 56 Thread.Sleep(15000); 57 engine.RequestSnapshot(); 44 58 while (true) { 45 59 MessageContainer container = queue.GetMessage(); 46 Console.WriteLine(container.Message.ToString()); 60 Logging.getInstance().Info(this.ToString(), container.Message.ToString()); 61 DetermineAction(container); 62 63 47 64 } 48 65 } 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 } 49 79 } 50 80 } -
trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs
r739 r768 61 61 void heartbeatTimer_Elapsed(object sender, ElapsedEventArgs e) { 62 62 Console.WriteLine("tick"); 63 MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.FetchJob);63 //MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.FetchJob); 64 64 } 65 65 -
trunk/sources/HeuristicLab.Hive.Client.Core/HeuristicLab.Hive.Client.Core.csproj
r742 r768 86 86 <Name>HeuristicLab.Hive.Client.Common</Name> 87 87 </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> 88 92 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 89 93 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/HeuristicLab.Hive.Client.ExecutionEngine.csproj
r749 r768 48 48 </ItemGroup> 49 49 <ItemGroup> 50 <Compile Include="Executor.cs" /> 50 51 <Compile Include="ExecutionEnginePlugin.cs" /> 51 52 <Compile Include="Properties\AssemblyInfo.cs" /> … … 56 57 </ItemGroup> 57 58 <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> 58 63 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 59 64 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
Note: See TracChangeset
for help on using the changeset viewer.