1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2018 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 |
|
---|
22 | using System.Collections.Generic;
|
---|
23 | using System.Linq;
|
---|
24 | using System.Web.Http;
|
---|
25 | using HeuristicLab.Services.Hive;
|
---|
26 | using HeuristicLab.Services.Hive.DataAccess.Interfaces;
|
---|
27 | using HeuristicLab.Services.WebApp.Maintenance.WebApi.DataTransfer;
|
---|
28 | using DA = HeuristicLab.Services.Hive.DataAccess.Data;
|
---|
29 |
|
---|
30 | namespace 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 | "AssignedJobResource",
|
---|
39 | "AssignedProjectResource",
|
---|
40 | "Downtime",
|
---|
41 | "Job",
|
---|
42 | "JobPermission",
|
---|
43 | "Lifecycle",
|
---|
44 | "Plugin",
|
---|
45 | "PluginData",
|
---|
46 | "Project",
|
---|
47 | "ProjectPermission",
|
---|
48 | "RequiredPlugins",
|
---|
49 | "Resource",
|
---|
50 | "StateLog",
|
---|
51 | "Task",
|
---|
52 | "TaskData",
|
---|
53 | "UserPriority"
|
---|
54 | };
|
---|
55 | var pm = PersistenceManager;
|
---|
56 | return pm.UseTransaction(() => (
|
---|
57 | from table in tables
|
---|
58 | select pm.GetTableInformation(table) into tableInformation
|
---|
59 | where tableInformation != null
|
---|
60 | select Convert(tableInformation)
|
---|
61 | ).ToList()
|
---|
62 | );
|
---|
63 | }
|
---|
64 |
|
---|
65 | public IEnumerable<TableInformation> GetStatisticsTableInformation() {
|
---|
66 | var tables = new List<string> {
|
---|
67 | "statistics.DimClient",
|
---|
68 | "statistics.DimJob",
|
---|
69 | "statistics.DimProject",
|
---|
70 | "statistics.DimTime",
|
---|
71 | "statistics.DimUser",
|
---|
72 | "statistics.FactClientInfo",
|
---|
73 | "statistics.FactProjectInfo",
|
---|
74 | "statistics.FactTask"
|
---|
75 | };
|
---|
76 | var pm = PersistenceManager;
|
---|
77 | return pm.UseTransaction(() => (
|
---|
78 | from table in tables
|
---|
79 | select pm.GetTableInformation(table) into tableInformation
|
---|
80 | where tableInformation != null
|
---|
81 | select Convert(tableInformation)
|
---|
82 | ).ToList()
|
---|
83 | );
|
---|
84 | }
|
---|
85 |
|
---|
86 | private TableInformation Convert(DA.TableInformation tableInformation) {
|
---|
87 | return new TableInformation {
|
---|
88 | Name = tableInformation.Name,
|
---|
89 | Rows = tableInformation.Rows,
|
---|
90 | Reserved = tableInformation.Reserved,
|
---|
91 | Data = tableInformation.Data,
|
---|
92 | IndexSize = tableInformation.IndexSize,
|
---|
93 | Unused = tableInformation.Unused
|
---|
94 | };
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|