Changeset 6006 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ExperimentManagerClient.cs
- Timestamp:
- 04/12/11 13:43:05 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources
- Property svn:ignore
-
old new 4 4 PrecompiledWeb 5 5 CreateEventLogSources 6 WindowsFormsTestProject
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ExperimentManagerClient.cs
r6000 r6006 145 145 146 146 public static void StartExperiment(Action<Exception> exceptionCallback, HiveExperiment hiveExperiment) { 147 ExperimentManagerClient.StoreAsync(exceptionCallback, hiveExperiment); 147 ExperimentManagerClient.StoreAsync( 148 new Action<Exception>((Exception ex) => { 149 hiveExperiment.ExecutionState = ExecutionState.Prepared; 150 exceptionCallback(ex); 151 }), hiveExperiment); 148 152 hiveExperiment.ExecutionState = ExecutionState.Started; 149 153 } … … 151 155 public static void PauseExperiment(HiveExperiment hiveExperiment) { 152 156 ServiceLocator.Instance.CallHiveService(service => { 153 foreach (HiveJob job in hiveExperiment. HiveJob.GetAllHiveJobs()) {157 foreach (HiveJob job in hiveExperiment.GetAllHiveJobs()) { 154 158 if (job.Job.State != JobState.Finished && job.Job.State != JobState.Aborted && job.Job.State != JobState.Failed) 155 159 service.PauseJob(job.Job.Id); … … 161 165 public static void StopExperiment(HiveExperiment hiveExperiment) { 162 166 ServiceLocator.Instance.CallHiveService(service => { 163 foreach (HiveJob job in hiveExperiment. HiveJob.GetAllHiveJobs()) {167 foreach (HiveJob job in hiveExperiment.GetAllHiveJobs()) { 164 168 if (job.Job.State != JobState.Finished && job.Job.State != JobState.Aborted && job.Job.State != JobState.Failed) 165 169 service.StopJob(job.Job.Id); … … 185 189 } 186 190 187 hiveExperiment.HiveJob.SetIndexInParentOptimizerList(null); 188 189 int totalJobCount = hiveExperiment.HiveJob.GetAllHiveJobs().Count(); 191 foreach (HiveJob hiveJob in hiveExperiment.HiveJobs) { 192 hiveJob.SetIndexInParentOptimizerList(null); 193 } 194 195 // upload HiveExperiment 196 hiveExperiment.Progress.Status = "Uploading HiveExperiment..."; 197 hiveExperiment.Id = service.AddHiveExperiment(hiveExperiment); 198 199 int totalJobCount = hiveExperiment.GetAllHiveJobs().Count(); 190 200 int jobCount = 0; 191 201 202 // upload plugins 192 203 hiveExperiment.Progress.Status = "Uploading plugins..."; 193 204 this.OnlinePlugins = service.GetPlugins(); … … 196 207 this.alreadyUploadedPlugins.Add(configFilePlugin); 197 208 209 // upload jobs 198 210 hiveExperiment.Progress.Status = "Uploading jobs..."; 199 UploadJobWithChildren(hiveExperiment.Progress, service, hiveExperiment.HiveJob, null, resourceIds, ref jobCount, totalJobCount, configFilePlugin.Id, hiveExperiment.UseLocalPlugins); 200 hiveExperiment.RootJobId = hiveExperiment.HiveJob.Job.Id; 201 202 // insert or update HiveExperiment 203 hiveExperiment.Progress.Status = "Uploading HiveExperiment..."; 204 hiveExperiment.Id = service.AddHiveExperiment(hiveExperiment); 211 212 foreach (HiveJob hiveJob in hiveExperiment.HiveJobs) { 213 UploadJobWithChildren(hiveExperiment.Progress, service, hiveJob, null, resourceIds, ref jobCount, totalJobCount, configFilePlugin.Id, hiveExperiment.UseLocalPlugins, hiveExperiment.Id); 214 } 215 205 216 if (hiveExperiment.RefreshAutomatically) hiveExperiment.StartResultPolling(); 206 217 }); … … 239 250 /// <param name="parentHiveJob">shall be null if its the root job</param> 240 251 /// <param name="groups"></param> 241 private void UploadJobWithChildren(IProgress progress, IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, ref int jobCount, int totalJobCount, Guid configPluginId, bool useLocalPlugins ) {252 private void UploadJobWithChildren(IProgress progress, IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, ref int jobCount, int totalJobCount, Guid configPluginId, bool useLocalPlugins, Guid hiveExperimentId) { 242 253 jobCount++; 243 254 progress.Status = string.Format("Serializing job {0} of {1}", jobCount, totalJobCount); … … 259 270 hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(service, this.onlinePlugins, this.alreadyUploadedPlugins, plugins, useLocalPlugins); 260 271 hiveJob.Job.PluginsNeededIds.Add(configPluginId); 272 hiveJob.Job.HiveExperimentId = hiveExperimentId; 261 273 262 274 progress.Status = string.Format("Uploading job {0} of {1} ({2} kb)", jobCount, totalJobCount, jobData.Data.Count() / 1024); … … 270 282 271 283 foreach (HiveJob child in hiveJob.ChildHiveJobs) { 272 UploadJobWithChildren(progress, service, child, hiveJob, groups, ref jobCount, totalJobCount, configPluginId, useLocalPlugins );284 UploadJobWithChildren(progress, service, child, hiveJob, groups, ref jobCount, totalJobCount, configPluginId, useLocalPlugins, hiveExperimentId); 273 285 } 274 286 } … … 276 288 277 289 #region Download Experiment 278 public static void LoadExperiment 290 public static void LoadExperiment(HiveExperiment hiveExperiment) { 279 291 hiveExperiment.Progress = new Progress(); 280 292 try { … … 286 298 // fetch all Job objects to create the full tree of tree of HiveJob objects 287 299 hiveExperiment.Progress.Status = "Downloading list of jobs..."; 288 allJobs = ServiceLocator.Instance.CallHiveService(s => s.GetLightweight ChildJobs(hiveExperiment.RootJobId, true, true));300 allJobs = ServiceLocator.Instance.CallHiveService(s => s.GetLightweightExperimentJobs(hiveExperiment.Id)); 289 301 totalJobCount = allJobs.Count(); 290 302 … … 299 311 IDictionary<Guid, HiveJob> allHiveJobs = downloader.Results; 300 312 301 hiveExperiment.HiveJob = allHiveJobs[hiveExperiment.RootJobId]; 302 303 if (hiveExperiment.HiveJob.Job.DateFinished.HasValue && hiveExperiment.HiveJob.Job.DateCreated.HasValue) { 304 hiveExperiment.ExecutionTime = hiveExperiment.HiveJob.Job.DateFinished.Value - hiveExperiment.HiveJob.Job.DateCreated.Value; 313 hiveExperiment.HiveJobs = new ItemCollection<HiveJob>(allHiveJobs.Values.Where(x => !x.Job.ParentJobId.HasValue)); 314 //hiveExperiment.HiveJobs = allHiveJobs[hiveExperiment.RootJobId]; 315 316 if (hiveExperiment.IsFinished()) { 317 //hiveExperiment.ExecutionTime = hiveExperiment.HiveJobs.Max(.Job.DateFinished.Value - hiveExperiment.HiveJobs.Job.DateCreated.Value; 305 318 //hiveExperiment.lastUpdateTime = hiveExperiment.HiveJob.Job.DateFinished.Value; 306 319 hiveExperiment.ExecutionState = Core.ExecutionState.Stopped; 307 320 //OnStopped(); // todo: stop timer 308 321 } else { 309 hiveExperiment.ExecutionTime = hiveExperiment.HiveJob.Job.DateCreated.HasValue ? DateTime.Now - hiveExperiment.HiveJob.Job.DateCreated.Value : TimeSpan.Zero;322 //hiveExperiment.ExecutionTime = hiveExperiment.HiveJobs.Job.DateCreated.HasValue ? DateTime.Now - hiveExperiment.HiveJobs.Job.DateCreated.Value : TimeSpan.Zero; 310 323 //hiveExperiment.lastUpdateTime = DateTime.Now; 311 324 hiveExperiment.ExecutionState = Core.ExecutionState.Started; 312 325 //OnStarted(); // todo: start timer 313 326 } 327 hiveExperiment.UpdateTotalExecutionTime(); 314 328 315 329 // build child-job tree 316 BuildHiveJobTree(hiveExperiment.HiveJob, allJobs, allHiveJobs); 330 foreach (HiveJob hiveJob in hiveExperiment.HiveJobs) { 331 BuildHiveJobTree(hiveJob, allJobs, allHiveJobs); 332 } 317 333 hiveExperiment.UpdateTotalExecutionTime(); 318 334 319 335 if (hiveExperiment.ExecutionState != ExecutionState.Stopped) { 320 336 hiveExperiment.RefreshAutomatically = true; 321 } 337 } 322 338 } 323 339 finally {
Note: See TracChangeset
for help on using the changeset viewer.