Changeset 2608
- Timestamp:
- 01/06/10 14:30:05 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.Core/3.2
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
r2591 r2608 38 38 using System.IO; 39 39 using System.Runtime.Serialization.Formatters.Binary; 40 using HeuristicLab.Tracing; 40 41 41 42 namespace HeuristicLab.Hive.Server.Core { … … 89 90 ITransaction tx = null; 90 91 92 HiveLogger.Info(this.ToString() + ": Server Heartbeat ticked"); 93 91 94 try { 92 95 IClientAdapter clientAdapter = … … 104 107 105 108 if (!lastHeartbeats.ContainsKey(client.Id)) { 109 HiveLogger.Info(this.ToString() + ": Client " + client.Id + " wasn't offline but hasn't sent heartbeats - setting offline"); 106 110 client.State = State.offline; 107 111 clientAdapter.Update(client); 108 foreach (Job job in jobAdapter.GetActiveJobsOf(client)) { 112 HiveLogger.Info(this.ToString() + ": Client " + client.Id + " wasn't offline but hasn't sent heartbeats - Resetting all his jobs"); 113 foreach (Job job in jobAdapter.GetActiveJobsOf(client)) { 109 114 jobManager.ResetJobsDependingOnResults(job); 110 115 } … … 116 121 if (dif.TotalSeconds > ApplicationConstants.HEARTBEAT_MAX_DIF) { 117 122 // if client calculated jobs, the job must be reset 123 HiveLogger.Info(this.ToString() + ": Client timed out and is on RESET"); 118 124 foreach (Job job in jobAdapter.GetActiveJobsOf(client)) { 119 125 jobManager.ResetJobsDependingOnResults(job); … … 136 142 heartbeatLock.ExitUpgradeableReadLock(); 137 143 } else { 144 //TODO: RLY neccesary? 145 //HiveLogger.Info(this.ToString() + ": Client " + client.Id + " has wrong state: Shouldn't have offline or nullstate, has " + client.State); 138 146 heartbeatLock.EnterWriteLock(); 147 //HiveLogger.Info(this.ToString() + ": Client " + client.Id + " has wrong state: Resetting all his jobs"); 139 148 if (lastHeartbeats.ContainsKey(client.Id)) 140 149 lastHeartbeats.Remove(client.Id); … … 232 241 /// <returns></returns> 233 242 public ResponseHB ProcessHeartBeat(HeartBeatData hbData) { 243 234 244 ISession session = factory.GetSessionForCurrentThread(); 235 245 ITransaction tx = null; 236 246 247 HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat for Client " + hbData.ClientId); 248 237 249 try { 250 HiveLogger.Info(this.ToString() + ": BEGIN Fetching Adapters"); 238 251 IClientAdapter clientAdapter = 239 252 session.GetDataAdapter<ClientInfo, IClientAdapter>(); 240 253 241 IJobAdapter jobAdapter = 254 IJobAdapter jobAdapter = 242 255 session.GetDataAdapter<Job, IJobAdapter>(); 243 256 HiveLogger.Info(this.ToString() + ": END Fetched Adapters"); 257 HiveLogger.Info(this.ToString() + ": BEGIN Starting Transaction"); 244 258 tx = session.BeginTransaction(); 259 HiveLogger.Info(this.ToString() + ": END Started Transaction"); 245 260 246 261 ResponseHB response = new ResponseHB(); 247 262 response.ActionRequest = new List<MessageContainer>(); 248 263 264 HiveLogger.Info(this.ToString() + ": BEGIN Started Client Fetching"); 249 265 ClientInfo client = clientAdapter.GetById(hbData.ClientId); 250 266 HiveLogger.Info(this.ToString() + ": END Finished Client Fetching"); 251 267 // check if the client is logged in 252 268 if (client.State == State.offline || client.State == State.nullState) { 253 269 response.Success = false; 254 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN; 270 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN; 255 271 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 272 273 HiveLogger.Error(this.ToString() + " ProcessHeartBeat: Client state null or offline: " + client); 274 256 275 return response; 257 276 } … … 261 280 262 281 // save timestamp of this heartbeat 282 HiveLogger.Info(this.ToString() + ": BEGIN Locking for Heartbeats"); 263 283 heartbeatLock.EnterWriteLock(); 284 HiveLogger.Info(this.ToString() + ": END Locked for Heartbeats"); 264 285 if (lastHeartbeats.ContainsKey(hbData.ClientId)) { 265 286 lastHeartbeats[hbData.ClientId] = DateTime.Now; … … 271 292 // check if client has a free core for a new job 272 293 // if true, ask scheduler for a new job for this client 273 if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) 294 HiveLogger.Info(this.ToString() + ": BEGIN Looking for Client Jobs"); 295 if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) { 274 296 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob)); 275 else297 } else { 276 298 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 277 299 } 300 HiveLogger.Info(this.ToString() + ": END Looked for Client Jobs"); 278 301 response.Success = true; 279 302 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED; 280 303 304 HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat Jobs"); 281 305 processJobProcess(hbData, jobAdapter, clientAdapter, response); 306 HiveLogger.Info(this.ToString() + ": END Processed Heartbeat Jobs"); 307 282 308 clientAdapter.Update(client); 283 309 284 310 tx.Commit(); 311 HiveLogger.Info(this.ToString() + ": END Processed Heartbeat for Client " + hbData.ClientId); 285 312 return response; 286 313 } … … 304 331 /// <param name="response"></param> 305 332 private void processJobProcess(HeartBeatData hbData, IJobAdapter jobAdapter, IClientAdapter clientAdapter, ResponseHB response) { 333 HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId); 334 306 335 if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) { 307 336 List<Job> jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId))); … … 309 338 response.Success = false; 310 339 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 340 HiveLogger.Error(this.ToString() + " processJobProcess: There is no job calculated by this user " + hbData.ClientId); 311 341 return; 312 342 } … … 317 347 response.Success = false; 318 348 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 349 HiveLogger.Error(this.ToString() + " processJobProcess: There is no job calculated by this user " + hbData.ClientId + " Job: " + curJob); 319 350 } else if (curJob.State == State.abort) { 320 351 // a request to abort the job has been set … … 345 376 if (newAssignedJobs.ContainsKey(currJob.Id)) { 346 377 newAssignedJobs[currJob.Id]--; 347 378 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client); 348 379 if (newAssignedJobs[currJob.Id] <= 0) { 380 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client); 381 349 382 currJob.State = State.offline; 350 383 jobAdapter.Update(currJob); 384 385 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id)); 386 351 387 newAssignedJobs.Remove(currJob.Id); 352 388 } 353 389 } else { 390 HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats: " + currJob); 354 391 currJob.State = State.offline; 355 392 jobAdapter.Update(currJob); … … 358 395 } else { 359 396 lock (newAssignedJobs) { 360 if (newAssignedJobs.ContainsKey(currJob.Id)) 397 398 if (newAssignedJobs.ContainsKey(currJob.Id)) { 399 HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob); 361 400 newAssignedJobs.Remove(currJob.Id); 401 } 362 402 } 363 403 } … … 391 431 response.Job = computableJob; 392 432 response.Success = true; 433 HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + computableJob.JobInfo + " for user " + clientId); 393 434 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 394 435 lock (newAssignedJobs) { … … 397 438 } 398 439 } else { 440 HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId); 399 441 response.Success = false; 400 442 response.Job = null; … … 439 481 response.Job = job2Calculate; 440 482 response.Success = true; 483 HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + job2Calculate + " for user " + clientId); 441 484 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 442 485 lock (newAssignedJobs) { … … 448 491 response.Job = null; 449 492 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 493 HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId); 450 494 } 451 495 … … 468 512 Stream stream, 469 513 bool finished) { 514 515 HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - main method:"); 516 470 517 ISession session = factory.GetSessionForCurrentThread(); 471 518 ITransaction tx = null; … … 482 529 //important - repeatable read isolation level is required here, 483 530 //otherwise race conditions could occur when writing the stream into the DB 484 tx = session.BeginTransaction(485 TransactionIsolationLevel.RepeatableRead);531 //just removed TransactionIsolationLevel.RepeatableRead 532 tx = session.BeginTransaction(); 486 533 487 534 ResponseResultReceived response = … … 520 567 tx.Commit(); 521 568 } 522 569 HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage:"); 523 570 return response; 524 571 } 525 572 catch (Exception ex) { 573 HiveLogger.Error(this.ToString() + " ProcessJobResult: Exception raised: " + ex); 526 574 if (tx != null) 527 575 tx.Rollback(); … … 546 594 Exception exception, 547 595 bool finished) { 596 597 HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - SUB method: " + jobId); 598 548 599 ISession session = factory.GetSessionForCurrentThread(); 600 549 601 ITransaction tx = null; 550 602 … … 556 608 IJobResultsAdapter jobResultAdapter = 557 609 session.GetDataAdapter<JobResult, IJobResultsAdapter>(); 558 610 611 //should fetch the existing transaction 559 612 tx = session.BeginTransaction(); 560 613 … … 575 628 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID; 576 629 response.JobId = jobId; 630 631 HiveLogger.Error(this.ToString() + " ProcessJobResult: No job with Id " + jobId); 632 577 633 tx.Rollback(); 578 634 return response; … … 581 637 response.Success = false; 582 638 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED; 639 640 HiveLogger.Error(this.ToString() + " ProcessJobResult: Job was aborted! " + job.JobInfo); 641 583 642 tx.Rollback(); 584 643 return response; … … 588 647 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 589 648 response.JobId = jobId; 649 650 HiveLogger.Error(this.ToString() + " ProcessJobResult: Job is not being calculated (client = null)! " + job.JobInfo); 651 590 652 tx.Rollback(); 591 653 return response; … … 595 657 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB; 596 658 response.JobId = jobId; 659 660 HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Client for this Job! " + job.JobInfo + ", Sending Client is: " + clientId); 661 597 662 tx.Rollback(); 598 663 return response; … … 602 667 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED; 603 668 response.JobId = jobId; 669 670 HiveLogger.Error(this.ToString() + " ProcessJobResult: Job already finished! " + job.JobInfo + ", Sending Client is: " + clientId); 671 604 672 tx.Rollback(); 605 673 return response; … … 613 681 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE; 614 682 response.JobId = jobId; 683 684 HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Job State, job is: " + job.JobInfo); 685 615 686 tx.Rollback(); 616 687 return response; … … 649 720 response.finished = finished; 650 721 response.JobResultId = jobResult.Id; 651 652 tx.Commit(); 722 723 //Removed for Testing 724 //tx.Commit(); 725 HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage - SUB method: " + jobId); 653 726 return response; 654 727 } … … 697 770 /// <returns></returns> 698 771 public Response Logout(Guid clientId) { 772 773 HiveLogger.Info("Client logged out " + clientId); 774 699 775 ISession session = factory.GetSessionForCurrentThread(); 700 776 ITransaction tx = null; … … 770 846 response.Success = false; 771 847 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST; 848 HiveLogger.Error(this.ToString() + " IsJobStillNeeded: Job doesn't exist (anymore)! " + jobId); 772 849 return response; 773 850 } … … 775 852 response.Success = true; 776 853 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED; 854 HiveLogger.Error(this.ToString() + " IsJobStillNeeded: already finished! " + job); 777 855 return response; 778 856 } -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj
r2117 r2608 117 117 <ItemGroup> 118 118 <None Include="app.config" /> 119 <None Include="ClassDiagram1.cd" /> 119 120 <None Include="HeuristicLab.snk" /> 120 121 <EmbeddedResource Include="Authorization\HivePermissionSet.xsd"> … … 156 157 <Name>HeuristicLab.Security.Contracts-3.2</Name> 157 158 </ProjectReference> 159 <ProjectReference Include="..\..\HeuristicLab.Tracing\3.2\HeuristicLab.Tracing-3.2.csproj"> 160 <Project>{EE2034D9-6E27-48A1-B855-42D45F69A4FC}</Project> 161 <Name>HeuristicLab.Tracing-3.2</Name> 162 </ProjectReference> 158 163 </ItemGroup> 159 164 <ItemGroup> -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs
r2117 r2608 32 32 using System.Data; 33 33 using System.IO; 34 using HeuristicLab.Tracing; 34 35 35 36 namespace HeuristicLab.Hive.Server.Core { … … 65 66 66 67 public void ResetJobsDependingOnResults(Job job) { 68 69 HiveLogger.Info(this.ToString() + ": Setting job " + job.Id + " offline"); 70 67 71 ISession session = factory.GetSessionForCurrentThread(); 68 72 ITransaction tx = null; … … 122 126 123 127 void checkForDeadJobs() { 128 HiveLogger.Info(this.ToString() + " Searching for dead Jobs"); 124 129 ISession session = factory.GetSessionForCurrentThread(); 125 130 -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Properties/Settings.Designer.cs
r1468 r2608 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:2.0.50727. 30534 // Runtime Version:2.0.50727.4927 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 26 26 [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 27 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 [global::System.Configuration.DefaultSettingValueAttribute("Data Source=1 0.20.71.10;Initial Catalog=HeuristicLab.Hive;Persist Security Info=T" +29 " rue;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true")]28 [global::System.Configuration.DefaultSettingValueAttribute("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive;Persist Security Info=Tru" + 29 "e;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true")] 30 30 public string HiveServerConnectionString { 31 31 get { -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Properties/Settings.settings
r1468 r2608 4 4 <Settings> 5 5 <Setting Name="HiveServerConnectionString" Type="System.String" Scope="Application"> 6 <Value Profile="(Default)">Data Source=1 0.20.71.10;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</Value>6 <Value Profile="(Default)">Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</Value> 7 7 </Setting> 8 8 </Settings> -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/app.config
r1530 r2608 9 9 <HeuristicLab.Hive.Server.Core.Properties.Settings> 10 10 <setting name="HiveServerConnectionString" serializeAs="String"> 11 <value>Data Source=1 0.20.71.10;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</value>11 <value>Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</value> 12 12 </setting> 13 13 </HeuristicLab.Hive.Server.Core.Properties.Settings>
Note: See TracChangeset
for help on using the changeset viewer.