Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9022


Ignore:
Timestamp:
12/11/12 15:07:54 (12 years ago)
Author:
ascheibe
Message:

#1994 added a dao method which loads lightweight tasks instead of tasks. Therefore the task datas are not loaded which reduces memory consumption and improves performance when

  • downloading tasks
  • refresh automatically is checked in the Hive Job Manager
  • loading the Hive Status page.

The Hive Status page now shows which users are currently calculating how many tasks.

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx

    r7047 r9022  
    2929    Slaves (CPU Utilization):
    3030    <asp:Label ID="slavesLabel" runat="server" />
     31      <br />
     32      <br />
     33      Number of calculating tasks by user:<asp:Table ID="calculatingTasksByUserTable" runat="server" GridLines="Both">
     34          <asp:TableRow runat="server">
     35              <asp:TableCell runat="server" Font-Bold="False">User</asp:TableCell>
     36              <asp:TableCell runat="server" Font-Bold="False">Nr. of tasks</asp:TableCell>
     37          </asp:TableRow>
     38      </asp:Table>
     39      <br />
     40      Number of waiting tasks by user:<asp:Table ID="waitingTasksByUserTable" runat="server" GridLines="Both">
     41          <asp:TableRow runat="server">
     42              <asp:TableCell runat="server" Font-Bold="False">User</asp:TableCell>
     43              <asp:TableCell runat="server" Font-Bold="False">Nr. of tasks</asp:TableCell>
     44          </asp:TableRow>
     45      </asp:Table>
    3146      <br />
    3247    <br />
     
    121136      </ChartAreas>
    122137    </asp:Chart>
    123     <br />
    124138      <br />
    125139  </div>
  • trunk/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx.cs

    r7259 r9022  
    4242    IEnumerable<DT.Slave> onlineSlaves = new List<DT.Slave>();
    4343    int currentlyJobsWaiting = 0;
     44    Dictionary<Guid, int> calculatingTasksByUser = new Dictionary<Guid,int>();
     45    Dictionary<Guid, int> waitingTasksByUser = new Dictionary<Guid, int>();
    4446
    4547    if (!string.IsNullOrEmpty(resourceName)) {
     
    5860    transactionManager.UseTransaction(() =>
    5961    {                     
    60         onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId));
    61         currentlyJobsWaiting = dao.GetTasks(x => x.State == DA.TaskState.Waiting).Count();
     62        onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId));       
     63        currentlyJobsWaiting = dao.GetLightweightTasks(x => x.State == DA.TaskState.Waiting).Count();
     64        calculatingTasksByUser = dao.GetCalculatingTasksByUser();
     65        waitingTasksByUser = dao.GetWaitingTasksByUser();
    6266    }, false, false);
    6367
     
    101105      memoryChart.Series[1].Points.AddXY(s.TimeStamp.ToOADate(), usedMemory / 1024.0);
    102106    }
     107
     108    foreach (var kvp in waitingTasksByUser) {
     109      TableRow curRow = new TableRow();
     110      TableCell cellUser = new TableCell();
     111      cellUser.Text = ServiceLocator.Instance.UserManager.GetUserById(kvp.Key).UserName;
     112      TableCell cellCnt = new TableCell();
     113      cellCnt.Text = kvp.Value.ToString();
     114
     115      curRow.Cells.Add(cellUser);
     116      curRow.Cells.Add(cellCnt);
     117      waitingTasksByUserTable.Rows.Add(curRow);
     118    }
     119
     120    foreach (var kvp in calculatingTasksByUser) {
     121      TableRow curRow = new TableRow();
     122      TableCell cellUser = new TableCell();
     123      cellUser.Text = ServiceLocator.Instance.UserManager.GetUserById(kvp.Key).UserName;
     124      TableCell cellCnt = new TableCell();
     125      cellCnt.Text = kvp.Value.ToString();
     126
     127      curRow.Cells.Add(cellUser);
     128      curRow.Cells.Add(cellCnt);
     129      calculatingTasksByUserTable.Rows.Add(curRow);
     130    }
    103131  }
    104132}
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r7916 r9022  
    4949    }
    5050
     51    public IEnumerable<DT.LightweightTask> GetLightweightTasksForJob(Guid jobId) {
     52      List<DT.LightweightTask> tasks = new List<DT.LightweightTask>();
     53
     54      using (var db = CreateContext()) {
     55        var tasksQuery = from task in db.Tasks
     56                         where task.JobId == jobId
     57                         select new { task.TaskId, task.ExecutionTimeMs, task.ParentTaskId, task.StateLogs, task.State, task.Command };
     58
     59        var taskDatasQuery = from task in db.Tasks
     60                             where task.JobId == jobId && task.JobData != null
     61                             select new { task.TaskId, task.JobData.LastUpdate };
     62
     63        foreach (var task in tasksQuery) {
     64          DT.LightweightTask t = new DT.LightweightTask();
     65          t.Id = task.TaskId;
     66          t.ExecutionTime = TimeSpan.FromMilliseconds(task.ExecutionTimeMs);
     67          t.ParentTaskId = task.ParentTaskId;
     68          t.StateLog = task.StateLogs == null ? new List<DT.StateLog>() : task.StateLogs.Select(x => DataTransfer.Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList();
     69          t.State = DataTransfer.Convert.ToDto(task.State);
     70          t.Command = DataTransfer.Convert.ToDto(task.Command);
     71          t.LastTaskDataUpdate = taskDatasQuery.Where(x => x.TaskId == task.TaskId).Count() > 0 ? taskDatasQuery.Select(x => x.LastUpdate).First() : DateTime.MinValue;
     72          tasks.Add(t);
     73        }
     74      }
     75      return tasks;
     76    }
     77
     78    public IEnumerable<DT.LightweightTask> GetLightweightTasks(Expression<Func<Task, bool>> predicate) {
     79      List<DT.LightweightTask> tasks = new List<DT.LightweightTask>();
     80
     81      using (var db = CreateContext()) {
     82        var tasksQuery = db.Tasks.Where(predicate).Select(task => new { task.TaskId, task.ExecutionTimeMs, task.ParentTaskId, task.StateLogs, task.State, task.Command });
     83        var taskDatasQuery = db.Tasks.Where(predicate).Where(task => task.JobData != null).Select(task => new { task.TaskId, task.JobData.LastUpdate });
     84
     85        foreach (var task in tasksQuery) {
     86          DT.LightweightTask t = new DT.LightweightTask();
     87          t.Id = task.TaskId;
     88          t.ExecutionTime = TimeSpan.FromMilliseconds(task.ExecutionTimeMs);
     89          t.ParentTaskId = task.ParentTaskId;
     90          t.StateLog = task.StateLogs == null ? new List<DT.StateLog>() : task.StateLogs.Select(x => DataTransfer.Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList();
     91          t.State = DataTransfer.Convert.ToDto(task.State);
     92          t.Command = DataTransfer.Convert.ToDto(task.Command);
     93          t.LastTaskDataUpdate = taskDatasQuery.Where(x => x.TaskId == task.TaskId).Count() > 0 ? taskDatasQuery.Select(x => x.LastUpdate).First() : DateTime.MinValue;
     94          tasks.Add(t);
     95        }
     96      }
     97      return tasks;
     98    }
     99
    51100    public Guid AddTask(DT.Task dto) {
    52101      using (var db = CreateContext()) {
     
    780829    }
    781830
     831    public Dictionary<Guid, int> GetWaitingTasksByUser() {
     832      using (var db = CreateContext()) {
     833        var waitingTasksByUser = from task in db.Tasks
     834                                 where task.State == TaskState.Waiting
     835                                 group task by task.Job.OwnerUserId into g
     836                                 select new { UserId = g.Key, UsedCores = g.Count() };
     837        return waitingTasksByUser.ToDictionary(x => x.UserId, x => x.UsedCores);
     838      }
     839    }
     840
     841    public Dictionary<Guid, int> GetCalculatingTasksByUser() {
     842      using (var db = CreateContext()) {
     843        var calculatingTasksByUser = from task in db.Tasks
     844                              where task.State == TaskState.Calculating
     845                              group task by task.Job.OwnerUserId into g
     846                              select new { UserId = g.Key, UsedCores = g.Count() };
     847        return calculatingTasksByUser.ToDictionary(x => x.UserId, x => x.UsedCores);
     848      }
     849    }
     850
    782851    public List<DT.UserStatistics> GetUserStatistics() {
    783852      using (var db = CreateContext()) {
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r8071 r9022  
    128128
    129129      return trans.UseTransaction(() => {
    130         return dao.GetTasks(x => x.JobId == jobId).Select(x => new LightweightTask(x)).ToArray();
     130        return dao.GetLightweightTasksForJob(jobId).ToArray();
    131131      }, false, false);
    132132    }
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r7916 r9022  
    3131    DT.Task GetTask(Guid id);
    3232    IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate);
     33    IEnumerable<DT.LightweightTask> GetLightweightTasksForJob(Guid jobId);
     34    IEnumerable<DT.LightweightTask> GetLightweightTasks(Expression<Func<Task, bool>> predicate);
    3335    Guid AddTask(DT.Task dto);
    3436    void UpdateTask(DT.Task dto);
     
    145147
    146148    #region Statistics Methods
     149    Dictionary<Guid, int> GetWaitingTasksByUser();
     150    Dictionary<Guid, int> GetCalculatingTasksByUser();
    147151    DT.Statistics GetStatistic(Guid id);
    148152    IEnumerable<DT.Statistics> GetStatistics(Expression<Func<Statistics, bool>> predicate);
Note: See TracChangeset for help on using the changeset viewer.