- Timestamp:
- 04/20/18 11:52:33 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15742 r15913 67 67 } 68 68 69 private Dictionary<Guid, HashSet<Guid>> projectAncestors; 70 public Dictionary<Guid, HashSet<Guid>> ProjectAncestors { 71 get { return projectAncestors; } 72 } 73 74 private Dictionary<Guid, HashSet<Guid>> projectDescendants; 75 public Dictionary<Guid, HashSet<Guid>> ProjectDescendants { 76 get { return projectDescendants; } 77 } 78 79 private Dictionary<Guid, HashSet<Guid>> resourceAncestors; 80 public Dictionary<Guid, HashSet<Guid>> ResourceAncestors { 81 get { return resourceAncestors; } 82 } 83 84 private Dictionary<Guid, HashSet<Guid>> resourceDescendants; 85 public Dictionary<Guid, HashSet<Guid>> ResourceDescendants { 86 get { return resourceDescendants; } 87 } 88 69 89 70 90 private List<Plugin> onlinePlugins; … … 107 127 resources = new ItemList<Resource>(); 108 128 jobs = new HiveItemCollection<RefreshableJob>(); 129 130 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); 131 projectDescendants = new Dictionary<Guid, HashSet<Guid>>(); 132 resourceAncestors = new Dictionary<Guid, HashSet<Guid>>(); 133 resourceDescendants = new Dictionary<Guid, HashSet<Guid>>(); 109 134 110 135 HiveServiceLocator.Instance.CallHiveService(service => { … … 114 139 service.GetJobs().ForEach(p => jobs.Add(new RefreshableJob(p))); 115 140 }); 141 142 UpdateResourceGenealogy(); 143 UpdateProjectGenealogy(); 116 144 } 117 145 catch { … … 133 161 resources = new ItemList<Resource>(); 134 162 163 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); 164 projectDescendants = new Dictionary<Guid, HashSet<Guid>>(); 165 resourceAncestors = new Dictionary<Guid, HashSet<Guid>>(); 166 resourceDescendants = new Dictionary<Guid, HashSet<Guid>>(); 167 135 168 HiveServiceLocator.Instance.CallHiveService(service => { 136 169 service.GetProjects().ForEach(p => projects.Add(p)); … … 138 171 service.GetSlaves().ForEach(s => resources.Add(s)); 139 172 }); 173 174 UpdateResourceGenealogy(); 175 UpdateProjectGenealogy(); 140 176 } catch { 141 177 projects = null; … … 162 198 }, null); 163 199 } 164 200 201 private void UpdateResourceGenealogy() { 202 resourceAncestors.Clear(); 203 resourceDescendants.Clear(); 204 205 // fetch resource ancestor set 206 HiveServiceLocator.Instance.CallHiveService(service => { 207 var ra = service.GetResourceGenealogy(); 208 ra.Keys.ToList().ForEach(k => resourceAncestors.Add(k, new HashSet<Guid>())); 209 resourceAncestors.Keys.ToList().ForEach(k => resourceAncestors[k].UnionWith(ra[k])); 210 }); 211 212 // build resource descendant set 213 resourceAncestors.Keys.ToList().ForEach(k => resourceDescendants.Add(k, new HashSet<Guid>())); 214 foreach (var ra in resourceAncestors) { 215 foreach(var ancestor in ra.Value) { 216 resourceDescendants[ancestor].Add(ra.Key); 217 } 218 } 219 } 220 221 private void UpdateProjectGenealogy() { 222 projectAncestors.Clear(); 223 projectDescendants.Clear(); 224 225 // fetch project ancestor list 226 HiveServiceLocator.Instance.CallHiveService(service => { 227 var pa = service.GetProjectGenealogy(); 228 pa.Keys.ToList().ForEach(k => projectAncestors.Add(k, new HashSet<Guid>())); 229 projectAncestors.Keys.ToList().ForEach(k => projectAncestors[k].UnionWith(pa[k])); 230 }); 231 232 // build project descendant list 233 projectAncestors.Keys.ToList().ForEach(k => projectDescendants.Add(k, new HashSet<Guid>())); 234 foreach(var pa in projectAncestors) { 235 foreach(var ancestor in pa.Value) { 236 projectDescendants[ancestor].Add(pa.Key); 237 } 238 } 239 } 240 241 public IEnumerable<Project> GetAvailableParentProjects(Guid id) { 242 return projects.Where(x => projectAncestors[id].Contains(x.Id)); 243 } 244 245 public IEnumerable<Project> GetAvailableChildProjects(Guid id) { 246 return projects.Where(x => projectDescendants[id].Contains(x.Id)); 247 } 248 249 public IEnumerable<Resource> GetAvailableParentResources(Guid id) { 250 return resources.Where(x => resourceAncestors[id].Contains(x.Id)); 251 } 252 253 public IEnumerable<Resource> GetAvailableChildResources(Guid id) { 254 return resources.Where(x => resourceDescendants[id].Contains(x.Id)); 255 } 256 165 257 #endregion 166 258 … … 446 538 } 447 539 } 448 449 450 /// <summary>451 /// Uploads the given task and all its child-jobs while setting the proper parentJobId values for the childs452 /// </summary>453 /// <param name="parentHiveTask">shall be null if its the root task</param>454 //private void UploadTaskWithChildren_Old(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, CancellationToken cancellationToken) {455 // taskUploadSemaphore.WaitOne();456 // bool semaphoreReleased = false;457 // try {458 // cancellationToken.ThrowIfCancellationRequested();459 // lock (jobCountLocker) {460 // taskCount[0]++;461 // }462 // TaskData taskData;463 // List<IPluginDescription> plugins;464 465 // if (hiveTask.ItemTask.ComputeInParallel) {466 // hiveTask.Task.IsParentTask = true;467 // hiveTask.Task.FinishWhenChildJobsFinished = true;468 // taskData = hiveTask.GetAsTaskData(true, out plugins);469 // } else {470 // hiveTask.Task.IsParentTask = false;471 // hiveTask.Task.FinishWhenChildJobsFinished = false;472 // taskData = hiveTask.GetAsTaskData(false, out plugins);473 // }474 // cancellationToken.ThrowIfCancellationRequested();475 476 // TryAndRepeat(() => {477 // if (!cancellationToken.IsCancellationRequested) {478 // lock (pluginLocker) {479 // HiveServiceLocator.Instance.CallHiveService((s) => hiveTask.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));480 // }481 // }482 // }, Settings.Default.MaxRepeatServiceCalls, "Failed to upload plugins");483 // cancellationToken.ThrowIfCancellationRequested();484 // hiveTask.Task.PluginsNeededIds.Add(configPluginId);485 // hiveTask.Task.JobId = jobId;486 487 // log.LogMessage(string.Format("Uploading task ({0} kb, {1} objects)", taskData.Data.Count() / 1024, hiveTask.ItemTask.GetObjectGraphObjects().Count()));488 // TryAndRepeat(() => {489 // if (!cancellationToken.IsCancellationRequested) {490 // if (parentHiveTask != null) {491 // hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData));492 // } else {493 // hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList()));494 // }495 // }496 // }, Settings.Default.MaxRepeatServiceCalls, "Failed to add task", log);497 // cancellationToken.ThrowIfCancellationRequested();498 499 // lock (jobCountLocker) {500 // progress.ProgressValue = (double)taskCount[0] / totalJobCount;501 // progress.Status = string.Format("Uploaded task ({0} of {1})", taskCount[0], totalJobCount);502 // }503 504 // var tasks = new List<TS.Task>();505 // foreach (HiveTask child in hiveTask.ChildHiveTasks) {506 // var task = TS.Task.Factory.StartNew((tuple) => {507 // var arguments = (Tuple<HiveTask, HiveTask>)tuple;508 // UploadTaskWithChildren_Old(progress, arguments.Item1, arguments.Item2, groups, taskCount, totalJobCount, configPluginId, jobId, log, cancellationToken);509 // }, new Tuple<HiveTask, HiveTask>(child, hiveTask));510 // task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted);511 // tasks.Add(task);512 // }513 // taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!514 // TS.Task.WaitAll(tasks.ToArray());515 // }516 // finally {517 // if (!semaphoreReleased) taskUploadSemaphore.Release();518 // }519 //}520 521 540 #endregion 522 541 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs
r15819 r15913 2449 2449 System.Collections.Generic.List<HeuristicLab.Clients.Hive.Project> GetProjectsForAdministration(); 2450 2450 2451 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProjectGenealogy", ReplyAction="http://tempuri.org/IHiveService/GetProjectGenealogyResponse")] 2452 System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetProjectGenealogy(); 2453 2451 2454 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/SaveProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/SaveProjectPermissionsResponse")] 2452 2455 void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading); … … 2490 2493 System.Collections.Generic.List<HeuristicLab.Clients.Hive.SlaveGroup> GetSlaveGroupsForAdministration(); 2491 2494 2495 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetResourceGenealogy", ReplyAction="http://tempuri.org/IHiveService/GetResourceGenealogyResponse")] 2496 System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetResourceGenealogy(); 2497 2492 2498 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateSlave", ReplyAction="http://tempuri.org/IHiveService/UpdateSlaveResponse")] 2493 2499 void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave); … … 2754 2760 } 2755 2761 2762 public System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetProjectGenealogy() 2763 { 2764 return base.Channel.GetProjectGenealogy(); 2765 } 2766 2756 2767 public void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading) 2757 2768 { … … 2819 2830 } 2820 2831 2832 public System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetResourceGenealogy() 2833 { 2834 return base.Channel.GetResourceGenealogy(); 2835 } 2836 2821 2837 public void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave) 2822 2838 {
Note: See TracChangeset
for help on using the changeset viewer.