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