Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/21/11 15:05:48 (14 years ago)
Author:
cneumuel
Message:

#1233

  • implemented pause, stop for single jobs
  • introduced Command property for jobs (to distinguish between state and command (abort vs. aborted))
  • improved behaviour of ItemTreeView (double click opens new window, selected item stays marked)
  • fixed bugs in StateLogGanttChartListView and HiveJobView
  • fixed cloning of client-side dtos
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs

    r5718 r5779  
    3939
    4040        // assign new job
    41         if (heartbeat.AssignJob && this.IsAllowedToSendJobs() && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
     41        if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
    4242          var availableJobs = dao.GetWaitingJobs(slave, 1);
    4343          if (availableJobs.Count() > 0) {
     
    8383            curJob.LastHeartbeat = DateTime.Now;
    8484
    85             if (curJob.State == JobState.Aborted) {
    86               // a request to abort the job has been set
    87               actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
     85            switch (curJob.Command) {
     86              case Command.Stop:
     87                actions.Add(new MessageContainer(MessageContainer.MessageType.StopJob, curJob.Id));
     88                break;
     89              case Command.Pause:
     90                actions.Add(new MessageContainer(MessageContainer.MessageType.PauseJob, curJob.Id));
     91                break;
     92              case Command.Abort:
     93                actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
     94                break;
    8895            }
    8996            dao.UpdateJob(curJob);
     
    93100      return actions;
    94101    }
    95 
    96     /// <summary>
    97     /// Returns true if there are enough resources to send a job
    98     /// There should not be too many jobs sent simultaniously
    99     /// </summary>
    100     private bool IsAllowedToSendJobs() {
    101       return true; // JobsCurrentlyTransferring < ApplicationConstants.MaxJobTransferCount;
    102       // Todo: see if unlimited job transfer count works. if not, look into db and count jobs in state Transferring
    103     }
    104102  }
    105103}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r5708 r5779  
    139139    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    140140    public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
    141       return trans.UseTransaction(() => dao.UpdateJobState(jobId, jobState, slaveId, userId, exception));
     141      return trans.UseTransaction(() => {
     142        Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
     143        if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == JobState.Paused) {
     144          job.Command = null;
     145        } else if (job.Command.HasValue && job.Command.Value == Command.Abort && job.State == JobState.Aborted) {
     146          job.Command = null;
     147        } else if (job.Command.HasValue && job.Command.Value == Command.Stop && job.State == JobState.Aborted) {
     148          job.Command = null;
     149        }
     150        dao.UpdateJob(job);
     151        return job;
     152      });
    142153    }
    143154    #endregion
     
    149160    public void StopJob(Guid jobId) {
    150161      trans.UseTransaction(() => {
    151         throw new NotImplementedException();
     162        //dao.UpdateJobState(jobId, JobState.Aborted, null, auth.UserId, string.Empty);
     163        var job = dao.GetJob(jobId);
     164        job.Command = Command.Stop;
     165        dao.UpdateJob(job);
    152166      });
    153167    }
     
    158172    public void PauseJob(Guid jobId) {
    159173      trans.UseTransaction(() => {
    160         throw new NotImplementedException();
     174        //dao.UpdateJobState(jobId, JobState.Paused, null, auth.UserId, string.Empty);
     175        var job = dao.GetJob(jobId);
     176        job.Command = Command.Pause;
     177        dao.UpdateJob(job);
     178      });
     179    }
     180
     181    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
     182    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
     183    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
     184    public void RestartJob(Guid jobId) {
     185      trans.UseTransaction(() => {
     186        Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, auth.UserId, string.Empty);
     187        job.Command = null;
     188        dao.UpdateJob(job);
    161189      });
    162190    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs

    r5718 r5779  
    5555      var jobs = dao.GetJobs(x => x.State == JobState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);
    5656      foreach (var j in jobs) {
    57         dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out");
     57        Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out");
     58        job.Command = null;
     59        dao.UpdateJob(job);
    5860      }
    5961    }
Note: See TracChangeset for help on using the changeset viewer.