Changeset 5314 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
- Timestamp:
- 01/17/11 20:03:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r5280 r5314 26 26 using System.ServiceModel; 27 27 using System.Threading; 28 using HeuristicLab.Clients.Hive.Slave;29 28 using HeuristicLab.Clients.Hive.Slave.ServiceContracts; 30 29 using HeuristicLab.Common; … … 34 33 35 34 36 namespace HeuristicLab.Clients.Hive.S alve {35 namespace HeuristicLab.Clients.Hive.Slave { 37 36 /// <summary> 38 37 /// The core component of the Hive Client … … 160 159 ShutdownCore(); 161 160 break; 161 case MessageContainer.MessageType.HardPause: 162 doHardPause(); 163 break; 164 case MessageContainer.MessageType.SoftPause: 165 doSoftPause(); 166 break; 167 case MessageContainer.MessageType.Restart: 168 doRestart(); 169 break; 162 170 } 163 171 } else { 164 172 ClientCom.LogMessage("Unknown MessageContainer: " + container); 165 173 } 174 } 175 176 /// <summary> 177 /// reinitializes everything and continues operation, 178 /// can be called after SoftPause() or HardPause() 179 /// </summary> 180 public void Restart() { 181 MessageContainer mc = new MessageContainer(MessageContainer.MessageType.Restart); 182 MessageQueue.GetInstance().AddMessage(mc); 183 } 184 185 private void doRestart() { 186 ClientCom.LogMessage("Restart received"); 187 StartHeartbeats(); 188 ClientCom.LogMessage("Restart done"); 189 } 190 191 /// <summary> 192 /// wait for jobs to finish, then pause client 193 /// </summary> 194 public void SoftPause() { 195 MessageContainer mc = new MessageContainer(MessageContainer.MessageType.SoftPause); 196 MessageQueue.GetInstance().AddMessage(mc); 197 } 198 199 private void doSoftPause() { 200 ClientCom.LogMessage("Soft pause received"); 201 202 //TODO: jobs get removed from Jobs map, is this a problem? 203 foreach (Job job in Jobs.Values) { 204 engines[job.Id].Pause(); 205 JobData sJob = engines[job.Id].GetFinishedJob(); 206 job.Exception = engines[job.Id].CurrentException; 207 job.ExecutionTime = engines[job.Id].ExecutionTime; 208 209 try { 210 ClientCom.LogMessage("Sending the paused job with id: " + job.Id); 211 wcfService.UpdateJob(job, sJob); 212 SlaveStatusInfo.JobsProcessed++; //TODO: count or not count, thats the question 213 } 214 catch (Exception e) { 215 ClientCom.LogMessage("Transmitting to server failed. Storing the paused job with id: " + job.Id + " to hdd (" + e.ToString() + ")"); 216 } 217 finally { 218 KillAppDomain(job.Id); // kill app-domain in every case 219 } 220 } 221 222 heartbeatManager.StopHeartBeat(); 223 WcfService.Instance.Disconnect(); 224 ClientCom.LogMessage("Soft pause done"); 225 } 226 227 /// <summary> 228 /// pause slave immediately 229 /// </summary> 230 public void HardPause() { 231 MessageContainer mc = new MessageContainer(MessageContainer.MessageType.HardPause); 232 MessageQueue.GetInstance().AddMessage(mc); 233 } 234 235 private void doHardPause() { 236 ClientCom.LogMessage("Hard pause received"); 237 heartbeatManager.StopHeartBeat(); 238 239 lock (engines) { 240 ClientCom.LogMessage("engines locked"); 241 foreach (KeyValuePair<Guid, AppDomain> kvp in appDomains) { 242 ClientCom.LogMessage("Shutting down Appdomain for " + kvp.Key); 243 appDomains[kvp.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException); 244 AppDomain.Unload(kvp.Value); 245 } 246 } 247 WcfService.Instance.Disconnect(); 248 ClientCom.LogMessage("Hard pause done"); 166 249 } 167 250 … … 172 255 } 173 256 257 /// <summary> 258 /// hard shutdown, should be called before the the application is exited 259 /// </summary> 174 260 private void ShutdownCore() { 175 261 ClientCom.LogMessage("Shutdown Signal received");
Note: See TracChangeset
for help on using the changeset viewer.