Changeset 6357 for branches/HeuristicLab.Hive-3.4
- Timestamp:
- 06/05/11 22:35:40 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 24 added
- 7 deleted
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.LifecycleClient/app.config
r5593 r6357 33 33 </services> 34 34 <client> 35 <endpoint address="http:// localhost/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="HeuristicLab.Services.Hive.Common.ServiceContracts.IHiveService" name="wsHttpBinding_IHiveService">35 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="HeuristicLab.Services.Hive.Common.ServiceContracts.IHiveService" name="wsHttpBinding_IHiveService"> 36 36 <identity> 37 <certificate encodedValue="AwAAAAEAAAAUAAAA fEKvcVixnJay+q4hCPFuO0JL5TQgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhCNN5wrUcXMmE/9xwp4TYa9MAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMTAxOTEwNTMxNVoXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXwC5TGcAffd/0oAWHtm0s6YXVXEgXgb1AYmBkkkhkKIFJG/e/Z0KSYbJepmSJD44W3oOAVm+x1DAsZxU79HahDYgWCuHLMm1TLpwSmYOQ0kV3pGHWHhiWV7h7oGLds/eqZ2EOpaNGryfEPnrA4VmxY91vV5/2BTeVSWG6F8lRKQIDAQABo0kwRzBFBgNVHQEEPjA8gBAR7kBnMRHO5gzThEqda0wWoRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghCNN5wrUcXMmE/9xwp4TYa9MAkGBSsOAwIdBQADgYEAoPwEG4QTDXhlxERNDfsZmM2IhEpV42ppz1kEah2oYKDa/ElIMVtvqLv6flVtg18ENN/mEJWiHZ3NyP3qr2Pip+sh+/2WBiSbOaukES/CM7OJn9kJCImH7M/xqM8pxqY8IfgM6iBVrVj9uHqj3j2BBck+cYY8fKyh3CFifMIp6ac="/>37 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/> 38 38 </identity> 39 39 </endpoint> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4/SlaveCommListener.cs
r6101 r6357 21 21 22 22 using System; 23 using System.IO; 23 24 using System.ServiceModel; 24 25 using System.Threading; … … 32 33 [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)] 33 34 public class SlaveCommListener : ISlaveCommunicationCallbacks, IDisposable { 34 ISlaveCommunication pipeProxy; 35 DuplexChannelFactory<ISlaveCommunication> pipeFactory; 35 private ISlaveCommunication pipeProxy; 36 private DuplexChannelFactory<ISlaveCommunication> pipeFactory; 37 private StreamWriter debugOutput; 36 38 37 39 public void Open() { 38 40 pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(this, "SlaveCommunicationServiceEndpoint"); 41 debugOutput = new StreamWriter("slave-debug.txt"); 42 debugOutput.AutoFlush = true; 39 43 40 44 while (!ReconnectToSlaveCore()) { … … 49 53 return true; 50 54 } 51 catch (Exception e) {55 catch (Exception) { 52 56 OnMessageLogged("Couldn't connect to Slave Core. Waiting for the Core to start."); 53 57 return false; … … 67 71 pipeFactory.Abort(); 68 72 } 73 debugOutput.Close(); 69 74 } 70 75 71 public void OnStatusChanged(SlaveCore.StatusCommons status) { 72 System.Console.WriteLine("SlaveCommListener: " + status); 76 public void OnStatusChanged(StatusCommons status) { 77 string msg = string.Format( "{0}: {1}", DateTime.Now.ToString("HH:mm:ss"), status); 78 Console.WriteLine(msg); 79 debugOutput.WriteLine(msg); 73 80 } 74 81 75 82 public void OnMessageLogged(string message) { 76 System.Console.WriteLine("SlaveCommListener: " + message); 83 string msg = string.Format("{0}: {1}", DateTime.Now.ToString("HH:mm:ss"), message); 84 Console.WriteLine(msg); 85 debugOutput.WriteLine(msg); 77 86 } 78 87 79 88 public void OnShutdown() { 80 System.Console.WriteLine("SlaveCommListner: Slave quit");89 Console.WriteLine("SlaveCommListner: Slave quit"); 81 90 } 82 91 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4/app.config
r5402 r6357 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 3 <runtime> 4 <gcServer enabled="true" /> 5 </runtime> 6 4 7 <system.serviceModel> 5 8 <bindings> 6 9 <wsHttpBinding> 7 <binding name="wsHttpBinding " closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">8 <readerQuotas maxDepth="32" maxStringContentLength=" 8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>10 <binding name="wsHttpBinding_Hive" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 11 <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/> 9 12 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> 10 13 <security mode="Message"> … … 17 20 18 21 <services> 19 <service name="HeuristicLab.Clients.Hive.Slave .SlaveCommunicationService">20 <endpoint address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.Slave .ServiceContracts.ISlaveCommunication"/>22 <service name="HeuristicLab.Clients.Hive.SlaveCore.SlaveCommunicationService"> 23 <endpoint address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts.ISlaveCommunication"/> 21 24 </service> 22 25 </services> 23 26 24 27 <client> 25 < !--http://localhost:9000/Hive-3.4-->26 <endpoint address="http:// localhost/Hive-3.4/HiveService.svc"28 <endpoint name="SlaveCommunicationServiceEndpoint" address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts.ISlaveCommunication"/> 29 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" 27 30 binding="wsHttpBinding" 28 bindingConfiguration="wsHttpBinding "29 contract="HeuristicLab. Services.Hive.Common.ServiceContracts.IHiveService"31 bindingConfiguration="wsHttpBinding_Hive" 32 contract="HeuristicLab.Clients.Hive.IHiveService" 30 33 name="wsHttpBinding_IHiveService"> 31 <identity> 32 <certificate encodedValue="AwAAAAEAAAAUAAAAiQt8DnyaI8rYHhLNyW62i58+eG8gAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhAFNFYz6Srdmk3PZJ/mka5sMAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMTIwNjE0MTc0M1oXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCueTMWJzOZ1IBacG40aWdr3qDWijEO4VwhgtNr+WNFsRG+qW2rTZZFtaC0U028aj3MX13mr+pzpcPJMes2rr38PuxhN6BhdzgRfyEy/eHk4iKqZztuJSXgNAyfyjhovTchLitT2lilddTRFj2PlLYv+PUu+QhQNTm2iW4UDljS9wIDAQABo0kwRzBFBgNVHQEEPjA8gBBeipmIklE3kPz7i+AdKqAgoRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghAFNFYz6Srdmk3PZJ/mka5sMAkGBSsOAwIdBQADgYEAGnxEaFT8QKKk1DtJ8/+TOBxSo0UkBlNiTY0HKkA3w/2DOPZKybhslm8gqJic8ZPsk5YgEibrdQqB0AnNG983RAlFqgGvsAbQAMXTDJ5GoTgHaxk/T+7a7Sk4xJALUL/vWuPGbA354RVoKA4gV3gJzU+Fj3/fLACf0+D/nR9B5nw=" /> 33 </identity> 34 34 <identity> 35 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ==" /> 36 </identity> 35 37 </endpoint> 36 38 </client> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4/app_ascheibe.config
r6167 r6357 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 3 <runtime> 4 <gcServer enabled="true" /> 5 </runtime> 6 4 7 <system.serviceModel> 5 8 <bindings> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4/app_f005pc.config
r6167 r6357 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 3 <runtime> 4 <gcServer enabled="true" /> 5 </runtime> 6 4 7 <system.serviceModel> 5 8 <bindings> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4/app_services.config
r6167 r6357 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 3 <runtime> 4 <gcServer enabled="true" /> 5 </runtime> 6 4 7 <system.serviceModel> 5 8 <bindings> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/Mocks/MockHiveService.cs
r6006 r6357 87 87 88 88 private static List<Plugin> ReadPluginsFromServerCache() { 89 PluginManager pm = newPluginManager(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PluginCacheServer"));89 var pm = new HeuristicLab.PluginInfrastructure.Manager.PluginManager(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PluginCacheServer")); 90 90 pm.DiscoverAndCheckPlugins(); 91 91 pDescs = pm.Plugins.ToList(); … … 376 376 } 377 377 #endregion 378 379 380 public List<Job> GetJobsByResourceId(Guid resourceId) { 381 throw new NotImplementedException(); 382 } 378 383 } 379 384 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/SlaveTest.cs
r6101 r6357 34 34 [ClassInitialize] 35 35 public static void MyClassInitialize(TestContext testContext) { 36 PluginLoader.pluginAssemblies.Any();37 36 ServiceLocator.Instance = new MockServiceLocator(); 38 37 /* listener = new SlaveCommListener(); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r6263 r6357 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Diagnostics; 25 24 using System.ServiceModel; … … 29 28 using HeuristicLab.Common; 30 29 using HeuristicLab.Core; 30 using HeuristicLab.Hive; 31 31 32 32 … … 37 37 /// </summary> 38 38 public class Core : MarshalByRefObject { 39 public static ILog Log { get; set; }40 public static bool AbortRequested { get; set; }41 42 39 private static HeartbeatManager heartbeatManager; 43 40 public static HeartbeatManager HeartbeatManager { … … 45 42 } 46 43 44 private Semaphore waitShutdownSem = new Semaphore(0, 1); 45 private bool abortRequested; 47 46 private ISlaveCommunication clientCom; 48 47 private ServiceHost slaveComm; 49 private Semaphore waitShutdownSem = new Semaphore(0, 1);50 private Dictionary<Guid, SlaveJob> slaveJobs = new Dictionary<Guid, SlaveJob>();51 48 private WcfService wcfService; 49 private JobManager jobManager; 50 private ConfigManager configManager; 51 private PluginManager pluginManager; 52 52 53 53 public EventLog ServiceEventLog { get; set; } 54 public Dictionary<Guid, SlaveJob> SlaveJobs { get { return slaveJobs; } } 55 56 public Core() { } 54 55 public Core() { 56 var log = new ThreadSafeLog(new Log()); 57 this.pluginManager = new PluginManager(WcfService.Instance, log); 58 this.jobManager = new JobManager(pluginManager, log); 59 log.MessageAdded += new EventHandler<EventArgs<string>>(log_MessageAdded); 60 61 RegisterJobManagerEvents(); 62 63 this.configManager = new ConfigManager(jobManager); 64 ConfigManager.Instance = this.configManager; 65 } 57 66 58 67 /// <summary> … … 60 69 /// </summary> 61 70 public void Start() { 62 AbortRequested = false; 63 64 try { 65 ConfigManager manager = ConfigManager.Instance; 66 manager.Core = this; 71 abortRequested = false; 72 73 try { 74 //manager.Core = this; 67 75 68 76 //start the client communication service (pipe between slave and slave gui) … … 72 80 73 81 // delete all left over job directories 74 PluginCache.Instance.CleanPluginTemp();82 pluginManager.CleanPluginTemp(); 75 83 clientCom.LogMessage("Hive Slave started"); 76 84 … … 110 118 private void DispatchMessageQueue() { 111 119 MessageQueue queue = MessageQueue.GetInstance(); 112 while (! AbortRequested) {120 while (!abortRequested) { 113 121 MessageContainer container = queue.GetMessage(); 114 122 DetermineAction(container); 115 if (! AbortRequested) {116 clientCom.StatusChanged( ConfigManager.Instance.GetStatusForClientConsole());123 if (!abortRequested) { 124 clientCom.StatusChanged(configManager.GetStatusForClientConsole()); 117 125 } 118 126 } … … 150 158 switch (container.Message) { 151 159 case MessageContainer.MessageType.CalculateJob: 152 Task.Factory.StartNew(HandleCalculateJob, container.JobId) 153 .ContinueWith((t) => { 154 // handle exception of task 155 clientCom.LogMessage(t.Exception.ToString()); 156 if (t.Exception.GetType() != typeof(JobNotFoundException)) { 157 wcfService.UpdateJobState(container.JobId, JobState.Waiting, t.Exception.ToString()); 158 SlaveStatusInfo.IncrementJobsFailed(); 159 } 160 }, TaskContinuationOptions.OnlyOnFaulted); 160 CalculateJobAsync(container.JobId); 161 break; 162 case MessageContainer.MessageType.AbortJob: 163 AbortJobAsync(container.JobId); 164 break; 165 case MessageContainer.MessageType.StopJob: 166 StopJobAsync(container.JobId); 167 break; 168 case MessageContainer.MessageType.PauseJob: 169 PauseJobAsync(container.JobId); 170 break; 171 case MessageContainer.MessageType.StopAll: 172 DoStopAll(); 173 break; 174 case MessageContainer.MessageType.PauseAll: 175 DoPauseAll(); 176 break; 177 case MessageContainer.MessageType.AbortAll: 178 DoAbortAll(); 161 179 break; 162 180 case MessageContainer.MessageType.ShutdownSlave: 163 181 ShutdownCore(); 164 182 break; 165 case MessageContainer.MessageType.StopAll:166 DoStopAll();167 break;168 case MessageContainer.MessageType.PauseAll:169 DoPauseAll();170 break;171 case MessageContainer.MessageType.AbortAll:172 DoAbortAll();173 break;174 case MessageContainer.MessageType.AbortJob:175 SlaveStatusInfo.IncrementJobsAborted(); //TODO: move to a sane place176 177 Task.Factory.StartNew(HandleAbortJob, container.JobId)178 .ContinueWith((t) => {179 clientCom.LogMessage(t.Exception.ToString());180 }, TaskContinuationOptions.OnlyOnFaulted);181 break;182 case MessageContainer.MessageType.StopJob:183 Task.Factory.StartNew(HandleStopJob, container.JobId)184 .ContinueWith((t) => {185 clientCom.LogMessage(t.Exception.ToString());186 }, TaskContinuationOptions.OnlyOnFaulted);187 break;188 case MessageContainer.MessageType.PauseJob:189 Task.Factory.StartNew(HandlePauseJob, container.JobId)190 .ContinueWith((t) => {191 clientCom.LogMessage(t.Exception.ToString());192 }, TaskContinuationOptions.OnlyOnFaulted);193 break;194 183 case MessageContainer.MessageType.Restart: 195 184 DoStartSlave(); … … 199 188 break; 200 189 case MessageContainer.MessageType.SayHello: 201 wcfService.Connect( ConfigManager.Instance.GetClientInfo());190 wcfService.Connect(configManager.GetClientInfo()); 202 191 break; 203 192 } … … 207 196 } 208 197 198 private void CalculateJobAsync(Guid jobId) { 199 Task.Factory.StartNew(HandleCalculateJob, jobId) 200 .ContinueWith((t) => { 201 SlaveStatusInfo.IncrementExceptionOccured(); 202 clientCom.LogMessage(t.Exception.ToString()); 203 }, TaskContinuationOptions.OnlyOnFaulted); 204 } 205 206 private void StopJobAsync(Guid jobId) { 207 Task.Factory.StartNew(HandleStopJob, jobId) 208 .ContinueWith((t) => { 209 SlaveStatusInfo.IncrementExceptionOccured(); 210 clientCom.LogMessage(t.Exception.ToString()); 211 }, TaskContinuationOptions.OnlyOnFaulted); 212 } 213 214 private void PauseJobAsync(Guid jobId) { 215 Task.Factory.StartNew(HandlePauseJob, jobId) 216 .ContinueWith((t) => { 217 SlaveStatusInfo.IncrementExceptionOccured(); 218 clientCom.LogMessage(t.Exception.ToString()); 219 }, TaskContinuationOptions.OnlyOnFaulted); 220 } 221 222 private void AbortJobAsync(Guid jobId) { 223 Task.Factory.StartNew(HandleAbortJob, jobId) 224 .ContinueWith((t) => { 225 SlaveStatusInfo.IncrementExceptionOccured(); 226 clientCom.LogMessage(t.Exception.ToString()); 227 }, TaskContinuationOptions.OnlyOnFaulted); 228 } 229 209 230 private void HandleCalculateJob(object jobIdObj) { 210 231 Guid jobId = (Guid)jobIdObj; 211 SlaveJob newJob = new SlaveJob(this); 212 bool start = true; 213 214 lock (slaveJobs) { 215 if (ConfigManager.Instance.GetFreeCores() < 1) { 216 wcfService.UpdateJobState(jobId, JobState.Waiting, "Slave set status waiting because no cores were available"); 217 clientCom.LogMessage(string.Format("Setting job with id {0} to waiting, all cores are used", jobId)); 218 start = false; 219 } else { 220 if (slaveJobs.ContainsKey(jobId)) { 221 start = false; 222 clientCom.LogMessage(string.Format("Job with id {0} already exists. Start aborted.", jobId)); 223 } else { 224 slaveJobs.Add(jobId, newJob); 225 newJob.PrepareJob(jobId); 226 } 227 } 228 } 229 230 if (start) { 231 newJob.CalculateJob(); 232 Job job = null; 233 bool usedCoresIncremented = false; 234 try { 235 job = wcfService.GetJob(jobId); 236 if (job == null) throw new JobNotFoundException(jobId); 237 if (ConfigManager.Instance.GetFreeCores() < job.CoresNeeded) throw new OutOfCoresException(); 238 if (ConfigManager.GetFreeMemory() < job.MemoryNeeded) throw new OutOfMemoryException(); 239 SlaveStatusInfo.IncrementUsedCores(job.CoresNeeded); usedCoresIncremented = true; 240 JobData jobData = wcfService.GetJobData(jobId); 241 if (jobData == null) throw new JobDataNotFoundException(jobId); 242 job = wcfService.UpdateJobState(jobId, JobState.Calculating, null); 243 if (job == null) throw new JobNotFoundException(jobId); 244 jobManager.StartJobAsync(job, jobData); 245 } 246 catch (JobNotFoundException) { 247 if (usedCoresIncremented) SlaveStatusInfo.DecrementUsedCores(job.CoresNeeded); 248 throw; 249 } 250 catch (JobDataNotFoundException) { 251 SlaveStatusInfo.DecrementUsedCores(job.CoresNeeded); 252 throw; 253 } 254 catch (JobAlreadyRunningException) { 255 SlaveStatusInfo.DecrementUsedCores(job.CoresNeeded); 256 throw; 257 } 258 catch (OutOfCoresException) { 259 wcfService.UpdateJobState(jobId, JobState.Waiting, "No more cores available"); 260 throw; 261 } 262 catch (OutOfMemoryException) { 263 wcfService.UpdateJobState(jobId, JobState.Waiting, "No more memory available"); 264 throw; 265 } 266 catch (Exception) { 267 if (usedCoresIncremented) SlaveStatusInfo.DecrementUsedCores(job.CoresNeeded); 268 throw; 269 } 270 } 271 272 private void HandleStopJob(object jobIdObj) { 273 Guid jobId = (Guid)jobIdObj; 274 try { 275 Job job = wcfService.GetJob(jobId); 276 if (job == null) throw new JobNotFoundException(jobId); 277 jobManager.StopJobAsync(jobId); 278 } 279 catch (JobNotFoundException) { 280 throw; 281 } 282 catch (JobNotRunningException) { 283 throw; 284 } 285 catch (AppDomainNotCreatedException) { 286 throw; 287 } 288 } 289 290 private void HandlePauseJob(object jobIdObj) { 291 Guid jobId = (Guid)jobIdObj; 292 try { 293 Job job = wcfService.GetJob(jobId); 294 if (job == null) throw new JobNotFoundException(jobId); 295 jobManager.PauseJobAsync(jobId); 296 } 297 catch (JobNotFoundException) { 298 throw; 299 } 300 catch (JobNotRunningException) { 301 throw; 232 302 } 233 303 } … … 235 305 private void HandleAbortJob(object jobIdObj) { 236 306 Guid jobId = (Guid)jobIdObj; 237 bool abort = true; 238 SlaveJob sj = null; 239 240 lock (slaveJobs) { 241 if (!slaveJobs.ContainsKey(jobId)) { 242 clientCom.LogMessage(string.Format("Job with id {0} doesn't exist. Abort aborted.", jobId)); 243 abort = false; 307 try { 308 jobManager.AbortJob(jobId); 309 } 310 catch (JobNotFoundException) { 311 throw; 312 } 313 } 314 315 #region JobManager Events 316 private void RegisterJobManagerEvents() { 317 this.jobManager.JobStarted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobStarted); 318 this.jobManager.JobPaused += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_JobPaused); 319 this.jobManager.JobStopped += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_JobStopped); 320 this.jobManager.JobFailed += new EventHandler<EventArgs<Tuple<SlaveJob, JobData, Exception>>>(jobManager_JobFailed); 321 this.jobManager.ExceptionOccured += new EventHandler<EventArgs<SlaveJob, Exception>>(jobManager_ExceptionOccured); 322 this.jobManager.JobAborted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobAborted); 323 this.jobManager.NewChildJob += new EventHandler<EventArgs<SlaveJob, IJob>>(jobManager_NewChildJob); 324 this.jobManager.WaitForChildJobs += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_WaitForChildJobs); 325 this.jobManager.DeleteChildJobs += new EventHandler<EventArgs<SlaveJob>>(jobManager_DeleteChildJobs); 326 } 327 328 private void jobManager_JobStarted(object sender, EventArgs<SlaveJob> e) { 329 // successfully started, everything is good 330 } 331 332 private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, JobData> e) { 333 try { 334 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 335 heartbeatManager.AwakeHeartBeatThread(); 336 Job job = wcfService.GetJob(e.Value.JobId); 337 if (job == null) throw new JobNotFoundException(e.Value.JobId); 338 job.ExecutionTime = e.Value.ExecutionTime; 339 JobData jobData = e.Value.GetJobData(); 340 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Paused); 341 } 342 catch (JobNotFoundException ex) { 343 clientCom.LogMessage(ex.ToString()); 344 } 345 catch (Exception ex) { 346 clientCom.LogMessage(ex.ToString()); 347 } 348 } 349 350 private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, JobData> e) { 351 try { 352 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 353 heartbeatManager.AwakeHeartBeatThread(); 354 Job job = wcfService.GetJob(e.Value.JobId); 355 if (job == null) throw new JobNotFoundException(e.Value.JobId); 356 job.ExecutionTime = e.Value.ExecutionTime; 357 JobData jobData = e.Value.GetJobData(); 358 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Finished); 359 } 360 catch (JobNotFoundException ex) { 361 clientCom.LogMessage(ex.ToString()); 362 } 363 catch (Exception ex) { 364 clientCom.LogMessage(ex.ToString()); 365 } 366 } 367 368 private void jobManager_JobFailed(object sender, EventArgs<Tuple<SlaveJob, JobData, Exception>> e) { 369 try { 370 SlaveStatusInfo.DecrementUsedCores(e.Value.Item1.CoresNeeded); 371 heartbeatManager.AwakeHeartBeatThread(); 372 SlaveJob slaveJob = e.Value.Item1; 373 JobData jobData = e.Value.Item2; 374 Exception exception = e.Value.Item3; 375 376 Job job = wcfService.GetJob(slaveJob.JobId); 377 if (job == null) throw new JobNotFoundException(slaveJob.JobId); 378 job.ExecutionTime = slaveJob.ExecutionTime; 379 if (jobData != null) { 380 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Failed); 244 381 } else { 245 sj = slaveJobs[jobId];382 wcfService.UpdateJobState(job.Id, JobState.Failed, exception.ToString()); 246 383 } 247 } 248 249 if (abort && !sj.Finished) { 250 sj.KillAppDomain(); 251 } 252 } 253 254 private void HandleStopJob(object jobIdObj) { 255 Guid jobId = (Guid)jobIdObj; 256 bool stop = true; 257 SlaveJob sj = null; 258 259 lock (slaveJobs) { 260 if (!slaveJobs.ContainsKey(jobId)) { 261 clientCom.LogMessage(string.Format("Job with id {0} doesn't exist. Stop aborted.", jobId)); 262 stop = false; 263 } else { 264 sj = slaveJobs[jobId]; 265 } 266 } 267 268 if (stop && !sj.Finished) { 269 sj.StopJob(); 270 } 271 } 272 273 private void HandlePauseJob(object jobIdObj) { 274 Guid jobId = (Guid)jobIdObj; 275 bool pause = true; 276 SlaveJob sj = null; 277 278 lock (slaveJobs) { 279 if (!slaveJobs.ContainsKey(jobId)) { 280 clientCom.LogMessage(string.Format("Job with id {0} doesn't exist. Pause aborted.", jobId)); 281 pause = false; 282 } else { 283 sj = slaveJobs[jobId]; 284 } 285 } 286 287 if (pause && !sj.Finished) { 288 sj.PauseJob(); 289 } 290 } 384 clientCom.LogMessage(exception.Message); 385 } 386 catch (JobNotFoundException ex) { 387 SlaveStatusInfo.IncrementExceptionOccured(); 388 clientCom.LogMessage(ex.ToString()); 389 } 390 catch (Exception ex) { 391 SlaveStatusInfo.IncrementExceptionOccured(); 392 clientCom.LogMessage(ex.ToString()); 393 } 394 } 395 396 private void jobManager_ExceptionOccured(object sender, EventArgs<SlaveJob, Exception> e) { 397 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 398 SlaveStatusInfo.IncrementExceptionOccured(); 399 heartbeatManager.AwakeHeartBeatThread(); 400 clientCom.LogMessage(string.Format("Exception occured for job {0}: {1}", e.Value.JobId, e.Value2.ToString())); 401 } 402 403 private void jobManager_JobAborted(object sender, EventArgs<SlaveJob> e) { 404 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 405 } 406 407 private void jobManager_NewChildJob(object sender, EventArgs<SlaveJob, IJob> e) { 408 var job = new Job() { CoresNeeded = 1, MemoryNeeded = 0 }; 409 WcfService.Instance.AddChildJob(e.Value.JobId, job, e.Value2); 410 } 411 412 private void jobManager_WaitForChildJobs(object sender, EventArgs<SlaveJob, JobData> e) { 413 try { 414 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 415 heartbeatManager.AwakeHeartBeatThread(); 416 Job job = wcfService.GetJob(e.Value.JobId); 417 if (job == null) throw new JobNotFoundException(e.Value.JobId); 418 job.ExecutionTime = e.Value.ExecutionTime; 419 job.IsParentJob = true; 420 job.FinishWhenChildJobsFinished = false; 421 JobData jobData = e.Value.GetJobData(); 422 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Waiting); 423 } 424 catch (JobNotFoundException ex) { 425 clientCom.LogMessage(ex.ToString()); 426 } 427 catch (Exception ex) { 428 clientCom.LogMessage(ex.ToString()); 429 } 430 } 431 432 private void jobManager_DeleteChildJobs(object sender, EventArgs<SlaveJob> e) { 433 try { 434 WcfService.Instance.DeleteChildJobs(e.Value.JobId); 435 } 436 catch (Exception ex) { 437 clientCom.LogMessage(ex.ToString()); 438 } 439 } 440 #endregion 441 442 #region Log Events 443 private void log_MessageAdded(object sender, EventArgs<string> e) { 444 clientCom.LogMessage(e.Value.Split('\t')[1]); 445 ((ILog)sender).Clear(); // don't let the log take up memory 446 } 447 #endregion 291 448 292 449 /// <summary> … … 294 451 /// </summary> 295 452 private void DoAbortAll() { 296 lock (slaveJobs) { 297 foreach (SlaveJob sj in new List<SlaveJob>(slaveJobs.Values)) { 298 if (!sj.Finished) { 299 sj.KillAppDomain(); 300 } 301 } 302 } 303 clientCom.LogMessage("Aborted all jobs!"); 453 clientCom.LogMessage("Aborting all jobs."); 454 foreach (Guid jobId in jobManager.JobIds) { 455 AbortJobAsync(jobId); 456 } 304 457 } 305 458 … … 308 461 /// </summary> 309 462 private void DoPauseAll() { 310 clientCom.LogMessage("Pause all received"); 311 312 lock (slaveJobs) { 313 foreach (SlaveJob sj in new List<SlaveJob>(slaveJobs.Values)) { 314 if (!sj.Finished) { 315 sj.PauseJob(); 316 } 317 } 463 clientCom.LogMessage("Pausing all jobs."); 464 foreach (Guid jobId in jobManager.JobIds) { 465 PauseJobAsync(jobId); 318 466 } 319 467 } … … 323 471 /// </summary> 324 472 private void DoStopAll() { 325 clientCom.LogMessage("Stop all received"); 326 327 lock (slaveJobs) { 328 foreach (SlaveJob sj in new List<SlaveJob>(slaveJobs.Values)) { 329 if (!sj.Finished) { 330 sj.StopJob(); 331 } 332 } 333 } 334 } 335 473 clientCom.LogMessage("Stopping all jobs."); 474 foreach (Guid jobId in jobManager.JobIds) { 475 StopJobAsync(jobId); 476 } 477 } 478 479 #region Slave Lifecycle Methods 336 480 /// <summary> 337 481 /// completly shudown slave … … 350 494 clientCom.LogMessage("Stopping heartbeat"); 351 495 heartbeatManager.StopHeartBeat(); 352 AbortRequested = true;496 abortRequested = true; 353 497 clientCom.LogMessage("Logging out"); 354 498 … … 369 513 private void DoStartSlave() { 370 514 clientCom.LogMessage("Restart received"); 371 ConfigManager.Instance.Asleep = false;515 configManager.Asleep = false; 372 516 clientCom.LogMessage("Restart done"); 373 517 } … … 379 523 private void Sleep() { 380 524 clientCom.LogMessage("Sleep received - not accepting any new jobs"); 381 ConfigManager.Instance.Asleep = true; 382 DoPauseAll(); //TODO: or stop? can't decide... 383 } 384 385 public void RemoveSlaveJobFromList(Guid jobId) { 386 lock (slaveJobs) { 387 if (slaveJobs.ContainsKey(jobId)) { 388 slaveJobs.Remove(jobId); 389 } 390 } 391 } 525 configManager.Asleep = true; 526 DoPauseAll(); 527 } 528 #endregion 392 529 } 393 530 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Exceptions/JobNotDataFoundException.cs
r5786 r6357 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 3 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 4 25 public class JobDataNotFoundException : Exception { 5 public JobDataNotFoundException(Guid jobId) : base(string.Format("Job with Id {0} was not found.", jobId)) { }26 public JobDataNotFoundException(Guid jobId) : base(string.Format("JobData with JobId {0} was not found on server.", jobId)) { } 6 27 } 7 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Exceptions/JobNotFoundException.cs
r5786 r6357 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 3 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 4 25 public class JobNotFoundException : Exception { 5 public JobNotFoundException(Guid jobId) : base (string.Format("Job with Id {0} was not found .", jobId)) { }26 public JobNotFoundException(Guid jobId) : base (string.Format("Job with Id {0} was not found on server.", jobId)) { } 6 27 } 7 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs
r6203 r6357 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Hive; 29 using HeuristicLab.PluginInfrastructure;30 29 31 30 … … 45 44 public ExecutorQueue executorQueue; 46 45 47 public bool SendHeartbeatForExecutor { get; set; } 48 49 public bool Aborted{ get; set; }46 public bool SendHeartbeatForExecutor { get; set; } // Todo: get rid of?? 47 public bool IsStopping { get; set; } 48 public bool IsPausing { get; set; } 50 49 51 50 public DateTime CreationTime { get; set; } … … 76 75 public Executor() { 77 76 SendHeartbeatForExecutor = true; 77 IsStopping = false; 78 IsPausing = false; 78 79 executorQueue = new ExecutorQueue(); 79 80 } … … 84 85 try { 85 86 CreationTime = DateTime.Now; 86 Aborted = false;87 87 Job = PersistenceUtil.Deserialize<IJob>(serializedJob); 88 88 … … 107 107 108 108 public void Pause() { 109 IsPausing = true; 109 110 SendHeartbeatForExecutor = false; 110 111 // wait until job is started. if this does not happen, the Job is null an we give up 111 112 jobStartedSem.WaitOne(TimeSpan.FromSeconds(15)); 112 113 if (Job == null) { 113 currentException = new Exception("Pausing job " + this.JobId + ": Job is null"); 114 currentException = new Exception("Pausing job " + this.JobId + ": Job is null"); // Todo: use more specific exception 114 115 return; 115 116 } 116 117 117 if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) {118 if (Job.ExecutionState == ExecutionState.Started) { 118 119 try { 119 120 Job.Pause(); … … 122 123 } 123 124 catch (Exception ex) { 124 currentException = new Exception("Error pausing job " + this.JobId + ": " + ex.ToString()); 125 currentException = new Exception("Error pausing job " + this.JobId + ": " + ex.ToString()); // Todo: use more specific exception 125 126 } 126 127 } … … 128 129 129 130 public void Stop() { 131 IsStopping = true; 130 132 SendHeartbeatForExecutor = false; 131 133 // wait until job is started. if this does not happen, the Job is null an we give up 132 134 jobStartedSem.WaitOne(TimeSpan.FromSeconds(15)); 133 135 if (Job == null) { 134 currentException = new Exception("Stopping job " + this.JobId + ": Job is null"); 136 currentException = new Exception("Stopping job " + this.JobId + ": Job is null"); // Todo: use more specific exception 135 137 } 136 138 wasJobAborted = true; … … 142 144 } 143 145 catch (Exception ex) { 144 currentException = new Exception("Error stopping job " + this.JobId + ": " + ex.ToString()); 146 currentException = new Exception("Error stopping job " + this.JobId + ": " + ex.ToString()); // Todo: use more specific exception 145 147 } 146 148 } … … 167 169 } 168 170 169 private List<Guid> FindPluginsNeeded(IJob obj) { 170 List<Guid> guids = new List<Guid>(); 171 foreach (IPluginDescription desc in PluginUtil.GetDeclaringPlugins(obj)) { 172 } 173 throw new NotImplementedException("FindPluginsNeeded for Job_NewChildJob"); 174 175 return guids; 176 } 177 171 #region Job Events 178 172 private void Job_NewChildJob(object sender, EventArgs<IJob> e) { 179 JobData childJobData = new JobData(); 180 childJobData.Data = PersistenceUtil.Serialize(e.Value); 181 182 Job childJob = new Job(); 183 childJob.CoresNeeded = 1; 184 childJob.MemoryNeeded = 0; 185 childJob.PluginsNeededIds = FindPluginsNeeded(e.Value); 186 187 ExecutorMessage msg = new ExecutorMessage(ExecutorMessageType.NewChildJob); 188 msg.MsgData = childJobData; 189 msg.MsgJob = childJob; 190 191 executorQueue.AddMessage(msg); 173 //JobData childJobData = new JobData(); 174 //IEnumerable<Type> types; 175 //childJobData.Data = PersistenceUtil.Serialize(e.Value, out types); 176 //IEnumerable<Plugin> plugins; 177 //PluginUtil.CollectDeclaringPlugins 178 179 //Job childJob = new Job(); 180 //childJob.CoresNeeded = 1; 181 //childJob.MemoryNeeded = 0; 182 //childJob.PluginsNeededIds = FindPluginsNeeded(e.Value); 183 184 //ExecutorMessage msg = new ExecutorMessage(ExecutorMessageType.NewChildJob); 185 //msg.MsgData = childJobData; 186 //msg.MsgJob = childJob; 187 188 //executorQueue.AddMessage(msg); 189 190 executorQueue.AddMessage(new JobExecutorMessage(ExecutorMessageType.NewChildJob, e.Value)); 192 191 } 193 192 … … 196 195 this.Job.CollectChildJobs = true; 197 196 198 JobData jdata = new JobData(); 199 jdata.Data = PersistenceUtil.Serialize(Job); 200 jdata.JobId = this.JobId; 201 202 ExecutorMessage msg = new ExecutorMessage(ExecutorMessageType.WaitForChildJobs); 203 msg.MsgData = jdata; 204 executorQueue.AddMessage(msg); 197 //JobData jdata = new JobData(); 198 //jdata.Data = PersistenceUtil.Serialize(Job); 199 //jdata.JobId = this.JobId; 200 201 //ExecutorMessage msg = new ExecutorMessage(ExecutorMessageType.WaitForChildJobs); 202 //msg.MsgData = jdata; 203 //executorQueue.AddMessage(msg); 204 205 executorQueue.AddMessage(new ExecutorMessage(ExecutorMessageType.WaitForChildJobs)); 205 206 } 206 207 … … 210 211 211 212 private void Job_JobFailed(object sender, EventArgs e) { 212 HeuristicLab.Common.EventArgs<Exception> ex = (HeuristicLab.Common.EventArgs<Exception>)e;213 EventArgs<Exception> ex = (EventArgs<Exception>)e; 213 214 currentException = ex.Value; 214 Aborted = true;215 215 216 216 executorQueue.AddMessage(ExecutorMessageType.JobFailed); … … 218 218 219 219 private void Job_JobStopped(object sender, EventArgs e) { 220 if (wasJobAborted) {220 if (wasJobAborted) 221 221 pauseStopSem.Release(); 222 Aborted = true; 223 } else { 224 //it's a clean and finished job, so send it 225 executorQueue.AddMessage(ExecutorMessageType.JobStopped); 226 } 227 } 228 229 public JobData GetFinishedJob() { 230 if (Job == null) { 231 if (currentException == null) { 232 currentException = new Exception("Getting finished job " + this.JobId + ": Job is null"); 233 return GetJob(); 234 } 235 } 236 237 if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) { 238 try { 239 Job.Stop(); 240 wasJobAborted = true; 241 pauseStopSem.WaitOne(); 242 } 243 catch (Exception ex) { 244 currentException = new Exception("Error getting finished job " + this.JobId + ": " + ex.ToString()); 245 } 246 } 247 248 return GetJob(); 249 } 250 251 public JobData GetPausedJob() { 252 if (Job.ExecutionState != HeuristicLab.Core.ExecutionState.Paused) { 253 throw new Exception("Executor: Job has to be paused before fetching results."); 254 } 255 return GetJob(); 222 223 executorQueue.AddMessage(ExecutorMessageType.JobStopped); 256 224 } 257 225 258 226 private void Job_JobPaused(object sender, EventArgs e) { 259 227 pauseStopSem.Release(); 260 } 261 262 void Job_JobStarted(object sender, EventArgs e) { 228 executorQueue.AddMessage(ExecutorMessageType.JobPaused); 229 } 230 231 private void Job_JobStarted(object sender, EventArgs e) { 263 232 jobStartedSem.Release(); 264 } 265 266 private JobData GetJob() { 267 if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) { 233 executorQueue.AddMessage(ExecutorMessageType.JobStarted); 234 } 235 #endregion 236 237 public JobData GetJobData() { 238 if (Job.ExecutionState == ExecutionState.Started) { 268 239 throw new InvalidStateException("Job is still running"); 269 240 } else { 270 JobData j data = new JobData();241 JobData jobData = new JobData(); 271 242 if (Job == null) { 272 243 //send empty job and save exception 273 j data.Data = PersistenceUtil.Serialize(new JobData());244 jobData.Data = PersistenceUtil.Serialize(new JobData()); 274 245 if (currentException == null) { 275 246 currentException = new Exception("Job with id " + this.JobId + " is null, sending empty job"); 276 247 } 277 248 } else { 278 j data.Data = PersistenceUtil.Serialize(Job);279 } 280 j data.JobId = JobId;281 return j data;249 jobData.Data = PersistenceUtil.Serialize(Job); 250 } 251 jobData.JobId = JobId; 252 return jobData; 282 253 } 283 254 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/ExecutorMessage.cs
r6203 r6357 1 1 2 2 using System; 3 using HeuristicLab.Hive; 3 4 namespace HeuristicLab.Clients.Hive.SlaveCore { 4 5 [Serializable] 5 6 public enum ExecutorMessageType { 7 JobStarted, 8 JobPaused, 6 9 JobStopped, 7 10 JobFailed, … … 19 22 MessageType = messageType; 20 23 } 24 } 21 25 22 public JobData MsgData { get; set; } 23 public Job MsgJob { get; set; } 26 [Serializable] 27 public class JobExecutorMessage : ExecutorMessage { 28 public IJob Job { get; private set; } 29 30 public JobExecutorMessage(ExecutorMessageType messageType, IJob job) : base(messageType) { 31 this.Job = job; 32 } 24 33 } 25 34 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/HeuristicLab.Clients.Hive.Slave-3.4.csproj
r6203 r6357 77 77 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath> 78 78 </Reference> 79 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 80 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath> 81 </Reference> 79 82 <Reference Include="HeuristicLab.Core-3.3"> 80 83 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath> … … 88 91 <Reference Include="System" /> 89 92 <Reference Include="System.Core" /> 93 <Reference Include="System.Drawing" /> 90 94 <Reference Include="System.Management" /> 91 95 <Reference Include="System.Runtime.Serialization" /> … … 97 101 </ItemGroup> 98 102 <ItemGroup> 99 <Compile Include="ConfigManager.cs" /> 100 <Compile Include="Exceptions\JobAlreadyExistsException.cs" /> 103 <Compile Include="Exceptions\JobFailedException.cs" /> 104 <Compile Include="Manager\ConfigManager.cs" /> 105 <Compile Include="Exceptions\SerializationException.cs" /> 106 <Compile Include="Exceptions\OutOfMemoryException.cs" /> 107 <Compile Include="Exceptions\JobNotRunningException.cs" /> 108 <Compile Include="Exceptions\JobAlreadyRunningException.cs" /> 101 109 <Compile Include="Exceptions\JobNotFoundException.cs" /> 102 110 <Compile Include="Exceptions\JobNotDataFoundException.cs" /> 103 111 <Compile Include="ExecutorMessage.cs" /> 104 112 <Compile Include="ExecutorQueue.cs" /> 113 <Compile Include="IPluginProvider.cs" /> 114 <Compile Include="Manager\JobManager.cs" /> 115 <Compile Include="Exceptions\OutOfCoresException.cs" /> 116 <Compile Include="Exceptions\JobNotStartedException.cs" /> 105 117 <Compile Include="SlaveClientCom.cs" /> 106 118 <Compile Include="Core.cs" /> 107 119 <Compile Include="DummyListener.cs" /> 108 120 <Compile Include="Executor.cs" /> 109 <Compile Include=" HeartbeatManager.cs" />121 <Compile Include="Manager\HeartbeatManager.cs" /> 110 122 <Compile Include="Exceptions\InvalidStateException.cs" /> 111 123 <Compile Include="JobStatus.cs" /> 112 124 <Compile Include="MessageQueue.cs" /> 113 125 <Compile Include="NetworkEnum.cs" /> 114 <Compile Include="PluginCache.cs" /> 115 <Compile Include="PluginUtil.cs" /> 126 <Compile Include="Manager\PluginManager.cs" /> 116 127 <Compile Include="Properties\Settings.Designer.cs"> 117 128 <AutoGen>True</AutoGen> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/JobStatus.cs
r5599 r6357 32 32 public Guid JobId { get; set; } 33 33 /// <summary> 34 /// When has the calculation of the Job begun?35 /// </summary>36 [DataMember]37 public DateTime Since { get; set; }38 /// <summary>39 34 /// Current progress 40 35 /// </summary> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveCommunicationService.cs
r6263 r6357 65 65 } 66 66 67 public void StatusChanged(S laveCore.StatusCommons status) {67 public void StatusChanged(StatusCommons status) { 68 68 subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) { 69 69 if (((ICommunicationObject)callback).State == CommunicationState.Opened) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveJob.cs
r6258 r6357 3 3 using System.IO; 4 4 using System.Threading; 5 using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts; 5 using HeuristicLab.Common; 6 using HeuristicLab.Core; 7 using HeuristicLab.Hive; 8 using HeuristicLab.PluginInfrastructure.Sandboxing; 6 9 7 10 namespace HeuristicLab.Clients.Hive.SlaveCore { … … 13 16 private bool executorMonitoringRun; 14 17 private Thread executorMonitoringThread; 15 private Core core; 16 private bool finished; 18 private PluginManager pluginManager; 19 private ILog log; 20 21 public Guid JobId { get; private set; } 22 public bool IsPrepared { get; private set; } 23 17 24 private int coresNeeded; 18 19 private ISlaveCommunication clientCom; 20 private WcfService wcfService; 21 22 public Guid JobId; 23 public Executor JobExecutor { get { return executor; } } 24 public bool Finished { get { return finished; } } 25 26 27 public SlaveJob(Core core) { 28 clientCom = SlaveClientCom.Instance.ClientCom; 29 wcfService = WcfService.Instance; 25 public int CoresNeeded { 26 get { return coresNeeded; } 27 set { this.coresNeeded = value; } 28 } 29 30 public TimeSpan ExecutionTime { 31 get { return executor != null ? executor.ExecutionTime : TimeSpan.Zero; } 32 } 33 34 public SlaveJob(PluginManager pluginManager, int coresNeeded, ILog log) { 35 this.pluginManager = pluginManager; 36 this.coresNeeded = coresNeeded; 37 this.log = log; 30 38 waitForStartBeforeKillSem = new Semaphore(0, 1); 31 39 executorMonitoringRun = true; 32 this.core = core; 33 finished = false; 34 } 35 36 public void PrepareJob(Guid jobId) { 37 JobId = jobId; 38 Job job = wcfService.GetJob(jobId); 39 if (job == null) throw new JobNotFoundException(jobId); 40 coresNeeded = job.CoresNeeded; 41 SlaveStatusInfo.IncrementUsedCores(coresNeeded); 42 } 43 44 public void CalculateJob() { 45 Job job = wcfService.GetJob(JobId); 46 if (job == null) throw new JobNotFoundException(JobId); 47 48 JobData jobData = wcfService.GetJobData(job.Id); 49 if (jobData == null) throw new JobDataNotFoundException(JobId); 50 SlaveStatusInfo.IncrementJobsFetched(); 51 job = wcfService.UpdateJobState(job.Id, JobState.Calculating, null); 52 if (job == null) throw new JobNotFoundException(JobId); 53 StartJobInAppDomain(job, jobData); 40 IsPrepared = false; 41 } 42 43 public void StartJobAsync(Job job, JobData jobData) { 44 try { 45 this.JobId = job.Id; 46 Prepare(job); 47 StartJobInAppDomain(jobData); 48 } 49 catch (Exception) { 50 DisposeAppDomain(); // make sure to clean up if something went wrong 51 throw; 52 } 53 } 54 55 public void PauseJob() { 56 if (!IsPrepared) throw new AppDomainNotCreatedException(); 57 if (!executor.IsPausing && !executor.IsStopping) executor.Pause(); 54 58 } 55 59 56 60 public void StopJob() { 57 if (executor == null) { 58 clientCom.LogMessage(string.Format("StopJob: job with id {0} is missing the executor", JobId)); 59 } else { 60 Job job = wcfService.GetJob(JobId); 61 62 if (job != null) { 63 executor.Stop(); 64 65 try { 66 JobData sJob = executor.GetFinishedJob(); 67 job.ExecutionTime = executor.ExecutionTime; 68 69 if (executor.CurrentException != string.Empty) { 70 wcfService.UpdateJobState(job.Id, JobState.Failed, executor.CurrentException); 71 } 72 SlaveStatusInfo.IncrementJobsAborted(); 73 74 clientCom.LogMessage(string.Format("Sending the stopped job with id: {0}", job.Id)); 75 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Aborted); 76 } 77 catch (Exception e) { 78 clientCom.LogMessage(string.Format("Transmitting the stopped job with id {0} to server failed. Exception is: {1}", job.Id, e.ToString())); 79 } 80 finally { 81 KillAppDomain(); // kill appdomain in every case 82 } 83 } 84 } 85 } 86 87 public void PauseJob() { 88 if (executor == null) { 89 clientCom.LogMessage("PauseJob: Can't pause job with uninitialized executor"); 90 } else { 91 Job job = wcfService.GetJob(JobId); 92 93 if (job != null) { 94 executor.Pause(); 95 JobData sJob = executor.GetPausedJob(); 96 job.ExecutionTime = executor.ExecutionTime; 97 98 try { 99 if (executor.CurrentException != string.Empty) { 100 wcfService.UpdateJobState(job.Id, JobState.Failed, executor.CurrentException); 101 SlaveStatusInfo.IncrementJobsFailed(); 102 } else { 103 SlaveStatusInfo.IncrementJobsFinished(); 104 } 105 clientCom.LogMessage("Sending the paused job with id: " + job.Id); 106 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused); 107 } 108 catch (Exception e) { 109 clientCom.LogMessage(string.Format("Transmitting the paused job with id {0} to server failed. Exception is: {1}", job.Id, e.ToString())); 110 } 111 finally { 112 KillAppDomain(); // kill appdomain in every case 113 } 114 } 115 } 116 } 117 118 /// <summary> 119 /// Pauses a job, which means sending it to the server and killing it locally; 120 /// atm only used when executor is waiting for child jobs 121 /// </summary> 122 public void PauseWaitJob(JobData data) { 123 try { 124 if (executor == null) { 125 clientCom.LogMessage(string.Format("PauseWaitJob: Can't pause job with id {0} with uninitialized executor", JobId)); 126 } else { 127 Job job = wcfService.GetJob(data.JobId); 128 wcfService.UpdateJobData(job, data, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused); 129 wcfService.UpdateJobState(job.Id, JobState.Waiting, null); 130 } 131 } 132 catch (Exception ex) { 133 clientCom.LogMessage(string.Format("Pausing job with id {0} failed. Exception: {1}", JobId, ex.ToString())); 134 } 135 finally { 136 KillAppDomain(); 137 } 138 } 139 140 /// <summary> 141 /// serializes the finished job and submits it to the server. If, at the time, a network connection is unavailable, the Job gets stored on the disk. 142 /// once the connection gets reestablished, the job gets submitted 143 /// </summary> 144 public void SendFinishedJob() { 145 try { 146 clientCom.LogMessage(string.Format("Getting the finished job with id: {0} ", JobId)); 147 if (executor == null) { 148 clientCom.LogMessage(string.Format("SendFinishedJob: Can't pause job with id {0} with uninitialized executor", JobId)); 149 return; 150 } 151 152 Job job = wcfService.GetJob(JobId); 153 job.ExecutionTime = executor.ExecutionTime; 154 155 if (executor.Aborted) { 156 SlaveStatusInfo.IncrementJobsAborted(); 157 } else { 158 SlaveStatusInfo.IncrementJobsFinished(); 159 } 160 161 if (executor.CurrentException != string.Empty) { 162 wcfService.UpdateJobState(JobId, JobState.Failed, executor.CurrentException); 163 } 164 165 try { 166 JobData sJob = executor.GetFinishedJob(); 167 if (sJob != null) { 168 clientCom.LogMessage(string.Format("Sending the finished job with id: {0}", JobId)); 169 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Finished); 170 } 171 } 172 catch (Exception e) { 173 clientCom.LogMessage(string.Format("Transmitting the job with id {0} to server failed. Exception is: {1}", job.Id, e.ToString())); 174 } 175 finally { 176 KillAppDomain(); 177 Core.HeartbeatManager.AwakeHeartBeatThread(); 178 } 179 } 180 catch (Exception e) { 181 clientCom.LogMessage(string.Format("SendFinishedJob: The following exception has been thrown: {0}", e.ToString())); 182 } 183 } 184 185 /// <summary> 186 /// A new Job from the wcfService has been received and will be started within a AppDomain. 187 /// </summary> 188 private void StartJobInAppDomain(Job job, JobData jobData) { 189 JobId = job.Id; 190 191 clientCom.LogMessage(string.Format("Received new job with id {0}", job.Id)); 192 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 193 194 String pluginDir = Path.Combine(PluginCache.Instance.PluginTempBaseDir, job.Id.ToString()); 195 bool pluginsPrepared = false; 196 string configFileName = string.Empty; 197 198 try { 199 PluginCache.Instance.PreparePlugins(job, out configFileName); 200 clientCom.LogMessage(string.Format("Plugins fetched for job {0}", job.Id)); 201 pluginsPrepared = true; 202 } 203 catch (Exception exception) { 204 clientCom.LogMessage(string.Format("Copying plugins for job {0} failed: {1}", job.Id, exception)); 205 wcfService.UpdateJobState(job.Id, JobState.Failed, exception.ToString()); 206 SlaveStatusInfo.IncrementJobsFailed(); 207 core.RemoveSlaveJobFromList(JobId); 208 finished = true; 209 SlaveStatusInfo.DecrementUsedCores(coresNeeded); 210 } 211 212 if (pluginsPrepared) { 213 try { 214 appDomain = HeuristicLab.PluginInfrastructure.Sandboxing.SandboxManager.CreateAndInitPrivilegedSandbox(job.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName)); 215 appDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 216 217 clientCom.LogMessage("Creating AppDomain"); 218 executor = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 219 clientCom.LogMessage("Created AppDomain"); 220 221 executor.JobId = job.Id; 222 executor.CoresNeeded = job.CoresNeeded; 223 executor.MemoryNeeded = job.MemoryNeeded; 224 clientCom.LogMessage(string.Format("Starting Executor for job {0}", job.Id)); 225 226 executor.Start(jobData.Data); 227 waitForStartBeforeKillSem.Release(); 228 229 StartExecutorMonitoringThread(); 230 } 231 catch (Exception exception) { 232 clientCom.LogMessage(string.Format("Creating the Appdomain and loading the job failed for job {0}", job.Id)); 233 clientCom.LogMessage(string.Format("Error thrown is: {0}", exception.ToString())); 234 235 if (executor != null && executor.CurrentException != string.Empty) { 236 wcfService.UpdateJobState(job.Id, JobState.Failed, executor.CurrentException); 237 } else { 238 wcfService.UpdateJobState(job.Id, JobState.Failed, exception.ToString()); 239 } 240 SlaveStatusInfo.IncrementJobsFailed(); 241 242 KillAppDomain(); 243 } 244 } 245 Core.HeartbeatManager.AwakeHeartBeatThread(); 61 if (!IsPrepared) throw new AppDomainNotCreatedException(); 62 if (!executor.IsPausing && !executor.IsStopping) executor.Stop(); 63 } 64 65 private void Prepare(Job job) { 66 string pluginDir = Path.Combine(pluginManager.PluginTempBaseDir, job.Id.ToString()); 67 string configFileName; 68 pluginManager.PreparePlugins(job, out configFileName); 69 appDomain = CreateAppDomain(job, pluginDir, configFileName); 70 IsPrepared = true; 71 } 72 73 private AppDomain CreateAppDomain(Job job, String pluginDir, string configFileName) { 74 appDomain = SandboxManager.CreateAndInitPrivilegedSandbox(job.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName)); 75 appDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 76 77 log.LogMessage("Creating AppDomain"); 78 executor = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 79 80 executor.JobId = job.Id; 81 executor.CoresNeeded = job.CoresNeeded; 82 executor.MemoryNeeded = job.MemoryNeeded; 83 return appDomain; 84 } 85 86 private void StartJobInAppDomain(JobData jobData) { 87 executor.Start(jobData.Data); 88 waitForStartBeforeKillSem.Release(); 89 StartExecutorMonitoringThread(); 246 90 } 247 91 … … 250 94 /// </summary> 251 95 /// <param name="JobId">the GUID of the job</param> 252 public void KillAppDomain() { 253 clientCom.LogMessage(string.Format("Shutting down Appdomain for Job {0}", JobId)); 254 255 try { 256 StopExecutorMonitoringThread(); 257 finished = true; 258 SlaveStatusInfo.DecrementUsedCores(coresNeeded); 259 260 if (executor != null) { 261 executor.Dispose(); 262 } 263 264 if (appDomain != null) { 265 appDomain.UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 266 int repeat = 5; 267 while (repeat > 0) { 268 try { 269 waitForStartBeforeKillSem.WaitOne(); 270 AppDomain.Unload(appDomain); 271 waitForStartBeforeKillSem.Dispose(); 272 repeat = 0; 273 } 274 catch (CannotUnloadAppDomainException) { 275 clientCom.LogMessage("Could not unload AppDomain, will try again in 1 sec."); 276 Thread.Sleep(1000); 277 repeat--; 278 if (repeat == 0) { 279 clientCom.LogMessage("Could not unload AppDomain, shutting down core..."); 280 throw; // rethrow and let app crash 281 } 96 public void DisposeAppDomain() { 97 log.LogMessage(string.Format("Shutting down Appdomain for Job {0}", JobId)); 98 StopExecutorMonitoringThread(); 99 100 if (executor != null) { 101 executor.Dispose(); 102 } 103 104 if (appDomain != null) { 105 appDomain.UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 106 int repeat = 5; 107 while (repeat > 0) { 108 try { 109 waitForStartBeforeKillSem.WaitOne(); 110 AppDomain.Unload(appDomain); 111 waitForStartBeforeKillSem.Dispose(); 112 repeat = 0; 113 } 114 catch (CannotUnloadAppDomainException) { 115 log.LogMessage("Could not unload AppDomain, will try again in 1 sec."); 116 Thread.Sleep(1000); 117 repeat--; 118 if (repeat == 0) { 119 throw; // rethrow and let app crash 282 120 } 283 121 } 284 122 } 285 286 PluginCache.Instance.DeletePluginsForJob(JobId); 287 GC.Collect(); 288 } 289 catch (Exception ex) { 290 clientCom.LogMessage(string.Format("Exception when unloading the appdomain: {0}", ex.ToString())); 291 } 292 finally { 293 core.RemoveSlaveJobFromList(JobId); 294 } 295 123 } 124 pluginManager.DeletePluginsForJob(JobId); 296 125 GC.Collect(); 297 clientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());298 126 } 299 127 300 128 private void AppDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { 301 clientCom.LogMessage(string.Format("Exception in AppDomain: ", e.ExceptionObject.ToString())); 302 KillAppDomain(); 303 } 304 129 DisposeAppDomain(); 130 OnExceptionOccured(new Exception("Unhandled exception: " +e.ExceptionObject.ToString())); 131 } 132 133 public JobData GetJobData() { 134 return executor.GetJobData(); 135 } 305 136 306 137 #region ExecutorMonitorThread 307 308 138 private void StartExecutorMonitoringThread() { 309 139 executorMonitoringThread = new Thread(MonitorExecutor); … … 331 161 332 162 switch (message.MessageType) { 163 case ExecutorMessageType.JobStarted: 164 OnJobStarted(); 165 break; 166 167 case ExecutorMessageType.JobPaused: 168 executorMonitoringRun = false; 169 OnJobPaused(); 170 DisposeAppDomain(); 171 break; 172 333 173 case ExecutorMessageType.JobStopped: 334 174 executorMonitoringRun = false; 335 SendFinishedJob(); 175 OnJobStopped(); 176 DisposeAppDomain(); 336 177 break; 337 178 338 179 case ExecutorMessageType.JobFailed: 339 180 executorMonitoringRun = false; 340 SendFinishedJob(); 181 OnJobFailed(new JobFailedException(executor.CurrentException)); 182 DisposeAppDomain(); 341 183 break; 342 184 343 185 case ExecutorMessageType.NewChildJob: 344 WcfService.Instance.AddChildJob(JobId, message.MsgJob, message.MsgData);186 OnNewChildJob(((JobExecutorMessage)message).Job); 345 187 break; 346 188 347 189 case ExecutorMessageType.WaitForChildJobs: 348 190 executorMonitoringRun = false; 349 PauseWaitJob(message.MsgData); 191 OnWaitForChildJobs(); 192 DisposeAppDomain(); 350 193 break; 351 194 352 195 case ExecutorMessageType.DeleteChildJobs: 353 WcfService.Instance.DeleteChildJobs(JobId);196 OnDeleteChildJobs(); 354 197 break; 355 198 … … 361 204 } 362 205 #endregion 206 207 public event EventHandler<EventArgs<Guid>> JobStarted; 208 private void OnJobStarted() { 209 var handler = JobStarted; 210 if (handler != null) handler(this, new EventArgs<Guid>(this.JobId)); 211 } 212 213 public event EventHandler<EventArgs<Guid>> JobStopped; 214 private void OnJobStopped() { 215 var handler = JobStopped; 216 if (handler != null) handler(this, new EventArgs<Guid>(this.JobId)); 217 } 218 219 public event EventHandler<EventArgs<Guid>> JobPaused; 220 private void OnJobPaused() { 221 var handler = JobPaused; 222 if (handler != null) handler(this, new EventArgs<Guid>(this.JobId)); 223 } 224 225 public event EventHandler<EventArgs<Guid>> JobAborted; 226 private void OnJobAborted() { 227 var handler = JobAborted; 228 if (handler != null) handler(this, new EventArgs<Guid>(this.JobId)); 229 } 230 231 public event EventHandler<EventArgs<Guid, Exception>> JobFailed; 232 private void OnJobFailed(Exception exception) { 233 var handler = JobFailed; 234 if (handler != null) handler(this, new EventArgs<Guid, Exception>(this.JobId, exception)); 235 } 236 237 public event EventHandler<EventArgs<Guid, Exception>> ExceptionOccured; 238 private void OnExceptionOccured(Exception exception) { 239 var handler = ExceptionOccured; 240 if (handler != null) handler(this, new EventArgs<Guid, Exception>(this.JobId, exception)); 241 } 242 243 public event EventHandler<EventArgs<Guid, IJob>> NewChildJob; 244 private void OnNewChildJob(IJob job) { 245 var handler = NewChildJob; 246 if (handler != null) handler(this, new EventArgs<Guid, IJob>(this.JobId, job)); 247 } 248 249 public event EventHandler<EventArgs<Guid>> WaitForChildJobs; 250 private void OnWaitForChildJobs() { 251 var handler = WaitForChildJobs; 252 if (handler != null) handler(this, new EventArgs<Guid>(this.JobId)); 253 } 254 255 public event EventHandler<EventArgs<Guid>> DeleteChildJobs; 256 private void OnDeleteChildJobs() { 257 var handler = DeleteChildJobs; 258 if (handler != null) handler(this, new EventArgs<Guid>(this.JobId)); 259 } 363 260 } 364 261 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveStatusInfo.cs
r6203 r6357 21 21 22 22 using System; 23 using System.Threading; 23 24 24 25 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 26 public class SlaveStatusInfo { 26 static private int jobsFinished; // everything went fine 27 static private int jobsAborted; // server sent stop or abort 28 static private int jobsFetched; // number of fetched jobs 29 static private int jobsFailed; // jobs that failed in the sandbox 30 static private int usedCores; // number of cores currently used 27 private static object coreLock = new object(); 28 private static int jobsFetched; // number of fetched jobs 29 private static int jobsStarted; // number of started jobs 30 private static int jobsFinished; // everything went fine 31 private static int jobsAborted; // server sent abort 32 private static int jobsFailed; // jobs that failed in the sandbox 33 private static int exceptionsOccured; // number jobs failed caused by the business logic, not a faulted job 34 private static int usedCores; // number of cores currently used 31 35 32 static public DateTime LoginTime { get; set; } 33 static private Object jobStatLock = new Object(); 34 static private Object coreLock = new Object(); 36 public static DateTime LoginTime { get; set; } 35 37 36 static public int UsedCores { 37 get { 38 lock (coreLock) { 39 return usedCores; 40 } 41 } 38 public static int UsedCores { 39 get { return usedCores; } 42 40 } 43 41 44 static public int JobsFinished { 45 get { 46 lock (jobStatLock) { 47 return jobsFinished; 48 } 49 } 42 public static int JobsStarted { 43 get { return jobsStarted; } 50 44 } 51 45 52 static public int JobsAborted { 53 get { 54 lock (jobStatLock) { 55 return jobsAborted; 56 } 57 } 46 public static int JobsFinished { 47 get { return jobsFinished; } 58 48 } 59 49 60 static public int JobsFetched { 61 get { 62 lock (jobStatLock) { 63 return jobsFetched; 64 } 65 } 50 public static int JobsAborted { 51 get { return jobsAborted; } 66 52 } 67 53 68 static public int JobsFailed { 69 get { 70 lock (jobStatLock) { 71 return jobsFailed; 72 } 73 } 54 public static int JobsFetched { 55 get { return jobsFetched; } 56 } 57 58 public static int JobsFailed { 59 get { return jobsFailed; } 60 } 61 62 public static int ExceptionsOccured { 63 get { return exceptionsOccured; } 64 } 65 66 public static void IncrementJobsStarted() { 67 Interlocked.Increment(ref jobsStarted); 74 68 } 75 69 76 70 public static void IncrementJobsFinished() { 77 lock (jobStatLock) { 78 jobsFinished++; 79 } 71 Interlocked.Increment(ref jobsFinished); 80 72 } 81 73 82 74 public static void IncrementJobsFailed() { 83 lock (jobStatLock) { 84 jobsFailed++; 85 } 75 Interlocked.Increment(ref jobsFailed); 86 76 } 87 77 88 78 public static void IncrementJobsAborted() { 89 lock (jobStatLock) { 90 jobsAborted++; 91 } 79 Interlocked.Increment(ref jobsAborted); 92 80 } 93 81 94 82 public static void IncrementJobsFetched() { 95 lock (jobStatLock) { 96 jobsFetched++; 97 } 83 Interlocked.Increment(ref jobsFetched); 84 } 85 86 public static void IncrementExceptionOccured() { 87 Interlocked.Increment(ref exceptionsOccured); 98 88 } 99 89 100 90 public static void IncrementUsedCores(int val) { 101 lock (coreLock) { 102 usedCores += val; 103 } 91 Interlocked.Add(ref usedCores, val); 104 92 } 105 93 106 94 public static void DecrementUsedCores(int val) { 107 lock (coreLock) { 108 usedCores -= val; 109 } 95 Interlocked.Add(ref usedCores, -val); 110 96 } 111 97 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/StatusCommons.cs
r6257 r6357 43 43 public int JobsFetched { get; set; } 44 44 [DataMember] 45 public int JobsStarted { get; set; } 46 [DataMember] 45 47 public int JobsFinished { get; set; } 46 48 [DataMember] … … 49 51 public int JobsFailed { get; set; } 50 52 [DataMember] 53 public int ExceptionsOccured { get; set; } 54 [DataMember] 51 55 public List<JobStatus> Jobs { get; set; } 52 56 [DataMember] … … 54 58 55 59 public override string ToString() { 56 return string.Format("Status: {0}, Fetched/Finished/Aborted/Failed: {1},{2},{3},{4}", Status, JobsFetched, JobsFinished, JobsAborted, JobsFailed); 60 return string.Format("Status: {0}, Fetc,Start,Fin,Abor,Fail,Exc: {1},{2},{3},{4},{5},{6}", 61 Status, JobsFetched, JobsStarted, JobsFinished, JobsAborted, JobsFailed, ExceptionsOccured); 57 62 } 58 63 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs
r6004 r6357 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Hive; 26 using HeuristicLab.PluginInfrastructure; 25 27 26 28 namespace HeuristicLab.Clients.Hive.SlaveCore { … … 29 31 /// WcfService class is implemented as a Singleton and works as a communication Layer with the Server 30 32 /// </summary> 31 public class WcfService : MarshalByRefObject {33 public class WcfService : MarshalByRefObject, IPluginProvider { 32 34 private static WcfService instance; 33 35 /// <summary> … … 62 64 } 63 65 64 public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) { 65 return CallHiveService(s => s.AddChildJob(parentJobId, job, jobData)); 66 public Guid AddChildJob(Guid parentJobId, Job job, IJob jobDataObject) { 67 return CallHiveService(s => { 68 JobData jobData = new JobData(); 69 IEnumerable<Type> types; 70 jobData.Data = PersistenceUtil.Serialize(jobDataObject, out types); 71 var plugins = new List<IPluginDescription>(); 72 PluginUtil.CollectDeclaringPlugins(plugins, types); 73 job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, new List<Plugin>(), new List<Plugin>(), plugins, false); 74 return s.AddChildJob(parentJobId, job, jobData); 75 }); 66 76 } 67 77 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/app.config
r6039 r6357 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 <configSections> 4 <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 5 <section name="HeuristicLab.Clients.Hive.Slave.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> 6 </sectionGroup> 7 </configSections> 8 <userSettings> 9 <HeuristicLab.Clients.Hive.Slave.Properties.Settings> 10 <setting name="Guid" serializeAs="String"> 11 <value>00000000-0000-0000-0000-000000000000</value> 12 </setting> 13 </HeuristicLab.Clients.Hive.Slave.Properties.Settings> 14 </userSettings> 3 <runtime> 4 <gcServer enabled="true" /> 5 </runtime> 6 7 <configSections> 8 <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 9 <section name="HeuristicLab.Clients.Hive.Slave.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> 10 </sectionGroup> 11 </configSections> 12 <userSettings> 13 <HeuristicLab.Clients.Hive.Slave.Properties.Settings> 14 <setting name="Guid" serializeAs="String"> 15 <value>00000000-0000-0000-0000-000000000000</value> 16 </setting> 17 </HeuristicLab.Clients.Hive.Slave.Properties.Settings> 18 </userSettings> 15 19 16 20 <system.serviceModel> 17 21 <bindings> 18 22 <wsHttpBinding> 19 <binding name="wsHttpBinding " closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">23 <binding name="wsHttpBinding_Hive" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 20 24 <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 21 25 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> … … 28 32 </bindings> 29 33 <services> 30 <service name="HeuristicLab.Clients.Hive.SlaveCore.SlaveCommunicationService"> 34 <service name="HeuristicLab.Clients.Hive.SlaveCore.SlaveCommunicationService"> 31 35 <endpoint address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts.ISlaveCommunication"/> 32 36 </service> … … 34 38 <client> 35 39 <endpoint name="SlaveCommunicationServiceEndpoint" address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts.ISlaveCommunication"/> 36 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding " contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService">40 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Hive" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService"> 37 41 <identity> 38 42 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/> … … 42 46 </system.serviceModel> 43 47 44 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> 48 <startup> 49 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 50 </startup> 51 </configuration> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj
r6200 r6357 112 112 </ItemGroup> 113 113 <ItemGroup> 114 <Compile Include="ThreadSafeLog.cs" /> 114 115 <None Include="app_f005pc.config" /> 115 116 <None Include="app_services.config" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/app.config
r5537 r6357 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 <system.serviceModel> 4 <bindings> 5 <wsHttpBinding> 6 <binding name="wsHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 7 <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 8 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> 9 <security mode="Message"> 10 <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> 11 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/> 12 </security> 13 </binding> 14 </wsHttpBinding> 15 </bindings> 16 <client> 17 <endpoint address="http://localhost/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="HeuristicLab.Services.Hive.Common.ServiceContracts.IHiveService" name="wsHttpBinding_IHiveService"> 18 <identity> 19 <certificate encodedValue="AwAAAAEAAAAUAAAAfEKvcVixnJay+q4hCPFuO0JL5TQgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhCNN5wrUcXMmE/9xwp4TYa9MAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMTAxOTEwNTMxNVoXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXwC5TGcAffd/0oAWHtm0s6YXVXEgXgb1AYmBkkkhkKIFJG/e/Z0KSYbJepmSJD44W3oOAVm+x1DAsZxU79HahDYgWCuHLMm1TLpwSmYOQ0kV3pGHWHhiWV7h7oGLds/eqZ2EOpaNGryfEPnrA4VmxY91vV5/2BTeVSWG6F8lRKQIDAQABo0kwRzBFBgNVHQEEPjA8gBAR7kBnMRHO5gzThEqda0wWoRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghCNN5wrUcXMmE/9xwp4TYa9MAkGBSsOAwIdBQADgYEAoPwEG4QTDXhlxERNDfsZmM2IhEpV42ppz1kEah2oYKDa/ElIMVtvqLv6flVtg18ENN/mEJWiHZ3NyP3qr2Pip+sh+/2WBiSbOaukES/CM7OJn9kJCImH7M/xqM8pxqY8IfgM6iBVrVj9uHqj3j2BBck+cYY8fKyh3CFifMIp6ac="/> 20 </identity> 21 </endpoint> 22 </client> 23 </system.serviceModel> 24 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> 3 <system.serviceModel> 4 <bindings> 5 <wsHttpBinding> 6 <binding name="wsHttpBinding_IHiveService" 7 closeTimeout="00:01:00" 8 openTimeout="00:01:00" 9 receiveTimeout="00:20:00" 10 sendTimeout="00:20:00" 11 bypassProxyOnLocal="false" 12 transactionFlow="false" 13 hostNameComparisonMode="StrongWildcard" 14 maxBufferPoolSize="2147483647" 15 maxReceivedMessageSize="2147483647" 16 messageEncoding="Text" 17 textEncoding="utf-8" 18 useDefaultWebProxy="true" 19 allowCookies="false"> 20 21 <readerQuotas maxDepth="2147483647" 22 maxStringContentLength="2147483647" 23 maxArrayLength="2147483647" 24 maxBytesPerRead="2147483647" 25 maxNameTableCharCount="2147483647"/> 26 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> 27 <security mode="Message"> 28 <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> 29 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/> 30 </security> 31 </binding> 32 </wsHttpBinding> 33 </bindings> 34 <client> 35 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService"> 36 <identity> 37 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/> 38 </identity> 39 </endpoint> 40 </client> 41 </system.serviceModel> 42 <startup> 43 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 44 </startup> 45 </configuration> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive 3.4.sln
r6215 r6357 53 53 EndProjectSection 54 54 EndProject 55 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave .Tests-3.4", "HeuristicLab.Clients.Hive.Slave.Tests\HeuristicLab.Clients.Hive.Slave.Tests-3.4.csproj", "{C4CBD11E-1B83-464A-B0AD-0DC0FF7E57AA}"56 EndProject 57 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Hive .Tests-3.4", "HeuristicLab.Services.Hive.Tests\HeuristicLab.Services.Hive.Tests-3.4.csproj", "{17187EAC-5D8C-4B11-9CEA-D88F71B59658}"55 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave-3.4.Tests", "HeuristicLab.Clients.Hive.Slave.Tests\HeuristicLab.Clients.Hive.Slave-3.4.Tests.csproj", "{C4CBD11E-1B83-464A-B0AD-0DC0FF7E57AA}" 56 EndProject 57 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Hive-3.4.Tests", "HeuristicLab.Services.Hive.Tests\HeuristicLab.Services.Hive-3.4.Tests.csproj", "{17187EAC-5D8C-4B11-9CEA-D88F71B59658}" 58 58 EndProject 59 59 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4", "HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4\HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4.csproj", "{464D70B8-2D91-485C-B622-22E4A4891C68}" … … 93 93 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.HiveEngine-3.4", "HeuristicLab.HiveEngine\3.4\HeuristicLab.HiveEngine-3.4.csproj", "{2C036542-5451-4A23-AFF6-87575C7BAFE7}" 94 94 EndProject 95 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.HiveEngine .Test", "HeuristicLab.HiveEngine.Test\HeuristicLab.HiveEngine.Test.csproj", "{87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}"95 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.HiveEngine-3.4.Tests", "HeuristicLab.HiveEngine.Test\HeuristicLab.HiveEngine-3.4.Tests.csproj", "{87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}" 96 96 EndProject 97 97 Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "HeuristicLab.Clients.Hive.Slave.TrayIconSetup", "HeuristicLab.Clients.Hive.Slave.TrayIconSetup\HeuristicLab.Clients.Hive.Slave.TrayIconSetup.vdproj", "{542AD827-817C-44E9-AD28-D6607BC4FA10}" 98 98 EndProject 99 99 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.HiveEngine.Views-3.4", "HeuristicLab.HiveEngine.Views\3.4\HeuristicLab.HiveEngine.Views-3.4.csproj", "{E37F15E0-D0D6-4C6E-AD22-0DA514C943A3}" 100 EndProject 101 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave-3.4.ConsoleTests", "HeuristicLab.Clients.Hive.Slave\3.4\ConsoleTests\HeuristicLab.Clients.Hive.Slave-3.4.ConsoleTests.csproj", "{B09E8C65-8D4D-48B3-8E9A-F6FC52107261}" 100 102 EndProject 101 103 Global … … 441 443 {E37F15E0-D0D6-4C6E-AD22-0DA514C943A3}.Release|x86.ActiveCfg = Release|x86 442 444 {E37F15E0-D0D6-4C6E-AD22-0DA514C943A3}.Release|x86.Build.0 = Release|x86 445 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 446 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|Any CPU.Build.0 = Debug|Any CPU 447 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 448 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 449 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|x64.ActiveCfg = Debug|x86 450 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|x86.ActiveCfg = Debug|x86 451 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Debug|x86.Build.0 = Debug|x86 452 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|Any CPU.ActiveCfg = Release|Any CPU 453 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|Any CPU.Build.0 = Release|Any CPU 454 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 455 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|Mixed Platforms.Build.0 = Release|Any CPU 456 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|x64.ActiveCfg = Release|x86 457 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|x86.ActiveCfg = Release|x86 458 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261}.Release|x86.Build.0 = Release|x86 443 459 EndGlobalSection 444 460 GlobalSection(SolutionProperties) = preSolution … … 455 471 {989FE92B-484E-41EE-87E2-6A24AF0381D8} = {622F8E95-CDFC-4B4E-BBA7-3EE4E47DB52A} 456 472 {542AD827-817C-44E9-AD28-D6607BC4FA10} = {622F8E95-CDFC-4B4E-BBA7-3EE4E47DB52A} 473 {B09E8C65-8D4D-48B3-8E9A-F6FC52107261} = {622F8E95-CDFC-4B4E-BBA7-3EE4E47DB52A} 457 474 {EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC} = {E69A1E5F-63F7-493F-BBA2-163D6E321D44} 458 475 {CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE} = {E69A1E5F-63F7-493F-BBA2-163D6E321D44} -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive/3.4/ItemJob.cs
r6219 r6357 28 28 29 29 namespace HeuristicLab.Hive { 30 [Item(" Abstract Job", "Represents a executable hive job.")]30 [Item("Item Job", "Represents a executable hive job which contains a HeuristicLab Item.")] 31 31 [StorableClass] 32 32 public abstract class ItemJob : DeepCloneable, IJob { … … 86 86 #endregion 87 87 88 #region OptimizerEvents88 #region Item Events 89 89 protected virtual void RegisterItemEvents() { 90 90 item.ItemImageChanged += new EventHandler(item_ItemImageChanged); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Test/Program.cs
r6219 r6357 36 36 job.IndexInParentOptimizerList = 15; 37 37 38 byte[] data = PersistenceUtil.Serialize(job);38 //byte[] data = PersistenceUtil.Serialize(job); 39 39 40 var job2 = PersistenceUtil.Deserialize<OptimizerJob>(data);40 //var job2 = PersistenceUtil.Deserialize<OptimizerJob>(data); 41 41 42 42 #region Credentials 43 43 ServiceLocator.Instance.Username = "cneumuel"; 44 ServiceLocator.Instance.Password = " YouWillNeverKnow";44 ServiceLocator.Instance.Password = "Stormlord105."; 45 45 #endregion 46 46 47 GeneticAlgorithm ga= new GeneticAlgorithm();48 ga.Problem = new SingleObjectiveTestFunctionProblem();49 ga.Engine = new HiveEngine();50 ga.Elites.Value = 0;51 ga.PopulationSize.Value = 4;52 ga.MaximumGenerations.Value = 3;47 GeneticAlgorithm alg = new GeneticAlgorithm(); 48 alg.Problem = new SingleObjectiveTestFunctionProblem(); 49 alg.Engine = new HiveEngine() { ResourceNames = "CHRISTOPH-PC" }; 50 alg.Elites.Value = 0; 51 alg.PopulationSize.Value = 10; 52 alg.MaximumGenerations.Value = 3; 53 53 54 //var plugins = new List<IPluginDescription>();55 // IEnumerable<Type> types;56 // PersistenceUtil.Serialize(ga, out types);57 // PluginUtil.CollectDeclaringPlugins(plugins, types);54 //var alg = ContentManager.Load("Meta-GA - Meta Optimization Problem (Genetic Programming - Symbolic Regression 3.4 scaled)_small.hl") as GeneticAlgorithm; 55 //alg.Engine = new HiveEngine() { ResourceNames = "CHRISTOPH-PC" }; 56 //alg.PopulationSize.Value = 2; 57 //((MetaOptimizationProblem)alg.Problem).Repetitions.Value = 5; 58 58 59 alg.Start(); 59 60 60 ga.Start(); 61 62 while (ga.ExecutionState != Core.ExecutionState.Stopped && ga.ExecutionState != Core.ExecutionState.Paused) { 61 while (alg.ExecutionState != Core.ExecutionState.Stopped && alg.ExecutionState != Core.ExecutionState.Paused) { 63 62 Thread.Sleep(2000); 64 63 Console.Clear(); 65 Console.WriteLine(string.Join(Environment.NewLine, ga.Results.Select(x => x.ToString()).ToArray()));64 Console.WriteLine(string.Join(Environment.NewLine, alg.Results.Select(x => x.ToString()).ToArray())); 66 65 Console.WriteLine("---"); 67 66 Console.WriteLine("Log:"); 68 Console.WriteLine(string.Join(Environment.NewLine, ga.Engine.Log.Messages.ToArray())); 67 Console.WriteLine(string.Join(Environment.NewLine, alg.Engine.Log.Messages.ToArray())); 68 var exps = ((HiveEngine)alg.Engine).HiveExperiments; 69 foreach (var exp in exps) { 70 Console.WriteLine("# " + exp.ToString()); 71 Console.WriteLine(string.Join(Environment.NewLine, exp.Log.Messages.ToArray())); 72 } 69 73 } 70 Console.WriteLine("finished: " + ga.ExecutionState);74 Console.WriteLine("finished: " + alg.ExecutionState); 71 75 72 76 Console.WriteLine("Storing..."); 73 ContentManager.Save((IStorableContent) ga, string.Format("result_{0}.hl", DateTime.Now.ToString("yy.MM.dd HH;mm;ss")), true);77 ContentManager.Save((IStorableContent)alg, string.Format("result_{0}.hl", DateTime.Now.ToString("yy.MM.dd HH;mm;ss")), true); 74 78 Console.WriteLine("Finished"); 75 79 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Test/app.config
r6033 r6357 1 <?xml version="1.0" encoding="utf-8"?>1 <?xml version="1.0" encoding="utf-8"?> 2 2 <configuration> 3 3 <configSections> … … 52 52 </security> 53 53 </binding> 54 <binding name="wsHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 55 <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 56 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> 54 <binding name="wsHttpBinding_IHiveService" 55 closeTimeout="00:01:00" 56 openTimeout="00:01:00" 57 receiveTimeout="00:20:00" 58 sendTimeout="00:20:00" 59 bypassProxyOnLocal="false" 60 transactionFlow="false" 61 hostNameComparisonMode="StrongWildcard" 62 maxBufferPoolSize="2147483647" 63 maxReceivedMessageSize="2147483647" 64 messageEncoding="Text" 65 textEncoding="utf-8" 66 useDefaultWebProxy="true" 67 allowCookies="false"> 68 69 <readerQuotas maxDepth="2147483647" 70 maxStringContentLength="2147483647" 71 maxArrayLength="2147483647" 72 maxBytesPerRead="2147483647" 73 maxNameTableCharCount="2147483647"/> 74 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> 57 75 <security mode="Message"> 58 <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" 59 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" 76 <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> 77 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/> 60 78 </security> 61 79 </binding> … … 73 91 </identity> 74 92 </endpoint> 75 <endpoint address="http:// localhost/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService">93 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService"> 76 94 <identity> 77 <certificate encodedValue="AwAAAAEAAAAUAAAA fEKvcVixnJay+q4hCPFuO0JL5TQgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhCNN5wrUcXMmE/9xwp4TYa9MAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMTAxOTEwNTMxNVoXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXwC5TGcAffd/0oAWHtm0s6YXVXEgXgb1AYmBkkkhkKIFJG/e/Z0KSYbJepmSJD44W3oOAVm+x1DAsZxU79HahDYgWCuHLMm1TLpwSmYOQ0kV3pGHWHhiWV7h7oGLds/eqZ2EOpaNGryfEPnrA4VmxY91vV5/2BTeVSWG6F8lRKQIDAQABo0kwRzBFBgNVHQEEPjA8gBAR7kBnMRHO5gzThEqda0wWoRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghCNN5wrUcXMmE/9xwp4TYa9MAkGBSsOAwIdBQADgYEAoPwEG4QTDXhlxERNDfsZmM2IhEpV42ppz1kEah2oYKDa/ElIMVtvqLv6flVtg18ENN/mEJWiHZ3NyP3qr2Pip+sh+/2WBiSbOaukES/CM7OJn9kJCImH7M/xqM8pxqY8IfgM6iBVrVj9uHqj3j2BBck+cYY8fKyh3CFifMIp6ac="/>95 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/> 78 96 </identity> 79 97 </endpoint> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Test/app_services.config
r6198 r6357 52 52 </security> 53 53 </binding> 54 <binding name="wsHttpBinding_IHiveService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 55 <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 56 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> 54 <binding name="wsHttpBinding_IHiveService" 55 closeTimeout="00:01:00" 56 openTimeout="00:01:00" 57 receiveTimeout="00:20:00" 58 sendTimeout="00:20:00" 59 bypassProxyOnLocal="false" 60 transactionFlow="false" 61 hostNameComparisonMode="StrongWildcard" 62 maxBufferPoolSize="2147483647" 63 maxReceivedMessageSize="2147483647" 64 messageEncoding="Text" 65 textEncoding="utf-8" 66 useDefaultWebProxy="true" 67 allowCookies="false"> 68 69 <readerQuotas maxDepth="2147483647" 70 maxStringContentLength="2147483647" 71 maxArrayLength="2147483647" 72 maxBytesPerRead="2147483647" 73 maxNameTableCharCount="2147483647"/> 74 <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> 57 75 <security mode="Message"> 58 <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" 59 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" 76 <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> 77 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/> 60 78 </security> 61 79 </binding> … … 75 93 <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService"> 76 94 <identity> 77 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ==" 95 <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/> 78 96 </identity> 79 97 </endpoint> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HeuristicLab.HiveEngine.Views-3.4.csproj
r6217 r6357 103 103 <ItemGroup> 104 104 <Reference Include="HeuristicLab.Collections-3.3"> 105 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath>105 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath> 106 106 </Reference> 107 107 <Reference Include="HeuristicLab.Common-3.3"> 108 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>108 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath> 109 109 </Reference> 110 110 <Reference Include="HeuristicLab.Core-3.3"> 111 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>111 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath> 112 112 </Reference> 113 113 <Reference Include="HeuristicLab.Core.Views-3.3"> 114 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Core.Views-3.3.dll</HintPath>114 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core.Views-3.3.dll</HintPath> 115 115 </Reference> 116 116 <Reference Include="HeuristicLab.MainForm-3.3"> 117 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm-3.3.dll</HintPath>117 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm-3.3.dll</HintPath> 118 118 </Reference> 119 119 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3"> 120 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>120 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath> 121 121 </Reference> 122 122 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 123 <HintPath> ..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>123 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 124 124 </Reference> 125 125 <Reference Include="System" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs
r6219 r6357 37 37 [Item("Hive Engine", "Engine for parallel execution on the hive. You need enable `Parallel` for at least one operator in your operator graph to have all childoperations parallelized. Also those childoperations must not have sideeffects on a higher scope.")] 38 38 public class HiveEngine : Engine { 39 private static object locker = new object(); 39 40 private static object logLocker = new object(); 40 41 private CancellationToken cancellationToken; 41 42 private bool firstRun = true; 43 42 44 [Storable] 43 45 private IOperator currentOperator; … … 136 138 OperationCollection coll; 137 139 IAtomicOperation operation; 138 TaskScheduler.UnobservedTaskException += new EventHandler<UnobservedTaskExceptionEventArgs>(TaskScheduler_UnobservedTaskException); 139 140 this.OnlinePlugins = ServiceLocator.Instance.CallHiveService(s => s.GetPlugins()).Where(x => x.IsLocal == false).ToList(); 141 this.AlreadyUploadedPlugins = new List<Plugin>(); 142 143 while (ExecutionStack.Count > 0) { 140 141 if (firstRun) { 142 TaskScheduler.UnobservedTaskException += new EventHandler<UnobservedTaskExceptionEventArgs>(TaskScheduler_UnobservedTaskException); 143 this.OnlinePlugins = ServiceLocator.Instance.CallHiveService(s => s.GetPlugins()).Where(x => x.IsLocal == false).ToList(); 144 this.AlreadyUploadedPlugins = new List<Plugin>(); 145 firstRun = false; 146 } 147 148 while (executionStack.Count > 0) { 144 149 cancellationToken.ThrowIfCancellationRequested(); 145 150 146 next = ExecutionStack.Pop(); 151 next = executionStack.Pop(); 152 bool isOpCollection = next is OperationCollection; 153 int collCount = isOpCollection ? ((OperationCollection)next).Count : 0; 154 string opName = !isOpCollection ? ((IAtomicOperation)next).Operator.Name : "OpCollection"; 155 147 156 if (next is OperationCollection) { 148 157 coll = (OperationCollection)next; 149 if (coll.Parallel) { 158 159 bool isPMOEvaluator = coll.Count > 0 && coll.First() is HeuristicLab.Core.ExecutionContext && ((HeuristicLab.Core.ExecutionContext)coll.First()).Operator.GetType().Name == "PMOEvaluator"; 160 bool isAlgorithmEvaluator = coll.Count > 0 && coll.First() is HeuristicLab.Core.ExecutionContext && ((HeuristicLab.Core.ExecutionContext)coll.First()).Operator.GetType().Name == "AlgorithmEvaluator"; 161 162 if (coll.Parallel && isPMOEvaluator) { 163 Task[] tasks = new Task[coll.Count]; 164 Stack<IOperation>[] stacks = new Stack<IOperation>[coll.Count]; 165 for (int i = 0; i < coll.Count; i++) { 166 stacks[i] = new Stack<IOperation>(); 167 stacks[i].Push(coll[i]); 168 tasks[i] = Task.Factory.StartNew(Run, stacks[i], cancellationToken); 169 } 170 try { 171 Task.WaitAll(tasks); 172 } 173 catch (AggregateException ex) { 174 OperationCollection remaining = new OperationCollection() { Parallel = true }; 175 for (int i = 0; i < stacks.Length; i++) { 176 if (stacks[i].Count == 1) 177 remaining.Add(stacks[i].Pop()); 178 if (stacks[i].Count > 1) { 179 OperationCollection ops = new OperationCollection(); 180 while (stacks[i].Count > 0) 181 ops.Add(stacks[i].Pop()); 182 remaining.Add(ops); 183 } 184 } 185 if (remaining.Count > 0) executionStack.Push(remaining); 186 throw ex; 187 } 188 } else if (coll.Parallel) { 150 189 // clone the parent scope here and reuse it for each operation. otherwise for each job the whole scope-tree first needs to be copied and then cleaned, which causes a lot of work for the Garbage Collector 151 190 IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone(); … … 158 197 } 159 198 160 IScope[] scopes = ExecuteOnHive(jobs, parentScopeClone, cancellationToken); 161 //IScope[] scopes = ExecuteLocally(jobs, parentScopeClone, cancellationToken); 199 var experiment = CreateHiveExperiment(); 200 IScope[] scopes = ExecuteOnHive(experiment, jobs, parentScopeClone, cancellationToken); 201 DisposeHiveExperiment(experiment); 162 202 163 203 for (int i = 0; i < coll.Count; i++) { … … 178 218 } 179 219 catch (Exception ex) { 180 ExecutionStack.Push(operation);220 executionStack.Push(operation); 181 221 if (ex is OperationCanceledException) throw ex; 182 222 else throw new OperatorExecutionException(operation.Operator, ex); 183 223 } 184 if (next != null) ExecutionStack.Push(next);224 if (next != null) executionStack.Push(next); 185 225 186 226 if (operation.Operator.Breakpoint) { … … 227 267 /// </summary> 228 268 /// <param name="jobs"></param> 229 private IScope[] ExecuteOnHive( EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) {269 private IScope[] ExecuteOnHive(RefreshableHiveExperiment refreshableHiveExperiment, EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) { 230 270 LogMessage(string.Format("Executing {0} operations on the hive.", jobs.Length)); 231 271 IScope[] scopes = new Scope[jobs.Length]; 232 272 object locker = new object(); 233 273 IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>(); 234 var hiveExperiment = new HiveExperiment();274 var hiveExperiment = refreshableHiveExperiment.HiveExperiment; 235 275 236 276 try { 237 277 List<Guid> remainingJobIds = new List<Guid>(); 238 278 239 // create hive experiment 279 // create upload-tasks 280 var uploadTasks = new List<Task<Job>>(); 281 for (int i = 0; i < jobs.Length; i++) { 282 hiveExperiment.HiveJobs.Add(new EngineHiveJob(jobs[i], parentScopeClone)); 283 284 // shuffle random variable to avoid the same random sequence in each operation; todo: does not yet work (it cannot find the random variable) 285 IRandom random = FindRandomParameter(jobs[i].InitialOperation as IExecutionContext); 286 if (random != null) 287 random.Reset(random.Next()); 288 } 289 ExperimentManagerClient.StartExperiment((e) => { 290 LogException(e); 291 }, refreshableHiveExperiment); 292 293 // do polling until experiment is finished and all jobs are downloaded 294 while (!refreshableHiveExperiment.AllJobsFinished()) { 295 Thread.Sleep(500); 296 this.ExecutionTimeOnHive = TimeSpan.FromMilliseconds(hiveExperiments.Sum(x => x.HiveExperiment.ExecutionTime.TotalMilliseconds)); 297 cancellationToken.ThrowIfCancellationRequested(); 298 } 299 LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableHiveExperiment.ToString(), refreshableHiveExperiment.HiveExperiment.ExecutionTime)); 300 301 // get scopes 302 int j = 0; 303 foreach (var hiveJob in hiveExperiment.HiveJobs) { 304 if (hiveJob.Job.State != JobState.Finished) 305 throw new HiveEngineException("Job failed: " + hiveJob.Job.StateLog.Last().Exception); 306 307 var scope = ((IAtomicOperation)((EngineJob)hiveJob.ItemJob).InitialOperation).Scope; 308 scopes[j++] = scope; 309 } 310 return scopes; 311 } 312 catch (OperationCanceledException e) { 313 lock (locker) { 314 if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id); 315 } 316 throw e; 317 } 318 catch (Exception e) { 319 lock (locker) { 320 if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id); 321 } 322 LogException(e); 323 throw e; 324 } 325 } 326 327 private RefreshableHiveExperiment CreateHiveExperiment() { 328 lock (locker) { 329 var hiveExperiment = new HiveExperiment(); 240 330 hiveExperiment.Name = "HiveEngine Run " + hiveExperiments.Count; 241 331 hiveExperiment.DateCreated = DateTime.Now; … … 245 335 refreshableHiveExperiment.IsControllable = false; 246 336 hiveExperiments.Add(refreshableHiveExperiment); 247 248 // create upload-tasks 249 var uploadTasks = new List<Task<Job>>(); 250 for (int i = 0; i < jobs.Length; i++) { 251 hiveExperiment.HiveJobs.Add(new EngineHiveJob(jobs[i], parentScopeClone)); 252 253 // shuffle random variable to avoid the same random sequence in each operation; todo: does not yet work (it cannot find the random variable) 254 IRandom random = FindRandomParameter(jobs[i].InitialOperation as IExecutionContext); 255 if (random != null) 256 random.Reset(random.Next()); 257 } 258 ExperimentManagerClient.StartExperiment((e) => { 259 LogException(e); 260 }, refreshableHiveExperiment); 261 262 // do polling until experiment is finished and all jobs are downloaded 263 while (!refreshableHiveExperiment.AllJobsFinished()) { 264 Thread.Sleep(500); 265 this.ExecutionTimeOnHive = TimeSpan.FromMilliseconds(hiveExperiments.Sum(x => x.HiveExperiment.ExecutionTime.TotalMilliseconds)); 266 cancellationToken.ThrowIfCancellationRequested(); 267 } 268 LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableHiveExperiment.ToString(), refreshableHiveExperiment.HiveExperiment.ExecutionTime)); 269 270 // get scopes 271 int j = 0; 272 foreach (var hiveJob in hiveExperiment.HiveJobs) { 273 var scope = ((IAtomicOperation) ((EngineJob)hiveJob.ItemJob).InitialOperation).Scope; 274 scopes[j++] = scope; 275 } 276 refreshableHiveExperiment.RefreshAutomatically = false; 277 DeleteHiveExperiment(hiveExperiment.Id); 278 ClearData(refreshableHiveExperiment); 279 return scopes; 280 } 281 catch (OperationCanceledException e) { 282 lock (locker) { 283 if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id); 284 } 285 throw e; 286 } 287 catch (Exception e) { 288 lock (locker) { 289 if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id); 290 } 291 LogException(e); 292 throw e; 293 } 337 return refreshableHiveExperiment; 338 } 339 } 340 341 private void DisposeHiveExperiment(RefreshableHiveExperiment refreshableHiveExperiment) { 342 refreshableHiveExperiment.RefreshAutomatically = false; 343 DeleteHiveExperiment(refreshableHiveExperiment.HiveExperiment.Id); 344 ClearData(refreshableHiveExperiment); 294 345 } 295 346 … … 306 357 }, 5, string.Format("Could not delete jobs")); 307 358 } 308 359 309 360 private List<Guid> GetResourceIds() { 310 361 return ServiceLocator.Instance.CallHiveService(service => { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
r6267 r6357 103 103 where child.ParentJobId == ar.Job.JobId 104 104 select child).Count() > 0 105 orderby ar.Job.Priority descending105 orderby ar.Job.Priority, db.Random() descending 106 106 select Convert.ToDto(ar.Job); 107 107 return count == 0 ? query.ToArray() : query.Take(count).ToArray(); … … 121 121 && ar.Job.CoresNeeded <= slave.FreeCores 122 122 && ar.Job.MemoryNeeded <= slave.FreeMemory 123 orderby ar.Job.Priority descending123 orderby ar.Job.Priority, db.Random() descending // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned) 124 124 select Convert.ToDto(ar.Job); 125 125 var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray(); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.cs
r6229 r6357 1 using System; 2 using System.Data.Linq.Mapping; 1 3 namespace HeuristicLab.Services.Hive.DataAccess { 2 4 partial class SlaveStatistics { … … 4 6 5 7 partial class HiveDataContext { 8 // source: http://stackoverflow.com/questions/648196/random-row-from-linq-to-sql 9 [Function(Name = "NEWID", IsComposable = true)] 10 public Guid Random() { 11 // to prove not used by our C# code... 12 throw new NotImplementedException(); 13 } 6 14 } 7 15 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs
r6267 r6357 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Services.Hive.Common;26 using HeuristicLab.Services.Hive.Common.DataTransfer;27 using HeuristicLab.Services.Hive.Common.ServiceContracts;28 25 using Microsoft.VisualStudio.TestTools.UnitTesting; 29 26 30 27 namespace HeuristicLab.Services.Hive.Tests { 31 28 29 using HeuristicLab.Services.Hive.Common; 30 using HeuristicLab.Services.Hive.Common.DataTransfer; 31 using HeuristicLab.Services.Hive.Common.ServiceContracts; 32 32 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 33 33 … … 304 304 // Name = "Slave " + i, 305 305 // IsAllowedToCalculate = true, 306 // SlaveState = SlaveState.Idle,306 // SlaveState = DT.SlaveState.Idle, 307 307 // CpuSpeed = 2800, 308 308 // FreeCores = 2, -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs
r6269 r6357 41 41 // assign new job 42 42 if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) { 43 var availableJobs = dao.GetWaitingJobs(slave, 1); 44 if (availableJobs.Count() > 0) { 45 var job = availableJobs.First(); 46 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id)); 47 AssignJob(slave, job); 48 } 43 // this part needs to be in a serializable transaction to avoid race conditions 44 //trans.UseTransaction(() => { 45 var availableJobs = dao.GetWaitingJobs(slave, 1); 46 if (availableJobs.Count() > 0) { 47 var job = availableJobs.First(); 48 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id)); 49 AssignJob(slave, job); 50 } 51 //}, true); 49 52 } 50 53 }
Note: See TracChangeset
for help on using the changeset viewer.