Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/11 16:38:28 (13 years ago)
Author:
ascheibe
Message:

#1233 more renaming for more consistency

File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveJobs/OptimizerHiveTask.cs

    r6721 r6725  
    3030
    3131namespace HeuristicLab.Clients.Hive {
    32   public class OptimizerHiveJob : HiveJob<OptimizerJob> {
     32  public class OptimizerHiveTask : HiveTask<OptimizerTask> {
    3333
    3434    #region Constructors and Cloning
    35     public OptimizerHiveJob() { }
    36     public OptimizerHiveJob(IOptimizer optimizer)
     35    public OptimizerHiveTask() { }
     36    public OptimizerHiveTask(IOptimizer optimizer)
    3737      : this() {
    38       this.ItemJob = new OptimizerJob(optimizer);
    39     }
    40     public OptimizerHiveJob(OptimizerJob optimizerJob)
     38      this.ItemTask = new OptimizerTask(optimizer);
     39    }
     40    public OptimizerHiveTask(OptimizerTask optimizerJob)
    4141      : this() {
    42       this.ItemJob = optimizerJob;
    43     }
    44     protected OptimizerHiveJob(OptimizerHiveJob original, Cloner cloner)
     42      this.ItemTask = optimizerJob;
     43    }
     44    protected OptimizerHiveTask(OptimizerHiveTask original, Cloner cloner)
    4545      : base(original, cloner) {
    4646    }
    4747    public override IDeepCloneable Clone(Cloner cloner) {
    48       return new OptimizerHiveJob(this, cloner);
     48      return new OptimizerHiveTask(this, cloner);
    4949    }
    5050    #endregion
     
    5252    /// <summary>
    5353    /// if this.Optimizer is an experiment
    54     ///   Uses the child-optimizers of this.HiveJob and creates HiveJob-childs
     54    ///   Uses the child-optimizers of this.HiveTask and creates HiveTask-childs
    5555    /// if this.Optimizer is a batchrun
    5656    ///   Creates a number of child-jobs according to repetitions
    5757    /// </summary>
    58     protected override void UpdateChildHiveJobs() {
    59       base.UpdateChildHiveJobs();
    60       if (Job != null && syncJobsWithOptimizers) {
    61         if (!ItemJob.ComputeInParallel) {
    62           this.childHiveJobs.Clear();
     58    protected override void UpdateChildHiveTasks() {
     59      base.UpdateChildHiveTasks();
     60      if (Task != null && syncTasksWithOptimizers) {
     61        if (!ItemTask.ComputeInParallel) {
     62          this.childHiveTasks.Clear();
    6363        } else {
    64           if (ItemJob.Item is Optimization.Experiment) {
    65             Optimization.Experiment experiment = (Optimization.Experiment)ItemJob.Item;
     64          if (ItemTask.Item is Optimization.Experiment) {
     65            Optimization.Experiment experiment = (Optimization.Experiment)ItemTask.Item;
    6666            foreach (IOptimizer childOpt in experiment.Optimizers) {
    67               this.childHiveJobs.Add(new OptimizerHiveJob(childOpt));
     67              this.childHiveTasks.Add(new OptimizerHiveTask(childOpt));
    6868            }
    69           } else if (ItemJob.Item is Optimization.BatchRun) {
    70             Optimization.BatchRun batchRun = ItemJob.OptimizerAsBatchRun;
     69          } else if (ItemTask.Item is Optimization.BatchRun) {
     70            Optimization.BatchRun batchRun = ItemTask.OptimizerAsBatchRun;
    7171            if (batchRun.Optimizer != null) {
    72               while (this.childHiveJobs.Count < batchRun.Repetitions) {
    73                 this.childHiveJobs.Add(new OptimizerHiveJob(batchRun.Optimizer));
     72              while (this.childHiveTasks.Count < batchRun.Repetitions) {
     73                this.childHiveTasks.Add(new OptimizerHiveTask(batchRun.Optimizer));
    7474              }
    75               while (this.childHiveJobs.Count > batchRun.Repetitions) {
    76                 this.childHiveJobs.Remove(this.childHiveJobs.Last());
     75              while (this.childHiveTasks.Count > batchRun.Repetitions) {
     76                this.childHiveTasks.Remove(this.childHiveTasks.Last());
    7777              }
    7878            }
     
    8282    }
    8383
    84     protected override void RegisterItemJobEvents() {
    85       base.RegisterItemJobEvents();
    86       if (ItemJob != null) {
    87         if (ItemJob.Item is Optimization.Experiment) {
    88           Optimization.Experiment experiment = ItemJob.OptimizerAsExperiment;
     84    protected override void RegisterItemTaskEvents() {
     85      base.RegisterItemTaskEvents();
     86      if (ItemTask != null) {
     87        if (ItemTask.Item is Optimization.Experiment) {
     88          Optimization.Experiment experiment = ItemTask.OptimizerAsExperiment;
    8989          experiment.Optimizers.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded);
    9090          experiment.Optimizers.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsReplaced);
    9191          experiment.Optimizers.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsRemoved);
    9292          experiment.Optimizers.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_CollectionReset);
    93         } else if (ItemJob.Item is Optimization.BatchRun) {
    94           Optimization.BatchRun batchRun = ItemJob.OptimizerAsBatchRun;
     93        } else if (ItemTask.Item is Optimization.BatchRun) {
     94          Optimization.BatchRun batchRun = ItemTask.OptimizerAsBatchRun;
    9595          batchRun.RepetitionsChanged += new EventHandler(batchRun_RepetitionsChanged);
    9696          batchRun.OptimizerChanged += new EventHandler(batchRun_OptimizerChanged);
     
    9898      }
    9999    }
    100     protected override void DergisterItemJobEvents() {
    101       base.DergisterItemJobEvents();
    102       if (ItemJob != null) {
    103         if (ItemJob.Item is Optimization.Experiment) {
    104           Optimization.Experiment experiment = ItemJob.OptimizerAsExperiment;
     100    protected override void DergisterItemTaskEvents() {
     101      base.DergisterItemTaskEvents();
     102      if (ItemTask != null) {
     103        if (ItemTask.Item is Optimization.Experiment) {
     104          Optimization.Experiment experiment = ItemTask.OptimizerAsExperiment;
    105105          experiment.Optimizers.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded);
    106106          experiment.Optimizers.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsReplaced);
    107107          experiment.Optimizers.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsRemoved);
    108108          experiment.Optimizers.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_CollectionReset);
    109         } else if (ItemJob.Item is Optimization.BatchRun) {
    110           Optimization.BatchRun batchRun = ItemJob.OptimizerAsBatchRun;
     109        } else if (ItemTask.Item is Optimization.BatchRun) {
     110          Optimization.BatchRun batchRun = ItemTask.OptimizerAsBatchRun;
    111111          batchRun.RepetitionsChanged -= new EventHandler(batchRun_RepetitionsChanged);
    112112          batchRun.OptimizerChanged -= new EventHandler(batchRun_OptimizerChanged);
     
    116116
    117117    private void batchRun_OptimizerChanged(object sender, EventArgs e) {
    118       if (syncJobsWithOptimizers) {
    119         UpdateChildHiveJobs();
     118      if (syncTasksWithOptimizers) {
     119        UpdateChildHiveTasks();
    120120      }
    121121    }
    122122
    123123    private void batchRun_RepetitionsChanged(object sender, EventArgs e) {
    124       if (syncJobsWithOptimizers) {
    125         UpdateChildHiveJobs();
     124      if (syncTasksWithOptimizers) {
     125        UpdateChildHiveTasks();
    126126      }
    127127    }
    128128
    129129    private void Optimizers_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
    130       if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) {
    131         childHiveJobsLock.EnterWriteLock();
     130      if (syncTasksWithOptimizers && this.ItemTask.ComputeInParallel) {
     131        childHiveTasksLock.EnterWriteLock();
    132132        try {
    133133          foreach (var item in e.Items) {
    134134            if (GetChildByOptimizer(item.Value) == null && item.Value.Name != "Placeholder") {
    135               this.childHiveJobs.Add(new OptimizerHiveJob(item.Value));
     135              this.childHiveTasks.Add(new OptimizerHiveTask(item.Value));
    136136            }
    137137          }
    138138        }
    139         finally { childHiveJobsLock.ExitWriteLock(); }
     139        finally { childHiveTasksLock.ExitWriteLock(); }
    140140      }
    141141    }
    142142    private void Optimizers_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
    143       if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) {
    144         childHiveJobsLock.EnterWriteLock();
     143      if (syncTasksWithOptimizers && this.ItemTask.ComputeInParallel) {
     144        childHiveTasksLock.EnterWriteLock();
    145145        try {
    146146          foreach (var item in e.OldItems) {
    147             this.childHiveJobs.Remove(this.GetChildByOptimizer(item.Value));
     147            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
    148148          }
    149149          foreach (var item in e.Items) {
    150150            if (GetChildByOptimizer(item.Value) == null && item.Value.Name != "Placeholder") {
    151               this.childHiveJobs.Add(new OptimizerHiveJob(item.Value));
     151              this.childHiveTasks.Add(new OptimizerHiveTask(item.Value));
    152152            }
    153153          }
    154154        }
    155         finally { childHiveJobsLock.ExitWriteLock(); }
     155        finally { childHiveTasksLock.ExitWriteLock(); }
    156156      }
    157157    }
    158158    private void Optimizers_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
    159       if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) {
    160         childHiveJobsLock.EnterWriteLock();
     159      if (syncTasksWithOptimizers && this.ItemTask.ComputeInParallel) {
     160        childHiveTasksLock.EnterWriteLock();
    161161        try {
    162162          foreach (var item in e.Items) {
    163             this.childHiveJobs.Remove(this.GetChildByOptimizer(item.Value));
    164           }
    165         }
    166         finally { childHiveJobsLock.ExitWriteLock(); }
     163            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
     164          }
     165        }
     166        finally { childHiveTasksLock.ExitWriteLock(); }
    167167      }
    168168    }
    169169    private void Optimizers_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
    170       if (syncJobsWithOptimizers && this.ItemJob.ComputeInParallel) {
    171         childHiveJobsLock.EnterWriteLock();
     170      if (syncTasksWithOptimizers && this.ItemTask.ComputeInParallel) {
     171        childHiveTasksLock.EnterWriteLock();
    172172        try {
    173173          foreach (var item in e.Items) {
    174             this.childHiveJobs.Remove(this.GetChildByOptimizer(item.Value));
    175           }
    176         }
    177         finally { childHiveJobsLock.ExitWriteLock(); }
     174            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
     175          }
     176        }
     177        finally { childHiveTasksLock.ExitWriteLock(); }
    178178      }
    179179    }
     
    183183    ///   replace the child-optimizer in the experiment
    184184    /// if this.Optimizer is BatchRun
    185     ///   add the runs from the optimizerJob to the batchrun and replace the Optimizer
    186     /// </summary>
    187     public override void IntegrateChild(ItemJob job, Guid childJobId) {
    188       var optimizerJob = (OptimizerJob)job;
    189       syncJobsWithOptimizers = false; // don't sync with optimizers during this method
    190 
    191       if (this.ItemJob != null && this.ItemJob.Item != null) {
    192         if (this.ItemJob.Item is Optimization.Experiment) {
    193           UpdateOptimizerInExperiment(this.ItemJob.OptimizerAsExperiment, optimizerJob);
    194         } else if (this.ItemJob.Item is Optimization.BatchRun) {
    195           UpdateOptimizerInBatchRun(this.ItemJob.OptimizerAsBatchRun, optimizerJob);
    196         }
    197       }
    198 
    199       childHiveJobsLock.EnterReadLock();
    200       OptimizerHiveJob child = (OptimizerHiveJob)this.ChildHiveJobs.Single(j => j.Job.Id == childJobId);
     185    ///   add the runs from the optimizerTask to the batchrun and replace the Optimizer
     186    /// </summary>
     187    public override void IntegrateChild(ItemTask task, Guid childJobId) {
     188      var optimizerTask = (OptimizerTask)task;
     189      syncTasksWithOptimizers = false; // don't sync with optimizers during this method
     190
     191      if (this.ItemTask != null && this.ItemTask.Item != null) {
     192        if (this.ItemTask.Item is Optimization.Experiment) {
     193          UpdateOptimizerInExperiment(this.ItemTask.OptimizerAsExperiment, optimizerTask);
     194        } else if (this.ItemTask.Item is Optimization.BatchRun) {
     195          UpdateOptimizerInBatchRun(this.ItemTask.OptimizerAsBatchRun, optimizerTask);
     196        }
     197      }
     198
     199      childHiveTasksLock.EnterReadLock();
     200      OptimizerHiveTask child = (OptimizerHiveTask)this.ChildHiveTasks.Single(j => j.Task.Id == childJobId);
    201201      try {
    202         if (!optimizerJob.ComputeInParallel) {
    203           child.syncJobsWithOptimizers = false;
    204           child.ItemJob = optimizerJob;
    205           child.syncJobsWithOptimizers = true;
    206         }
    207       }
    208       finally { childHiveJobsLock.ExitReadLock(); }
    209       syncJobsWithOptimizers = true;
    210     }
    211 
    212     /// <summary>
    213     /// Adds the runs from the optimizerJob to the batchrun and replaces the Optimizer
    214     /// Sideeffect: the optimizerJob.Optimizer will be prepared (scopes are deleted and executionstate will be reset)
    215     /// </summary>
    216     private void UpdateOptimizerInBatchRun(BatchRun batchRun, OptimizerJob optimizerJob) {
     202        if (!optimizerTask.ComputeInParallel) {
     203          child.syncTasksWithOptimizers = false;
     204          child.ItemTask = optimizerTask;
     205          child.syncTasksWithOptimizers = true;
     206        }
     207      }
     208      finally { childHiveTasksLock.ExitReadLock(); }
     209      syncTasksWithOptimizers = true;
     210    }
     211
     212    /// <summary>
     213    /// Adds the runs from the optimizerTask to the batchrun and replaces the Optimizer
     214    /// Sideeffect: the optimizerTask.Optimizer will be prepared (scopes are deleted and executionstate will be reset)
     215    /// </summary>
     216    private void UpdateOptimizerInBatchRun(BatchRun batchRun, OptimizerTask optimizerTask) {
    217217      if (batchRun.Optimizer == null) {
    218         batchRun.Optimizer = (IOptimizer)optimizerJob.Item; // only set the first optimizer as Optimizer. if every time the Optimizer would be set, the runs would be cleared each time
    219       }
    220       foreach (IRun run in optimizerJob.Item.Runs) {
     218        batchRun.Optimizer = (IOptimizer)optimizerTask.Item; // only set the first optimizer as Optimizer. if every time the Optimizer would be set, the runs would be cleared each time
     219      }
     220      foreach (IRun run in optimizerTask.Item.Runs) {
    221221        if (!batchRun.Runs.Contains(run)) {
    222222          run.Name = GetNewRunName(run, batchRun.Runs);
     
    228228    /// <summary>
    229229    /// replace the child-optimizer in the experiment
    230     /// Sideeffect: the optimizerJob.Optimizer will be prepared (scopes are deleted and executionstate will be reset)
    231     /// </summary>
    232     private void UpdateOptimizerInExperiment(Optimization.Experiment experiment, OptimizerJob optimizerJob) {
    233       if (optimizerJob.IndexInParentOptimizerList < 0)
     230    /// Sideeffect: the optimizerTask.Optimizer will be prepared (scopes are deleted and executionstate will be reset)
     231    /// </summary>
     232    private void UpdateOptimizerInExperiment(Optimization.Experiment experiment, OptimizerTask optimizerTask) {
     233      if (optimizerTask.IndexInParentOptimizerList < 0)
    234234        throw new IndexOutOfRangeException("IndexInParentOptimizerList must be equal or greater than zero! The Task is invalid and the optimizer-tree cannot be reassembled.");
    235235
    236       while (experiment.Optimizers.Count < optimizerJob.IndexInParentOptimizerList) {
    237         experiment.Optimizers.Add(new UserDefinedAlgorithm("Placeholder")); // add dummy-entries to Optimizers so that its possible to insert the optimizerJob at the correct position
    238       }
    239       if (experiment.Optimizers.Count < optimizerJob.IndexInParentOptimizerList + 1) {
    240         experiment.Optimizers.Add(optimizerJob.Item);
     236      while (experiment.Optimizers.Count < optimizerTask.IndexInParentOptimizerList) {
     237        experiment.Optimizers.Add(new UserDefinedAlgorithm("Placeholder")); // add dummy-entries to Optimizers so that its possible to insert the optimizerTask at the correct position
     238      }
     239      if (experiment.Optimizers.Count < optimizerTask.IndexInParentOptimizerList + 1) {
     240        experiment.Optimizers.Add(optimizerTask.Item);
    241241      } else {
    242242        // if ComputeInParallel==true, don't replace the optimizer (except it is still a Placeholder)
    243243        // this is because Jobs with ComputeInParallel get submitted to hive with their child-optimizers deleted
    244         if (!optimizerJob.ComputeInParallel || experiment.Optimizers[optimizerJob.IndexInParentOptimizerList].Name == "Placeholder") {
    245           experiment.Optimizers[optimizerJob.IndexInParentOptimizerList] = optimizerJob.Item;
     244        if (!optimizerTask.ComputeInParallel || experiment.Optimizers[optimizerTask.IndexInParentOptimizerList].Name == "Placeholder") {
     245          experiment.Optimizers[optimizerTask.IndexInParentOptimizerList] = optimizerTask.Item;
    246246        }
    247247      }
     
    250250    /// <summary>
    251251    /// Sets the IndexInParentOptimizerList property of the OptimizerJob
    252     /// according to the position in the OptimizerList of the parentHiveJob.Task
     252    /// according to the position in the OptimizerList of the parentHiveTask.Task
    253253    /// Recursively updates all the child-jobs as well
    254254    /// </summary>
    255     internal void SetIndexInParentOptimizerList(OptimizerHiveJob parentHiveJob) {
    256       if (parentHiveJob != null) {
    257         if (parentHiveJob.ItemJob.Item is Optimization.Experiment) {
    258           this.ItemJob.IndexInParentOptimizerList = parentHiveJob.ItemJob.OptimizerAsExperiment.Optimizers.IndexOf(this.ItemJob.Item);
    259         } else if (parentHiveJob.ItemJob.Item is Optimization.BatchRun) {
    260           this.ItemJob.IndexInParentOptimizerList = 0;
     255    internal void SetIndexInParentOptimizerList(OptimizerHiveTask parentHiveTask) {
     256      if (parentHiveTask != null) {
     257        if (parentHiveTask.ItemTask.Item is Optimization.Experiment) {
     258          this.ItemTask.IndexInParentOptimizerList = parentHiveTask.ItemTask.OptimizerAsExperiment.Optimizers.IndexOf(this.ItemTask.Item);
     259        } else if (parentHiveTask.ItemTask.Item is Optimization.BatchRun) {
     260          this.ItemTask.IndexInParentOptimizerList = 0;
    261261        } else {
    262262          throw new NotSupportedException("Only Experiment and BatchRuns are supported");
    263263        }
    264264      }
    265       childHiveJobsLock.EnterReadLock();
     265      childHiveTasksLock.EnterReadLock();
    266266      try {
    267         foreach (OptimizerHiveJob child in childHiveJobs) {
     267        foreach (OptimizerHiveTask child in childHiveTasks) {
    268268          child.SetIndexInParentOptimizerList(this);
    269269        }
    270270      }
    271       finally { childHiveJobsLock.ExitReadLock(); }
    272     }
    273 
    274     public override void AddChildHiveJob(HiveJob hiveJob) {
     271      finally { childHiveTasksLock.ExitReadLock(); }
     272    }
     273
     274    public override void AddChildHiveJob(HiveTask hiveJob) {
    275275      base.AddChildHiveJob(hiveJob);
    276       var optimizerHiveJob = (OptimizerHiveJob)hiveJob;
    277       syncJobsWithOptimizers = false;
    278       if (this.ItemJob != null && optimizerHiveJob.ItemJob != null) {
    279         // if job is in state Paused, it has to preserve its ResultCollection, which is cleared when a optimizer is added to an experiment
    280         OptimizerJob optimizerJobClone = null;
    281         if (optimizerHiveJob.Job.State == TaskState.Paused) {
    282           optimizerJobClone = (OptimizerJob)optimizerHiveJob.ItemJob.Clone();
    283         }
    284 
    285         if (this.ItemJob.Item is Optimization.Experiment) {
    286           if (!this.ItemJob.OptimizerAsExperiment.Optimizers.Contains(optimizerHiveJob.ItemJob.Item)) {
    287             UpdateOptimizerInExperiment(this.ItemJob.OptimizerAsExperiment, optimizerHiveJob.ItemJob);
    288           }
    289         } else if (this.ItemJob.Item is Optimization.BatchRun) {
    290           UpdateOptimizerInBatchRun(this.ItemJob.OptimizerAsBatchRun, optimizerHiveJob.ItemJob);
    291         }
    292 
    293         if (optimizerHiveJob.Job.State == TaskState.Paused) {
    294           optimizerHiveJob.ItemJob = optimizerJobClone;
    295         }
    296       }
    297       syncJobsWithOptimizers = true;
     276      var optimizerHiveJob = (OptimizerHiveTask)hiveJob;
     277      syncTasksWithOptimizers = false;
     278      if (this.ItemTask != null && optimizerHiveJob.ItemTask != null) {
     279        // if task is in state Paused, it has to preserve its ResultCollection, which is cleared when a optimizer is added to an experiment
     280        OptimizerTask optimizerJobClone = null;
     281        if (optimizerHiveJob.Task.State == TaskState.Paused) {
     282          optimizerJobClone = (OptimizerTask)optimizerHiveJob.ItemTask.Clone();
     283        }
     284
     285        if (this.ItemTask.Item is Optimization.Experiment) {
     286          if (!this.ItemTask.OptimizerAsExperiment.Optimizers.Contains(optimizerHiveJob.ItemTask.Item)) {
     287            UpdateOptimizerInExperiment(this.ItemTask.OptimizerAsExperiment, optimizerHiveJob.ItemTask);
     288          }
     289        } else if (this.ItemTask.Item is Optimization.BatchRun) {
     290          UpdateOptimizerInBatchRun(this.ItemTask.OptimizerAsBatchRun, optimizerHiveJob.ItemTask);
     291        }
     292
     293        if (optimizerHiveJob.Task.State == TaskState.Paused) {
     294          optimizerHiveJob.ItemTask = optimizerJobClone;
     295        }
     296      }
     297      syncTasksWithOptimizers = true;
    298298    }
    299299
     
    302302    /// </summary>
    303303    /// <param name="withoutChildOptimizers">
    304     ///   if true the Child-Optimizers will not be serialized (if the job contains an Experiment)
     304    ///   if true the Child-Optimizers will not be serialized (if the task contains an Experiment)
    305305    /// </param>
    306     public override TaskData GetAsJobData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) {
     306    public override TaskData GetAsTaskData(bool withoutChildOptimizers, out List<IPluginDescription> plugins) {
    307307      plugins = new List<IPluginDescription>();
    308       if (this.itemJob == null) // || this.jobItem.Optimizer == null
     308      if (this.itemTask == null) // || this.jobItem.Optimizer == null
    309309        return null;
    310310
    311311      IEnumerable<Type> usedTypes;
    312312      byte[] jobByteArray;
    313       if (withoutChildOptimizers && this.ItemJob.Item is Optimization.Experiment) {
    314         OptimizerJob clonedJob = (OptimizerJob)this.ItemJob.Clone(); // use a cloned job, so that the childHiveJob don't get confused
     313      if (withoutChildOptimizers && this.ItemTask.Item is Optimization.Experiment) {
     314        OptimizerTask clonedJob = (OptimizerTask)this.ItemTask.Clone(); // use a cloned task, so that the childHiveJob don't get confused
    315315        clonedJob.OptimizerAsExperiment.Optimizers.Clear();
    316316        jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes);
    317       } else if (withoutChildOptimizers && this.ItemJob.Item is Optimization.BatchRun) {
    318         OptimizerJob clonedJob = (OptimizerJob)this.ItemJob.Clone();
     317      } else if (withoutChildOptimizers && this.ItemTask.Item is Optimization.BatchRun) {
     318        OptimizerTask clonedJob = (OptimizerTask)this.ItemTask.Clone();
    319319        clonedJob.OptimizerAsBatchRun.Optimizer = null;
    320320        jobByteArray = PersistenceUtil.Serialize(clonedJob, out usedTypes);
    321       } else if (this.ItemJob.Item is IAlgorithm) {
    322         ((IAlgorithm)this.ItemJob.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size
    323         jobByteArray = PersistenceUtil.Serialize(this.ItemJob, out usedTypes);
     321      } else if (this.ItemTask.Item is IAlgorithm) {
     322        ((IAlgorithm)this.ItemTask.Item).StoreAlgorithmInEachRun = false; // avoid storing the algorithm in runs to reduce size
     323        jobByteArray = PersistenceUtil.Serialize(this.ItemTask, out usedTypes);
    324324      } else {
    325         jobByteArray = PersistenceUtil.Serialize(this.ItemJob, out usedTypes);
    326       }
    327 
    328       TaskData jobData = new TaskData() { TaskId = job.Id, Data = jobByteArray };
     325        jobByteArray = PersistenceUtil.Serialize(this.ItemTask, out usedTypes);
     326      }
     327
     328      TaskData jobData = new TaskData() { TaskId = task.Id, Data = jobByteArray };
    329329      PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);
    330330      return jobData;
    331331    }
    332332
    333     public OptimizerHiveJob GetChildByOptimizerJob(OptimizerJob optimizerJob) {
    334       childHiveJobsLock.EnterReadLock();
     333    public OptimizerHiveTask GetChildByOptimizerJob(OptimizerTask optimizerJob) {
     334      childHiveTasksLock.EnterReadLock();
    335335      try {
    336         foreach (OptimizerHiveJob child in childHiveJobs) {
    337           if (child.ItemJob == optimizerJob)
     336        foreach (OptimizerHiveTask child in childHiveTasks) {
     337          if (child.ItemTask == optimizerJob)
    338338            return child;
    339339        }
    340340        return null;
    341341      }
    342       finally { childHiveJobsLock.ExitReadLock(); }
    343     }
    344 
    345     public HiveJob<OptimizerJob> GetChildByOptimizer(IOptimizer optimizer) {
    346       childHiveJobsLock.EnterReadLock();
     342      finally { childHiveTasksLock.ExitReadLock(); }
     343    }
     344
     345    public HiveTask<OptimizerTask> GetChildByOptimizer(IOptimizer optimizer) {
     346      childHiveTasksLock.EnterReadLock();
    347347      try {
    348         foreach (OptimizerHiveJob child in childHiveJobs) {
    349           if (child.ItemJob.Item == optimizer)
     348        foreach (OptimizerHiveTask child in childHiveTasks) {
     349          if (child.ItemTask.Item == optimizer)
    350350            return child;
    351351        }
    352352        return null;
    353353      }
    354       finally { childHiveJobsLock.ExitReadLock(); }
     354      finally { childHiveTasksLock.ExitReadLock(); }
    355355    }
    356356
Note: See TracChangeset for help on using the changeset viewer.