- Timestamp:
- 03/05/14 14:48:13 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing
- Property svn:mergeinfo changed
-
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r9893 r10538 351 351 /// </summary> 352 352 /// <param name="parentHiveTask">shall be null if its the root task</param> 353 private void UploadTaskWithChildren( Progress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {353 private void UploadTaskWithChildren(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) { 354 354 taskUploadSemaphore.WaitOne(); 355 355 bool semaphoreReleased = false; … … 362 362 List<IPluginDescription> plugins; 363 363 364 if (hiveTask.ItemTask.ComputeInParallel && (hiveTask.ItemTask.Item is Optimization.Experiment || hiveTask.ItemTask.Item is Optimization.BatchRun)) {364 if (hiveTask.ItemTask.ComputeInParallel) { 365 365 hiveTask.Task.IsParentTask = true; 366 366 hiveTask.Task.FinishWhenChildJobsFinished = true; -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/HiveServiceLocator.cs
r9665 r10538 21 21 22 22 using System; 23 using System.ServiceModel; 23 24 using HeuristicLab.Clients.Common; 24 25 … … 69 70 return cl; 70 71 } 71 catch (E xception exc) {72 catch (EndpointNotFoundException exc) { 72 73 exception = exc; 73 74 EndpointRetries++; -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/HiveTasks/EngineHiveTask.cs
r9456 r10538 32 32 #region Constructors and cloning 33 33 public EngineHiveTask() { } 34 public EngineHiveTask(EngineTask engine Job, IScope parentScopeClone)35 : base(engine Job) {34 public EngineHiveTask(EngineTask engineTask, IScope parentScopeClone) 35 : base(engineTask) { 36 36 this.parentScopeClone = parentScopeClone; 37 37 } -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/HiveTasks/HiveTask.cs
r9819 r10538 182 182 } 183 183 184 public HiveTask(ItemTask item Job, bool autoCreateChildHiveJobs)184 public HiveTask(ItemTask itemTask, bool autoCreateChildHiveTasks) 185 185 : this() { 186 this.syncTasksWithOptimizers = autoCreateChildHive Jobs;187 this.ItemTask = item Job;186 this.syncTasksWithOptimizers = autoCreateChildHiveTasks; 187 this.ItemTask = itemTask; 188 188 this.syncTasksWithOptimizers = true; 189 189 } 190 190 191 public HiveTask(Task job, TaskData taskData, bool autoCreateChildHiveTasks) {191 public HiveTask(Task task, TaskData taskData, bool autoCreateChildHiveTasks) { 192 192 this.syncTasksWithOptimizers = autoCreateChildHiveTasks; 193 this.Task = job;193 this.Task = task; 194 194 try { 195 195 this.ItemTask = PersistenceUtil.Deserialize<ItemTask>(taskData.Data); … … 545 545 public new T ItemTask { 546 546 get { return (T)base.ItemTask; } 547 internalset { base.ItemTask = value; }547 set { base.ItemTask = value; } 548 548 } 549 549 … … 552 552 [StorableConstructor] 553 553 protected HiveTask(bool deserializing) { } 554 public HiveTask(T item Job) : base(itemJob, true) { }554 public HiveTask(T itemTask) : base(itemTask, true) { } 555 555 protected HiveTask(HiveTask<T> original, Cloner cloner) 556 556 : base(original, cloner) { -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs
r9893 r10538 157 157 } 158 158 159 private Progress progress;160 public Progress Progress {159 private IProgress progress; 160 public IProgress Progress { 161 161 get { return progress; } 162 162 set { -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/ServiceClients/Task.cs
r9456 r10538 27 27 public partial class Task : LightweightTask { 28 28 29 public Task() { } 29 public Task() { 30 Priority = 1; 31 } 30 32 31 33 protected Task(Task original, Cloner cloner) -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs
r9456 r10538 24 24 using System.Linq; 25 25 using System.Threading; 26 using HeuristicLab.Clients.Hive.Jobs;27 26 using HeuristicLab.Common; 28 27 … … 79 78 80 79 public TaskDownloader(IEnumerable<Guid> jobIds) { 81 t his.taskIds = jobIds;82 t his.taskDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads);83 t his.taskDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured);84 this.results = new Dictionary<Guid, HiveTask>();80 taskIds = jobIds; 81 taskDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads); 82 taskDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured); 83 results = new Dictionary<Guid, HiveTask>(); 85 84 } 86 85 … … 88 87 foreach (Guid taskId in taskIds) { 89 88 taskDownloader.DownloadTaskDataAndTask(taskId, 90 (localJob, itemJob) => { 91 if (localJob != null && itemJob != null) { 92 HiveTask hiveTask; 93 if (itemJob is OptimizerTask) { 94 hiveTask = new OptimizerHiveTask((OptimizerTask)itemJob); 95 } else { 96 hiveTask = new HiveTask(itemJob, true); 97 } 98 hiveTask.Task = localJob; 89 (localTask, itemTask) => { 90 if (localTask != null && itemTask != null) { 91 HiveTask hiveTask = itemTask.CreateHiveTask(); 92 hiveTask.Task = localTask; 99 93 try { 100 94 resultsLock.EnterWriteLock(); 101 this.results.Add(localJob.Id, hiveTask);95 results.Add(localTask.Id, hiveTask); 102 96 } 103 97 finally { resultsLock.ExitWriteLock(); } … … 113 107 public event EventHandler<EventArgs<Exception>> ExceptionOccured; 114 108 private void OnExceptionOccured(Exception exception) { 115 this.exceptionOccured = true;116 this.currentException = exception;109 exceptionOccured = true; 110 currentException = exception; 117 111 var handler = ExceptionOccured; 118 112 if (handler != null) handler(this, new EventArgs<Exception>(exception)); -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/Tasks/EngineTask.cs
r9819 r10538 29 29 [StorableClass] 30 30 public class EngineTask : ItemTask { 31 public override HiveTask CreateHiveTask() { 32 //only used when deserializing, so no problem with parentscope 33 return new EngineHiveTask(this, null); 34 } 35 31 36 [Storable] 32 37 protected IOperation initialOperation; … … 54 59 this.Item = engine; 55 60 } 61 62 public EngineTask(IEngine engine) : base(engine) { } 56 63 57 64 [StorableConstructor] -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/Tasks/ItemTask.cs
r9456 r10538 22 22 using System; 23 23 using System.Drawing; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Hive; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 28 30 29 31 namespace HeuristicLab.Clients.Hive { … … 31 33 [StorableClass] 32 34 public abstract class ItemTask : NamedItem, ITask { 35 public virtual HiveTask CreateHiveTask() { 36 return new HiveTask(this, true); 37 } 38 33 39 public virtual bool IsParallelizable { 34 40 get { return true; } 41 set { } 35 42 } 36 43 … … 71 78 this.Item = cloner.Clone(original.Item); 72 79 } 80 public ItemTask(IItem item) { 81 Item = item; 82 } 73 83 74 84 [StorableHook(HookType.AfterDeserialization)] … … 211 221 return Name; 212 222 } 223 224 #region Helpers 225 public static bool IsTypeSupported(Type itemType) { 226 var supportedHiveTaskTypes = ApplicationManager.Manager.GetTypes(typeof(ItemTask)) 227 .Select(t => t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType); 228 return supportedHiveTaskTypes.Any(x => x.IsAssignableFrom(itemType)); 229 } 230 231 public static Type GetHiveTaskType(Type itemType) { 232 if (!IsTypeSupported(itemType)) throw new Exception("Item " + itemType + " is not supported for Hive."); 233 234 var typeHiveTaskMap = ApplicationManager.Manager.GetTypes(typeof(ItemTask)) 235 .Select(t => new Tuple<Type, Type>(t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType, t)); 236 237 return typeHiveTaskMap.Single(x => x.Item1.IsAssignableFrom(itemType)).Item2; 238 } 239 240 public static ItemTask GetItemTaskForItem(IItem item) { 241 Type itemType = item.GetType(); 242 Type hiveTaskType = GetHiveTaskType(itemType); 243 return Activator.CreateInstance(hiveTaskType, new object[] { item }) as ItemTask; 244 } 245 #endregion 213 246 } 214 247 } -
branches/DataPreprocessing/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs
r9819 r10538 30 30 [StorableClass] 31 31 public class OptimizerTask : ItemTask { 32 public override HiveTask CreateHiveTask() { 33 return new OptimizerHiveTask(this); 34 } 35 32 36 public override bool IsParallelizable { 33 37 get { return this.Item is Experiment || this.Item is BatchRun; } … … 46 50 } 47 51 48 public OptimizerTask(IOptimizer optimizer) {49 this.Item = optimizer;50 51 if (optimizer is Experiment ) {52 public OptimizerTask(IOptimizer optimizer) 53 : base(optimizer) { 54 55 if (optimizer is Experiment || optimizer is BatchRun) { 52 56 this.ComputeInParallel = true; 53 } else if (optimizer is BatchRun) {54 this.ComputeInParallel = false;55 57 } else { 56 58 this.ComputeInParallel = false;
Note: See TracChangeset
for help on using the changeset viewer.