Changeset 16209 for trunk/HeuristicLab.Clients.Hive
- Timestamp:
- 10/03/18 15:06:21 (6 years ago)
- Location:
- trunk/HeuristicLab.Clients.Hive/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs
r16208 r16209 80 80 } 81 81 82 private Dictionary<Guid, List<LightweightTask>> tasks; 83 public Dictionary<Guid, List<LightweightTask>> Tasks { 84 get { return tasks; } 85 } 86 82 87 private Dictionary<Guid, HashSet<Guid>> projectAncestors; 83 88 public Dictionary<Guid, HashSet<Guid>> ProjectAncestors { … … 145 150 projectResourceAssignments = new ItemList<AssignedProjectResource>(); 146 151 jobs = new Dictionary<Guid, HiveItemCollection<RefreshableJob>>(); 152 tasks = new Dictionary<Guid, List<LightweightTask>>(); 147 153 projectNames = new Dictionary<Guid, string>(); 148 154 resourceNames = new Dictionary<Guid, string>(); … … 311 317 var projectIds = new List<Guid>(); 312 318 jobs = new Dictionary<Guid, HiveItemCollection<RefreshableJob>>(); 319 tasks = new Dictionary<Guid, List<LightweightTask>>(); 313 320 314 321 HiveServiceLocator.Instance.CallHiveService(service => { … … 329 336 } 330 337 331 public staticvoid LoadLightweightJob(RefreshableJob refreshableJob) {338 public void LoadLightweightJob(RefreshableJob refreshableJob) { 332 339 var job = refreshableJob.Job; 333 var tasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(job.Id)); 334 if (tasks != null && tasks.Count > 0 && tasks.All(x => x.Id != Guid.Empty)) { 335 if (tasks.All(x => 340 var lightweightTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(job.Id)); 341 342 if (tasks.ContainsKey(job.Id)) { 343 tasks[job.Id].Clear(); 344 tasks[job.Id].AddRange(lightweightTasks); 345 } else { 346 tasks.Add(job.Id, new List<LightweightTask>(lightweightTasks)); 347 } 348 349 if (lightweightTasks != null && lightweightTasks.Count > 0 && lightweightTasks.All(x => x.Id != Guid.Empty)) { 350 if (lightweightTasks.All(x => 336 351 x.State == TaskState.Finished 337 352 || x.State == TaskState.Aborted … … 340 355 refreshableJob.RefreshAutomatically = false; 341 356 } else if ( 342 tasks357 lightweightTasks 343 358 .Where(x => x.ParentTaskId != null) 344 359 .All(x => … … 346 361 || x.State != TaskState.Transferring 347 362 || x.State != TaskState.Calculating) 348 && tasks363 && lightweightTasks 349 364 .Where(x => x.ParentTaskId != null) 350 365 .Any(x => x.State == TaskState.Paused)) { 351 366 refreshableJob.ExecutionState = ExecutionState.Paused; 352 367 refreshableJob.RefreshAutomatically = false; 353 } else if ( tasks.Any(x => x.State == TaskState.Calculating368 } else if (lightweightTasks.Any(x => x.State == TaskState.Calculating 354 369 || x.State == TaskState.Transferring 355 370 || x.State == TaskState.Waiting)) { 356 371 refreshableJob.ExecutionState = ExecutionState.Started; 357 372 } 373 374 refreshableJob.ExecutionTime = TimeSpan.FromMilliseconds(lightweightTasks.Sum(x => x.ExecutionTime.TotalMilliseconds)); 358 375 } 359 376 } … … 451 468 public static void ResumeJob(RefreshableJob refreshableJob) { 452 469 HiveServiceLocator.Instance.CallHiveService(service => { 453 foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) { 454 if (task.Task.State == TaskState.Paused) { 455 service.RestartTask(task.Task.Id); 470 var tasks = service.GetLightweightJobTasksWithoutStateLog(refreshableJob.Id); 471 foreach (var task in tasks) { 472 if (task.State == TaskState.Paused) { 473 service.RestartTask(task.Id); 456 474 } 457 475 } … … 462 480 public static void PauseJob(RefreshableJob refreshableJob) { 463 481 HiveServiceLocator.Instance.CallHiveService(service => { 464 foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) { 465 if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed) 466 service.PauseTask(task.Task.Id); 482 var tasks = service.GetLightweightJobTasksWithoutStateLog(refreshableJob.Id); 483 foreach (var task in tasks) { 484 if (task.State != TaskState.Finished && task.State != TaskState.Aborted && task.State != TaskState.Failed) 485 service.PauseTask(task.Id); 467 486 } 468 487 }); … … 472 491 public static void StopJob(RefreshableJob refreshableJob) { 473 492 HiveServiceLocator.Instance.CallHiveService(service => { 474 foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) { 475 if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed) 476 service.StopTask(task.Task.Id); 493 var tasks = service.GetLightweightJobTasksWithoutStateLog(refreshableJob.Id); 494 foreach (var task in tasks) { 495 if (task.State != TaskState.Finished && task.State != TaskState.Aborted && task.State != TaskState.Failed) 496 service.StopTask(task.Id); 477 497 } 478 498 }); … … 481 501 482 502 public static void RemoveJob(RefreshableJob refreshableJob) { 483 HiveServiceLocator.Instance.CallHiveService((s ) => {484 s .UpdateJobState(refreshableJob.Id, JobState.StatisticsPending);503 HiveServiceLocator.Instance.CallHiveService((service) => { 504 service.UpdateJobState(refreshableJob.Id, JobState.StatisticsPending); 485 505 }); 486 506 } … … 624 644 } 625 645 646 public IEnumerable<Resource> GetAssignedResourcesForJob(Guid jobId) { 647 var assignedJobResource = HiveServiceLocator.Instance.CallHiveService(service => service.GetAssignedResourcesForJob(jobId)); 648 return Resources.Where(x => assignedJobResource.Select(y => y.ResourceId).Contains(x.Id)); 649 } 650 626 651 private bool IsAdmin() { 627 652 return HiveRoles.CheckAdminUserPermissions(); -
trunk/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r16202 r16209 756 756 return string.Join(" » ", projects.Select(x => ProjectNames[x]).ToArray()); 757 757 } 758 759 public IEnumerable<Resource> GetAssignedResourcesForJob(Guid jobId) { 760 var assignedJobResource = HiveServiceLocator.Instance.CallHiveService(service => service.GetAssignedResourcesForJob(jobId)); 761 return Resources.Where(x => assignedJobResource.Select(y => y.ResourceId).Contains(x.Id)); 762 } 758 763 } 759 764 }
Note: See TracChangeset
for help on using the changeset viewer.