Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/09 17:33:09 (15 years ago)
Author:
msteinbi
Message:

added request and abort snapshot (#572)

File:
1 edited

Legend:

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

    r1530 r1577  
    254254     
    255255      try {
    256        
     256        IJobAdapter jobAdapter = session.GetDataAdapter<Job, IJobAdapter>();
     257
     258        Job job = jobAdapter.GetById(jobId);
     259        if (job.State == State.requestSnapshot) {
     260          response.Success = true;
     261          response.StatusMessage = ApplicationConstants.RESPONSE_JOB_REQUEST_ALLREADY_SET;
     262          return response; // no commit needed
     263        }
     264        if (job.State != State.calculating) {
     265          response.Success = false;
     266          response.StatusMessage = ApplicationConstants.RESPONSE_JOB_IS_NOT_BEEING_CALCULATED;
     267          return response; // no commit needed
     268        }
     269        // job is in correct state
     270        job.State = State.requestSnapshot;
     271        jobAdapter.Update(job);
     272
     273        response.Success = true;
     274        response.StatusMessage = ApplicationConstants.RESPONSE_JOB_REQUEST_SET;
    257275
    258276        return response;
     
    265283
    266284    public Response AbortJob(Guid jobId) {
    267       throw new NotImplementedException();
     285      ISession session = factory.GetSessionForCurrentThread();
     286      Response response = new Response();
     287
     288      try {
     289        IJobAdapter jobAdapter = session.GetDataAdapter<Job, IJobAdapter>();
     290
     291        Job job = jobAdapter.GetById(jobId);
     292        if (job.State == State.abort) {
     293          response.Success = true;
     294          response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ABORT_REQUEST_ALLREADY_SET;
     295          return response; // no commit needed
     296        }
     297        if (job.State != State.calculating) {
     298          response.Success = false;
     299          response.StatusMessage = ApplicationConstants.RESPONSE_JOB_IS_NOT_BEEING_CALCULATED;
     300          return response; // no commit needed
     301        }
     302        // job is in correct state
     303        job.State = State.abort;
     304        jobAdapter.Update(job);
     305
     306        response.Success = true;
     307        response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ABORT_REQUEST_SET;
     308
     309        return response;
     310      }
     311      finally {
     312        if (session != null)
     313          session.EndSession();
     314      }
    268315    }
    269316
Note: See TracChangeset for help on using the changeset viewer.