- Timestamp:
- 03/12/10 10:57:21 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
r2904 r3011 40 40 using HeuristicLab.Tracing; 41 41 using Linq = HeuristicLab.Hive.Server.LINQDataAccess; 42 using System.Transactions; 42 43 43 44 namespace HeuristicLab.Hive.Server.Core { … … 57 58 new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); 58 59 59 private ISessionFactory factory;60 //private ISessionFactory factory; 60 61 private ILifecycleManager lifecycleManager; 61 62 private IInternalJobManager jobManager; 62 private IScheduler scheduler; 63 64 Linq.ClientDao clientDao = new Linq.ClientDao(); 63 private IScheduler scheduler; 65 64 66 65 private static int PENDING_TIMEOUT = 100; … … 72 71 /// </summary> 73 72 public ClientCommunicator() { 74 factory = ServiceLocator.GetSessionFactory();73 //factory = ServiceLocator.GetSessionFactory(); 75 74 76 75 lifecycleManager = ServiceLocator.GetLifecycleManager(); … … 90 89 /// <param name="e"></param> 91 90 void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) { 92 ISession session = factory.GetSessionForCurrentThread();93 ITransaction tx = null;94 95 91 HiveLogger.Info(this.ToString() + ": Server Heartbeat ticked"); 96 92 97 try { 98 IClientAdapter clientAdapter = 99 session.GetDataAdapter<ClientInfo, IClientAdapter>(); 100 IJobAdapter jobAdapter = 101 session.GetDataAdapter<Job, IJobAdapter>(); 102 103 tx = session.BeginTransaction(); 104 105 List<ClientInfo> allClients = new List<ClientInfo>(clientAdapter.GetAll()); 106 107 foreach (ClientInfo client in allClients) { 93 using (TransactionScope scope = new TransactionScope()) { 94 95 List<ClientDto> allClients = new List<ClientDto>(DaoLocator.ClientDao.FindAll()); 96 97 foreach (ClientDto client in allClients) { 108 98 if (client.State != State.offline && client.State != State.nullState) { 109 99 heartbeatLock.EnterUpgradeableReadLock(); 110 100 111 101 if (!lastHeartbeats.ContainsKey(client.Id)) { 112 HiveLogger.Info(this.ToString() + ": Client " + client.Id + " wasn't offline but hasn't sent heartbeats - setting offline"); 102 HiveLogger.Info(this.ToString() + ": Client " + client.Id + 103 " wasn't offline but hasn't sent heartbeats - setting offline"); 113 104 client.State = State.offline; 114 clientAdapter.Update(client); 115 HiveLogger.Info(this.ToString() + ": Client " + client.Id + " wasn't offline but hasn't sent heartbeats - Resetting all his jobs"); 116 foreach (Job job in jobAdapter.GetActiveJobsOf(client)) { 105 DaoLocator.ClientDao.Update(client); 106 //clientAdapter.Update(client); 107 HiveLogger.Info(this.ToString() + ": Client " + client.Id + 108 " wasn't offline but hasn't sent heartbeats - Resetting all his jobs"); 109 foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) { 117 110 jobManager.ResetJobsDependingOnResults(job); 118 111 } 119 } else { 112 } 113 else { 120 114 DateTime lastHbOfClient = lastHeartbeats[client.Id]; 121 115 … … 125 119 // if client calculated jobs, the job must be reset 126 120 HiveLogger.Info(this.ToString() + ": Client timed out and is on RESET"); 127 foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {121 foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) { 128 122 jobManager.ResetJobsDependingOnResults(job); 129 123 lock (newAssignedJobs) { … … 135 129 // client must be set offline 136 130 client.State = State.offline; 137 clientAdapter.Update(client); 131 132 //clientAdapter.Update(client); 133 DaoLocator.ClientDao.Update(client); 138 134 139 135 heartbeatLock.EnterWriteLock(); … … 144 140 145 141 heartbeatLock.ExitUpgradeableReadLock(); 146 } else { 142 } 143 else { 147 144 //TODO: RLY neccesary? 148 145 //HiveLogger.Info(this.ToString() + ": Client " + client.Id + " has wrong state: Shouldn't have offline or nullstate, has " + client.State); … … 151 148 if (lastHeartbeats.ContainsKey(client.Id)) 152 149 lastHeartbeats.Remove(client.Id); 153 foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {150 foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) { 154 151 jobManager.ResetJobsDependingOnResults(job); 155 152 } … … 157 154 } 158 155 } 159 CheckForPendingJobs(jobAdapter); 160 161 tx.Commit(); 162 } 163 catch (Exception ex) { 164 if (tx != null) 165 tx.Rollback(); 166 throw ex; 167 } 168 finally { 169 if (session != null) 170 session.EndSession(); 171 } 172 } 173 174 private void CheckForPendingJobs(IJobAdapter jobAdapter) { 175 IList<Job> pendingJobsInDB = new List<Job>(jobAdapter.GetJobsByState(State.pending)); 176 177 foreach (Job currJob in pendingJobsInDB) { 156 CheckForPendingJobs(); 157 DaoLocator.DestroyContext(); 158 scope.Complete(); 159 } 160 } 161 162 private void CheckForPendingJobs() { 163 IList<JobDto> pendingJobsInDB = new List<JobDto>(DaoLocator.JobDao.GetJobsByState(State.pending)); 164 165 foreach (JobDto currJob in pendingJobsInDB) { 178 166 lock (pendingJobs) { 179 167 if (pendingJobs.ContainsKey(currJob.Id)) { 180 168 if (pendingJobs[currJob.Id] <= 0) { 181 169 currJob.State = State.offline; 182 jobAdapter.Update(currJob); 170 DaoLocator.JobDao.Update(currJob); 171 //jobAdapter.Update(currJob); 183 172 } else { 184 173 pendingJobs[currJob.Id]--; … … 197 186 /// <param name="clientInfo"></param> 198 187 /// <returns></returns> 199 public Response Login(Client Info clientInfo) {188 public Response Login(ClientDto clientInfo) { 200 189 // ISession session = factory.GetSessionForCurrentThread(); 201 190 // ITransaction tx = null; … … 219 208 clientInfo.State = State.idle; 220 209 221 if (clientDao.FindById(clientInfo.Id) == null) 222 clientDao.Insert(clientInfo); 223 else 224 clientDao.Update(clientInfo); 225 //clientAdapter.Update(clientInfo); 210 if (DaoLocator.ClientDao.FindById(clientInfo.Id) == null) 211 DaoLocator.ClientDao.Insert(clientInfo); 212 else 213 DaoLocator.ClientDao.Update(clientInfo); 226 214 response.Success = true; 227 215 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGIN_SUCCESS; … … 250 238 public ResponseHB ProcessHeartBeat(HeartBeatData hbData) { 251 239 252 ISession session = factory.GetSessionForCurrentThread();253 ITransaction tx = null; 240 /* ISession session = factory.GetSessionForCurrentThread(); 241 ITransaction tx = null;*/ 254 242 255 243 HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat for Client " + hbData.ClientId); 256 244 257 try {245 //try { 258 246 HiveLogger.Info(this.ToString() + ": BEGIN Fetching Adapters"); 259 IClientAdapter clientAdapter =260 session.GetDataAdapter<Client Info, IClientAdapter>();247 /* IClientAdapter clientAdapter = 248 session.GetDataAdapter<ClientDto, IClientAdapter>(); 261 249 262 250 IJobAdapter jobAdapter = 263 session.GetDataAdapter<Job , IJobAdapter>();251 session.GetDataAdapter<JobDto, IJobAdapter>(); */ 264 252 HiveLogger.Info(this.ToString() + ": END Fetched Adapters"); 265 253 HiveLogger.Info(this.ToString() + ": BEGIN Starting Transaction"); 266 tx = session.BeginTransaction();254 //tx = session.BeginTransaction(); 267 255 HiveLogger.Info(this.ToString() + ": END Started Transaction"); 268 256 … … 271 259 272 260 HiveLogger.Info(this.ToString() + ": BEGIN Started Client Fetching"); 273 Client Info client = clientAdapter.GetById(hbData.ClientId);261 ClientDto client = DaoLocator.ClientDao.FindById(hbData.ClientId); 274 262 HiveLogger.Info(this.ToString() + ": END Finished Client Fetching"); 275 263 // check if the client is logged in … … 311 299 312 300 HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat Jobs"); 313 processJobProcess(hbData, jobAdapter, clientAdapter,response);301 processJobProcess(hbData, response); 314 302 HiveLogger.Info(this.ToString() + ": END Processed Heartbeat Jobs"); 315 303 316 clientAdapter.Update(client);317 318 tx.Commit();304 DaoLocator.ClientDao.Update(client); 305 306 //tx.Commit(); 319 307 HiveLogger.Info(this.ToString() + ": END Processed Heartbeat for Client " + hbData.ClientId); 320 308 return response; 321 } 309 } /* 322 310 catch (Exception ex) { 323 311 if (tx != null) … … 328 316 if (session != null) 329 317 session.EndSession(); 330 } 331 } 318 } 319 } */ 332 320 333 321 /// <summary> … … 338 326 /// <param name="clientAdapter"></param> 339 327 /// <param name="response"></param> 340 private void processJobProcess(HeartBeatData hbData, IJobAdapter jobAdapter, IClientAdapter clientAdapter,ResponseHB response) {328 private void processJobProcess(HeartBeatData hbData, ResponseHB response) { 341 329 HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId); 342 330 343 331 if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) { 344 List<Job > jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId)));332 List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId))); 345 333 if (jobsOfClient == null || jobsOfClient.Count == 0) { 346 334 response.Success = false; … … 351 339 352 340 foreach (KeyValuePair<Guid, double> jobProgress in hbData.JobProgress) { 353 Job curJob = jobAdapter.GetById(jobProgress.Key); 341 JobDto curJob = DaoLocator.JobDao.FindById(jobProgress.Key); 342 curJob.Client = DaoLocator.ClientDao.GetClientForJob(curJob.Id); 354 343 if (curJob.Client == null || curJob.Client.Id != hbData.ClientId) { 355 344 response.Success = false; … … 370 359 } 371 360 } 372 jobAdapter.Update(curJob);373 } 374 foreach (Job currJob in jobsOfClient) {361 DaoLocator.JobDao.Update(curJob); 362 } 363 foreach (JobDto currJob in jobsOfClient) { 375 364 bool found = false; 376 365 foreach (Guid jobId in hbData.JobProgress.Keys) { … … 389 378 390 379 currJob.State = State.offline; 391 jobAdapter.Update(currJob);380 DaoLocator.JobDao.Update(currJob); 392 381 393 382 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id)); … … 398 387 HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats: " + currJob); 399 388 currJob.State = State.offline; 400 jobAdapter.Update(currJob);389 DaoLocator.JobDao.Update(currJob); 401 390 } 402 391 } // lock … … 420 409 /// <param name="clientId"></param> 421 410 /// <returns></returns> 422 public ResponseSerializedJob SendSerializedJob(Guid clientId) {411 /*public ResponseSerializedJob SendSerializedJob(Guid clientId) { 423 412 ISession session = factory.GetSessionForCurrentThread(); 424 413 ITransaction tx = null; … … 426 415 try { 427 416 IJobAdapter jobAdapter = 428 session.GetDataAdapter<Job , IJobAdapter>();417 session.GetDataAdapter<JobDto, IJobAdapter>(); 429 418 430 419 tx = session.BeginTransaction(); … … 432 421 ResponseSerializedJob response = new ResponseSerializedJob(); 433 422 434 Job job2Calculate = scheduler.GetNextJobForClient(clientId);423 JobDto job2Calculate = scheduler.GetNextJobForClient(clientId); 435 424 if (job2Calculate != null) { 436 425 SerializedJob computableJob = … … 465 454 session.EndSession(); 466 455 } 467 } 456 } */ 468 457 469 458 /// <summary> … … 474 463 /// <returns></returns> 475 464 public ResponseJob SendJob(Guid clientId) { 476 ISession session = factory.GetSessionForCurrentThread(); 477 ITransaction tx = null; 478 479 try { 480 IJobAdapter jobAdapter = 481 session.GetDataAdapter<Job, IJobAdapter>(); 482 483 tx = session.BeginTransaction(); 484 485 ResponseJob response = new ResponseJob(); 486 487 Job job2Calculate = scheduler.GetNextJobForClient(clientId); 488 if (job2Calculate != null) { 489 response.Job = job2Calculate; 490 response.Success = true; 491 HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + job2Calculate + " for user " + clientId); 492 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 493 lock (newAssignedJobs) { 494 if (!newAssignedJobs.ContainsKey(job2Calculate.Id)) 495 newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE); 496 } 497 } else { 498 response.Success = false; 499 response.Job = null; 500 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 501 HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId); 502 } 503 504 tx.Commit(); 505 506 return response; 507 } 508 catch (Exception ex) { 509 if (tx != null) 510 tx.Rollback(); 511 throw ex; 512 } 513 finally { 514 if (session != null) 515 session.EndSession(); 516 } 465 466 ResponseJob response = new ResponseJob(); 467 468 JobDto job2Calculate = scheduler.GetNextJobForClient(clientId); 469 if (job2Calculate != null) { 470 response.Job = job2Calculate; 471 response.Success = true; 472 HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + job2Calculate + " for user " + clientId); 473 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 474 lock (newAssignedJobs) { 475 if (!newAssignedJobs.ContainsKey(job2Calculate.Id)) 476 newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE); 477 } 478 } 479 else { 480 response.Success = false; 481 response.Job = null; 482 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 483 HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId); 484 } 485 486 487 488 return response; 517 489 } 518 490 … … 523 495 HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - main method:"); 524 496 525 ISession session = factory.GetSessionForCurrentThread(); 526 ITransaction tx = null; 497 527 498 Stream jobResultStream = null; 528 499 Stream jobStream = null; 529 500 530 try {501 //try { 531 502 BinaryFormatter formatter = 532 503 new BinaryFormatter(); … … 538 509 //otherwise race conditions could occur when writing the stream into the DB 539 510 //just removed TransactionIsolationLevel.RepeatableRead 540 tx = session.BeginTransaction();511 //tx = session.BeginTransaction(); 541 512 542 513 ResponseResultReceived response = … … 550 521 551 522 if (response.Success) { 552 //second deserialize the BLOB 553 IJobResultsAdapter jobResultsAdapter = 554 session.GetDataAdapter<JobResult, IJobResultsAdapter>(); 555 556 IJobAdapter jobAdapter = 557 session.GetDataAdapter<Job, IJobAdapter>(); 558 559 jobResultStream = 560 jobResultsAdapter.GetSerializedJobResultStream(response.JobResultId, true); 561 562 jobStream = 563 jobAdapter.GetSerializedJobStream(result.JobId, true); 523 jobStream = DaoLocator.JobDao.GetSerializedJobStream(result.JobId); 564 524 565 525 byte[] buffer = new byte[3024]; 566 526 int read = 0; 567 while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { 568 jobResultStream.Write(buffer, 0, read); 527 while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { 569 528 jobStream.Write(buffer, 0, read); 570 529 } 571 572 jobResultStream.Close(); 573 jobStream.Close(); 574 575 tx.Commit(); 576 } 530 jobStream.Close(); 531 } 577 532 HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage:"); 578 533 return response; 579 534 } 580 catch (Exception ex) { 581 HiveLogger.Error(this.ToString() + " ProcessJobResult: Exception raised: " + ex); 582 if (tx != null) 583 tx.Rollback(); 584 throw ex; 585 } 586 finally { 587 if (jobStream != null) 588 jobStream.Dispose(); 589 590 if (jobResultStream != null) 591 jobResultStream.Dispose(); 592 593 if (session != null) 594 session.EndSession(); 595 } 596 } 535 597 536 598 537 private ResponseResultReceived ProcessJobResult(Guid clientId, … … 605 544 HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - SUB method: " + jobId); 606 545 607 ISession session = factory.GetSessionForCurrentThread();608 609 ITransaction tx = null;610 611 try {612 IClientAdapter clientAdapter =613 session.GetDataAdapter<ClientInfo, IClientAdapter>();614 IJobAdapter jobAdapter =615 session.GetDataAdapter<Job, IJobAdapter>();616 IJobResultsAdapter jobResultAdapter =617 session.GetDataAdapter<JobResult, IJobResultsAdapter>();618 619 //should fetch the existing transaction620 tx = session.BeginTransaction();621 622 546 ResponseResultReceived response = new ResponseResultReceived(); 623 Client Info client =624 clientAdapter.GetById(clientId);547 ClientDto client = 548 DaoLocator.ClientDao.FindById(clientId); 625 549 626 550 SerializedJob job = … … 629 553 if (job != null) { 630 554 job.JobInfo = 631 jobAdapter.GetById(jobId); 555 DaoLocator.JobDao.FindById(jobId); 556 job.JobInfo.Client = job.JobInfo.Client = DaoLocator.ClientDao.GetClientForJob(jobId); 632 557 } 633 558 … … 639 564 HiveLogger.Error(this.ToString() + " ProcessJobResult: No job with Id " + jobId); 640 565 641 tx.Rollback();566 //tx.Rollback(); 642 567 return response; 643 568 } … … 648 573 HiveLogger.Error(this.ToString() + " ProcessJobResult: Job was aborted! " + job.JobInfo); 649 574 650 tx.Rollback();575 //tx.Rollback(); 651 576 return response; 652 577 } … … 658 583 HiveLogger.Error(this.ToString() + " ProcessJobResult: Job is not being calculated (client = null)! " + job.JobInfo); 659 584 660 tx.Rollback();585 //tx.Rollback(); 661 586 return response; 662 587 } … … 668 593 HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Client for this Job! " + job.JobInfo + ", Sending Client is: " + clientId); 669 594 670 tx.Rollback();595 //tx.Rollback(); 671 596 return response; 672 597 } … … 678 603 HiveLogger.Error(this.ToString() + " ProcessJobResult: Job already finished! " + job.JobInfo + ", Sending Client is: " + clientId); 679 604 680 tx.Rollback();605 //tx.Rollback(); 681 606 return response; 682 607 } … … 692 617 HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Job State, job is: " + job.JobInfo); 693 618 694 tx.Rollback();619 //tx.Rollback(); 695 620 return response; 696 621 } … … 702 627 703 628 job.SerializedJobData = result; 704 jobAdapter.UpdateSerializedJob(job); 705 706 List<JobResult> jobResults = new List<JobResult>( 707 jobResultAdapter.GetResultsOf(job.JobInfo.Id)); 708 foreach (JobResult currentResult in jobResults) 709 jobResultAdapter.Delete(currentResult); 710 711 SerializedJobResult serializedjobResult = 712 new SerializedJobResult(); 713 JobResult jobResult = new JobResult(); 714 jobResult.ClientId = client.Id; 715 jobResult.JobId = job.JobInfo.Id; 716 jobResult.Percentage = percentage; 717 jobResult.Exception = exception; 718 jobResult.DateFinished = DateTime.Now; 719 serializedjobResult.JobResult = jobResult; 720 serializedjobResult.SerializedJobResultData = 721 result; 722 723 jobResultAdapter.UpdateSerializedJobResult(serializedjobResult); 629 630 DaoLocator.JobDao.Update(job.JobInfo); 724 631 725 632 response.Success = true; 726 633 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED; 727 634 response.JobId = jobId; 728 response.finished = finished; 729 response.JobResultId = jobResult.Id; 635 response.finished = finished; 730 636 731 tx.Commit();732 637 HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage - SUB method: " + jobId); 733 638 return response; 734 } 735 catch (Exception ex) { 736 if (tx != null) 737 tx.Rollback(); 738 throw ex; 739 } 740 finally { 741 if (session != null) 742 session.EndSession(); 743 } 639 744 640 } 745 641 … … 780 676 HiveLogger.Info("Client logged out " + clientId); 781 677 782 ISession session = factory.GetSessionForCurrentThread();678 /*ISession session = factory.GetSessionForCurrentThread(); 783 679 ITransaction tx = null; 784 680 785 681 try { 786 682 IClientAdapter clientAdapter = 787 session.GetDataAdapter<Client Info, IClientAdapter>();683 session.GetDataAdapter<ClientDto, IClientAdapter>(); 788 684 IJobAdapter jobAdapter = 789 session.GetDataAdapter<Job , IJobAdapter>();685 session.GetDataAdapter<JobDto, IJobAdapter>(); 790 686 791 687 tx = session.BeginTransaction(); 792 688 */ 793 689 Response response = new Response(); 794 690 … … 798 694 heartbeatLock.ExitWriteLock(); 799 695 800 ClientInfo client = clientAdapter.GetById(clientId);696 ClientDto client = DaoLocator.ClientDao.FindById(clientId); 801 697 if (client == null) { 802 698 response.Success = false; … … 806 702 if (client.State == State.calculating) { 807 703 // check wich job the client was calculating and reset it 808 I Collection<Job> jobsOfClient = jobAdapter.GetJobsOf(client);809 foreach (Job job in jobsOfClient) {704 IEnumerable<JobDto> jobsOfClient = DaoLocator.JobDao.FindActiveJobsOfClient(client); 705 foreach (JobDto job in jobsOfClient) { 810 706 if (job.State != State.finished) 811 707 jobManager.ResetJobsDependingOnResults(job); … … 814 710 815 711 client.State = State.offline; 816 clientAdapter.Update(client);712 DaoLocator.ClientDao.Update(client); 817 713 818 714 response.Success = true; 819 715 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGOUT_SUCCESS; 820 716 821 tx.Commit();717 //tx.Commit(); 822 718 return response; 823 } 719 } /* 824 720 catch (Exception ex) { 825 721 if (tx != null) … … 831 727 session.EndSession(); 832 728 } 833 } 729 } */ 834 730 835 731 /// <summary> … … 840 736 /// <returns></returns> 841 737 public Response IsJobStillNeeded(Guid jobId) { 842 ISession session = factory.GetSessionForCurrentThread();738 /*ISession session = factory.GetSessionForCurrentThread(); 843 739 ITransaction tx = null; 844 740 845 741 try { 846 742 IJobAdapter jobAdapter = 847 session.GetDataAdapter<Job , IJobAdapter>();848 tx = session.BeginTransaction(); 743 session.GetDataAdapter<JobDto, IJobAdapter>(); 744 tx = session.BeginTransaction(); */ 849 745 850 746 Response response = new Response(); 851 Job job = jobAdapter.GetById(jobId);747 JobDto job = DaoLocator.JobDao.FindById(jobId); 852 748 if (job == null) { 853 749 response.Success = false; … … 867 763 } 868 764 869 jobAdapter.Update(job);765 DaoLocator.JobDao.Update(job); 870 766 871 767 response.Success = true; 872 768 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT; 873 tx.Commit();769 //tx.Commit(); 874 770 return response; 875 771 } 876 catch (Exception ex) {772 /*catch (Exception ex) { 877 773 if (tx != null) 878 774 tx.Rollback(); … … 883 779 session.EndSession(); 884 780 } 885 } 886 887 public ResponsePlugin SendPlugins(List<HivePluginInfo > pluginList) {781 } */ 782 783 public ResponsePlugin SendPlugins(List<HivePluginInfoDto> pluginList) { 888 784 ResponsePlugin response = new ResponsePlugin(); 889 foreach (HivePluginInfo pluginInfo in pluginList) {785 foreach (HivePluginInfoDto pluginInfo in pluginList) { 890 786 // TODO: BuildDate deleted, not needed??? 891 787 // TODO: Split version to major, minor and revision number … … 893 789 if (currPlugin.Name == pluginInfo.Name) { 894 790 895 CachedHivePluginInfo currCachedPlugin = new CachedHivePluginInfo {791 CachedHivePluginInfoDto currCachedPlugin = new CachedHivePluginInfoDto { 896 792 Name = currPlugin.Name, 897 793 Version = currPlugin.Version.ToString(),
Note: See TracChangeset
for help on using the changeset viewer.