Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1490


Ignore:
Timestamp:
04/02/09 15:26:11 (16 years ago)
Author:
msteinbi
Message:

Transaction management embedded (#566)

File:
1 edited

Legend:

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

    r1478 r1490  
    7878    void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) {
    7979      ISession session = factory.GetSessionForCurrentThread();
     80      ITransaction tx = null;
    8081
    8182      try {
     
    8485        IJobAdapter jobAdapter =
    8586          session.GetDataAdapter<Job, IJobAdapter>();
     87
     88        tx = session.BeginTransaction();
    8689
    8790        List<ClientInfo> allClients = new List<ClientInfo>(clientAdapter.GetAll());
     
    126129          }
    127130        }
     131        tx.Commit();
     132      }
     133      catch (Exception ex) {
     134        if (tx != null)
     135          tx.Rollback();
     136        throw ex;
    128137      }
    129138      finally {
     
    143152    public Response Login(ClientInfo clientInfo) {
    144153      ISession session = factory.GetSessionForCurrentThread();
     154      ITransaction tx = null;
    145155
    146156      try {
    147157        IClientAdapter clientAdapter =
    148158          session.GetDataAdapter<ClientInfo, IClientAdapter>();
     159
     160        tx = session.BeginTransaction();
    149161
    150162        Response response = new Response();
     
    169181        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGIN_SUCCESS;
    170182
     183        tx.Commit();
    171184        return response;
     185      }
     186      catch (Exception ex) {
     187        if (tx != null)
     188          tx.Rollback();
     189        throw ex;
    172190      }
    173191      finally {
     
    186204    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
    187205      ISession session = factory.GetSessionForCurrentThread();
     206      ITransaction tx = null;
    188207
    189208      try {
     
    193212        IJobAdapter jobAdapter =
    194213          session.GetDataAdapter<Job, IJobAdapter>();
     214
     215        tx = session.BeginTransaction();
    195216
    196217        ResponseHB response = new ResponseHB();
     
    248269          }
    249270        }
    250 
     271        tx.Commit();
    251272        return response;
     273      }
     274      catch (Exception ex) {
     275        if (tx != null)
     276          tx.Rollback();
     277        throw ex;
    252278      }
    253279      finally {
     
    286312      bool finished) {
    287313      ISession session = factory.GetSessionForCurrentThread();
     314      ITransaction tx = null;
    288315
    289316      try {
     
    294321        IJobResultsAdapter jobResultAdapter =
    295322          session.GetDataAdapter<JobResult, IJobResultsAdapter>();
     323
     324        tx = session.BeginTransaction();
    296325
    297326        ResponseResultReceived response = new ResponseResultReceived();
     
    359388        response.finished = finished;
    360389
     390        tx.Commit();
    361391        return response;
     392      }
     393      catch (Exception ex) {
     394        if (tx != null)
     395          tx.Rollback();
     396        throw ex;
    362397      }
    363398      finally {
     
    401436    public Response Logout(Guid clientId) {
    402437      ISession session = factory.GetSessionForCurrentThread();
     438      ITransaction tx = null;
    403439
    404440      try {
     
    407443        IJobAdapter jobAdapter =
    408444          session.GetDataAdapter<Job, IJobAdapter>();
     445
     446        tx = session.BeginTransaction();
    409447
    410448        Response response = new Response();
     
    437475        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGOUT_SUCCESS;
    438476
     477        tx.Commit();
    439478        return response;
     479      }
     480      catch (Exception ex) {
     481        if (tx != null)
     482          tx.Rollback();
     483        throw ex;
    440484      }
    441485      finally {
     
    453497    public Response IsJobStillNeeded(Guid jobId) {
    454498      ISession session = factory.GetSessionForCurrentThread();
     499      ITransaction tx = null;
    455500
    456501      try {
    457502        IJobAdapter jobAdapter =
    458503          session.GetDataAdapter<Job, IJobAdapter>();
     504        tx = session.BeginTransaction();
    459505
    460506        Response response = new Response();
     
    475521        response.Success = true;
    476522        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT;
     523        tx.Commit();
    477524        return response;
     525      }
     526      catch (Exception ex) {
     527        if (tx != null)
     528          tx.Rollback();
     529        throw ex;
    478530      }
    479531      finally {
Note: See TracChangeset for help on using the changeset viewer.