Ignore:
Timestamp:
01/18/18 15:08:25 (3 years ago)
Author:
jzenisek
Message:

#2839

  • updated Heartbeat processing (regarding: checking against AssignedJobResources and handling of the updated Job deletion routine)
  • updated Job deletion routine(still in progress at GenerateStatistics)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15628 r15630  
    361361        return pm.UseTransaction(() => {
    362362          var jobs = jobDao.GetAll()
    363             .Where(x => x.OwnerUserId == currentUserId
    364                      || x.JobPermissions.Count(y => y.Permission != DA.Permission.NotAllowed
    365                                                  && y.GrantedUserId == currentUserId) > 0)
     363            .Where(x => x.State == DA.JobState.Online
     364                          && (x.OwnerUserId == currentUserId
     365                            || x.JobPermissions.Count(y => y.Permission != DA.Permission.NotAllowed
     366                              && y.GrantedUserId == currentUserId) > 0)
     367                          )
    366368            .Select(x => x.ToDto())
    367369            .ToList();
     
    524526    }
    525527
    526     public void DeleteJob(Guid jobId) {
     528    public void UpdateJobState(Guid jobId, DT.JobState jobState) {
    527529      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    528530      AuthorizationManager.AuthorizeForJob(jobId, DT.Permission.Full);
    529531      var pm = PersistenceManager;
    530       using (new PerformanceLogger("DeleteJob")) {
     532      using (new PerformanceLogger("UpdateJobState")) {
    531533        var jobDao = pm.JobDao;
    532534        pm.UseTransaction(() => {
    533           // not necessary anymore: child tasks will be deleted by db-trigger
    534           // now: tasks are deleted by jobId
    535           // entries in AssignedJobResource will be deleted by foreign key clause CASCADE ON DELETE
    536           jobDao.Delete(jobId);
    537           pm.SubmitChanges();
     535          var job = jobDao.GetById(jobId);
     536          if(job != null) {
     537            var jobStateEntity = jobState.ToEntity();
     538            // note: allow solely state changes from "Online" to "StatisticsPending"
     539            // and from "StatisticsPending" to "DeletionPending"
     540            if (job.State == DA.JobState.Online && jobStateEntity == DA.JobState.StatisticsPending) {
     541              job.State = jobStateEntity;
     542              foreach(var task in job.Tasks
     543              .Where(x => x.State == DA.TaskState.Waiting
     544                || x.State == DA.TaskState.Paused
     545                || x.State == DA.TaskState.Offline)) {
     546                task.State = DA.TaskState.Aborted;
     547              }
     548              pm.SubmitChanges();
     549            } else if(job.State == DA.JobState.StatisticsPending && jobStateEntity == DA.JobState.DeletionPending) {
     550              job.State = jobStateEntity;
     551              pm.SubmitChanges();
     552            }
     553          }
    538554        });
    539555      }
Note: See TracChangeset for help on using the changeset viewer.