Ignore:
Timestamp:
01/18/18 15:08:25 (3 years ago)
Author:
jzenisek
Message:

#2839

  • updated Heartbeat processing (regarding: checking against AssignedJobResources and handling of the updated Job deletion routine)
  • updated Job deletion routine(still in progress at GenerateStatistics)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15412 r15630  
    144144        }
    145145      } 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        }
    148150        if (item is Project)
    149151          HiveServiceLocator.Instance.CallHiveService(s => s.UpdateProject((Project)item));
     
    173175
    174176      if (item is Job)
    175         HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
     177        HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(item.Id, JobState.StatisticsPending));
    176178      if (item is RefreshableJob) {
    177179        RefreshableJob job = (RefreshableJob)item;
     
    179181          job.StopResultPolling();
    180182        }
    181         HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
     183        HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(item.Id, JobState.StatisticsPending));
    182184      }
    183185      if (item is JobPermission) {
     
    262264        // upload Job
    263265        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));
    265267        refreshableJob.Job = HiveServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions
    266268        cancellationToken.ThrowIfCancellationRequested();
     
    284286        foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {
    285287          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);
    287289          }, hiveTask);
    288290          task.ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted);
     
    329331    /// </summary>
    330332    /// <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) {
    332334      taskUploadSemaphore.WaitOne();
    333335      bool semaphoreReleased = false;
     
    368370              hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData));
    369371            } 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));
    371373            }
    372374          }
     
    383385          var task = TS.Task.Factory.StartNew((tuple) => {
    384386            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);
    386388          }, new Tuple<HiveTask, HiveTask>(child, hiveTask));
    387389          task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted);
     
    390392        taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!
    391393        TS.Task.WaitAll(tasks.ToArray());
    392       }
    393       finally {
     394      } finally {
    394395        if (!semaphoreReleased) taskUploadSemaphore.Release();
    395396      }
    396397    }
     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   
    397471    #endregion
    398472
Note: See TracChangeset for help on using the changeset viewer.