Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2522_RefactorPluginInfrastructure/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/SpaceUsageController.cs @ 18242

Last change on this file since 18242 was 15973, checked in by gkronber, 6 years ago

#2522: merged trunk changes from r13402:15972 to branch resolving conflicts where necessary

File size: 3.1 KB
RevLine 
[12761]1#region License Information
2/* HeuristicLab
[15973]3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[12761]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      };
[12858]53      var pm = PersistenceManager;
54      return pm.UseTransaction(() => (
[12761]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    public IEnumerable<TableInformation> GetStatisticsTableInformation() {
64      var tables = new List<string> {
65        "statistics.DimClient",
66        "statistics.DimJob",
67        "statistics.DimTime",
68        "statistics.DimUser",
69        "statistics.FactClientInfo",
70        "statistics.FactTask"
71      };
[12858]72      var pm = PersistenceManager;
73      return pm.UseTransaction(() => (
[12761]74          from table in tables
75          select pm.GetTableInformation(table) into tableInformation
76          where tableInformation != null
77          select Convert(tableInformation)
78          ).ToList()
79        );
80    }
81
82    private TableInformation Convert(DA.TableInformation tableInformation) {
83      return new TableInformation {
84        Name = tableInformation.Name,
85        Rows = tableInformation.Rows,
86        Reserved = tableInformation.Reserved,
87        Data = tableInformation.Data,
88        IndexSize = tableInformation.IndexSize,
89        Unused = tableInformation.Unused
90      };
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.