Changeset 6444 for branches/HeuristicLab.Hive-3.4/sources
- Timestamp:
- 06/19/11 23:21:21 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.Designer.cs
r6426 r6444 254 254 this.resourceNamesTextBox.Location = new System.Drawing.Point(73, 53); 255 255 this.resourceNamesTextBox.Name = "resourceNamesTextBox"; 256 this.resourceNamesTextBox.Size = new System.Drawing.Size( 304, 20);256 this.resourceNamesTextBox.Size = new System.Drawing.Size(415, 20); 257 257 this.resourceNamesTextBox.TabIndex = 14; 258 258 this.resourceNamesTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated); … … 292 292 this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 293 293 this.isPrivilegedCheckBox.AutoSize = true; 294 this.isPrivilegedCheckBox.Location = new System.Drawing.Point( 383, 55);294 this.isPrivilegedCheckBox.Location = new System.Drawing.Point(494, 55); 295 295 this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox"; 296 296 this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17); … … 299 299 this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the job will be executed in a privileged sandbox on the slave."); 300 300 this.isPrivilegedCheckBox.UseVisualStyleBackColor = true; 301 this.isPrivilegedCheckBox. CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckedChanged);301 this.isPrivilegedCheckBox.Validated += new System.EventHandler(this.isPrivilegedCheckBox_Validated); 302 302 // 303 303 // refreshAutomaticallyCheckBox … … 310 310 this.refreshAutomaticallyCheckBox.Text = "&Refresh Automatically"; 311 311 this.refreshAutomaticallyCheckBox.UseVisualStyleBackColor = true; 312 this.refreshAutomaticallyCheckBox. CheckedChanged += new System.EventHandler(this.refreshAutomaticallyCheckBox_CheckedChanged);312 this.refreshAutomaticallyCheckBox.Validated += new System.EventHandler(this.refreshAutomaticallyCheckBox_Validated); 313 313 // 314 314 // infoGroupBox -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.cs
r6426 r6444 281 281 #region Control events 282 282 private void startButton_Click(object sender, EventArgs e) { 283 HiveClient.StartExperiment((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content );283 HiveClient.StartExperiment((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken()); 284 284 } 285 285 private void pauseButton_Click(object sender, EventArgs e) { … … 301 301 } 302 302 303 private void includeJobsCheckBox_CheckedChanged(object sender, EventArgs e) { 304 //if (Content != null) Content.IncludeJobs = includeJobsCheckBox.Checked; 305 } 306 307 private void refreshAutomaticallyCheckBox_CheckedChanged(object sender, EventArgs e) { 308 if (Content != null) { 309 Content.RefreshAutomatically = refreshAutomaticallyCheckBox.Checked; 310 } 311 } 312 313 private void isPrivilegedCheckBox_CheckedChanged(object sender, EventArgs e) { 303 private void refreshAutomaticallyCheckBox_Validated(object sender, EventArgs e) { 304 if (Content != null) Content.RefreshAutomatically = refreshAutomaticallyCheckBox.Checked; 305 } 306 307 private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) { 314 308 if (Content != null) Content.HiveExperiment.IsPrivileged = isPrivilegedCheckBox.Checked; 315 309 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs
r6426 r6444 27 27 using System.Security.Cryptography; 28 28 using System.Threading; 29 using System.Threading.Tasks; 29 30 using HeuristicLab.Common; 30 31 using HeuristicLab.Core; … … 104 105 105 106 #region Store 106 public static void Store(IHiveItem item ) {107 public static void Store(IHiveItem item, CancellationToken cancellationToken) { 107 108 if (item.Id == Guid.Empty) { 108 109 if (item is RefreshableHiveExperiment) { 109 HiveClient.Instance.UploadExperiment((RefreshableHiveExperiment)item );110 HiveClient.Instance.UploadExperiment((RefreshableHiveExperiment)item, cancellationToken); 110 111 } 111 112 } else { … … 114 115 } 115 116 } 116 public static void StoreAsync(Action<Exception> exceptionCallback, IHiveItem item ) {117 public static void StoreAsync(Action<Exception> exceptionCallback, IHiveItem item, CancellationToken cancellationToken) { 117 118 var call = new Func<Exception>(delegate() { 118 119 try { 119 Store(item );120 Store(item, cancellationToken); 120 121 } 121 122 catch (Exception ex) { … … 159 160 #endregion 160 161 161 public static void StartExperiment(Action<Exception> exceptionCallback, RefreshableHiveExperiment refreshableHiveExperiment ) {162 public static void StartExperiment(Action<Exception> exceptionCallback, RefreshableHiveExperiment refreshableHiveExperiment, CancellationToken cancellationToken) { 162 163 HiveClient.StoreAsync( 163 164 new Action<Exception>((Exception ex) => { 164 165 refreshableHiveExperiment.HiveExperiment.ExecutionState = ExecutionState.Prepared; 165 166 exceptionCallback(ex); 166 }), refreshableHiveExperiment );167 }), refreshableHiveExperiment, cancellationToken); 167 168 refreshableHiveExperiment.HiveExperiment.ExecutionState = ExecutionState.Started; 168 169 } … … 189 190 190 191 #region Upload Experiment 191 private void UploadExperiment(RefreshableHiveExperiment refreshableHiveExperiment) { 192 private Semaphore jobUploadSemaphore = new Semaphore(4, 4); // todo: take magic number into config 193 private static object jobCountLocker = new object(); 194 private void UploadExperiment(RefreshableHiveExperiment refreshableHiveExperiment, CancellationToken cancellationToken) { 192 195 try { 193 196 refreshableHiveExperiment.HiveExperiment.Progress = new Progress("Connecting to server..."); 194 197 refreshableHiveExperiment.HiveExperiment.IsProgressing = true; 195 ServiceLocator.Instance.CallHiveService(service => { 196 IEnumerable<string> resourceNames = ToResourceNameList(refreshableHiveExperiment.HiveExperiment.ResourceNames); 197 var resourceIds = new List<Guid>(); 198 foreach (var resourceName in resourceNames) { 199 Guid resourceId = service.GetResourceId(resourceName); 200 if (resourceId == Guid.Empty) { 201 throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName)); 202 } 203 resourceIds.Add(resourceId); 198 199 IEnumerable<string> resourceNames = ToResourceNameList(refreshableHiveExperiment.HiveExperiment.ResourceNames); 200 var resourceIds = new List<Guid>(); 201 foreach (var resourceName in resourceNames) { 202 Guid resourceId = ServiceLocator.Instance.CallHiveService((s) => s.GetResourceId(resourceName)); 203 if (resourceId == Guid.Empty) { 204 throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName)); 204 205 } 205 206 foreach (OptimizerHiveJob hiveJob in refreshableHiveExperiment.HiveExperiment.HiveJobs.OfType<OptimizerHiveJob>()) { 207 hiveJob.SetIndexInParentOptimizerList(null); 208 } 209 210 // upload HiveExperiment 211 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading HiveExperiment..."; 212 refreshableHiveExperiment.HiveExperiment.Id = service.AddHiveExperiment(refreshableHiveExperiment.HiveExperiment); 213 214 int totalJobCount = refreshableHiveExperiment.HiveExperiment.GetAllHiveJobs().Count(); 215 int jobCount = 0; 216 217 // upload plugins 218 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading plugins..."; 219 this.OnlinePlugins = service.GetPlugins(); 220 this.AlreadyUploadedPlugins = new List<Plugin>(); 221 Plugin configFilePlugin = UploadConfigurationFile(service, onlinePlugins); 222 this.alreadyUploadedPlugins.Add(configFilePlugin); 223 224 // upload jobs 225 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading jobs..."; 226 227 foreach (HiveJob hiveJob in refreshableHiveExperiment.HiveExperiment.HiveJobs) { 228 UploadJobWithChildren(refreshableHiveExperiment.HiveExperiment.Progress, service, hiveJob, null, resourceIds, ref jobCount, totalJobCount, configFilePlugin.Id, refreshableHiveExperiment.HiveExperiment.Id, refreshableHiveExperiment.Log, refreshableHiveExperiment.HiveExperiment.IsPrivileged); 229 } 230 231 if (refreshableHiveExperiment.RefreshAutomatically) refreshableHiveExperiment.StartResultPolling(); 232 }); 206 resourceIds.Add(resourceId); 207 } 208 209 foreach (OptimizerHiveJob hiveJob in refreshableHiveExperiment.HiveExperiment.HiveJobs.OfType<OptimizerHiveJob>()) { 210 hiveJob.SetIndexInParentOptimizerList(null); 211 } 212 213 // upload HiveExperiment 214 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading HiveExperiment..."; 215 refreshableHiveExperiment.HiveExperiment.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddHiveExperiment(refreshableHiveExperiment.HiveExperiment)); 216 cancellationToken.ThrowIfCancellationRequested(); 217 218 int totalJobCount = refreshableHiveExperiment.HiveExperiment.GetAllHiveJobs().Count(); 219 int[] jobCount = new int[1]; // use a reference type (int-array) instead of value type (int) in order to pass the value via a delegate to task-parallel-library 220 cancellationToken.ThrowIfCancellationRequested(); 221 222 // upload plugins 223 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading plugins..."; 224 this.OnlinePlugins = ServiceLocator.Instance.CallHiveService((s) => s.GetPlugins()); 225 this.AlreadyUploadedPlugins = new List<Plugin>(); 226 Plugin configFilePlugin = ServiceLocator.Instance.CallHiveService((s) => UploadConfigurationFile(s, onlinePlugins)); 227 this.alreadyUploadedPlugins.Add(configFilePlugin); 228 cancellationToken.ThrowIfCancellationRequested(); 229 230 if (refreshableHiveExperiment.RefreshAutomatically) refreshableHiveExperiment.StartResultPolling(); 231 232 // upload jobs 233 refreshableHiveExperiment.HiveExperiment.Progress.Status = "Uploading jobs..."; 234 235 var tasks = new List<Task>(); 236 foreach (HiveJob hiveJob in refreshableHiveExperiment.HiveExperiment.HiveJobs) { 237 tasks.Add(Task.Factory.StartNew((hj) => { 238 UploadJobWithChildren(refreshableHiveExperiment.HiveExperiment.Progress, (HiveJob)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableHiveExperiment.HiveExperiment.Id, refreshableHiveExperiment.Log, refreshableHiveExperiment.HiveExperiment.IsPrivileged, cancellationToken); 239 }, hiveJob) 240 .ContinueWith((x) => refreshableHiveExperiment.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted)); 241 } 242 Task.WaitAll(tasks.ToArray()); 233 243 } 234 244 finally { … … 267 277 /// Uploads the given job and all its child-jobs while setting the proper parentJobId values for the childs 268 278 /// </summary> 269 /// <param name="service"></param>270 /// <param name="hiveJob"></param>271 279 /// <param name="parentHiveJob">shall be null if its the root job</param> 272 /// <param name="groups"></param> 273 private void UploadJobWithChildren(IProgress progress, IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, ref int jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged) { 274 jobCount++; 275 progress.Status = string.Format("Serializing job {0} of {1}", jobCount, totalJobCount); 276 JobData jobData; 277 List<IPluginDescription> plugins; 278 279 if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) { 280 hiveJob.Job.IsParentJob = true; 281 hiveJob.Job.FinishWhenChildJobsFinished = true; 282 jobData = hiveJob.GetAsJobData(true, out plugins); 283 } else { 284 hiveJob.Job.IsParentJob = false; 285 hiveJob.Job.FinishWhenChildJobsFinished = false; 286 jobData = hiveJob.GetAsJobData(false, out plugins); 287 } 288 289 TryAndRepeat(() => { 290 hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(service, this.onlinePlugins, this.alreadyUploadedPlugins, plugins); 291 }, -1, "Failed to upload plugins"); 292 hiveJob.Job.PluginsNeededIds.Add(configPluginId); 293 hiveJob.Job.HiveExperimentId = hiveExperimentId; 294 hiveJob.Job.IsPrivileged = isPrivileged; 295 296 progress.Status = string.Format("Uploading job {0} of {1} ({2} kb, {3} objects)", jobCount, totalJobCount, jobData.Data.Count() / 1024, hiveJob.ItemJob.GetObjectGraphObjects().Count()); 297 progress.ProgressValue = (double)jobCount / totalJobCount; 298 299 log.LogMessage(progress.Status); 300 TryAndRepeat(() => { 301 if (parentHiveJob != null) { 302 hiveJob.Job.Id = service.AddChildJob(parentHiveJob.Job.Id, hiveJob.Job, jobData); 303 } else { 304 hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, groups.ToList()); 305 } 306 }, -1, "Failed to add job", log); 307 308 foreach (HiveJob child in hiveJob.ChildHiveJobs) { 309 UploadJobWithChildren(progress, service, child, hiveJob, groups, ref jobCount, totalJobCount, configPluginId, hiveExperimentId, log, isPrivileged); 280 private void UploadJobWithChildren(IProgress progress, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, int[] jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged, CancellationToken cancellationToken) { 281 jobUploadSemaphore.WaitOne(); 282 try { 283 cancellationToken.ThrowIfCancellationRequested(); 284 lock (jobCountLocker) { 285 jobCount[0]++; 286 } 287 JobData jobData = null; 288 List<IPluginDescription> plugins = null; 289 290 TryAndRepeat(() => { // workaround for persistence bug (thread-safe access to bitmaps) - remove later 291 if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) { 292 hiveJob.Job.IsParentJob = true; 293 hiveJob.Job.FinishWhenChildJobsFinished = true; 294 jobData = hiveJob.GetAsJobData(true, out plugins); 295 } else { 296 hiveJob.Job.IsParentJob = false; 297 hiveJob.Job.FinishWhenChildJobsFinished = false; 298 jobData = hiveJob.GetAsJobData(false, out plugins); 299 } 300 }, 30, "Could not serialize job"); 301 cancellationToken.ThrowIfCancellationRequested(); 302 303 TryAndRepeat(() => { 304 if (!cancellationToken.IsCancellationRequested) { 305 ServiceLocator.Instance.CallHiveService((s) => hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins)); 306 } 307 }, -1, "Failed to upload plugins"); 308 cancellationToken.ThrowIfCancellationRequested(); 309 hiveJob.Job.PluginsNeededIds.Add(configPluginId); 310 hiveJob.Job.HiveExperimentId = hiveExperimentId; 311 hiveJob.Job.IsPrivileged = isPrivileged; 312 313 log.LogMessage(string.Format("Uploading job ({0} kb, {1} objects)", jobData.Data.Count() / 1024, hiveJob.ItemJob.GetObjectGraphObjects().Count())); 314 TryAndRepeat(() => { 315 if (!cancellationToken.IsCancellationRequested) { 316 if (parentHiveJob != null) { 317 hiveJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddChildJob(parentHiveJob.Job.Id, hiveJob.Job, jobData)); 318 } else { 319 hiveJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddJob(hiveJob.Job, jobData, groups.ToList())); 320 } 321 } 322 }, 50, "Failed to add job", log); 323 cancellationToken.ThrowIfCancellationRequested(); 324 325 lock (jobCountLocker) { 326 progress.ProgressValue = (double)jobCount[0] / totalJobCount; 327 progress.Status = string.Format("Uploaded job ({0} of {1})", jobCount[0], totalJobCount); 328 } 329 330 var tasks = new List<Task>(); 331 foreach (HiveJob child in hiveJob.ChildHiveJobs) { 332 tasks.Add(Task.Factory.StartNew((tuple) => { 333 var arguments = (Tuple<HiveJob, HiveJob>)tuple; 334 UploadJobWithChildren(progress, arguments.Item1, arguments.Item2, groups, jobCount, totalJobCount, configPluginId, hiveExperimentId, log, isPrivileged, cancellationToken); 335 }, new Tuple<HiveJob, HiveJob>(child, hiveJob )) 336 .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted)); 337 } 338 Task.WaitAll(tasks.ToArray()); 339 } 340 finally { 341 jobUploadSemaphore.Release(); 310 342 } 311 343 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveItem.cs
r6373 r6444 86 86 87 87 public void Store() { 88 HiveClient.Store(this );88 HiveClient.Store(this, new System.Threading.CancellationToken()); 89 89 Modified = false; 90 90 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Util/PluginUtil.cs
r6426 r6444 30 30 namespace HeuristicLab.Clients.Hive { 31 31 public static class PluginUtil { 32 private static object locker = new object(); 32 33 33 34 /// <summary> … … 40 41 /// <returns></returns> 41 42 public static List<Guid> GetPluginDependencies(IHiveService service, List<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, IEnumerable<IPluginDescription> neededPlugins) { 42 var pluginIds = new List<Guid>(); 43 Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins); 43 lock (locker) { 44 var pluginIds = new List<Guid>(); 45 Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins); 44 46 45 foreach (var neededPlugin in checksumsNeededPlugins) { 46 Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Hash.SequenceEqual(neededPlugin.Value)); 47 if (foundPlugin == null) { 48 foundPlugin = onlinePlugins.FirstOrDefault(p => { 49 if (p.Hash != null) { 50 return p.Hash.SequenceEqual(neededPlugin.Value); 47 foreach (var neededPlugin in checksumsNeededPlugins) { 48 Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Hash.SequenceEqual(neededPlugin.Value)); 49 if (foundPlugin == null) { 50 foundPlugin = onlinePlugins.FirstOrDefault(p => { 51 if (p.Hash != null) { 52 return p.Hash.SequenceEqual(neededPlugin.Value); 53 } else { 54 return false; 55 } 56 }); 57 58 if (foundPlugin == null) { 59 Plugin p = CreatePlugin(neededPlugin.Key, neededPlugin.Value); 60 List<PluginData> pd = CreatePluginDatas(neededPlugin.Key); 61 try { 62 p.Id = service.AddPlugin(p, pd); 63 alreadyUploadedPlugins.Add(p); 64 pluginIds.Add(p.Id); 65 } 66 catch (FaultException<PluginAlreadyExistsFault> fault) { 67 onlinePlugins.Add(service.GetPlugin(fault.Detail.Id)); 68 } 51 69 } else { 52 return false; 53 } 54 }); 55 56 if (foundPlugin == null) { 57 Plugin p = CreatePlugin(neededPlugin.Key, neededPlugin.Value); 58 List<PluginData> pd = CreatePluginDatas(neededPlugin.Key); 59 try { 60 p.Id = service.AddPlugin(p, pd); 61 alreadyUploadedPlugins.Add(p); 62 pluginIds.Add(p.Id); 63 } 64 catch (FaultException<PluginAlreadyExistsFault> fault) { 65 onlinePlugins.Add(service.GetPlugin(fault.Detail.Id)); 70 pluginIds.Add(foundPlugin.Id); 66 71 } 67 72 } else { 68 73 pluginIds.Add(foundPlugin.Id); 69 74 } 70 } else {71 pluginIds.Add(foundPlugin.Id);72 75 } 76 return pluginIds; 73 77 } 74 return pluginIds;75 78 } 76 79 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.Designer.cs
r6426 r6444 60 60 this.resourceIdsTextBox.Location = new System.Drawing.Point(189, 52); 61 61 this.resourceIdsTextBox.Name = "resourceIdsTextBox"; 62 this.resourceIdsTextBox.Size = new System.Drawing.Size( 319, 20);62 this.resourceIdsTextBox.Size = new System.Drawing.Size(428, 20); 63 63 this.resourceIdsTextBox.TabIndex = 4; 64 64 this.resourceIdsTextBox.Text = "HEAL"; … … 184 184 this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 185 185 this.isPrivilegedCheckBox.AutoSize = true; 186 this.isPrivilegedCheckBox.Location = new System.Drawing.Point( 514, 55);186 this.isPrivilegedCheckBox.Location = new System.Drawing.Point(623, 54); 187 187 this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox"; 188 188 this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17); … … 190 190 this.isPrivilegedCheckBox.Text = "IsPrivileged"; 191 191 this.isPrivilegedCheckBox.UseVisualStyleBackColor = true; 192 this.isPrivilegedCheckBox. CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckedChanged);192 this.isPrivilegedCheckBox.Validated += new System.EventHandler(this.isPrivilegedCheckBox_Validated); 193 193 // 194 194 // HiveEngineView -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.cs
r6426 r6444 109 109 } 110 110 111 private void isPrivilegedCheckBox_ CheckedChanged(object sender, EventArgs e) {111 private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) { 112 112 Content.IsPrivileged = isPrivilegedCheckBox.Checked; 113 113 } 114 114 #endregion 115 116 117 115 } 118 116 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs
r6435 r6444 256 256 random.Reset(random.Next()); 257 257 } 258 HiveClient.StartExperiment((e) => { log.LogException(e); }, refreshableHiveExperiment );258 HiveClient.StartExperiment((e) => { log.LogException(e); }, refreshableHiveExperiment, cancellationToken); 259 259 260 260 // do polling until experiment is finished and all jobs are downloaded -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs
r6431 r6444 27 27 public static class TransactionManager { 28 28 public static void UseTransaction(Action call, bool serializable = false, bool longRunning = false) { 29 TransactionScope transaction = CreateTransaction(serializable, longRunning); 30 try { 31 call(); 32 transaction.Complete(); 33 } 34 finally { 35 transaction.Dispose(); 29 int n = 10; 30 while (n > 0) { 31 TransactionScope transaction = CreateTransaction(serializable, longRunning); 32 try { 33 call(); 34 transaction.Complete(); 35 n = 0; 36 } 37 catch (System.Data.SqlClient.SqlException e) { 38 n--; // probably deadlock situation, let it roll back and repeat the transaction n times 39 LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString())); 40 if (n <= 0) throw; 41 } 42 finally { 43 transaction.Dispose(); 44 } 36 45 } 37 46 } 38 47 39 48 public static T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) { 40 TransactionScope transaction = CreateTransaction(serializable, longRunning); 41 try { 42 T result = call(); 43 transaction.Complete(); 44 return result; 49 int n = 10; 50 while (n > 0) { 51 TransactionScope transaction = CreateTransaction(serializable, longRunning); 52 try { 53 T result = call(); 54 transaction.Complete(); 55 n = 0; 56 return result; 57 } 58 catch (System.Data.SqlClient.SqlException e) { 59 n--; // probably deadlock situation, let it roll back and repeat the transaction n times 60 LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString())); 61 if (n <= 0) throw; 62 } 63 finally { 64 transaction.Dispose(); 65 } 45 66 } 46 finally { 47 transaction.Dispose(); 48 } 67 throw new Exception("This code should not be reached"); 49 68 } 50 69 51 70 private static TransactionScope CreateTransaction(bool serializable, bool longRunning) { 52 71 var options = new TransactionOptions(); … … 58 77 if (longRunning) 59 78 options.Timeout = ApplicationConstants.LongRunningDatabaseCommandTimeout; 60 79 61 80 return new TransactionScope(TransactionScopeOption.Required, options); 62 81 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs
r6431 r6444 62 62 if (availableJobs.Count() > 0) { 63 63 var job = availableJobs.First(); 64 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id));65 AssignJob(slave, job);64 if (AssignJob(slave, job)) 65 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id)); 66 66 } 67 67 } … … 70 70 } 71 71 72 private void AssignJob(Slave slave, Job job) { 72 // returns true if assignment was successful 73 private bool AssignJob(Slave slave, Job job) { 74 // load job again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same job assigned) 75 if (dao.GetJob(job.Id).State != JobState.Waiting) return false; 76 73 77 job = dao.UpdateJobState(job.Id, JobState.Transferring, slave.Id, null, null); 74 dao.UpdateSlave(slave);75 78 76 79 // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout) 77 80 job.LastHeartbeat = DateTime.Now; 78 81 dao.UpdateJob(job); 82 return true; 79 83 } 80 84
Note: See TracChangeset
for help on using the changeset viewer.