Changeset 12789 for branches/HiveStatistics/sources
- Timestamp:
- 07/21/15 11:48:49 (9 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs
r12691 r12789 27 27 namespace HeuristicLab.Services.Hive.DataAccess.Daos { 28 28 public class TaskDao : GenericDao<Guid, Task> { 29 private Table<AssignedResource> AssignedResourceTable { 30 get { return DataContext.GetTable<AssignedResource>(); } 31 } 32 29 33 public TaskDao(DataContext dataContext) : base(dataContext) { } 30 34 … … 51 55 //we skip this step because it's wasted runtime 52 56 return DataContext.ExecuteQuery<TaskPriorityInfo>(GetWaitingTasksQueryString, slave.ResourceId, Enum.GetName(typeof(TaskState), TaskState.Waiting), slave.FreeCores, slave.FreeMemory).ToList(); 57 } 58 59 /// <summary> 60 /// returns all parent tasks which are waiting for their child tasks to finish 61 /// </summary> 62 /// <param name="resourceIds">list of resourceids which for which the task should be valid</param> 63 /// <param name="count">maximum number of task to return</param> 64 /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param> 65 /// <returns></returns> 66 public IEnumerable<Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) { 67 var query = from ar in AssignedResourceTable 68 where resourceIds.Contains(ar.ResourceId) 69 && ar.Task.State == TaskState.Waiting 70 && ar.Task.IsParentTask 71 && (finished ? ar.Task.FinishWhenChildJobsFinished : !ar.Task.FinishWhenChildJobsFinished) 72 && (from child in Table 73 where child.ParentTaskId == ar.Task.TaskId 74 select child.State == TaskState.Finished 75 || child.State == TaskState.Aborted 76 || child.State == TaskState.Failed).All(x => x) 77 && (from child in Table // avoid returning WaitForChildTasks task where no child-task exist (yet) 78 where child.ParentTaskId == ar.Task.TaskId 79 select child).Any() 80 orderby ar.Task.Priority descending 81 select ar.Task; 82 return count == 0 ? query.ToArray() : query.Take(count).ToArray(); 53 83 } 54 84 -
branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj
r12768 r12789 143 143 <Compile Include="HiveStatisticsGenerator.cs" /> 144 144 <Compile Include="Interfaces\IStatisticsGenerator.cs" /> 145 <Compile Include="Manager\NewEventManager.cs" /> 145 146 <Compile Include="Manager\NewHeartbeatManager.cs" /> 146 147 <Compile Include="NewHiveService.cs" /> -
branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs
r12484 r12789 31 31 private AutoResetEvent generateStatisticsWaitHandle; 32 32 33 private I TransactionManager trans{34 get { return ServiceLocator.Instance. TransactionManager; }33 private IPersistenceManager PersistenceManager { 34 get { return ServiceLocator.Instance.PersistenceManager; } 35 35 } 36 37 private IEventManager eventManager { 36 private IEventManager EventManager { 38 37 get { return ServiceLocator.Instance.EventManager; } 39 38 } 40 39 41 private IStatisticsGenerator statisticsGenerator {40 private IStatisticsGenerator StatisticsGenerator { 42 41 get { return ServiceLocator.Instance.StatisticsGenerator; } 43 }44 45 private IHiveDao dao {46 get { return ServiceLocator.Instance.HiveDao; }47 42 } 48 43 … … 64 59 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting cleanup."); 65 60 bool cleanup = false; 66 trans.UseTransaction(() => { 67 DateTime lastCleanup = dao.GetLastCleanup(); 68 if (DateTime.Now - lastCleanup > HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval) { 69 dao.SetLastCleanup(DateTime.Now); 70 cleanup = true; 71 } 72 }, true); 73 61 using (var pm = PersistenceManager) { 62 var lifecycleDao = pm.LifecycleDao; 63 pm.UseTransaction(() => { 64 var lifecycle = lifecycleDao.GetLastLifecycle(); 65 if (lifecycle == null 66 || DateTime.Now - lifecycle.LastCleanup > HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval) { 67 lifecycleDao.UpdateLifecycle(); 68 cleanup = true; 69 } 70 pm.SubmitChanges(); 71 }, true); 72 } 74 73 if (cleanup) { 75 eventManager.Cleanup();74 EventManager.Cleanup(); 76 75 } 77 76 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: cleanup finished."); … … 89 88 try { 90 89 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting generate statistics."); 91 statisticsGenerator.GenerateStatistics();90 StatisticsGenerator.GenerateStatistics(); 92 91 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: generate statistics finished."); 93 92 } -
branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs
r12691 r12789 82 82 public IEventManager EventManager { 83 83 get { 84 if (eventManager == null) eventManager = new EventManager();84 if (eventManager == null) eventManager = new NewEventManager(); 85 85 return eventManager; 86 86 }
Note: See TracChangeset
for help on using the changeset viewer.