Changeset 12789


Ignore:
Timestamp:
07/21/15 11:48:49 (6 years ago)
Author:
dglaser
Message:

#2388:

HeuristicLab.Services.Access.DataAccess-3.3:

  • Added a new method to the TaskDao

HeuristicLab.Services.Hive-3.3:

  • Added NewEventManager.cs
  • Updated HiveJanitor.cs
  • Updated ServiceLocator.cs
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  
    2727namespace HeuristicLab.Services.Hive.DataAccess.Daos {
    2828  public class TaskDao : GenericDao<Guid, Task> {
     29    private Table<AssignedResource> AssignedResourceTable {
     30      get { return DataContext.GetTable<AssignedResource>(); }
     31    }
     32
    2933    public TaskDao(DataContext dataContext) : base(dataContext) { }
    3034
     
    5155      //we skip this step because it's wasted runtime
    5256      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();
    5383    }
    5484
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r12768 r12789  
    143143    <Compile Include="HiveStatisticsGenerator.cs" />
    144144    <Compile Include="Interfaces\IStatisticsGenerator.cs" />
     145    <Compile Include="Manager\NewEventManager.cs" />
    145146    <Compile Include="Manager\NewHeartbeatManager.cs" />
    146147    <Compile Include="NewHiveService.cs" />
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs

    r12484 r12789  
    3131    private AutoResetEvent generateStatisticsWaitHandle;
    3232
    33     private ITransactionManager trans {
    34       get { return ServiceLocator.Instance.TransactionManager; }
     33    private IPersistenceManager PersistenceManager {
     34      get { return ServiceLocator.Instance.PersistenceManager; }
    3535    }
    36 
    37     private IEventManager eventManager {
     36    private IEventManager EventManager {
    3837      get { return ServiceLocator.Instance.EventManager; }
    3938    }
    4039
    41     private IStatisticsGenerator statisticsGenerator {
     40    private IStatisticsGenerator StatisticsGenerator {
    4241      get { return ServiceLocator.Instance.StatisticsGenerator; }
    43     }
    44 
    45     private IHiveDao dao {
    46       get { return ServiceLocator.Instance.HiveDao; }
    4742    }
    4843
     
    6459          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting cleanup.");
    6560          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          }
    7473          if (cleanup) {
    75             eventManager.Cleanup();
     74            EventManager.Cleanup();
    7675          }
    7776          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: cleanup finished.");
     
    8988        try {
    9089          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting generate statistics.");
    91           statisticsGenerator.GenerateStatistics();
     90          StatisticsGenerator.GenerateStatistics();
    9291          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: generate statistics finished.");
    9392        }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs

    r12691 r12789  
    8282    public IEventManager EventManager {
    8383      get {
    84         if (eventManager == null) eventManager = new EventManager();
     84        if (eventManager == null) eventManager = new NewEventManager();
    8585        return eventManager;
    8686      }
Note: See TracChangeset for help on using the changeset viewer.