Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/SpaceUsageController.cs @ 12761

Last change on this file since 12761 was 12761, checked in by dglaser, 9 years ago

#2429: Worked on the maintenance WebApp plugin:

  • Space Usage Page: Displays the number of rows and allocated disk space for every database table
  • Plugin Page: Shows unused plugins and provides functionality to delete all and specific plugins
  • FactTask Page: Allows to aggregate all Job Tasks to a single task for a given job or jobs within an selected time period
  • FactClientInfo Page: Allows to aggregate consecutive FactClientInfo entries with the same state and isallowedtocalculate flag
File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Collections.Generic;
23using System.Linq;
24using System.Web.Http;
25using HeuristicLab.Services.Hive;
26using HeuristicLab.Services.Hive.DataAccess.Interfaces;
27using HeuristicLab.Services.WebApp.Maintenance.WebApi.DataTransfer;
28using DA = HeuristicLab.Services.Hive.DataAccess.Data;
29
30namespace HeuristicLab.Services.WebApp.Maintenance.WebApi {
31  public class SpaceUsageController : ApiController {
32    private IPersistenceManager PersistenceManager {
33      get { return ServiceLocator.Instance.PersistenceManager; }
34    }
35
36    public IEnumerable<TableInformation> GetHiveTableInformation() {
37      var tables = new List<string> {
38        "AssignedResources",
39        "Downtime",
40        "Job",
41        "JobPermission",
42        "Lifecycle",
43        "Plugin",
44        "PluginData",
45        "RequiredPlugins",
46        "Resource",
47        "ResourcePermission",
48        "StateLog",
49        "Task",
50        "TaskData",
51        "UserPriority"
52      };
53      using (var pm = PersistenceManager) {
54        return pm.UseTransaction(() => (
55          from table in tables
56          select pm.GetTableInformation(table) into tableInformation
57          where tableInformation != null
58          select Convert(tableInformation)
59          ).ToList()
60        );
61      }
62    }
63
64    public IEnumerable<TableInformation> GetStatisticsTableInformation() {
65      var tables = new List<string> {
66        "statistics.DimClient",
67        "statistics.DimJob",
68        "statistics.DimTime",
69        "statistics.DimUser",
70        "statistics.FactClientInfo",
71        "statistics.FactTask"
72      };
73      using (var pm = PersistenceManager) {
74        return pm.UseTransaction(() => (
75          from table in tables
76          select pm.GetTableInformation(table) into tableInformation
77          where tableInformation != null
78          select Convert(tableInformation)
79          ).ToList()
80        );
81      }
82    }
83
84    private TableInformation Convert(DA.TableInformation tableInformation) {
85      return new TableInformation {
86        Name = tableInformation.Name,
87        Rows = tableInformation.Rows,
88        Reserved = tableInformation.Reserved,
89        Data = tableInformation.Data,
90        IndexSize = tableInformation.IndexSize,
91        Unused = tableInformation.Unused
92      };
93    }
94  }
95}
Note: See TracBrowser for help on using the repository browser.