Changeset 779
- Timestamp:
- 11/19/08 16:08:44 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Common/HeuristicLab.Hive.Client.Common.csproj
r768 r779 66 66 <ItemGroup> 67 67 <Compile Include="CommonPlugin.cs" /> 68 <Compile Include="Interfaces\IJob.cs" /> 68 69 <Compile Include="JobBase.cs" /> 69 70 <Compile Include="Logging.cs" /> -
trunk/sources/HeuristicLab.Hive.Client.Common/JobBase.cs
r770 r779 27 27 using System.Xml; 28 28 using HeuristicLab.Core; 29 using HeuristicLab.Hive.Client.Common; 29 30 30 31 namespace HeuristicLab.Hive.Client.Common { 31 32 [Serializable] 32 abstract public class JobBase { 33 abstract public class JobBase : IJob { 34 35 public long JobId { get; set; } 33 36 34 37 private Thread thread = null; -
trunk/sources/HeuristicLab.Hive.Client.Common/TestJob.cs
r770 r779 24 24 using System.Linq; 25 25 using System.Text; 26 using System.Diagnostics; 26 27 27 28 namespace HeuristicLab.Hive.Client.Common { … … 33 34 if (abort == true) { 34 35 Logging.getInstance().Info(this.ToString(), "Job Processing aborted"); 35 //Console.WriteLine("Job Abort Processing");36 Debug.WriteLine("Job Abort Processing"); 36 37 break; 37 38 } 38 39 Logging.getInstance().Info(this.ToString(), "Iteration " + x + " done"); 39 //Console.WriteLine("Iteration " + x + " done");40 Debug.WriteLine("Iteration " + x + " done"); 40 41 } 41 42 OnJobStopped(); -
trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs
r770 r779 58 58 } 59 59 60 public void Start() { 61 Logging.getInstance().Info(this.ToString(), "Info Message"); 62 //Logging.getInstance().Error(this.ToString(), "Error Message"); 63 //Logging.getInstance().Error(this.ToString(), "Exception Message", new Exception("Exception")); 64 60 public void Start() { 65 61 Heartbeat beat = new Heartbeat(); 66 62 beat.Interval = 5000; … … 68 64 69 65 MessageQueue queue = MessageQueue.GetInstance(); 70 71 TestJob job = new TestJob(); 72 73 AppDomain appDomain = CreateNewAppDomain(false); 74 75 //This is a HACK. remove static directory ASAP 76 //Executor engine = (Executor)appDomain.CreateInstanceFromAndUnwrap(@"C:\Program Files\HeuristicLab 3.0\plugins\HeuristicLab.Hive.Client.ExecutionEngine-3.2.dll", "HeuristicLab.Hive.Client.ExecutionEngine.Executor"); 77 78 Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 79 //ExecutionEngine.Executor engine = new ExecutionEngine.Executor(); 80 engine.Job = job; 81 engine.JobId = 1L; 82 engine.Queue = queue; 83 engine.Start(); 84 engines.Add(engine.JobId, engine); 85 86 Thread.Sleep(15000); 87 engine.RequestSnapshot(); 66 queue.AddMessage(MessageContainer.MessageType.FetchJob); 88 67 while (true) { 89 68 MessageContainer container = queue.GetMessage(); 69 Debug.WriteLine("Main loop received this message: " + container.Message.ToString()); 90 70 Logging.getInstance().Info(this.ToString(), container.Message.ToString()); 91 71 DetermineAction(container); 92 93 94 72 } 95 }96 97 Assembly appDomain_TypeResolve(object sender, ResolveEventArgs args) {98 throw new NotImplementedException();99 73 } 100 74 … … 116 90 117 91 private void DetermineAction(MessageContainer container) { 118 if(container.Message == MessageContainer.MessageType.AbortJob) 119 engines[container.JobId].Abort(); 120 else if (container.Message == MessageContainer.MessageType.JobAborted) 121 //kill appdomain 122 Console.WriteLine("tmp"); 123 else if (container.Message == MessageContainer.MessageType.RequestSnapshot) 124 engines[container.JobId].RequestSnapshot(); 125 else if (container.Message == MessageContainer.MessageType.SnapshotReady) 126 // must be async! 127 engines[container.JobId].GetSnapshot(); 128 } 92 switch (container.Message) { 93 case MessageContainer.MessageType.AbortJob: 94 engines[container.JobId].Abort(); 95 break; 96 case MessageContainer.MessageType.JobAborted: 97 Debug.WriteLine("-- Job Aborted Message received"); 98 break; 99 100 101 case MessageContainer.MessageType.RequestSnapshot: 102 engines[container.JobId].RequestSnapshot(); 103 break; 104 case MessageContainer.MessageType.SnapshotReady: 105 engines[container.JobId].GetSnapshot(); 106 break; 107 108 109 case MessageContainer.MessageType.FetchJob: 110 IJob job = CreateNewJob(); 111 112 AppDomain appDomain = CreateNewAppDomain(false); 113 appDomains.Add(job.JobId, appDomain); 114 115 Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 116 engine.Job = job; 117 engine.JobId = job.JobId; 118 engine.Queue = MessageQueue.GetInstance(); 119 engine.Start(); 120 engines.Add(engine.JobId, engine); 121 break; 122 123 case MessageContainer.MessageType.FinishedJob: 124 engines[container.JobId].GetFinishedJob(); 125 AppDomain.Unload(appDomains[container.JobId]); 126 appDomains.Remove(container.JobId); 127 engines.Remove(container.JobId); 128 break; 129 130 } 131 } 132 133 /// <summary> 134 /// Simulator Class for new Jobs. will be replaced with fetching Jobs from the Interface 135 /// </summary> 136 /// <returns></returns> 137 private IJob CreateNewJob() { 138 Random random = new Random(); 139 IJob job = new TestJob(); 140 job.JobId = random.Next(); 141 return job; 142 } 129 143 } 130 144 } -
trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/Executor.cs
r771 r779 32 32 public class Executor: MarshalByRefObject { 33 33 public long JobId { get; set; } 34 public TestJob Job { get; set; }34 public IJob Job { get; set; } 35 35 public MessageContainer.MessageType CurrentMessage { get; set; } 36 36 public MessageQueue Queue { get; set; } … … 55 55 } 56 56 57 public XmlNodeGetSnapshot() {57 public String GetSnapshot() { 58 58 //if the job is still running, something went VERY bad. 59 59 if (Job.Running) { … … 63 63 CurrentMessage = MessageContainer.MessageType.NoMessage; 64 64 // Pack the whole job inside an xml document 65 String job = SerializeJobObject(); 66 XmlNode node = Job.GetXmlNode(); 65 String job = SerializeJobObject(); 67 66 // Restart the job 68 67 Job.Start(); 69 68 // Return the Snapshot 70 return node;69 return job; 71 70 } 72 71 } 73 72 74 public XmlNodeGetFinishedJob() {73 public String GetFinishedJob() { 75 74 //Job isn't finished! 76 75 if (Job.Running) { 77 76 return null; 78 77 } else { 79 return Job.GetXmlNode();78 return SerializeJobObject(); 80 79 } 81 80 }
Note: See TracChangeset
for help on using the changeset viewer.