Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/12/10 10:57:21 (15 years ago)
Author:
kgrading
Message:

changed the complete DAL to LINQ 2 SQL (with the exception of the job streaming), did a lot of refactoring, Introduced DTOs (that are named DTOs for better understanding), added the spring.NET Interceptor, reintroduced transactions and cleaned up the whole JobResult thing and updated a part of the config merger (#830)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs

    r2904 r3011  
    4040using HeuristicLab.Tracing;
    4141using Linq = HeuristicLab.Hive.Server.LINQDataAccess;
     42using System.Transactions;
    4243
    4344namespace HeuristicLab.Hive.Server.Core {
     
    5758      new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
    5859
    59     private ISessionFactory factory;
     60    //private ISessionFactory factory;
    6061    private ILifecycleManager lifecycleManager;
    6162    private IInternalJobManager jobManager;
    62     private IScheduler scheduler;
    63 
    64     Linq.ClientDao clientDao = new Linq.ClientDao();
     63    private IScheduler scheduler;   
    6564
    6665    private static int PENDING_TIMEOUT = 100;
     
    7271    /// </summary>
    7372    public ClientCommunicator() {
    74       factory = ServiceLocator.GetSessionFactory();
     73      //factory = ServiceLocator.GetSessionFactory();
    7574
    7675      lifecycleManager = ServiceLocator.GetLifecycleManager();
     
    9089    /// <param name="e"></param>
    9190    void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) {
    92       ISession session = factory.GetSessionForCurrentThread();
    93       ITransaction tx = null;
    94 
    9591      HiveLogger.Info(this.ToString() + ": Server Heartbeat ticked");
    9692
    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) {
    10898          if (client.State != State.offline && client.State != State.nullState) {
    10999            heartbeatLock.EnterUpgradeableReadLock();
    110100
    111101            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");
    113104              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)) {
    117110                jobManager.ResetJobsDependingOnResults(job);
    118111              }
    119             } else {
     112            }
     113            else {
    120114              DateTime lastHbOfClient = lastHeartbeats[client.Id];
    121115
     
    125119                // if client calculated jobs, the job must be reset
    126120                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)) {
    128122                  jobManager.ResetJobsDependingOnResults(job);
    129123                  lock (newAssignedJobs) {
     
    135129                // client must be set offline
    136130                client.State = State.offline;
    137                 clientAdapter.Update(client);
     131
     132                //clientAdapter.Update(client);
     133                DaoLocator.ClientDao.Update(client);
    138134
    139135                heartbeatLock.EnterWriteLock();
     
    144140
    145141            heartbeatLock.ExitUpgradeableReadLock();
    146           } else {
     142          }
     143          else {
    147144            //TODO: RLY neccesary?
    148145            //HiveLogger.Info(this.ToString() + ": Client " + client.Id + " has wrong state: Shouldn't have offline or nullstate, has " + client.State);
     
    151148            if (lastHeartbeats.ContainsKey(client.Id))
    152149              lastHeartbeats.Remove(client.Id);
    153             foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {
     150            foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) {
    154151              jobManager.ResetJobsDependingOnResults(job);
    155152            }
     
    157154          }
    158155        }
    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) {
    178166        lock (pendingJobs) {
    179167          if (pendingJobs.ContainsKey(currJob.Id)) {
    180168            if (pendingJobs[currJob.Id] <= 0) {
    181169              currJob.State = State.offline;
    182               jobAdapter.Update(currJob);
     170              DaoLocator.JobDao.Update(currJob);
     171              //jobAdapter.Update(currJob);
    183172            } else {
    184173              pendingJobs[currJob.Id]--;
     
    197186    /// <param name="clientInfo"></param>
    198187    /// <returns></returns>
    199     public Response Login(ClientInfo clientInfo) {
     188    public Response Login(ClientDto clientInfo) {
    200189    //  ISession session = factory.GetSessionForCurrentThread();
    201190    //  ITransaction tx = null;
     
    219208        clientInfo.State = State.idle;
    220209
    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);       
    226214        response.Success = true;
    227215        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGIN_SUCCESS;
     
    250238    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
    251239     
    252       ISession session = factory.GetSessionForCurrentThread();
    253       ITransaction tx = null;
     240     /* ISession session = factory.GetSessionForCurrentThread();
     241      ITransaction tx = null;*/
    254242
    255243      HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat for Client " + hbData.ClientId);
    256244
    257       try {
     245      //try {
    258246        HiveLogger.Info(this.ToString() + ": BEGIN Fetching Adapters");
    259         IClientAdapter clientAdapter =
    260           session.GetDataAdapter<ClientInfo, IClientAdapter>();
     247      /*  IClientAdapter clientAdapter =
     248          session.GetDataAdapter<ClientDto, IClientAdapter>();
    261249
    262250        IJobAdapter jobAdapter =       
    263           session.GetDataAdapter<Job, IJobAdapter>();
     251          session.GetDataAdapter<JobDto, IJobAdapter>(); */
    264252        HiveLogger.Info(this.ToString() + ": END Fetched Adapters");
    265253        HiveLogger.Info(this.ToString() + ": BEGIN Starting Transaction");
    266         tx = session.BeginTransaction();
     254        //tx = session.BeginTransaction();
    267255        HiveLogger.Info(this.ToString() + ": END Started Transaction");
    268256
     
    271259
    272260        HiveLogger.Info(this.ToString() + ": BEGIN Started Client Fetching");
    273         ClientInfo client = clientAdapter.GetById(hbData.ClientId);
     261        ClientDto client = DaoLocator.ClientDao.FindById(hbData.ClientId);
    274262        HiveLogger.Info(this.ToString() + ": END Finished Client Fetching");
    275263        // check if the client is logged in
     
    311299
    312300        HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat Jobs");
    313         processJobProcess(hbData, jobAdapter, clientAdapter, response);
     301        processJobProcess(hbData, response);
    314302        HiveLogger.Info(this.ToString() + ": END Processed Heartbeat Jobs");
    315303       
    316         clientAdapter.Update(client);
    317 
    318         tx.Commit();
     304        DaoLocator.ClientDao.Update(client);
     305
     306        //tx.Commit();
    319307        HiveLogger.Info(this.ToString() + ": END Processed Heartbeat for Client " + hbData.ClientId);
    320308        return response;
    321       }
     309      } /*
    322310      catch (Exception ex) {
    323311        if (tx != null)
     
    328316        if (session != null)
    329317          session.EndSession();
    330       }
    331     }
     318      }   
     319    }     */
    332320
    333321    /// <summary>
     
    338326    /// <param name="clientAdapter"></param>
    339327    /// <param name="response"></param>
    340     private void processJobProcess(HeartBeatData hbData, IJobAdapter jobAdapter, IClientAdapter clientAdapter, ResponseHB response) {
     328    private void processJobProcess(HeartBeatData hbData, ResponseHB response) {
    341329      HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId);     
    342330     
    343331      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)));
    345333        if (jobsOfClient == null || jobsOfClient.Count == 0) {
    346334          response.Success = false;
     
    351339
    352340        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);
    354343          if (curJob.Client == null || curJob.Client.Id != hbData.ClientId) {
    355344            response.Success = false;
     
    370359            }
    371360          }
    372           jobAdapter.Update(curJob);
    373         }
    374         foreach (Job currJob in jobsOfClient) {
     361          DaoLocator.JobDao.Update(curJob);
     362        }
     363        foreach (JobDto currJob in jobsOfClient) {
    375364          bool found = false;
    376365          foreach (Guid jobId in hbData.JobProgress.Keys) {
     
    389378
    390379                  currJob.State = State.offline;
    391                   jobAdapter.Update(currJob);
     380                  DaoLocator.JobDao.Update(currJob);
    392381
    393382                  response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id));
     
    398387                HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);                     
    399388                currJob.State = State.offline;
    400                 jobAdapter.Update(currJob);
     389                DaoLocator.JobDao.Update(currJob);
    401390              }
    402391            } // lock
     
    420409    /// <param name="clientId"></param>
    421410    /// <returns></returns>
    422     public ResponseSerializedJob SendSerializedJob(Guid clientId) {
     411    /*public ResponseSerializedJob SendSerializedJob(Guid clientId) {
    423412      ISession session = factory.GetSessionForCurrentThread();
    424413      ITransaction tx = null;
     
    426415      try {
    427416        IJobAdapter jobAdapter =
    428           session.GetDataAdapter<Job, IJobAdapter>();
     417          session.GetDataAdapter<JobDto, IJobAdapter>();
    429418
    430419        tx = session.BeginTransaction();
     
    432421        ResponseSerializedJob response = new ResponseSerializedJob();
    433422
    434         Job job2Calculate = scheduler.GetNextJobForClient(clientId);
     423        JobDto job2Calculate = scheduler.GetNextJobForClient(clientId);
    435424        if (job2Calculate != null) {
    436425          SerializedJob computableJob =
     
    465454          session.EndSession();
    466455      }
    467     }
     456    }     */
    468457
    469458    /// <summary>
     
    474463    /// <returns></returns>
    475464    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;
    517489    }
    518490
     
    523495      HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - main method:");
    524496     
    525       ISession session = factory.GetSessionForCurrentThread();
    526       ITransaction tx = null;
     497     
    527498      Stream jobResultStream = null;
    528499      Stream jobStream = null;
    529500
    530       try {
     501      //try {
    531502        BinaryFormatter formatter =
    532503          new BinaryFormatter();
     
    538509        //otherwise race conditions could occur when writing the stream into the DB
    539510        //just removed TransactionIsolationLevel.RepeatableRead
    540         tx = session.BeginTransaction();
     511        //tx = session.BeginTransaction();
    541512
    542513        ResponseResultReceived response =
     
    550521
    551522        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);
    564524
    565525          byte[] buffer = new byte[3024];
    566526          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) {           
    569528            jobStream.Write(buffer, 0, read);
    570529          }
    571 
    572           jobResultStream.Close();
    573           jobStream.Close();
    574 
    575           tx.Commit();
    576         }
     530          jobStream.Close();         
     531        }                   
    577532        HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage:");
    578533        return response;
    579534      }
    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
    597536
    598537    private ResponseResultReceived ProcessJobResult(Guid clientId,
     
    605544      HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - SUB method: " + jobId);
    606545
    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 transaction       
    620         tx = session.BeginTransaction();
    621 
    622546        ResponseResultReceived response = new ResponseResultReceived();
    623         ClientInfo client =
    624           clientAdapter.GetById(clientId);
     547        ClientDto client =
     548          DaoLocator.ClientDao.FindById(clientId);
    625549
    626550        SerializedJob job =
     
    629553        if (job != null) {
    630554          job.JobInfo =
    631             jobAdapter.GetById(jobId);
     555            DaoLocator.JobDao.FindById(jobId);         
     556          job.JobInfo.Client = job.JobInfo.Client = DaoLocator.ClientDao.GetClientForJob(jobId);
    632557        }
    633558
     
    639564          HiveLogger.Error(this.ToString() + " ProcessJobResult: No job with Id " + jobId);                     
    640565         
    641           tx.Rollback();
     566          //tx.Rollback();
    642567          return response;
    643568        }
     
    648573          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job was aborted! " + job.JobInfo);                     
    649574         
    650           tx.Rollback();
     575          //tx.Rollback();
    651576          return response;
    652577        }
     
    658583          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job is not being calculated (client = null)! " + job.JobInfo);                     
    659584
    660           tx.Rollback();
     585          //tx.Rollback();
    661586          return response;
    662587        }
     
    668593          HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Client for this Job! " + job.JobInfo + ", Sending Client is: " + clientId);                     
    669594
    670           tx.Rollback();
     595          //tx.Rollback();
    671596          return response;
    672597        }
     
    678603          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job already finished! " + job.JobInfo + ", Sending Client is: " + clientId);                     
    679604
    680           tx.Rollback();
     605          //tx.Rollback();
    681606          return response;
    682607        }
     
    692617          HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Job State, job is: " + job.JobInfo);                     
    693618
    694           tx.Rollback();
     619          //tx.Rollback();
    695620          return response;
    696621        }
     
    702627
    703628        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);
    724631
    725632        response.Success = true;
    726633        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED;
    727634        response.JobId = jobId;
    728         response.finished = finished;
    729         response.JobResultId = jobResult.Id;
     635        response.finished = finished;       
    730636               
    731         tx.Commit();
    732637        HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage - SUB method: " + jobId);       
    733638        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
    744640    }
    745641
     
    780676      HiveLogger.Info("Client logged out " + clientId);
    781677     
    782       ISession session = factory.GetSessionForCurrentThread();
     678      /*ISession session = factory.GetSessionForCurrentThread();
    783679      ITransaction tx = null;
    784680
    785681      try {
    786682        IClientAdapter clientAdapter =
    787           session.GetDataAdapter<ClientInfo, IClientAdapter>();
     683          session.GetDataAdapter<ClientDto, IClientAdapter>();
    788684        IJobAdapter jobAdapter =
    789           session.GetDataAdapter<Job, IJobAdapter>();
     685          session.GetDataAdapter<JobDto, IJobAdapter>();
    790686
    791687        tx = session.BeginTransaction();
    792 
     688           */
    793689        Response response = new Response();
    794690
     
    798694        heartbeatLock.ExitWriteLock();
    799695
    800         ClientInfo client = clientAdapter.GetById(clientId);
     696      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    801697        if (client == null) {
    802698          response.Success = false;
     
    806702        if (client.State == State.calculating) {
    807703          // check wich job the client was calculating and reset it
    808           ICollection<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) {
    810706            if (job.State != State.finished)
    811707              jobManager.ResetJobsDependingOnResults(job);
     
    814710
    815711        client.State = State.offline;
    816         clientAdapter.Update(client);
     712        DaoLocator.ClientDao.Update(client);
    817713
    818714        response.Success = true;
    819715        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGOUT_SUCCESS;
    820716
    821         tx.Commit();
     717        //tx.Commit();
    822718        return response;
    823       }
     719      } /*
    824720      catch (Exception ex) {
    825721        if (tx != null)
     
    831727          session.EndSession();
    832728      }
    833     }
     729    }     */
    834730
    835731    /// <summary>
     
    840736    /// <returns></returns>
    841737    public Response IsJobStillNeeded(Guid jobId) {
    842       ISession session = factory.GetSessionForCurrentThread();
     738      /*ISession session = factory.GetSessionForCurrentThread();
    843739      ITransaction tx = null;
    844740
    845741      try {
    846742        IJobAdapter jobAdapter =
    847           session.GetDataAdapter<Job, IJobAdapter>();
    848         tx = session.BeginTransaction();
     743          session.GetDataAdapter<JobDto, IJobAdapter>();
     744        tx = session.BeginTransaction();                */
    849745
    850746        Response response = new Response();
    851         Job job = jobAdapter.GetById(jobId);
     747      JobDto job = DaoLocator.JobDao.FindById(jobId);
    852748        if (job == null) {
    853749          response.Success = false;
     
    867763        }
    868764
    869         jobAdapter.Update(job);
     765        DaoLocator.JobDao.Update(job);
    870766
    871767        response.Success = true;
    872768        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT;
    873         tx.Commit();
     769        //tx.Commit();
    874770        return response;
    875771      }
    876       catch (Exception ex) {
     772      /*catch (Exception ex) {
    877773        if (tx != null)
    878774          tx.Rollback();
     
    883779          session.EndSession();
    884780      }
    885     }
    886 
    887     public ResponsePlugin SendPlugins(List<HivePluginInfo> pluginList) {
     781    }   */
     782
     783    public ResponsePlugin SendPlugins(List<HivePluginInfoDto> pluginList) {
    888784      ResponsePlugin response = new ResponsePlugin();
    889       foreach (HivePluginInfo pluginInfo in pluginList) {
     785      foreach (HivePluginInfoDto pluginInfo in pluginList) {
    890786        // TODO: BuildDate deleted, not needed???
    891787        // TODO: Split version to major, minor and revision number
     
    893789          if (currPlugin.Name == pluginInfo.Name) {
    894790
    895             CachedHivePluginInfo currCachedPlugin = new CachedHivePluginInfo {
     791            CachedHivePluginInfoDto currCachedPlugin = new CachedHivePluginInfoDto {
    896792              Name = currPlugin.Name,
    897793              Version = currPlugin.Version.ToString(),
Note: See TracChangeset for help on using the changeset viewer.