Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17067


Ignore:
Timestamp:
07/04/19 15:20:26 (5 years ago)
Author:
mkommend
Message:

#2839: Merged 16622, 16878 into stable.

Location:
stable
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive

  • stable/HeuristicLab.Clients.Hive.Administrator

  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r17062 r17067  
    2626using System.Threading.Tasks;
    2727using System.Windows.Forms;
     28using HeuristicLab.Clients.Hive.Views;
     29using HeuristicLab.Core;
     30using HeuristicLab.Core.Views;
     31using HeuristicLab.Data;
    2832using HeuristicLab.MainForm;
    2933using HeuristicLab.MainForm.WindowsForms;
    30 using HeuristicLab.Core.Views;
    31 using HeuristicLab.Data;
    32 using HeuristicLab.Clients.Hive.Views;
    33 using HeuristicLab.Core;
    3434
    3535namespace HeuristicLab.Clients.Hive.Administrator.Views {
     
    297297
    298298    private void RefreshJobs() {
    299       HiveAdminClient.Instance.RefreshJobs();
     299      HiveAdminClient.Instance.RefreshJobs(Content.Id);
    300300      UpdateJobs();
    301301      SetEnabledStateOfControls();
     
    303303
    304304    private StringMatrix CreateValueMatrix() {
    305       if (Content == null || Content.Id == Guid.Empty)
     305      if (Content == null || Content.Id == Guid.Empty || !HiveAdminClient.Instance.Jobs.ContainsKey(Content.Id))
    306306        return new StringMatrix();
    307307
     
    352352
    353353            matrixView.DataGridView.AutoResizeColumns();
    354             matrixView.DataGridView.Columns[0].MinimumWidth = 90;
    355             matrixView.DataGridView.Columns[1].MinimumWidth = 108;
    356354          }
    357355        }
     
    360358
    361359    private void RefreshJobsAsync() {
    362       HiveAdminClient.Instance.RefreshJobs();
     360      HiveAdminClient.Instance.RefreshJobs(Content.Id);
    363361      UpdateJobs();
    364362    }
  • stable/HeuristicLab.Clients.Hive.Slave

  • stable/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r15584 r17067  
    3838  /// </summary>
    3939  public class Core : MarshalByRefObject {
     40    private static readonly object locker = new object();
     41
    4042    private static HeartbeatManager heartbeatManager;
    4143    public static HeartbeatManager HeartbeatManager {
     
    240242        task = wcfService.GetTask(taskId);
    241243        if (task == null) throw new TaskNotFoundException(taskId);
    242         if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException();
    243         if (ConfigManager.Instance.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
    244         SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded;
     244        lock (locker) {
     245          // the amount of used cores/memory could exceed the amount of available cores/memory
     246          // if HandleCalculateTask is called simultaneously from within two different tasks
     247          if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException();
     248          if (ConfigManager.Instance.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
     249          SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded;
     250        }
    245251        TaskData taskData = wcfService.GetTaskData(taskId);
    246252        if (taskData == null) throw new TaskDataNotFoundException(taskId);
     
    400406
    401407    private void taskManager_TaskAborted(object sender, EventArgs<SlaveTask> e) {
     408      var slaveTask = e.Value;
     409      var task = wcfService.GetTask(slaveTask.TaskId);
     410      wcfService.UpdateJobState(task.Id, TaskState.Aborted, null);
    402411      SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded);
    403412    }
  • stable/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r17059 r17067  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using System.Threading;
     26using HeuristicLab.Clients.Access;
    2427using HeuristicLab.Common;
    2528using HeuristicLab.Core;
    26 using System.Collections.Generic;
    27 using System.Linq;
    28 using HeuristicLab.Clients.Access;
    2929
    3030namespace HeuristicLab.Clients.Hive {
     
    7777        if (value != jobs)
    7878          jobs = value;
    79         }
     79      }
    8080    }
    8181
     
    166166          if (projectIds.Any()) {
    167167            service.GetAssignedResourcesForProjectsAdministration(projectIds)
    168               .ForEach(a => projectResourceAssignments.Add(a));
    169             projectIds.ForEach(p => jobs.Add(p, new HiveItemCollection<RefreshableJob>()));
     168                   .ForEach(a => projectResourceAssignments.Add(a));
     169
    170170            var unsortedJobs = service.GetJobsByProjectIds(projectIds)
    171               .OrderBy(x => x.DateCreated).ToList();
    172 
    173             unsortedJobs.Where(j => j.State == JobState.DeletionPending).ToList().ForEach(j => jobs[j.ProjectId].Add(new RefreshableJob(j)));
    174             unsortedJobs.Where(j => j.State == JobState.StatisticsPending).ToList().ForEach(j => jobs[j.ProjectId].Add(new RefreshableJob(j)));
    175             unsortedJobs.Where(j => j.State == JobState.Online).ToList().ForEach(j => jobs[j.ProjectId].Add(new RefreshableJob(j)));
    176 
    177             foreach (var job in jobs.SelectMany(x => x.Value))
    178               LoadLightweightJob(job);
     171                                      .OrderBy(x => x.DateCreated).ToList();
    179172
    180173            projectNames = service.GetProjectNames();
     
    187180        RefreshDisabledParentProjects();
    188181        RefreshDisabledParentResources();
    189       }
    190       catch {
     182      } catch {
    191183        throw;
    192       }
    193       finally {
     184      } finally {
    194185        OnRefreshed();
    195186      }
    196187    }
    197 
    198     //public void UpdateResourceGenealogy(IItemList<Resource> resources) {
    199     //  resourceAncestors.Clear();
    200     //  resourceDescendants.Clear();
    201 
    202     //  foreach (var r in resources) {
    203     //    resourceAncestors.Add(r.Id, new HashSet<Resource>());
    204     //    resourceDescendants.Add(r.Id, new HashSet<Resource>());
    205     //  }
    206 
    207     //  foreach (var r in resources) {
    208     //    var parentResourceId = r.ParentResourceId;
    209     //    while (parentResourceId != null) {
    210     //      var parent = resources.SingleOrDefault(x => x.Id == parentResourceId);
    211     //      if (parent != null) {
    212     //        resourceAncestors[r.Id].Add(parent);
    213     //        resourceDescendants[parent.Id].Add(r);
    214     //        parentResourceId = parent.ParentResourceId;
    215     //      } else {
    216     //        parentResourceId = null;
    217     //      }
    218     //    }
    219     //  }
    220     //}
    221 
    222     //public void UpdateProjectGenealogy(IItemList<Project> projects) {
    223     //  projectAncestors.Clear();
    224     //  projectDescendants.Clear();
    225 
    226     //  foreach (var p in projects) {
    227     //    projectAncestors.Add(p.Id, new HashSet<Project>());
    228     //    projectDescendants.Add(p.Id, new HashSet<Project>());
    229     //  }
    230 
    231     //  foreach (var p in projects) {
    232     //    var parentProjectId = p.ParentProjectId;
    233     //    while (parentProjectId != null) {
    234     //      var parent = projects.SingleOrDefault(x => x.Id == parentProjectId);
    235     //      if (parent != null) {
    236     //        projectAncestors[p.Id].Add(parent);
    237     //        projectDescendants[parent.Id].Add(p);
    238     //        parentProjectId = parent.ParentProjectId;
    239     //      } else {
    240     //        parentProjectId = null;
    241     //      }
    242     //    }
    243     //  }
    244     //}
    245188
    246189    private void UpdateResourceGenealogy() {
     
    314257    }
    315258
    316     public void RefreshJobs() {
    317       var projectIds = new List<Guid>();
    318       jobs = new Dictionary<Guid, HiveItemCollection<RefreshableJob>>();
    319       tasks = new Dictionary<Guid, List<LightweightTask>>();
    320 
     259    public void RefreshJobs(Guid projectId) {
    321260      HiveServiceLocator.Instance.CallHiveService(service => {
    322         service.GetProjectsForAdministration().ForEach(p => projectIds.Add(p.Id));
    323         if(projectIds.Any()) {
    324           projectIds.ForEach(p => jobs.Add(p, new HiveItemCollection<RefreshableJob>()));
    325           var unsortedJobs = service.GetJobsByProjectIds(projectIds)
    326             .OrderBy(x => x.DateCreated).ToList();
    327          
     261        var projectIds = new HashSet<Guid>(service.GetProjectsForAdministration().Select(x => x.Id));
     262        if (projectIds.Contains(projectId)) {
     263          jobs.Add(projectId, new HiveItemCollection<RefreshableJob>());
     264
     265          var unsortedJobs = service.GetJobsByProjectId(projectId)
     266                                    .OrderBy(x => x.DateCreated).ToList();
     267
    328268          unsortedJobs.Where(j => j.State == JobState.DeletionPending).ToList().ForEach(j => jobs[j.ProjectId].Add(new RefreshableJob(j)));
    329269          unsortedJobs.Where(j => j.State == JobState.StatisticsPending).ToList().ForEach(j => jobs[j.ProjectId].Add(new RefreshableJob(j)));
    330270          unsortedJobs.Where(j => j.State == JobState.Online).ToList().ForEach(j => jobs[j.ProjectId].Add(new RefreshableJob(j)));
    331271
    332           foreach(var job in jobs.SelectMany(x => x.Value))
     272          foreach (var job in jobs.SelectMany(x => x.Value))
    333273            LoadLightweightJob(job);
    334274        }
     
    344284        tasks[job.Id].AddRange(lightweightTasks);
    345285      } else {
    346         tasks.Add(job.Id, new List<LightweightTask>(lightweightTasks));       
     286        tasks.Add(job.Id, new List<LightweightTask>(lightweightTasks));
    347287      }
    348288
    349289      if (lightweightTasks != null && lightweightTasks.Count > 0 && lightweightTasks.All(x => x.Id != Guid.Empty)) {
    350290        if (lightweightTasks.All(x =>
    351           x.State == TaskState.Finished 
    352           || x.State == TaskState.Aborted 
     291          x.State == TaskState.Finished
     292          || x.State == TaskState.Aborted
    353293          || x.State == TaskState.Failed)) {
    354294          refreshableJob.ExecutionState = ExecutionState.Stopped;
     
    366306          refreshableJob.ExecutionState = ExecutionState.Paused;
    367307          refreshableJob.RefreshAutomatically = false;
    368         } else if (lightweightTasks.Any(x => x.State == TaskState.Calculating 
    369                                   || x.State == TaskState.Transferring 
     308        } else if (lightweightTasks.Any(x => x.State == TaskState.Calculating
     309                                  || x.State == TaskState.Transferring
    370310                                  || x.State == TaskState.Waiting)) {
    371311          refreshableJob.ExecutionState = ExecutionState.Started;
     
    377317
    378318    public void SortJobs() {
    379       for(int i = 0; i < jobs.Count; i++) {
     319      for (int i = 0; i < jobs.Count; i++) {
    380320        var projectId = jobs.Keys.ElementAt(i);
    381321        var unsortedJobs = jobs.Values.ElementAt(i);
     
    403343            service.GetDowntimesForResource(downtimeForResourceId).ForEach(d => downtimes.Add(d));
    404344          });
    405         }
    406         catch {
     345        } catch {
    407346          throw;
    408         }
    409         finally {
     347        } finally {
    410348          OnRefreshed();
    411349        }
     
    521459
    522460    public IEnumerable<Project> GetAvailableProjectDescendants(Guid id) {
    523       if(projectDescendants.ContainsKey(id)) return projects.Where(x => projectDescendants[id].Contains(x.Id));
     461      if (projectDescendants.ContainsKey(id)) return projects.Where(x => projectDescendants[id].Contains(x.Id));
    524462      else return Enumerable.Empty<Project>();
    525463    }
     
    545483
    546484    public bool CheckAccessToAdminAreaGranted() {
    547       if(projects != null) {
     485      if (projects != null) {
    548486        return projects.Count > 0;
    549487      } else {
     
    561499      if (res.OwnerUserId == userId) {
    562500        return true;
    563       } else if(resourceAncestors.ContainsKey(res.Id)) {
     501      } else if (resourceAncestors.ContainsKey(res.Id)) {
    564502        return GetAvailableResourceAncestors(res.Id).Where(x => x.OwnerUserId == userId).Any();
    565503      }
     
    583521      if (pro == null || userId == Guid.Empty) return false;
    584522
    585       if(projectAncestors.ContainsKey(pro.Id)) {
     523      if (projectAncestors.ContainsKey(pro.Id)) {
    586524        return GetAvailableProjectAncestors(pro.Id).Any(x => x.OwnerUserId == userId);
    587525      }
     
    613551        // ... if the user is no admin nor owner of the new parent or grand..grandparents
    614552        changePossible = false;
    615       } else if(parent != null && projectDescendants.ContainsKey(child.Id)) {
     553      } else if (parent != null && projectDescendants.ContainsKey(child.Id)) {
    616554        // ... if the new parent is among the moved project's descendants
    617555        changePossible = !GetAvailableProjectDescendants(child.Id).Where(x => x.Id == parent.Id).Any();
     
    630568      // ... or the new parent is a slave
    631569      // ... or there is not parental change
    632       if (child == null 
     570      if (child == null
    633571        || child == parent
    634572        || (parent != null && parent.Id == Guid.Empty)
     
    645583
    646584    public IEnumerable<Resource> GetAssignedResourcesForJob(Guid jobId) {
    647       var assignedJobResource =  HiveServiceLocator.Instance.CallHiveService(service => service.GetAssignedResourcesForJob(jobId));
     585      var assignedJobResource = HiveServiceLocator.Instance.CallHiveService(service => service.GetAssignedResourcesForJob(jobId));
    648586      return Resources.Where(x => assignedJobResource.Select(y => y.ResourceId).Contains(x.Id));
    649587    }
  • stable/HeuristicLab.Clients.Hive/3.3/ServiceClients/GenerateServiceClients.cmd

    r15386 r17067  
    1313IF "%GENERATECONFIG%"=="" SET GENERATECONFIG=y
    1414
    15 SET ARGS=http://%HOST%/Hive-3.3/HiveService.svc?wsdl ^
     15SET ARGS=http://%HOST%/Hive-3.4/HiveService.svc?wsdl ^
    1616/out:HiveServiceClient ^
    1717/namespace:*,HeuristicLab.Clients.Hive ^
  • stable/HeuristicLab.Services.Hive

  • stable/HeuristicLab.Services.Hive.DataAccess

  • stable/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs

    r17059 r17067  
    8888        (from job in db.GetTable<Job>()
    8989         where job.State == JobState.StatisticsPending
    90          && (from task in db.GetTable<Task>()
    91              where task.JobId == job.JobId
    92              select task.State == TaskState.Finished
    93               || task.State == TaskState.Aborted
    94               || task.State == TaskState.Failed).All(x => x)
     90               && (from task in db.GetTable<Task>()
     91                   where task.JobId == job.JobId
     92                   select task).All(x => x.State == TaskState.Finished
     93                                      || x.State == TaskState.Aborted
     94                                      || x.State == TaskState.Failed)
    9595         select job));
    9696    #endregion
  • stable/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r17059 r17067  
    6666
    6767          pm.UseTransaction(() => {
    68             UpdateFactTaskTable(pm);
    6968            try {
    70               pm.SubmitChanges();
     69              UpdateFactTaskTable(pm);
    7170              UpdateExistingDimJobs(pm);
     71              FlagJobsForDeletion(pm);
    7272              pm.SubmitChanges();
    7373            }
     
    8181          });
    8282        }
    83 
    84         pm.UseTransaction(() => {
    85           FlagJobsForDeletion(pm);
    86           pm.SubmitChanges();
    87         });
    8883      }
    8984    }
Note: See TracChangeset for help on using the changeset viewer.