Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/07/10 10:22:27 (14 years ago)
Author:
cneumuel
Message:
  • created HiveClient which shows an overview over all submitted HiveExperiments
  • its possible to download all submitted HiveExperiments including results
  • Experiments are now sent as a whole to the Hive and the Hive-Slaves take care of creating child-jobs (if necessary). The parent job is then paused and will be reactivated when all child-jobs are finished
  • WcfService-Clients are now consistently managed by WcfServicePool which allows to use IDisposable-Pattern and always keeps exactly one proxy-object until all callers disposed them.
  • created ProgressView which is able to lock a View and display progress of an action. It also allows to simulate progress if no progress-information is available so that users don't get too nervous while waiting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/JobDao.cs

    r4333 r4368  
    7373      Job j = DtoToEntity(job.JobInfo, null);
    7474      j.SerializedJob = job.SerializedJobData;
    75       foreach (Guid assignRessourceId in job.JobInfo.AssignedResourceIds)
    76         j.AssignedResources.Add(new AssignedResource { ResourceId = assignRessourceId });
     75      //foreach (Guid assignRessourceId in job.JobInfo.AssignedResourceIds)
     76      //  j.AssignedResources.Add(new AssignedResource { ResourceId = assignRessourceId });
    7777      Context.Jobs.InsertOnSubmit(j);
    7878      CommitChanges();
     
    9898                     j.JobState == Enum.GetName(typeof(JobState), JobState.Aborted) ||
    9999                     j.JobState == Enum.GetName(typeof(JobState), JobState.SnapshotRequested) ||
    100                      j.JobState == Enum.GetName(typeof(JobState), JobState.SnapshotSent)) &&
     100                     j.JobState == Enum.GetName(typeof(JobState), JobState.SnapshotSent) ||
     101                     j.JobState == Enum.GetName(typeof(JobState), JobState.WaitForChildJobs)) &&
    101102                    (j.ResourceId.Equals(slave.Id))
    102103              select EntityToDto(j, null)).ToList();
    103104    }
    104105
    105     public IEnumerable<JobDto> FindFittingJobsForSlave(JobState state, int freeCores, int freeMemory, Guid slaveId) {
     106    public IEnumerable<JobDto> FindFittingJobs(JobState state, int freeCores, int freeMemory, Guid slaveId) {
    106107      SlaveGroupDao cgd = new SlaveGroupDao();
    107108
     
    111112
    112113      var q = (from ar in Context.AssignedResources
    113                where ar.Job.JobState == Enum.GetName(typeof(JobState), JobState.Offline) &&
     114               where ar.Job.JobState == Enum.GetName(typeof(JobState), state) &&
    114115                     ar.Job.CoresNeeded <= freeCores &&
    115116                     ar.Job.MemoryNeeded <= freeMemory &&
     
    120121    }
    121122
     123    public IEnumerable<JobDto> FindJobsWithFinishedChilds(Guid slaveId) {
     124      SlaveGroupDao cgd = new SlaveGroupDao();
     125     
     126      List<Guid> idList = new List<Guid>(cgd.FindAllGroupAndParentGroupIdsForSlave(slaveId));
     127      //Add myself too - enables jobs for one specific host!
     128      idList.Add(slaveId);
     129
     130      var query = from ar in Context.AssignedResources
     131                  where ar.Job.JobState == Enum.GetName(typeof(JobState), JobState.WaitForChildJobs) &&
     132                    (from child in Context.Jobs
     133                     where child.ParentJobId == ar.Job.JobId
     134                     select child.JobState == Enum.GetName(typeof(JobState), JobState.Finished)).All(x => x)
     135                  orderby ar.Job.Priority descending
     136                  select EntityToDto(ar.Job, null);
     137      var list = query.ToList();
     138      return list;
     139    }
     140
    122141    public IEnumerable<JobDto> GetJobsByState(JobState state) {
    123142      return (from j in Context.Jobs
     
    127146
    128147    public void AssignSlaveToJob(Guid slaveId, Guid jobId) {
    129       Slave c = Context.Resources.OfType<Slave>().SingleOrDefault(slave => slave.ResourceId.Equals(slaveId));
     148      Slave s = Context.Resources.OfType<Slave>().SingleOrDefault(slave => slave.ResourceId.Equals(slaveId));
    130149      Job j = Context.Jobs.SingleOrDefault(job => job.JobId.Equals(jobId));
    131       c.Jobs.Add(j);
    132       j.Slave = c;
     150      s.Jobs.Add(j);
     151      j.Slave = s;
     152      CommitChanges();
     153    }
     154
     155    public void UnAssignSlaveToJob(Guid jobId) {
     156      Job j = Context.Jobs.SingleOrDefault(job => job.JobId.Equals(jobId));
     157      j.Slave = null;
    133158      CommitChanges();
    134159    }
     
    153178    }
    154179
    155     public bool IsUserAuthorizedForJobs(string userId, params Guid[] jobIds) {
     180    public bool IsUserAuthorizedForJobs(Guid userId, params Guid[] jobIds) {
    156181      var jobs = from job in Context.Jobs
    157182                 where jobIds.Contains(job.JobId)
     
    159184      return jobs.All(job => job.UserId == userId);
    160185    }
     186
     187    public IEnumerable<JobDto> FindJobsByParentId(Guid? parentJobId, bool recursive) {
     188      IQueryable<JobDto> query = from job in Context.Jobs
     189                                 where parentJobId == null ? !job.ParentJobId.HasValue : job.ParentJobId.Value == parentJobId
     190                                 select EntityToDto(job, null);
     191      List<JobDto> jobs = query.ToList();
     192      if (recursive) {
     193        List<JobDto> childs = new List<JobDto>();
     194        foreach (JobDto job in jobs) {
     195          childs.AddRange(FindJobsByParentId(job.Id, recursive));
     196        }
     197        jobs.AddRange(childs);
     198      }
     199      return jobs;
     200    }
     201
    161202    #endregion
    162203
     
    181222      target.JobState = Enum.GetName(typeof(JobState), source.State);
    182223      target.UserId = source.UserId;
     224      if (source.ParentJob != null) {
     225        target.ParentJobId = source.ParentJob.Id;
     226      }
     227
     228      foreach (Guid assignRessourceId in source.AssignedResourceIds) {
     229        if (!target.AssignedResources.Select(x => x.ResourceId).Contains(assignRessourceId)) {
     230          target.AssignedResources.Add(new AssignedResource { ResourceId = assignRessourceId });
     231        }
     232      }
     233
    183234      return target;
    184235    }
    185236
    186     //Assigned ressources are not used atm!
    187237    //Slave is not used ATM - not sure when we stopped using those...
    188238    public override JobDto EntityToDto(Job source, JobDto target) {
     
    199249      target.DateFinished = source.DateFinished;
    200250      target.Id = source.JobId;
    201      
     251
    202252      target.Exception = source.Exception;
    203253      target.Percentage = source.Percentage;
     
    206256      target.State = (JobState)Enum.Parse(typeof(JobState), source.JobState, true);
    207257      target.UserId = source.UserId;
     258
     259      if (source.ParentJobId.HasValue) {
     260        target.ParentJob = new JobDto() { Id = source.ParentJobId.Value };
     261      }
     262      target.AssignedResourceIds = source.AssignedResources.Select(x => x.ResourceId).ToList();
     263
    208264      return target;
    209265    }
Note: See TracChangeset for help on using the changeset viewer.