- Timestamp:
- 01/18/18 15:08:25 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15412 r15630 144 144 } 145 145 } else { 146 if (item is Job) 147 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item)); 146 if (item is Job) { 147 var job = (Job)item; 148 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob(job, job.ResourceIds)); 149 } 148 150 if (item is Project) 149 151 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateProject((Project)item)); … … 173 175 174 176 if (item is Job) 175 HiveServiceLocator.Instance.CallHiveService(s => s. DeleteJob(item.Id));177 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(item.Id, JobState.StatisticsPending)); 176 178 if (item is RefreshableJob) { 177 179 RefreshableJob job = (RefreshableJob)item; … … 179 181 job.StopResultPolling(); 180 182 } 181 HiveServiceLocator.Instance.CallHiveService(s => s. DeleteJob(item.Id));183 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(item.Id, JobState.StatisticsPending)); 182 184 } 183 185 if (item is JobPermission) { … … 262 264 // upload Job 263 265 refreshableJob.Progress.Status = "Uploading Job..."; 264 refreshableJob.Job.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddJob(refreshableJob.Job ));266 refreshableJob.Job.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddJob(refreshableJob.Job, refreshableJob.Job.ResourceIds)); 265 267 refreshableJob.Job = HiveServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions 266 268 cancellationToken.ThrowIfCancellationRequested(); … … 284 286 foreach (HiveTask hiveTask in refreshableJob.HiveTasks) { 285 287 var task = TS.Task.Factory.StartNew((hj) => { 286 UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, refreshableJob.Job.ResourceIds,jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, cancellationToken);288 UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, cancellationToken); 287 289 }, hiveTask); 288 290 task.ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted); … … 329 331 /// </summary> 330 332 /// <param name="parentHiveTask">shall be null if its the root task</param> 331 private void UploadTaskWithChildren(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups,int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, CancellationToken cancellationToken) {333 private void UploadTaskWithChildren(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, CancellationToken cancellationToken) { 332 334 taskUploadSemaphore.WaitOne(); 333 335 bool semaphoreReleased = false; … … 368 370 hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData)); 369 371 } else { 370 hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData , groups.ToList()));372 hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData)); 371 373 } 372 374 } … … 383 385 var task = TS.Task.Factory.StartNew((tuple) => { 384 386 var arguments = (Tuple<HiveTask, HiveTask>)tuple; 385 UploadTaskWithChildren(progress, arguments.Item1, arguments.Item2, groups,taskCount, totalJobCount, configPluginId, jobId, log, cancellationToken);387 UploadTaskWithChildren(progress, arguments.Item1, arguments.Item2, taskCount, totalJobCount, configPluginId, jobId, log, cancellationToken); 386 388 }, new Tuple<HiveTask, HiveTask>(child, hiveTask)); 387 389 task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted); … … 390 392 taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall! 391 393 TS.Task.WaitAll(tasks.ToArray()); 392 } 393 finally { 394 } finally { 394 395 if (!semaphoreReleased) taskUploadSemaphore.Release(); 395 396 } 396 397 } 398 399 400 /// <summary> 401 /// Uploads the given task and all its child-jobs while setting the proper parentJobId values for the childs 402 /// </summary> 403 /// <param name="parentHiveTask">shall be null if its the root task</param> 404 //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) { 405 // taskUploadSemaphore.WaitOne(); 406 // bool semaphoreReleased = false; 407 // try { 408 // cancellationToken.ThrowIfCancellationRequested(); 409 // lock (jobCountLocker) { 410 // taskCount[0]++; 411 // } 412 // TaskData taskData; 413 // List<IPluginDescription> plugins; 414 415 // if (hiveTask.ItemTask.ComputeInParallel) { 416 // hiveTask.Task.IsParentTask = true; 417 // hiveTask.Task.FinishWhenChildJobsFinished = true; 418 // taskData = hiveTask.GetAsTaskData(true, out plugins); 419 // } else { 420 // hiveTask.Task.IsParentTask = false; 421 // hiveTask.Task.FinishWhenChildJobsFinished = false; 422 // taskData = hiveTask.GetAsTaskData(false, out plugins); 423 // } 424 // cancellationToken.ThrowIfCancellationRequested(); 425 426 // TryAndRepeat(() => { 427 // if (!cancellationToken.IsCancellationRequested) { 428 // lock (pluginLocker) { 429 // HiveServiceLocator.Instance.CallHiveService((s) => hiveTask.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins)); 430 // } 431 // } 432 // }, Settings.Default.MaxRepeatServiceCalls, "Failed to upload plugins"); 433 // cancellationToken.ThrowIfCancellationRequested(); 434 // hiveTask.Task.PluginsNeededIds.Add(configPluginId); 435 // hiveTask.Task.JobId = jobId; 436 437 // log.LogMessage(string.Format("Uploading task ({0} kb, {1} objects)", taskData.Data.Count() / 1024, hiveTask.ItemTask.GetObjectGraphObjects().Count())); 438 // TryAndRepeat(() => { 439 // if (!cancellationToken.IsCancellationRequested) { 440 // if (parentHiveTask != null) { 441 // hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData)); 442 // } else { 443 // hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList())); 444 // } 445 // } 446 // }, Settings.Default.MaxRepeatServiceCalls, "Failed to add task", log); 447 // cancellationToken.ThrowIfCancellationRequested(); 448 449 // lock (jobCountLocker) { 450 // progress.ProgressValue = (double)taskCount[0] / totalJobCount; 451 // progress.Status = string.Format("Uploaded task ({0} of {1})", taskCount[0], totalJobCount); 452 // } 453 454 // var tasks = new List<TS.Task>(); 455 // foreach (HiveTask child in hiveTask.ChildHiveTasks) { 456 // var task = TS.Task.Factory.StartNew((tuple) => { 457 // var arguments = (Tuple<HiveTask, HiveTask>)tuple; 458 // UploadTaskWithChildren_Old(progress, arguments.Item1, arguments.Item2, groups, taskCount, totalJobCount, configPluginId, jobId, log, cancellationToken); 459 // }, new Tuple<HiveTask, HiveTask>(child, hiveTask)); 460 // task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted); 461 // tasks.Add(task); 462 // } 463 // taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall! 464 // TS.Task.WaitAll(tasks.ToArray()); 465 // } 466 // finally { 467 // if (!semaphoreReleased) taskUploadSemaphore.Release(); 468 // } 469 //} 470 397 471 #endregion 398 472
Note: See TracChangeset
for help on using the changeset viewer.