Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/11 13:41:25 (13 years ago)
Author:
ascheibe
Message:

#1233 Review comments: renamed Job to Task

Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3
Files:
10 edited
4 copied

Legend:

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

    r6717 r6721  
    3131  public static class Convert {
    3232    #region Job
    33     public static DT.Job ToDto(DB.Job source) {
    34       if (source == null) return null;
    35       return new DT.Job {
    36         Id = source.JobId,
     33    public static DT.Task ToDto(DB.Task source) {
     34      if (source == null) return null;
     35      return new DT.Task {
     36        Id = source.TaskId,
    3737        CoresNeeded = source.CoresNeeded,
    3838        ExecutionTime = TimeSpan.FromMilliseconds(source.ExecutionTimeMs),
    3939        MemoryNeeded = source.MemoryNeeded,
    40         ParentJobId = source.ParentJobId,
     40        ParentTaskId = source.ParentTaskId,
    4141        Priority = source.Priority,
    4242        PluginsNeededIds = (source.RequiredPlugins == null ? new List<Guid>() : source.RequiredPlugins.Select(x => x.PluginId).ToList()),
     
    4444        State = Convert.ToDto(source.State),
    4545        StateLog = (source.StateLogs == null ? new List<DT.StateLog>() : source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()),
    46         IsParentJob = source.IsParentJob,
     46        IsParentJob = source.IsParentTask,
    4747        FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished,
    4848        Command = Convert.ToDto(source.Command),
     
    5353    }
    5454
    55     public static DB.Job ToEntity(DT.Job source) {
    56       if (source == null) return null;
    57       var entity = new DB.Job(); ToEntity(source, entity);
    58       return entity;
    59     }
    60     public static void ToEntity(DT.Job source, DB.Job target) {
    61       if ((source != null) && (target != null)) {
    62         target.JobId = source.Id;
     55    public static DB.Task ToEntity(DT.Task source) {
     56      if (source == null) return null;
     57      var entity = new DB.Task(); ToEntity(source, entity);
     58      return entity;
     59    }
     60    public static void ToEntity(DT.Task source, DB.Task target) {
     61      if ((source != null) && (target != null)) {
     62        target.TaskId = source.Id;
    6363        target.CoresNeeded = source.CoresNeeded;
    6464        target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
    6565        target.MemoryNeeded = source.MemoryNeeded;
    66         target.ParentJobId = source.ParentJobId;
     66        target.ParentTaskId = source.ParentTaskId;
    6767        target.Priority = source.Priority;
    6868        target.LastHeartbeat = source.LastHeartbeat;
     
    7272          target.StateLogs.Add(Convert.ToEntity(sl));
    7373        }
    74         target.IsParentJob = source.IsParentJob;
     74        target.IsParentTask = source.IsParentJob;
    7575        target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
    7676        target.Command = Convert.ToEntity(source.Command);
     
    8383
    8484    #region JobData
    85     public static DT.JobData ToDto(DB.JobData source) {
    86       if (source == null) return null;
    87       return new DT.JobData { JobId = source.JobId, Data = source.Data.ToArray(), LastUpdate = source.LastUpdate };
    88     }
    89     public static DB.JobData ToEntity(DT.JobData source) {
    90       if (source == null) return null;
    91       var entity = new DB.JobData(); ToEntity(source, entity);
    92       return entity;
    93     }
    94     public static void ToEntity(DT.JobData source, DB.JobData target) {
    95       if ((source != null) && (target != null)) {
    96         target.JobId = source.JobId; target.Data = new Binary(source.Data); target.LastUpdate = source.LastUpdate;
     85    public static DT.TaskData ToDto(DB.TaskData source) {
     86      if (source == null) return null;
     87      return new DT.TaskData { TaskId = source.TaskId, Data = source.Data.ToArray(), LastUpdate = source.LastUpdate };
     88    }
     89    public static DB.TaskData ToEntity(DT.TaskData source) {
     90      if (source == null) return null;
     91      var entity = new DB.TaskData(); ToEntity(source, entity);
     92      return entity;
     93    }
     94    public static void ToEntity(DT.TaskData source, DB.TaskData target) {
     95      if ((source != null) && (target != null)) {
     96        target.TaskId = source.TaskId; target.Data = new Binary(source.Data); target.LastUpdate = source.LastUpdate;
    9797      }
    9898    }
     
    102102    public static DT.StateLog ToDto(DB.StateLog source) {
    103103      if (source == null) return null;
    104       return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = Convert.ToDto(source.State), UserId = source.UserId };
     104      return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, TaskId = source.TaskId, SlaveId = source.SlaveId, State = Convert.ToDto(source.State), UserId = source.UserId };
    105105    }
    106106    public static DB.StateLog ToEntity(DT.StateLog source) {
     
    111111    public static void ToEntity(DT.StateLog source, DB.StateLog target) {
    112112      if ((source != null) && (target != null)) {
    113         target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = Convert.ToEntity(source.State); target.UserId = source.UserId;
     113        target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.TaskId = source.TaskId; target.SlaveId = source.SlaveId; target.State = Convert.ToEntity(source.State); target.UserId = source.UserId;
    114114      }
    115115    }
     
    365365
    366366
    367     #region JobState
    368     public static DT.JobState ToDto(DB.JobState source) {
    369       if (source == DB.JobState.Aborted) {
    370         return JobState.Aborted;
    371       } else if (source == DB.JobState.Calculating) {
    372         return JobState.Calculating;
    373       } else if (source == DB.JobState.Failed) {
    374         return JobState.Failed;
    375       } else if (source == DB.JobState.Finished) {
    376         return JobState.Finished;
    377       } else if (source == DB.JobState.Offline) {
    378         return JobState.Offline;
    379       } else if (source == DB.JobState.Paused) {
    380         return JobState.Paused;
    381       } else if (source == DB.JobState.Transferring) {
    382         return JobState.Transferring;
    383       } else if (source == DB.JobState.Waiting) {
    384         return JobState.Waiting;
    385       } else
    386         return JobState.Failed;
    387     }
    388 
    389     public static DB.JobState ToEntity(DT.JobState source) {
    390       if (source == DT.JobState.Aborted) {
    391         return DB.JobState.Aborted;
    392       } else if (source == DT.JobState.Calculating) {
    393         return DB.JobState.Calculating;
    394       } else if (source == DT.JobState.Failed) {
    395         return DB.JobState.Failed;
    396       } else if (source == DT.JobState.Finished) {
    397         return DB.JobState.Finished;
    398       } else if (source == DT.JobState.Offline) {
    399         return DB.JobState.Offline;
    400       } else if (source == DT.JobState.Paused) {
    401         return DB.JobState.Paused;
    402       } else if (source == DT.JobState.Transferring) {
    403         return DB.JobState.Transferring;
    404       } else if (source == DT.JobState.Waiting) {
    405         return DB.JobState.Waiting;
    406       } else
    407         return DB.JobState.Failed;
     367    #region TaskData
     368    public static DT.TaskState ToDto(DB.TaskState source) {
     369      if (source == DB.TaskState.Aborted) {
     370        return TaskState.Aborted;
     371      } else if (source == DB.TaskState.Calculating) {
     372        return TaskState.Calculating;
     373      } else if (source == DB.TaskState.Failed) {
     374        return TaskState.Failed;
     375      } else if (source == DB.TaskState.Finished) {
     376        return TaskState.Finished;
     377      } else if (source == DB.TaskState.Offline) {
     378        return TaskState.Offline;
     379      } else if (source == DB.TaskState.Paused) {
     380        return TaskState.Paused;
     381      } else if (source == DB.TaskState.Transferring) {
     382        return TaskState.Transferring;
     383      } else if (source == DB.TaskState.Waiting) {
     384        return TaskState.Waiting;
     385      } else
     386        return TaskState.Failed;
     387    }
     388
     389    public static DB.TaskState ToEntity(DT.TaskState source) {
     390      if (source == DT.TaskState.Aborted) {
     391        return DB.TaskState.Aborted;
     392      } else if (source == DT.TaskState.Calculating) {
     393        return DB.TaskState.Calculating;
     394      } else if (source == DT.TaskState.Failed) {
     395        return DB.TaskState.Failed;
     396      } else if (source == DT.TaskState.Finished) {
     397        return DB.TaskState.Finished;
     398      } else if (source == DT.TaskState.Offline) {
     399        return DB.TaskState.Offline;
     400      } else if (source == DT.TaskState.Paused) {
     401        return DB.TaskState.Paused;
     402      } else if (source == DT.TaskState.Transferring) {
     403        return DB.TaskState.Transferring;
     404      } else if (source == DT.TaskState.Waiting) {
     405        return DB.TaskState.Waiting;
     406      } else
     407        return DB.TaskState.Failed;
    408408    }
    409409    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/LightweightTask.cs

    r6717 r6721  
    2828  [DataContract]
    2929  [Serializable]
    30   public class LightweightJob : HiveItem {
     30  public class LightweightTask : HiveItem {
    3131    [DataMember]
    3232    public TimeSpan ExecutionTime { get; set; }
    3333    [DataMember]
    34     public Guid? ParentJobId { get; set; }
     34    public Guid? ParentTaskId { get; set; }
    3535    [DataMember]
    3636    public List<StateLog> StateLog { get; set; }
    3737    [DataMember]
    38     public JobState State { get; set; }
     38    public TaskState State { get; set; }
    3939    [DataMember]
    4040    public Command? Command { get; set; }
     
    4444    public StateLog CurrentStateLog { get { return StateLog.LastOrDefault(); } }
    4545    public DateTime? DateCreated { get { return StateLog.Count > 0 ? new DateTime?(StateLog.First().DateTime) : null; } }
    46     public DateTime? DateFinished { get { return (StateLog.Count > 0 && CurrentStateLog.State == JobState.Finished) ? new DateTime?(CurrentStateLog.DateTime) : null; } }
     46    public DateTime? DateFinished { get { return (StateLog.Count > 0 && CurrentStateLog.State == TaskState.Finished) ? new DateTime?(CurrentStateLog.DateTime) : null; } }
    4747
    48     public LightweightJob() {
     48    public LightweightTask() {
    4949      StateLog = new List<DataTransfer.StateLog>();
    5050    }
    5151
    52     public LightweightJob(Job job) {
     52    public LightweightTask(Task job) {
    5353      this.Id = job.Id;
    5454      this.ExecutionTime = job.ExecutionTime;
    55       this.ParentJobId = job.ParentJobId;
     55      this.ParentTaskId = job.ParentTaskId;
    5656      this.StateLog = new List<StateLog>(job.StateLog);
    5757      this.State = job.State;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/StateLog.cs

    r6717 r6721  
    3636    public string Exception { get; set; }
    3737    [DataMember]
    38     public JobState State { get; set; }
     38    public TaskState State { get; set; }
    3939    [DataMember]
    40     public Guid JobId { get; set; }
     40    public Guid TaskId { get; set; }
    4141
    4242    public StateLog() { }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Task.cs

    r6717 r6721  
    2727  [DataContract]
    2828  [Serializable]
    29   public class Job : LightweightJob {
     29  public class Task : LightweightTask {
    3030    [DataMember]
    3131    public int Priority { get; set; }
     
    4747    public bool IsPrivileged { get; set; }
    4848
    49     public Job() {
     49    public Task() {
    5050      this.PluginsNeededIds = new List<Guid>();
    5151    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/TaskData.cs

    r6717 r6721  
    2626  [DataContract]
    2727  [Serializable]
    28   public class JobData {
     28  public class TaskData {
    2929    [DataMember]
    30     public Guid JobId { get; set; }
     30    public Guid TaskId { get; set; }
    3131    [DataMember]
    3232    public byte[] Data { get; set; }
     
    3434    public DateTime LastUpdate { get; set; }
    3535
    36     public JobData() { }
     36    public TaskData() { }
    3737  }
    3838}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/TaskState.cs

    r6717 r6721  
    2424namespace HeuristicLab.Services.Hive.DataTransfer {
    2525  [Serializable]
    26   public enum JobState {
     26  public enum TaskState {
    2727    /// <summary>
    28     /// A job is offline as long as he is not yet submitted to the hive
     28    /// A task is offline as long as he is not yet submitted to the hive
    2929    /// </summary>
    3030    Offline,
    3131
    3232    /// <summary>
    33     /// Job is waiting to be calculated
     33    /// Task is waiting to be calculated
    3434    /// </summary>
    3535    Waiting,
    3636
    3737    /// <summary>
    38     /// Job is beeing transferred
     38    /// Task is beeing transferred
    3939    /// </summary>
    4040    Transferring,
    4141
    4242    /// <summary>
    43     /// Job is actively calculated on a Slave
     43    /// Task is actively calculated on a Slave
    4444    /// </summary>
    4545    Calculating,
    4646
    4747    /// <summary>
    48     /// Job is paused, will not be picked up by slaves
     48    /// Task is paused, will not be picked up by slaves
    4949    /// </summary>
    5050    Paused,
    5151
    5252    /// <summary>
    53     /// Job as finished and is ready to be collected by the Client
     53    /// Task as finished and is ready to be collected by the Client
    5454    /// </summary>
    5555    Finished,
    5656
    5757    /// <summary>
    58     /// Job is aborted and result can be collected by the Client
     58    /// Task is aborted and result can be collected by the Client
    5959    /// </summary>
    6060    Aborted,
    6161
    6262    /// <summary>
    63     /// Job as been aborted due to an error. Results are ready to be collected
     63    /// Task as been aborted due to an error. Results are ready to be collected
    6464    /// </summary>
    6565    Failed
    6666  };
    6767
    68   public static class JobStateExtensions {
     68  public static class TaskStateExtensions {
    6969    /// <summary>
    7070    /// This job is not yet done
    7171    /// </summary>
    72     public static bool IsActive(this JobState jobState) {
    73       return !jobState.IsDone();
     72    public static bool IsActive(this TaskState taskState) {
     73      return !taskState.IsDone();
    7474    }
    7575
     
    7777    /// This job is Waiting
    7878    /// </summary>
    79     public static bool IsWaiting(this JobState jobState) {
    80       return jobState == JobState.Waiting;
     79    public static bool IsWaiting(this TaskState taskState) {
     80      return taskState == TaskState.Waiting;
    8181    }
    8282
     
    8484    /// This job is Finished || Failed || Aborted
    8585    /// </summary>
    86     public static bool IsDone(this JobState jobState) {
    87       return jobState == JobState.Finished ||
    88         jobState == JobState.Aborted ||
    89         jobState == JobState.Failed;
     86    public static bool IsDone(this TaskState taskState) {
     87      return taskState == TaskState.Finished ||
     88        taskState == TaskState.Aborted ||
     89        taskState == TaskState.Failed;
    9090    }
    9191  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r6717 r6721  
    111111    <Compile Include="DataTransfer\HiveExperimentPermission.cs" />
    112112    <Compile Include="DataTransfer\HiveItem.cs" />
    113     <Compile Include="DataTransfer\Job.cs" />
    114     <Compile Include="DataTransfer\JobData.cs" />
    115     <Compile Include="DataTransfer\JobState.cs" />
    116     <Compile Include="DataTransfer\LightweightJob.cs" />
     113    <Compile Include="DataTransfer\Task.cs" />
     114    <Compile Include="DataTransfer\TaskData.cs" />
     115    <Compile Include="DataTransfer\TaskState.cs" />
     116    <Compile Include="DataTransfer\LightweightTask.cs" />
    117117    <Compile Include="DataTransfer\NamedHiveItem.cs" />
    118118    <Compile Include="DataTransfer\Permission.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r6717 r6721  
    3737
    3838    #region Job Methods
    39     public DT.Job GetJob(Guid id) {
    40       using (var db = CreateContext()) {
    41         return DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id));
    42       }
    43     }
    44 
    45     public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) {
    46       using (var db = CreateContext()) {
    47         return db.Jobs.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    48       }
    49     }
    50 
    51     public Guid AddJob(DT.Job dto) {
    52       using (var db = CreateContext()) {
    53         var entity = DT.Convert.ToEntity(dto);
    54         db.Jobs.InsertOnSubmit(entity);
     39    public DT.Task GetJob(Guid id) {
     40      using (var db = CreateContext()) {
     41        return DT.Convert.ToDto(db.Tasks.SingleOrDefault(x => x.TaskId == id));
     42      }
     43    }
     44
     45    public IEnumerable<DT.Task> GetJobs(Expression<Func<Task, bool>> predicate) {
     46      using (var db = CreateContext()) {
     47        return db.Tasks.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
     48      }
     49    }
     50
     51    public Guid AddJob(DT.Task dto) {
     52      using (var db = CreateContext()) {
     53        var entity = DT.Convert.ToEntity(dto);
     54        db.Tasks.InsertOnSubmit(entity);
    5555        db.SubmitChanges();
    5656        foreach (Guid pluginId in dto.PluginsNeededIds) {
    57           db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin() { JobId = entity.JobId, PluginId = pluginId });
    58         }
    59         db.SubmitChanges();
    60         return entity.JobId;
    61       }
    62     }
    63 
    64     public void UpdateJob(DT.Job dto) {
    65       using (var db = CreateContext()) {
    66         var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id);
    67         if (entity == null) db.Jobs.InsertOnSubmit(DT.Convert.ToEntity(dto));
     57          db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin() { TaskId = entity.TaskId, PluginId = pluginId });
     58        }
     59        db.SubmitChanges();
     60        return entity.TaskId;
     61      }
     62    }
     63
     64    public void UpdateJob(DT.Task dto) {
     65      using (var db = CreateContext()) {
     66        var entity = db.Tasks.FirstOrDefault(x => x.TaskId == dto.Id);
     67        if (entity == null) db.Tasks.InsertOnSubmit(DT.Convert.ToEntity(dto));
    6868        else DT.Convert.ToEntity(dto, entity);
    6969        foreach (Guid pluginId in dto.PluginsNeededIds) {
    7070          if (db.RequiredPlugins.Count(p => p.PluginId == pluginId) == 0) {
    71             db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin() { JobId = entity.JobId, PluginId = pluginId });
     71            db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin() { TaskId = entity.TaskId, PluginId = pluginId });
    7272          }
    7373        }
     
    7878    public void DeleteJob(Guid id) {
    7979      using (var db = CreateContext()) {
    80         var entity = db.Jobs.FirstOrDefault(x => x.JobId == id);
    81         if (entity != null) db.Jobs.DeleteOnSubmit(entity);
     80        var entity = db.Tasks.FirstOrDefault(x => x.TaskId == id);
     81        if (entity != null) db.Tasks.DeleteOnSubmit(entity);
    8282        db.SubmitChanges(); // JobData and child jobs are deleted by db-trigger
    8383      }
     
    9191    /// <param name="finished">if true, all parent jobs which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
    9292    /// <returns></returns>
    93     public IEnumerable<DT.Job> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished) {
     93    public IEnumerable<DT.Task> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished) {
    9494      using (var db = CreateContext()) {
    9595        var query = from ar in db.AssignedResources
    9696                    where resourceIds.Contains(ar.ResourceId)
    97                        && ar.Job.State == JobState.Waiting
    98                        && ar.Job.IsParentJob
    99                        && (finished ? ar.Job.FinishWhenChildJobsFinished : !ar.Job.FinishWhenChildJobsFinished)
    100                        && (from child in db.Jobs
    101                            where child.ParentJobId == ar.Job.JobId
    102                            select child.State == JobState.Finished
    103                                || child.State == JobState.Aborted
    104                                || child.State == JobState.Failed).All(x => x)
    105                        && (from child in db.Jobs // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
    106                            where child.ParentJobId == ar.Job.JobId
     97                       && ar.Task.State == TaskState.Waiting
     98                       && ar.Task.IsParentTask
     99                       && (finished ? ar.Task.FinishWhenChildJobsFinished : !ar.Task.FinishWhenChildJobsFinished)
     100                       && (from child in db.Tasks
     101                           where child.ParentTaskId == ar.Task.TaskId
     102                           select child.State == TaskState.Finished
     103                               || child.State == TaskState.Aborted
     104                               || child.State == TaskState.Failed).All(x => x)
     105                       && (from child in db.Tasks // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
     106                           where child.ParentTaskId == ar.Task.TaskId
    107107                           select child).Count() > 0
    108                     orderby ar.Job.Priority descending, db.Random()
    109                     select DT.Convert.ToDto(ar.Job);
     108                    orderby ar.Task.Priority descending, db.Random()
     109                    select DT.Convert.ToDto(ar.Task);
    110110        return count == 0 ? query.ToArray() : query.Take(count).ToArray();
    111111      }
    112112    }
    113113
    114     public IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave, int count) {
     114    public IEnumerable<DT.Task> GetWaitingJobs(DT.Slave slave, int count) {
    115115      using (var db = CreateContext()) {
    116116        var resourceIds = GetParentResources(slave.Id).Select(r => r.Id);
     
    120120        var query = from ar in db.AssignedResources
    121121                    where resourceIds.Contains(ar.ResourceId)
    122                        && !(ar.Job.IsParentJob && ar.Job.FinishWhenChildJobsFinished)
    123                        && ar.Job.State == JobState.Waiting
    124                        && ar.Job.CoresNeeded <= slave.FreeCores
    125                        && ar.Job.MemoryNeeded <= slave.FreeMemory
    126                     orderby ar.Job.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
    127                     select DT.Convert.ToDto(ar.Job);
     122                       && !(ar.Task.IsParentTask && ar.Task.FinishWhenChildJobsFinished)
     123                       && ar.Task.State == TaskState.Waiting
     124                       && ar.Task.CoresNeeded <= slave.FreeCores
     125                       && ar.Task.MemoryNeeded <= slave.FreeMemory
     126                    orderby ar.Task.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
     127                    select DT.Convert.ToDto(ar.Task);
    128128        var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray();
    129129        return waitingJobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
     
    131131    }
    132132
    133     public DT.Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
    134       using (var db = CreateContext()) {
    135         var job = db.Jobs.SingleOrDefault(x => x.JobId == jobId);
     133    public DT.Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {
     134      using (var db = CreateContext()) {
     135        var job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);
    136136        job.State = jobState;
    137137        db.StateLogs.InsertOnSubmit(new StateLog {
    138           JobId = jobId,
     138          TaskId = jobId,
    139139          State = jobState,
    140140          SlaveId = slaveId,
     
    144144        });
    145145        db.SubmitChanges();
    146         job = db.Jobs.SingleOrDefault(x => x.JobId == jobId);
     146        job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);
    147147        return DT.Convert.ToDto(job);
    148148      }
     
    151151
    152152    #region JobData Methods
    153     public DT.JobData GetJobData(Guid id) {
     153    public DT.TaskData GetJobData(Guid id) {
    154154      using (var db = CreateContext(true)) {
    155         return DT.Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id));
    156       }
    157     }
    158 
    159     public IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate) {
     155        return DT.Convert.ToDto(db.TaskDatas.SingleOrDefault(x => x.TaskId == id));
     156      }
     157    }
     158
     159    public IEnumerable<DT.TaskData> GetJobDatas(Expression<Func<TaskData, bool>> predicate) {
    160160      using (var db = CreateContext(true)) {
    161         return db.JobDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    162       }
    163     }
    164 
    165     public Guid AddJobData(DT.JobData dto) {
     161        return db.TaskDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
     162      }
     163    }
     164
     165    public Guid AddJobData(DT.TaskData dto) {
    166166      using (var db = CreateContext(true)) {
    167167        var entity = DT.Convert.ToEntity(dto);
    168         db.JobDatas.InsertOnSubmit(entity);
    169         db.SubmitChanges();
    170         return entity.JobId;
    171       }
    172     }
    173 
    174     public void UpdateJobData(DT.JobData dto) {
     168        db.TaskDatas.InsertOnSubmit(entity);
     169        db.SubmitChanges();
     170        return entity.TaskId;
     171      }
     172    }
     173
     174    public void UpdateJobData(DT.TaskData dto) {
    175175      using (var db = CreateContext(true)) {
    176         var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.JobId);
    177         if (entity == null) db.JobDatas.InsertOnSubmit(DT.Convert.ToEntity(dto));
     176        var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == dto.TaskId);
     177        if (entity == null) db.TaskDatas.InsertOnSubmit(DT.Convert.ToEntity(dto));
    178178        else DT.Convert.ToEntity(dto, entity);
    179179        db.SubmitChanges();
     
    183183    public void DeleteJobData(Guid id) {
    184184      using (var db = CreateContext()) {
    185         var entity = db.JobDatas.FirstOrDefault(x => x.JobId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it
    186         if (entity != null) db.JobDatas.DeleteOnSubmit(entity);
     185        var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it
     186        if (entity != null) db.TaskDatas.DeleteOnSubmit(entity);
    187187        db.SubmitChanges();
    188188      }
     
    241241        return null;
    242242
    243       var jobs = db.Jobs.Where(j => j.HiveExperimentId == exp.Id);
     243      var jobs = db.Tasks.Where(j => j.HiveExperimentId == exp.Id);
    244244      exp.JobCount = jobs.Count();
    245       exp.CalculatingCount = jobs.Count(j => j.State == JobState.Calculating);
    246       exp.FinishedCount = jobs.Count(j => j.State == JobState.Finished);
     245      exp.CalculatingCount = jobs.Count(j => j.State == TaskState.Calculating);
     246      exp.FinishedCount = jobs.Count(j => j.State == TaskState.Finished);
    247247      return exp;
    248248    }
     
    554554    public void AssignJobToResource(Guid jobId, Guid resourceId) {
    555555      using (var db = CreateContext()) {
    556         var job = db.Jobs.Where(x => x.JobId == jobId).Single();
    557         job.AssignedResources.Add(new AssignedResource() { JobId = jobId, ResourceId = resourceId });
     556        var job = db.Tasks.Where(x => x.TaskId == jobId).Single();
     557        job.AssignedResources.Add(new AssignedResource() { TaskId = jobId, ResourceId = resourceId });
    558558        db.SubmitChanges();
    559559      }
     
    562562    public IEnumerable<DT.Resource> GetAssignedResources(Guid jobId) {
    563563      using (var db = CreateContext()) {
    564         var job = db.Jobs.Where(x => x.JobId == jobId).Single();
     564        var job = db.Tasks.Where(x => x.TaskId == jobId).Single();
    565565        return job.AssignedResources.Select(x => DT.Convert.ToDto(x.Resource)).ToArray();
    566566      }
     
    598598    }
    599599
    600     public IEnumerable<DT.Job> GetJobsByResourceId(Guid resourceId) {
     600    public IEnumerable<DT.Task> GetJobsByResourceId(Guid resourceId) {
    601601      using (var db = CreateContext()) {
    602602        var resources = GetChildResources(resourceId).Select(x => x.Id).ToList();
    603603        resources.Add(resourceId);
    604604
    605         var jobs = db.Jobs.Where(j =>
    606           j.State == JobState.Calculating &&
     605        var jobs = db.Tasks.Where(j =>
     606          j.State == TaskState.Calculating &&
    607607          j.StateLogs.OrderByDescending(x => x.DateTime).First().SlaveId.HasValue &&
    608608          resources.Contains(j.StateLogs.OrderByDescending(x => x.DateTime).First().SlaveId.Value));
     
    631631    public Guid GetExperimentForJob(Guid jobId) {
    632632      using (var db = CreateContext()) {
    633         return db.Jobs.Single(j => j.JobId == jobId).HiveExperimentId;
     633        return db.Tasks.Single(j => j.TaskId == jobId).HiveExperimentId;
    634634      }
    635635    }
     
    743743        var userStats = new Dictionary<Guid, DT.UserStatistics>();
    744744
    745         var usedCoresByUser = from job in db.Jobs
    746                               where job.State == JobState.Calculating
     745        var usedCoresByUser = from job in db.Tasks
     746                              where job.State == TaskState.Calculating
    747747                              group job by job.HiveExperiment.OwnerUserId into g
    748748                              select new { UserId = g.Key, UsedCores = g.Count() };
     
    755755        }
    756756
    757         var executionTimesByUser = from job in db.Jobs
     757        var executionTimesByUser = from job in db.Tasks
    758758                                   group job by job.HiveExperiment.OwnerUserId into g
    759759                                   select new { UserId = g.Key, ExecutionTime = TimeSpan.FromMilliseconds(g.Select(x => x.ExecutionTimeMs).Sum()) };
     
    766766
    767767        // execution times only of finished jobs - necessary to compute efficieny
    768         var executionTimesFinishedJobs = from job in db.Jobs
    769                                          where job.State == JobState.Finished
     768        var executionTimesFinishedJobs = from job in db.Tasks
     769                                         where job.State == TaskState.Finished
    770770                                         group job by job.HiveExperiment.OwnerUserId into g
    771771                                         select new { UserId = g.Key, ExecutionTimeFinishedJobs = TimeSpan.FromMilliseconds(g.Select(x => x.ExecutionTimeMs).Sum()) };
     
    779779
    780780        // start to end times only of finished jobs - necessary to compute efficiency
    781         var startToEndTimesFinishedJobs = from job in db.Jobs
    782                                           where job.State == JobState.Finished
     781        var startToEndTimesFinishedJobs = from job in db.Tasks
     782                                          where job.State == TaskState.Finished
    783783                                          group job by job.HiveExperiment.OwnerUserId into g
    784784                                          select new {
     
    817817
    818818    #region Helpers
    819     private void CollectChildJobs(HiveDataContext db, Guid parentJobId, List<Job> collection) {
    820       var jobs = db.Jobs.Where(j => j.ParentJobId == parentJobId);
     819    private void CollectChildJobs(HiveDataContext db, Guid parentJobId, List<Task> collection) {
     820      var jobs = db.Tasks.Where(j => j.ParentTaskId == parentJobId);
    821821      foreach (var job in jobs) {
    822822        collection.Add(job);
    823         if (job.IsParentJob)
    824           CollectChildJobs(db, job.JobId, collection);
     823        if (job.IsParentTask)
     824          CollectChildJobs(db, job.TaskId, collection);
    825825      }
    826826    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r6717 r6721  
    6161
    6262    #region Job Methods
    63     public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
     63    public Guid AddJob(Task job, TaskData jobData, IEnumerable<Guid> resourceIds) {
    6464      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    6565      return trans.UseTransaction(() => {
    6666        job.Id = dao.AddJob(job);
    67         jobData.JobId = job.Id;
     67        jobData.TaskId = job.Id;
    6868        jobData.LastUpdate = DateTime.Now;
    6969        foreach (Guid slaveGroupId in resourceIds) {
     
    7171        }
    7272        dao.AddJobData(jobData);
    73         dao.UpdateJobState(job.Id, DA.JobState.Waiting, null, userManager.CurrentUserId, null);
    74         return jobData.JobId;
     73        dao.UpdateJobState(job.Id, DA.TaskState.Waiting, null, userManager.CurrentUserId, null);
     74        return jobData.TaskId;
    7575      }, false, true);
    7676    }
    7777
    78     public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
    79       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    80       return trans.UseTransaction(() => {
    81         job.ParentJobId = parentJobId;
     78    public Guid AddChildJob(Guid parentJobId, Task job, TaskData jobData) {
     79      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     80      return trans.UseTransaction(() => {
     81        job.ParentTaskId = parentJobId;
    8282        return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
    8383      }, false, true);
    8484    }
    8585
    86     public Job GetJob(Guid jobId) {
     86    public Task GetJob(Guid jobId) {
    8787      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    8888      author.AuthorizeForJob(jobId, Permission.Read);
     
    9090    }
    9191
    92     public IEnumerable<Job> GetJobs() {
     92    public IEnumerable<Task> GetJobs() {
    9393      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    9494      var jobs = dao.GetJobs(x => true);
     
    9898    }
    9999
    100     public IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds) {
    101       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    102       var jobs = dao.GetJobs(x => jobIds.Contains(x.JobId)).Select(x => new LightweightJob(x)).ToArray();
     100    public IEnumerable<LightweightTask> GetLightweightJobs(IEnumerable<Guid> jobIds) {
     101      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     102      var jobs = dao.GetJobs(x => jobIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray();
    103103      foreach (var job in jobs)
    104104        author.AuthorizeForJob(job.Id, Permission.Read);
     
    106106    }
    107107
    108     public IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
    109       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    110       var jobs = GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightJob(x)).ToArray();
     108    public IEnumerable<LightweightTask> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
     109      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     110      var jobs = GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightTask(x)).ToArray();
    111111      foreach (var job in jobs)
    112112        author.AuthorizeForJob(job.Id, Permission.Read);
     
    114114    }
    115115
    116     public IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId) {
     116    public IEnumerable<LightweightTask> GetLightweightExperimentJobs(Guid experimentId) {
    117117      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    118118      author.AuthorizeForExperiment(experimentId, Permission.Read);
    119       return dao.GetJobs(x => x.HiveExperimentId == experimentId).Select(x => new LightweightJob(x)).ToArray();
    120     }
    121 
    122     public JobData GetJobData(Guid jobId) {
     119      return dao.GetJobs(x => x.HiveExperimentId == experimentId).Select(x => new LightweightTask(x)).ToArray();
     120    }
     121
     122    public TaskData GetJobData(Guid jobId) {
    123123      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    124124      author.AuthorizeForJob(jobId, Permission.Read);
     
    126126    }
    127127
    128     public void UpdateJob(Job job) {
     128    public void UpdateJob(Task job) {
    129129      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    130130      author.AuthorizeForJob(job.Id, Permission.Full);
     
    134134    }
    135135
    136     public void UpdateJobData(Job job, JobData jobData) {
     136    public void UpdateJobData(Task job, TaskData jobData) {
    137137      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    138138      author.AuthorizeForJob(job.Id, Permission.Full);
    139       author.AuthorizeForJob(jobData.JobId, Permission.Full);
     139      author.AuthorizeForJob(jobData.TaskId, Permission.Full);
    140140      //trans.UseTransaction(() => { // cneumuel: try without transaction
    141141      jobData.LastUpdate = DateTime.Now;
     
    165165    }
    166166
    167     public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
     167    public Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {
    168168      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    169169      author.AuthorizeForJob(jobId, Permission.Full);
    170170      return trans.UseTransaction(() => {
    171         Job job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(jobState), slaveId, userId, exception);
    172 
    173         if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == JobState.Paused) {
     171        Task job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(jobState), slaveId, userId, exception);
     172
     173        if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == TaskState.Paused) {
    174174          job.Command = null;
    175         } else if (job.Command.HasValue && job.Command.Value == Command.Abort && job.State == JobState.Aborted) {
     175        } else if (job.Command.HasValue && job.Command.Value == Command.Abort && job.State == TaskState.Aborted) {
    176176          job.Command = null;
    177         } else if (job.Command.HasValue && job.Command.Value == Command.Stop && job.State == JobState.Aborted) {
     177        } else if (job.Command.HasValue && job.Command.Value == Command.Stop && job.State == TaskState.Aborted) {
    178178          job.Command = null;
    179         } else if (jobState == JobState.Paused && !job.Command.HasValue) {
     179        } else if (jobState == TaskState.Paused && !job.Command.HasValue) {
    180180          // slave paused and uploaded the job (no user-command) -> set waiting.
    181           job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(JobState.Waiting), slaveId, userId, exception);
     181          job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(TaskState.Waiting), slaveId, userId, exception);
    182182        }
    183183
     
    187187    }
    188188
    189     public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) {
     189    public IEnumerable<Task> GetJobsByResourceId(Guid resourceId) {
    190190      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    191191      var jobs = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     
    202202      trans.UseTransaction(() => {
    203203        var job = dao.GetJob(jobId);
    204         if (job.State == JobState.Calculating || job.State == JobState.Transferring) {
     204        if (job.State == TaskState.Calculating || job.State == TaskState.Transferring) {
    205205          job.Command = Command.Stop;
    206206          dao.UpdateJob(job);
    207207        } else {
    208           if (job.State != JobState.Aborted && job.State != JobState.Finished && job.State != JobState.Failed) {
    209             job = UpdateJobState(jobId, JobState.Aborted, null, null, string.Empty);
     208          if (job.State != TaskState.Aborted && job.State != TaskState.Finished && job.State != TaskState.Failed) {
     209            job = UpdateJobState(jobId, TaskState.Aborted, null, null, string.Empty);
    210210          }
    211211        }
     
    218218      trans.UseTransaction(() => {
    219219        var job = dao.GetJob(jobId);
    220         if (job.State == JobState.Calculating || job.State == JobState.Transferring) {
     220        if (job.State == TaskState.Calculating || job.State == TaskState.Transferring) {
    221221          job.Command = Command.Pause;
    222222          dao.UpdateJob(job);
    223223        } else {
    224           job = UpdateJobState(jobId, JobState.Paused, null, null, string.Empty);
     224          job = UpdateJobState(jobId, TaskState.Paused, null, null, string.Empty);
    225225        }
    226226      });
     
    231231      author.AuthorizeForJob(jobId, Permission.Full);
    232232      trans.UseTransaction(() => {
    233         Job job = dao.UpdateJobState(jobId, DA.JobState.Waiting, null, userManager.CurrentUserId, string.Empty);
     233        Task job = dao.UpdateJobState(jobId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty);
    234234        job.Command = null;
    235235        dao.UpdateJob(job);
     
    591591
    592592    #region Helper Methods
    593     private IEnumerable<Job> GetChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
    594       var jobs = new List<Job>(dao.GetJobs(x => parentJobId == null ? !x.ParentJobId.HasValue : x.ParentJobId.Value == parentJobId));
     593    private IEnumerable<Task> GetChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
     594      var jobs = new List<Task>(dao.GetJobs(x => parentJobId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentJobId));
    595595
    596596      if (recursive) {
    597         var childs = new List<Job>();
     597        var childs = new List<Task>();
    598598        foreach (var job in jobs) {
    599599          childs.AddRange(GetChildJobs(job.Id, recursive, false));
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r6717 r6721  
    2929  public interface IHiveDao {
    3030    #region Job Methods
    31     DT.Job GetJob(Guid id);
    32     IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate);
    33     Guid AddJob(DT.Job dto);
    34     void UpdateJob(DT.Job dto);
     31    DT.Task GetJob(Guid id);
     32    IEnumerable<DT.Task> GetJobs(Expression<Func<Task, bool>> predicate);
     33    Guid AddJob(DT.Task dto);
     34    void UpdateJob(DT.Task dto);
    3535    void DeleteJob(Guid id);
    36     IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave, int count);
    37     IEnumerable<DT.Job> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished);
    38     DT.Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception);
     36    IEnumerable<DT.Task> GetWaitingJobs(DT.Slave slave, int count);
     37    IEnumerable<DT.Task> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished);
     38    DT.Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception);
    3939    #endregion
    4040
    4141    #region JobData Methods
    42     DT.JobData GetJobData(Guid id);
    43     IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate);
    44     Guid AddJobData(DT.JobData dto);
    45     void UpdateJobData(DT.JobData dto);
     42    DT.TaskData GetJobData(Guid id);
     43    IEnumerable<DT.TaskData> GetJobDatas(Expression<Func<TaskData, bool>> predicate);
     44    Guid AddJobData(DT.TaskData dto);
     45    void UpdateJobData(DT.TaskData dto);
    4646    void DeleteJobData(Guid id);
    4747    #endregion
     
    117117    IEnumerable<DT.Resource> GetParentResources(Guid resourceId);
    118118    IEnumerable<DT.Resource> GetChildResources(Guid resourceId);
    119     IEnumerable<DT.Job> GetJobsByResourceId(Guid resourceId);
     119    IEnumerable<DT.Task> GetJobsByResourceId(Guid resourceId);
    120120    #endregion
    121121
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs

    r6717 r6721  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Services.Hive.DataAccess;
    2625using HeuristicLab.Services.Hive.DataAccess;
    2726using DT = HeuristicLab.Services.Hive.DataTransfer;
     
    9291      var parentJobsToFinish = dao.GetParentJobs(dao.GetResources(x => true).Select(x => x.Id), 0, true);
    9392      foreach (var job in parentJobsToFinish) {
    94         dao.UpdateJobState(job.Id, JobState.Finished, null, null, string.Empty);
     93        dao.UpdateJobState(job.Id, TaskState.Finished, null, null, string.Empty);
    9594      }
    9695    }
    9796
    9897    private void SetJobsWaiting(Guid slaveId) {
    99       var jobs = dao.GetJobs(x => x.State == JobState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);
     98      var jobs = dao.GetJobs(x => x.State == TaskState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);
    10099      foreach (var j in jobs) {
    101         DT.Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out.");
     100        DT.Task job = dao.UpdateJobState(j.Id, TaskState.Waiting, slaveId, null, "Slave timed out.");
    102101        job.Command = null;
    103102        dao.UpdateJob(job);
     
    109108    /// </summary>
    110109    private void SetTimeoutJobsWaiting() {
    111       var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout)
    112                                || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.TransferringJobHeartbeatTimeout));
     110      var jobs = dao.GetJobs(x => (x.State == TaskState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout)
     111                               || (x.State == TaskState.Transferring && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.TransferringJobHeartbeatTimeout));
    113112      foreach (var j in jobs) {
    114         DT.Job job = dao.UpdateJobState(j.Id, JobState.Waiting, null, null, "Slave timed out.");
     113        DT.Task job = dao.UpdateJobState(j.Id, TaskState.Waiting, null, null, "Slave timed out.");
    115114        job.Command = null;
    116115        dao.UpdateJob(job);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r6717 r6721  
    7171
    7272    // returns true if assignment was successful
    73     private bool AssignJob(Slave slave, Job job) {
     73    private bool AssignJob(Slave slave, Task job) {
    7474      // load job again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same job assigned)
    75       if (dao.GetJob(job.Id).State != JobState.Waiting) return false;
     75      if (dao.GetJob(job.Id).State != TaskState.Waiting) return false;
    7676
    77       job = dao.UpdateJobState(job.Id, DataAccess.JobState.Transferring, slave.Id, null, null);
     77      job = dao.UpdateJobState(job.Id, DataAccess.TaskState.Transferring, slave.Id, null, null);
    7878
    7979      // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
     
    9898        // process the jobProgresses
    9999        foreach (var jobProgress in heartbeat.JobProgress) {
    100           Job curJob = dao.GetJob(jobProgress.Key);
     100          Task curJob = dao.GetJob(jobProgress.Key);
    101101          if (curJob == null) {
    102102            // job does not exist in db
     
    135135    }
    136136
    137     private bool JobIsAllowedToBeCalculatedBySlave(Guid slaveId, Job curJob) {
     137    private bool JobIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curJob) {
    138138      var assignedResourceIds = dao.GetAssignedResources(curJob.Id).Select(x => x.Id);
    139139      var slaveResourceIds = dao.GetParentResources(slaveId).Select(x => x.Id);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/MessageContainer.cs

    r6717 r6721  
    2828  /// <summary>
    2929  /// The MessageContainer is a container class for Messages. Its two parts are:
    30   /// the actual message itself and the JobId, refered by the message
     30  /// the actual message itself and the TaskId, refered by the message
    3131  /// </summary>
    3232  [StorableClass]
     
    5656    [Storable]
    5757    [DataMember]
    58     public Guid JobId { get; set; }
     58    public Guid TaskId { get; set; }
    5959
    6060    [StorableConstructor]
     
    6363    public MessageContainer(MessageType message) {
    6464      Message = message;
    65       JobId = Guid.Empty;
     65      TaskId = Guid.Empty;
    6666    }
    6767    public MessageContainer(MessageType message, Guid jobId) {
    6868      Message = message;
    69       JobId = jobId;
     69      TaskId = jobId;
    7070    }
    7171    protected MessageContainer(MessageContainer original, Cloner cloner) {
    7272      cloner.RegisterClonedObject(original, this);
    7373      this.Message = original.Message;
    74       this.JobId = original.JobId;
     74      this.TaskId = original.TaskId;
    7575    }
    7676    public virtual IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r6717 r6721  
    3333    #region Job Methods
    3434    [OperationContract]
    35     Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds);
    36 
    37     [OperationContract]
    38     Guid AddChildJob(Guid parentJobId, Job job, JobData jobData);
    39 
    40     [OperationContract]
    41     Job GetJob(Guid jobId);
    42 
    43     [OperationContract]
    44     IEnumerable<Job> GetJobs();
    45 
    46     [OperationContract]
    47     IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds);
    48 
    49     [OperationContract]
    50     IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent);
    51 
    52     [OperationContract]
    53     IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId);
    54 
    55     [OperationContract]
    56     JobData GetJobData(Guid jobId);
    57 
    58     [OperationContract]
    59     void UpdateJob(Job jobDto);
    60 
    61     [OperationContract]
    62     void UpdateJobData(Job jobDto, JobData jobDataDto);
     35    Guid AddJob(Task job, TaskData jobData, IEnumerable<Guid> resourceIds);
     36
     37    [OperationContract]
     38    Guid AddChildJob(Guid parentJobId, Task job, TaskData jobData);
     39
     40    [OperationContract]
     41    Task GetJob(Guid jobId);
     42
     43    [OperationContract]
     44    IEnumerable<Task> GetJobs();
     45
     46    [OperationContract]
     47    IEnumerable<LightweightTask> GetLightweightJobs(IEnumerable<Guid> jobIds);
     48
     49    [OperationContract]
     50    IEnumerable<LightweightTask> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent);
     51
     52    [OperationContract]
     53    IEnumerable<LightweightTask> GetLightweightExperimentJobs(Guid experimentId);
     54
     55    [OperationContract]
     56    TaskData GetJobData(Guid jobId);
     57
     58    [OperationContract]
     59    void UpdateJob(Task jobDto);
     60
     61    [OperationContract]
     62    void UpdateJobData(Task jobDto, TaskData jobDataDto);
    6363
    6464    [OperationContract]
     
    6969
    7070    [OperationContract]
    71     Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception);
     71    Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception);
    7272    #endregion
    7373
     
    194194
    195195    [OperationContract]
    196     IEnumerable<Job> GetJobsByResourceId(Guid resourceId);
     196    IEnumerable<Task> GetJobsByResourceId(Guid resourceId);
    197197
    198198    [OperationContract]
Note: See TracChangeset for help on using the changeset viewer.