1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 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;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Security.Permissions;
|
---|
25 | using HeuristicLab.Hive.Contracts;
|
---|
26 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
27 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
28 | using HeuristicLab.Hive.Contracts.ResponseObjects;
|
---|
29 | using HeuristicLab.Hive.Server.DataAccess;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Hive.Server.Core {
|
---|
32 | public class ServerConsoleFacade : IServerConsoleFacade {
|
---|
33 | private ISlaveManager slaveManager = ServiceLocator.GetSlaveManager();
|
---|
34 |
|
---|
35 | private IJobManager jobManager = ServiceLocator.GetJobManager();
|
---|
36 |
|
---|
37 | private IContextFactory contextFactory = ServiceLocator.GetContextFactory();
|
---|
38 |
|
---|
39 | public Guid sessionID = Guid.Empty;
|
---|
40 |
|
---|
41 | public ServerConsoleFacade() {
|
---|
42 | }
|
---|
43 |
|
---|
44 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
45 | public Response Login() {
|
---|
46 | Response resp = new Response();
|
---|
47 | return resp;
|
---|
48 | }
|
---|
49 |
|
---|
50 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
51 | public ResponseList<SlaveDto> GetAllSlaves() {
|
---|
52 | using (contextFactory.GetContext(false)) {
|
---|
53 | return slaveManager.GetAllSlaves();
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
58 | public ResponseList<SlaveGroupDto> GetAllSlaveGroups() {
|
---|
59 | using (contextFactory.GetContext(false)) {
|
---|
60 | return slaveManager.GetAllSlaveGroups();
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
65 | public ResponseList<UpTimeStatisticsDto> GetAllUpTimeStatistics() {
|
---|
66 | using (contextFactory.GetContext(false)) {
|
---|
67 | return slaveManager.GetAllUpTimeStatistics();
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
72 | public ResponseObject<SlaveGroupDto> AddSlaveGroup(SlaveGroupDto slaveGroup) {
|
---|
73 | using (contextFactory.GetContext()) {
|
---|
74 | return slaveManager.AddSlaveGroup(slaveGroup);
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
79 | public Response AddResourceToGroup(Guid slaveGroupId, ResourceDto resource) {
|
---|
80 | using (contextFactory.GetContext()) {
|
---|
81 | return slaveManager.AddResourceToGroup(slaveGroupId, resource);
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
86 | public Response DeleteResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
|
---|
87 | using (contextFactory.GetContext()) {
|
---|
88 | return slaveManager.DeleteResourceFromGroup(slaveGroupId, resourceId);
|
---|
89 | }
|
---|
90 | }
|
---|
91 |
|
---|
92 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
93 | public ResponseList<JobDto> GetAllJobs() {
|
---|
94 | using (contextFactory.GetContext(false)) {
|
---|
95 | return jobManager.GetAllJobs();
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
100 | public ResponseList<JobDto> GetAllJobsWithFilter(JobState jobState, int offset, int count) {
|
---|
101 | using (contextFactory.GetContext(false)) {
|
---|
102 | return jobManager.GetAllJobsWithFilter(jobState, offset, count);
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
107 | public ResponseObject<JobDto> GetJobById(Guid jobId) {
|
---|
108 | using (contextFactory.GetContext(false)) {
|
---|
109 | return jobManager.GetJobById(jobId);
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
114 | public ResponseObject<JobDto> GetJobByIdWithDetails(Guid jobId) {
|
---|
115 | using (contextFactory.GetContext(false)) {
|
---|
116 | return jobManager.GetJobByIdWithDetails(jobId);
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|
120 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
121 | public ResponseObject<JobDto> AddNewJob(SerializedJob job) {
|
---|
122 | using (contextFactory.GetContext()) {
|
---|
123 | return jobManager.AddNewJob(job);
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
128 | public ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId) {
|
---|
129 | using (contextFactory.GetContext(false)) {
|
---|
130 | return jobManager.GetLastSerializedResult(jobId);
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
135 | public ResponseObject<SerializedJob> GetSnapshotResult(Guid jobId) {
|
---|
136 | using (contextFactory.GetContext(false)) {
|
---|
137 | return jobManager.GetSnapshotResult(jobId);
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
142 | public ResponseObject<JobResultList> GetJobResults(IEnumerable<Guid> jobIds) {
|
---|
143 | using (contextFactory.GetContext(false)) {
|
---|
144 | return jobManager.GetJobResults(jobIds);
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
149 | public Response RequestSnapshot(Guid jobId) {
|
---|
150 | using (contextFactory.GetContext()) {
|
---|
151 | return jobManager.RequestSnapshot(jobId);
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
156 | public Response AbortJob(Guid jobId) {
|
---|
157 | using (contextFactory.GetContext()) {
|
---|
158 | return jobManager.AbortJob(jobId);
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
163 | public ResponseObject<SlaveGroupDtoList> GetAllGroupsOfResource(Guid resourceId) {
|
---|
164 | using (contextFactory.GetContext(false)) {
|
---|
165 | return slaveManager.GetAllGroupsOfResource(resourceId);
|
---|
166 | }
|
---|
167 | }
|
---|
168 |
|
---|
169 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
170 | public Response DeleteSlaveGroup(Guid slaveGroupId) {
|
---|
171 | using (contextFactory.GetContext()) {
|
---|
172 | return slaveManager.DeleteSlaveGroup(slaveGroupId);
|
---|
173 | }
|
---|
174 | }
|
---|
175 |
|
---|
176 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
177 | public ResponseList<ProjectDto> GetAllProjects() {
|
---|
178 | using (contextFactory.GetContext(false)) {
|
---|
179 | return jobManager.GetAllProjects();
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
184 | public Response CreateProject(ProjectDto project) {
|
---|
185 | using (contextFactory.GetContext()) {
|
---|
186 | return jobManager.CreateProject(project);
|
---|
187 | }
|
---|
188 | }
|
---|
189 |
|
---|
190 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
191 | public Response ChangeProject(ProjectDto project) {
|
---|
192 | using (contextFactory.GetContext()) {
|
---|
193 | return jobManager.ChangeProject(project);
|
---|
194 | }
|
---|
195 | }
|
---|
196 |
|
---|
197 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
198 | public Response DeleteProject(Guid projectId) {
|
---|
199 | using (contextFactory.GetContext()) {
|
---|
200 | return jobManager.DeleteProject(projectId);
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
205 | public ResponseList<JobDto> GetJobsByProject(Guid projectId) {
|
---|
206 | using (contextFactory.GetContext(false)) {
|
---|
207 | return jobManager.GetJobsByProject(projectId);
|
---|
208 | }
|
---|
209 | }
|
---|
210 |
|
---|
211 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
212 | public ResponseList<AppointmentDto> GetUptimeCalendarForResource(Guid guid) {
|
---|
213 | using (contextFactory.GetContext(false)) {
|
---|
214 | return slaveManager.GetUptimeCalendarForResource(guid);
|
---|
215 | }
|
---|
216 | }
|
---|
217 |
|
---|
218 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
219 | public Response SetUptimeCalendarForResource(Guid guid, IEnumerable<AppointmentDto> appointments, bool isForced) {
|
---|
220 | using (contextFactory.GetContext()) {
|
---|
221 | return slaveManager.SetUptimeCalendarForResource(guid, appointments, isForced);
|
---|
222 | }
|
---|
223 | }
|
---|
224 |
|
---|
225 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
226 | public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {
|
---|
227 | using (contextFactory.GetContext()) {
|
---|
228 | return jobManager.AddJobWithGroupStrings(job, resources);
|
---|
229 | }
|
---|
230 | }
|
---|
231 |
|
---|
232 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
233 | public ResponseObject<JobResultList> GetChildJobResults(Guid? parentJobId, bool recursive, bool includeParent) {
|
---|
234 | using (contextFactory.GetContext(false)) {
|
---|
235 | return jobManager.GetChildJobResults(parentJobId, recursive, includeParent);
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
240 | public ResponseObject<JobDto> AddChildJob(Guid parentJobId, SerializedJob serializedJob) {
|
---|
241 | using (contextFactory.GetContext()) {
|
---|
242 | return jobManager.AddChildJob(parentJobId, serializedJob);
|
---|
243 | }
|
---|
244 | }
|
---|
245 |
|
---|
246 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
247 | public ResponseObject<JobDto> PauseJob(SerializedJob serializedJob) {
|
---|
248 | using (contextFactory.GetContext()) {
|
---|
249 | return jobManager.PauseJob(serializedJob);
|
---|
250 | }
|
---|
251 | }
|
---|
252 |
|
---|
253 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
254 | public ResponseObject<HiveExperimentDtoList> GetHiveExperiments() {
|
---|
255 | using (contextFactory.GetContext(false)) {
|
---|
256 | return jobManager.GetHiveExperiments();
|
---|
257 | }
|
---|
258 | }
|
---|
259 |
|
---|
260 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
261 | public ResponseObject<HiveExperimentDto> UpdateHiveExperiment(HiveExperimentDto hiveExperimentDto) {
|
---|
262 | using (contextFactory.GetContext()) {
|
---|
263 | return jobManager.UpdateHiveExperiment(hiveExperimentDto);
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
268 | public Response DeleteHiveExperiment(Guid hiveExperimentId) {
|
---|
269 | using (contextFactory.GetContext()) {
|
---|
270 | return jobManager.DeleteHiveExperiment(hiveExperimentId);
|
---|
271 | }
|
---|
272 | }
|
---|
273 |
|
---|
274 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
275 | public Response DeleteChildJobs(Guid jobId) {
|
---|
276 | using (contextFactory.GetContext()) {
|
---|
277 | return jobManager.DeleteChildJobs(jobId);
|
---|
278 | }
|
---|
279 | }
|
---|
280 |
|
---|
281 | [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
282 | public Response DeleteJob(Guid jobId) {
|
---|
283 | using (contextFactory.GetContext()) {
|
---|
284 | return jobManager.DeleteJob(jobId);
|
---|
285 | }
|
---|
286 | }
|
---|
287 | }
|
---|
288 | }
|
---|