Changeset 816
- Timestamp:
- 11/25/08 23:24:36 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Common/Interfaces/IJob.cs
r779 r816 1 1 using System; 2 using HeuristicLab.Core; 2 3 namespace HeuristicLab.Hive.Client.Common { 3 public interface IJob { 4 System.Xml.XmlNode GetXmlNode(); 4 public interface IJob: IStorable { 5 5 event EventHandler JobStopped; 6 6 long JobId { get; set; } 7 intProgress { get; set; }7 double Progress { get; set; } 8 8 void Run(); 9 9 bool Running { get; set; } -
trunk/sources/HeuristicLab.Hive.Client.Common/JobBase.cs
r779 r816 31 31 namespace HeuristicLab.Hive.Client.Common { 32 32 [Serializable] 33 abstract public class JobBase : IJob { 34 35 public long JobId { get; set; } 33 abstract public class JobBase : StorableBase, IJob { 36 34 37 35 private Thread thread = null; 36 public event EventHandler JobStopped; 38 37 39 public int Progress { get; set; } 38 public long JobId { get; set; } 39 public double Progress { get; set; } 40 public bool Running { get; set; } 40 41 41 protected bool abort = false; 42 public bool Running { get; set; } 43 44 public event EventHandler JobStopped; 42 protected bool abort = false; 45 43 46 44 abstract public void Run(); … … 63 61 } 64 62 65 public XmlNode GetXmlNode() { 66 XmlDocument doc = PersistenceManager.CreateXmlDocument(); 67 return doc.CreateNode(XmlNodeType.Element, "testnode", null); 63 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 64 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 65 66 XmlNode progr = document.CreateNode(XmlNodeType.Element, "Progress", null); 67 progr.InnerText = Convert.ToString(Progress); 68 69 node.AppendChild(progr); 70 return node; 71 } 72 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 73 base.Populate(node, restoredObjects); 74 75 XmlNode progr = node.SelectSingleNode("Progress"); 76 Progress = Convert.ToDouble(progr.InnerText); 68 77 } 69 78 -
trunk/sources/HeuristicLab.Hive.Client.Common/TestJob.cs
r782 r816 25 25 using System.Text; 26 26 using System.Diagnostics; 27 using System.Xml; 27 28 28 29 namespace HeuristicLab.Hive.Client.Common { 29 30 [Serializable] 30 31 public class TestJob: JobBase { 32 33 private int runValue = 0; 34 31 35 public override void Run() { 32 for (int x = 0; x < 10; x++) { 36 int max = 10; 37 while(runValue < max && abort == false) { 33 38 for (int y = 0; y < Int32.MaxValue; y++) ; 34 if (abort == true) { 35 Logging.GetInstance().Info(this.ToString(), "Job Processing aborted"); 36 Debug.WriteLine("Job Abort Processing"); 37 break; 38 } 39 Logging.GetInstance().Info(this.ToString(), "Iteration " + x + " done"); 40 Debug.WriteLine("Iteration " + x + " done"); 39 if (abort == true) { 40 Logging.GetInstance().Info(this.ToString(), "Job Processing aborted"); 41 Debug.WriteLine("Job Abort Processing"); 42 break; 43 } 44 runValue++; 45 Progress = runValue / max; 46 Logging.GetInstance().Info(this.ToString(), "Iteration " + runValue + " done"); 47 Debug.WriteLine("Iteration " + runValue + " done"); 48 Debug.WriteLine("Progress " + Progress*100 + " Percent"); 41 49 } 42 50 OnJobStopped(); 43 51 } 52 public override System.Xml.XmlNode GetXmlNode(string name, System.Xml.XmlDocument document, IDictionary<Guid, HeuristicLab.Core.IStorable> persistedObjects) { 53 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 54 55 XmlNode startValue = document.CreateNode(XmlNodeType.Element, "StartValue", null); 56 startValue.InnerText = Convert.ToString(runValue); 57 58 node.AppendChild(startValue); 59 return node; 60 } 61 62 public override void Populate(XmlNode node, IDictionary<Guid, HeuristicLab.Core.IStorable> restoredObjects) { 63 base.Populate(node, restoredObjects); 64 65 XmlNode startValue = node.SelectSingleNode("StartValue"); 66 runValue = Convert.ToInt32(startValue.InnerText); 67 } 68 69 44 70 } 45 71 } -
trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs
r811 r816 36 36 using HeuristicLab.Hive.Contracts; 37 37 using System.Runtime.Remoting.Messaging; 38 using HeuristicLab.PluginInfrastructure; 38 39 39 40 … … 140 141 private void GetFinishedJob(object jobId) { 141 142 long jId = (long)jobId; 142 Stringobj = engines[jId].GetFinishedJob();143 engines[jId].GetFinishedJob();143 byte[] obj = engines[jId].GetFinishedJob(); 144 144 145 AppDomain.Unload(appDomains[jId]); 145 146 appDomains.Remove(jId); … … 152 153 private void GetSnapshot(object jobId) { 153 154 long jId = (long)jobId; 154 Stringobj = engines[jId].GetSnapshot();155 byte[] obj = engines[jId].GetSnapshot(); 155 156 } 156 157 … … 160 161 IJob job = new TestJob { JobId = e.Result.JobId }; 161 162 162 AppDomain appDomain = CreateNewAppDomain(sandboxed); 163 PluginManager pm = PluginManager.Manager; 164 AppDomain appDomain = pm.CreateAndInitAppDomain("AppDomain"); 165 166 //AppDomain appDomain = CreateNewAppDomain(sandboxed); 163 167 appDomains.Add(job.JobId, appDomain); 164 168 165 169 Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 166 engine.Job = job;167 170 engine.JobId = job.JobId; 168 171 engine.Queue = MessageQueue.GetInstance(); -
trunk/sources/HeuristicLab.Hive.Client.Core/CoreApplication.cs
r735 r816 31 31 32 32 namespace HeuristicLab.Hive.Client.Core { 33 [ClassInfo(Name = "Hive Client Core", Description = "Hive Client Core baseclass", AutoRestart = true)]33 [ClassInfo(Name = "Hive Client", Description = "Hive Client Core baseclass", AutoRestart = true)] 34 34 public class CoreApplication: ApplicationBase { 35 35 public override void Run() { -
trunk/sources/HeuristicLab.Hive.Client.Core/HeuristicLab.Hive.Client.Core.csproj
r790 r816 82 82 </ItemGroup> 83 83 <ItemGroup> 84 <ProjectReference Include="..\HeuristicLab.Core\HeuristicLab.Core.csproj"> 85 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 86 <Name>HeuristicLab.Core</Name> 87 </ProjectReference> 84 88 <ProjectReference Include="..\HeuristicLab.Hive.Client.Common\HeuristicLab.Hive.Client.Common.csproj"> 85 89 <Project>{89F4BC52-C174-481E-9BD2-3814171020E8}</Project> -
trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/Executor.cs
r793 r816 29 29 using System.IO; 30 30 using HeuristicLab.Hive.Contracts; 31 using HeuristicLab.Core; 31 32 32 33 namespace HeuristicLab.Hive.Client.ExecutionEngine { … … 56 57 } 57 58 58 public StringGetSnapshot() {59 public byte[] GetSnapshot() { 59 60 //if the job is still running, something went VERY bad. 60 61 if (Job.Running) { … … 64 65 CurrentMessage = MessageContainer.MessageType.NoMessage; 65 66 // Pack the whole job inside an xml document 66 Stringjob = SerializeJobObject();67 byte[] job = SerializeJobObject(); 67 68 // Restart the job 68 69 Job.Start(); … … 72 73 } 73 74 74 public StringGetFinishedJob() {75 public byte[] GetFinishedJob() { 75 76 //Job isn't finished! 76 77 if (Job.Running) { … … 87 88 } 88 89 89 private String SerializeJobObject() { 90 XmlSerializer serializer = new XmlSerializer(typeof(TestJob)); 91 MemoryStream ms = new MemoryStream(); 92 serializer.Serialize(ms, Job); 93 StreamReader reader = new StreamReader(ms); 94 return reader.ReadToEnd(); 90 private byte[] SerializeJobObject() { 91 return PersistenceManager.SaveToGZip(Job); 95 92 } 96 93 97 private void RestoreJobObject(String serializedJob) { 98 System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); 99 XmlSerializer serializer = new XmlSerializer(typeof(TestJob)); 100 MemoryStream ms = new MemoryStream(); 101 ms.Write(encoding.GetBytes(serializedJob), 0, serializedJob.Length); 102 Job = (TestJob) serializer.Deserialize(ms); 94 private void RestoreJobObject(byte[] sjob) { 95 Job = (IJob)PersistenceManager.RestoreFromGZip(sjob); 103 96 } 104 97 105 98 public Executor() { 106 99 CurrentMessage = MessageContainer.MessageType.NoMessage; 100 Job = new TestJob(); 107 101 } 108 102 } -
trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/HeuristicLab.Hive.Client.ExecutionEngine.csproj
r793 r816 57 57 </ItemGroup> 58 58 <ItemGroup> 59 <ProjectReference Include="..\HeuristicLab.Core\HeuristicLab.Core.csproj"> 60 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 61 <Name>HeuristicLab.Core</Name> 62 </ProjectReference> 59 63 <ProjectReference Include="..\HeuristicLab.Hive.Client.Common\HeuristicLab.Hive.Client.Common.csproj"> 60 64 <Project>{89F4BC52-C174-481E-9BD2-3814171020E8}</Project> -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r811 r816 14 14 List<ClientInfo> clients; 15 15 LinkedList<long> jobs; 16 int nrOfJobs = 3;16 int nrOfJobs = 1; 17 17 18 18 public ClientCommunicator() {
Note: See TracChangeset
for help on using the changeset viewer.