Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/12/11 13:43:05 (13 years ago)
Author:
cneumuel
Message:

#1233

  • changed relationship between Job and HiveExperiment. There is no more HiveExperiment.RootJobId, instead there is Job.HiveExperimentId.
  • One HiveExperiment can now have multiple Experiments.
  • TreeView supports multiple root nodes
  • HiveEngine creates a HiveExperiment for each set of jobs, so jobs cannot be without an parent experiment anymore (no more loose jobs)
  • updated ExperimentManager binaries
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources

    • Property svn:ignore
      •  

        old new  
        44PrecompiledWeb
        55CreateEventLogSources
         6WindowsFormsTestProject
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4

    • Property svn:ignore
      •  

        old new  
        22obj
        33HeuristicLab.HiveEngine-3.4.csproj.vs10x
         4HeuristicLabHiveEnginePlugin.cs
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs

    r6000 r6006  
    2525
    2626    [Storable]
    27     public string ResourceIds { get; set; }
     27    public string ResourceNames { get; set; }
    2828
    2929    [Storable]
     
    4646    }
    4747
     48    [Storable]
     49    private bool useLocalPlugins;
     50    public bool UseLocalPlugins {
     51      get { return useLocalPlugins; }
     52      set { useLocalPlugins = value; }
     53    }
     54
     55    [Storable]
     56    private ItemCollection<HiveExperiment> hiveExperiments;
     57    public ItemCollection<HiveExperiment> HiveExperiments {
     58      get { return hiveExperiments; }
     59      set { hiveExperiments = value; }
     60    }
     61
    4862    private List<Plugin> onlinePlugins;
    4963    public List<Plugin> OnlinePlugins {
     
    6074    #region constructors and cloning
    6175    public HiveEngine() {
    62       ResourceIds = "HEAL";
     76      ResourceNames = "HEAL";
     77      HiveExperiments = new ItemCollection<HiveExperiment>();
     78      Priority = 0;
    6379    }
    6480
     
    6783    protected HiveEngine(HiveEngine original, Cloner cloner)
    6884      : base(original, cloner) {
    69       this.ResourceIds = original.ResourceIds;
     85      this.ResourceNames = original.ResourceNames;
    7086      this.currentOperator = cloner.Clone(original.currentOperator);
    7187      this.priority = original.priority;
    7288      this.executionTimeOnHive = original.executionTimeOnHive;
     89      this.useLocalPlugins = original.useLocalPlugins;
    7390    }
    7491    public override IDeepCloneable Clone(Cloner cloner) {
     
    123140
    124141            IScope[] scopes = ExecuteOnHive(jobs, parentScopeClone, cancellationToken);
    125             //IScope[] scopes = ExecuteLocally(jobs, parentScopeClone, cancellationToken);
    126142           
    127143            for (int i = 0; i < coll.Count; i++) {
     
    186202    }
    187203
    188     private IScope[] ExecuteLocally(EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) {
    189       IScope[] scopes = new Scope[jobs.Length];
    190 
    191       for (int i = 0; i < jobs.Length; i++) {
    192         var job = (EngineJob)jobs[i].Clone();
    193         job.Start();
    194         while (job.ExecutionState != ExecutionState.Stopped) {
    195           Thread.Sleep(100);
    196         }
    197         scopes[i] = ((IAtomicOperation)job.InitialOperation).Scope;
    198       }
    199 
    200       return scopes;
    201     }
     204    // testfunction:
     205    //private IScope[] ExecuteLocally(EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) {
     206    //  IScope[] scopes = new Scope[jobs.Length];
     207    //  for (int i = 0; i < jobs.Length; i++) {
     208    //    var job = (EngineJob)jobs[i].Clone();
     209    //    job.Start();
     210    //    while (job.ExecutionState != ExecutionState.Stopped) {
     211    //      Thread.Sleep(100);
     212    //    }
     213    //    scopes[i] = ((IAtomicOperation)job.InitialOperation).Scope;
     214    //  }
     215    //  return scopes;
     216    //}
    202217
    203218    /// <summary>
     
    211226      object locker = new object();
    212227      IDictionary<Guid, int> jobIndices = new Dictionary<Guid, int>();
     228      var hiveExperiment = new HiveExperiment();;
    213229
    214230      try {
     
    218234        int finishedCount = 0;
    219235        int uploadCount = 0;
     236
     237        // create hive experiment
     238        hiveExperiment.Name = "HiveEngine Run " + hiveExperiments.Count;
     239        hiveExperiment.UseLocalPlugins = this.UseLocalPlugins;
     240        hiveExperiment.ResourceNames = this.ResourceNames;
     241        hiveExperiment.RefreshAutomatically = false;
     242        hiveExperiment.Id = ServiceLocator.Instance.CallHiveService(s => s.AddHiveExperiment(hiveExperiment));
     243        hiveExperiments.Add(hiveExperiment);
    220244
    221245        // create upload-tasks
     
    230254
    231255          uploadTasks.Add(Task.Factory.StartNew<Job>((keyValuePairObj) => {
    232             return UploadJob(keyValuePairObj, parentScopeClone, cancellationToken, GetResourceIds());
     256            return UploadJob(keyValuePairObj, parentScopeClone, cancellationToken, GetResourceIds(), hiveExperiment.Id);
    233257          }, new KeyValuePair<int, EngineJob>(i, job), cancellationToken));
    234258        }
     
    313337
    314338        LogMessage(string.Format("All jobs finished (TotalExecutionTime: {0}).", executionTimes.Sum()));
    315         DeleteJobs(jobIndices);
     339        DeleteHiveExperiment(hiveExperiment.Id);
    316340
    317341        return scopes;
     
    319343      catch (OperationCanceledException e) {
    320344        lock (locker) {
    321           if (jobIndices != null) DeleteJobs(jobIndices);
     345          if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id);
    322346        }
    323347        throw e;
     
    325349      catch (Exception e) {
    326350        lock (locker) {
    327           if (jobIndices != null) DeleteJobs(jobIndices);
     351          if (jobIndices != null) DeleteHiveExperiment(hiveExperiment.Id);
    328352        }
    329353        LogException(e);
     
    332356    }
    333357
    334     private void DeleteJobs(IDictionary<Guid, int> jobIndices) {
    335       if (jobIndices.Count > 0) {
    336         TryAndRepeat(() => {
    337           LogMessage(string.Format("Deleting {0} jobs on hive.", jobIndices.Count));
    338           ServiceLocator.Instance.CallHiveService(service => {
    339             foreach (Guid jobId in jobIndices.Keys) {
    340               service.DeleteJob(jobId);
    341             }
    342             jobIndices.Clear();
    343           });
    344         }, 5, string.Format("Could not delete {0} jobs", jobIndices.Count));
    345       }
     358    private void DeleteHiveExperiment(Guid hiveExperimentId) {
     359      TryAndRepeat(() => {
     360        ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(hiveExperimentId));
     361      }, 5, string.Format("Could not delete jobs"));
    346362    }
    347363
    348364    private static object locker = new object();
    349     private Job UploadJob(object keyValuePairObj, IScope parentScopeClone, CancellationToken cancellationToken, List<Guid> resourceIds) {
     365    private Job UploadJob(object keyValuePairObj, IScope parentScopeClone, CancellationToken cancellationToken, List<Guid> resourceIds, Guid hiveExperimentId) {
    350366      var keyValuePair = (KeyValuePair<int, EngineJob>)keyValuePairObj;
    351367      Job job = new Job();
     
    370386        job.PluginsNeededIds = ServiceLocator.Instance.CallHiveService(s => PluginUtil.GetPluginDependencies(s, this.OnlinePlugins, this.AlreadyUploadedPlugins, neededPlugins, false));
    371387        job.Priority = priority;
     388        job.HiveExperimentId = hiveExperimentId;
    372389
    373390        try {
     
    396413    private List<Guid> GetResourceIds() {
    397414      return ServiceLocator.Instance.CallHiveService(service => {
    398         var resourceNames = ResourceIds.Split(';');
     415        var resourceNames = ResourceNames.Split(';');
    399416        var resourceIds = new List<Guid>();
    400417        foreach (var resourceName in resourceNames) {
Note: See TracChangeset for help on using the changeset viewer.