Changeset 5399 for branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3
- Timestamp:
- 01/31/11 10:35:57 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs
r5394 r5399 51 51 } 52 52 } 53 53 54 54 #region constructors and cloning 55 55 public HiveEngine() { … … 310 310 private void DeleteJobs(IDictionary<Guid, int> jobIndices) { 311 311 if (jobIndices.Count > 0) { 312 using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) { 313 foreach (Guid jobId in jobIndices.Keys) { 314 service.Obj.DeleteJob(jobId); 315 } 316 LogMessage(string.Format("Deleted {0} jobs on hive.", jobIndices.Count)); 317 jobIndices.Clear(); 318 } 312 TryAndRepeat(() => { 313 LogMessage(string.Format("Deleting {0} jobs on hive.", jobIndices.Count)); 314 using (Disposable<IClientFacade> service = ServiceLocator.Instance.ClientFacadePool.GetService()) { 315 foreach (Guid jobId in jobIndices.Keys) { 316 service.Obj.DeleteJob(jobId); 317 } 318 jobIndices.Clear(); 319 } 320 }, 5, string.Format("Could not delete {0} jobs", jobIndices.Count)); 319 321 } 320 322 } … … 364 366 catch (Exception e) { 365 367 LogException(e); 368 LogMessage("Repeating upload"); 366 369 } 367 370 } … … 393 396 catch (Exception e) { 394 397 LogException(e); 398 LogMessage("Repeating download"); 395 399 } 396 400 } … … 423 427 } 424 428 } 429 430 /// <summary> 431 /// Executes the action. If it throws an exception it is repeated until repetition-count is reached. 432 /// If repetitions is -1, it is repeated infinitely. 433 /// </summary> 434 private static void TryAndRepeat(Action action, int repetitions, string errorMessage) { 435 while (repetitions > 0) { 436 try { action(); } 437 catch (Exception e) { 438 repetitions--; 439 if (repetitions == 0) { 440 throw new HiveEngineException(errorMessage, e); 441 } 442 } 443 } 444 } 445 446 private static void TryAndRepeat(Action action) { 447 TryAndRepeat(action, -1, string.Empty); 448 } 425 449 } 426 450 -
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngineException.cs
r5228 r5399 7 7 public class HiveEngineException : Exception { 8 8 public HiveEngineException(string message) : base(message) { } 9 10 public HiveEngineException(string message, Exception innerException) : base (message, innerException) { } 9 11 } 10 12 }
Note: See TracChangeset
for help on using the changeset viewer.