- Timestamp:
- 06/16/11 14:20:48 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs
r6369 r6431 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 9 30 private DataAccess.IHiveDao dao { 10 31 get { return ServiceLocator.Instance.HiveDao; } 11 }12 private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {13 get { return ServiceLocator.Instance.TransactionManager; }14 32 } 15 33 private IAuthorizationManager auth { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLabServicesHivePlugin.cs.frame
r6369 r6431 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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; 2 23 using System.Collections.Generic; 3 24 using System.Linq; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs
r6426 r6431 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 6 27 using HeuristicLab.Services.Hive.Common.DataTransfer; 7 28 using HeuristicLab.Services.Hive.Common.ServiceContracts; 29 using DA = HeuristicLab.Services.Hive.DataAccess; 8 30 9 31 namespace HeuristicLab.Services.Hive { … … 18 40 get { return ServiceLocator.Instance.HiveDao; } 19 41 } 20 private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {21 get { return ServiceLocator.Instance.TransactionManager; }22 }23 42 private IAuthenticationManager authen { 24 43 get { return ServiceLocator.Instance.AuthenticationManager; } … … 37 56 public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) { 38 57 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 39 return trans.UseTransaction(() => {58 return DA.TransactionManager.UseTransaction(() => { 40 59 job.Id = dao.AddJob(job); 41 60 jobData.JobId = job.Id; … … 52 71 public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) { 53 72 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 54 return trans.UseTransaction(() => {73 return DA.TransactionManager.UseTransaction(() => { 55 74 job.ParentJobId = parentJobId; 56 75 return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id)); … … 90 109 public void UpdateJob(Job job) { 91 110 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 92 trans.UseTransaction(() => {111 DA.TransactionManager.UseTransaction(() => { 93 112 dao.UpdateJob(job); 94 113 }); … … 97 116 public void UpdateJobData(Job job, JobData jobData) { 98 117 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 99 // trans.UseTransaction(() => { // cneumuel: try without transaction118 //DA.TransactionManager.UseTransaction(() => { // cneumuel: try without transaction 100 119 jobData.LastUpdate = DateTime.Now; 101 120 dao.UpdateJob(job); … … 106 125 public void DeleteJob(Guid jobId) { 107 126 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 108 trans.UseTransaction(() => {127 DA.TransactionManager.UseTransaction(() => { 109 128 dao.DeleteJob(jobId); 110 129 }); … … 113 132 public void DeleteChildJobs(Guid parentJobId) { 114 133 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 115 trans.UseTransaction(() => {134 DA.TransactionManager.UseTransaction(() => { 116 135 var jobs = GetChildJobs(parentJobId, true, false); 117 136 foreach (var job in jobs) { … … 124 143 public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) { 125 144 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 126 return trans.UseTransaction(() => {145 return DA.TransactionManager.UseTransaction(() => { 127 146 Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception); 128 147 … … 147 166 public void StopJob(Guid jobId) { 148 167 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 149 trans.UseTransaction(() => {168 DA.TransactionManager.UseTransaction(() => { 150 169 var job = dao.GetJob(jobId); 151 170 if (job.State == JobState.Calculating || job.State == JobState.Transferring) { … … 162 181 public void PauseJob(Guid jobId) { 163 182 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 164 trans.UseTransaction(() => {183 DA.TransactionManager.UseTransaction(() => { 165 184 var job = dao.GetJob(jobId); 166 185 if (job.State == JobState.Calculating || job.State == JobState.Transferring) { … … 175 194 public void RestartJob(Guid jobId) { 176 195 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 177 trans.UseTransaction(() => {196 DA.TransactionManager.UseTransaction(() => { 178 197 Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, author.UserId, string.Empty); 179 198 job.Command = null; … … 204 223 public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) { 205 224 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 206 return trans.UseTransaction(() => {225 return DA.TransactionManager.UseTransaction(() => { 207 226 hiveExperimentDto.OwnerUserId = author.UserId; 208 227 hiveExperimentDto.DateCreated = DateTime.Now; … … 213 232 public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) { 214 233 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 215 trans.UseTransaction(() => {234 DA.TransactionManager.UseTransaction(() => { 216 235 dao.UpdateHiveExperiment(hiveExperimentDto); 217 236 }); … … 220 239 public void DeleteHiveExperiment(Guid hiveExperimentId) { 221 240 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 222 trans.UseTransaction(() => {241 DA.TransactionManager.UseTransaction(() => { 223 242 HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId); 224 243 dao.DeleteHiveExperiment(hiveExperimentId); // child jobs will be deleted by db-trigger … … 230 249 public void Hello(Slave slaveInfo) { 231 250 authen.AuthenticateForAnyRole(HiveRoles.Slave); 232 trans.UseTransaction(() => {251 DA.TransactionManager.UseTransaction(() => { 233 252 var slave = dao.GetSlave(slaveInfo.Id); 234 253 … … 261 280 public void GoodBye(Guid slaveId) { 262 281 authen.AuthenticateForAnyRole(HiveRoles.Slave); 263 trans.UseTransaction(() => {282 DA.TransactionManager.UseTransaction(() => { 264 283 var slave = dao.GetSlave(slaveId); 265 284 if (slave != null) { … … 275 294 authen.AuthenticateForAnyRole(HiveRoles.Slave); 276 295 TriggerLifecycle(false); 277 return trans.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));296 return DA.TransactionManager.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat)); 278 297 } 279 298 #endregion … … 282 301 public Guid AddPlugin(Plugin plugin, List<PluginData> pluginDatas) { 283 302 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 284 return trans.UseTransaction(() => {303 return DA.TransactionManager.UseTransaction(() => { 285 304 plugin.UserId = author.UserId; 286 305 plugin.DateCreated = DateTime.Now; … … 315 334 List<PluginData> pluginDatas = new List<PluginData>(); 316 335 317 return trans.UseTransaction(() => {336 return DA.TransactionManager.UseTransaction(() => { 318 337 foreach (Guid guid in pluginIds) { 319 338 pluginDatas.AddRange(dao.GetPluginDatas(x => x.PluginId == guid).ToList()); … … 328 347 public Guid AddSlave(Slave slave) { 329 348 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 330 return trans.UseTransaction(() => dao.AddSlave(slave));349 return DA.TransactionManager.UseTransaction(() => dao.AddSlave(slave)); 331 350 } 332 351 333 352 public Guid AddSlaveGroup(SlaveGroup slaveGroup) { 334 353 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 335 return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));354 return DA.TransactionManager.UseTransaction(() => dao.AddSlaveGroup(slaveGroup)); 336 355 } 337 356 … … 358 377 public void UpdateSlave(Slave slave) { 359 378 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 360 trans.UseTransaction(() => {379 DA.TransactionManager.UseTransaction(() => { 361 380 dao.UpdateSlave(slave); 362 381 }); … … 365 384 public void UpdateSlaveGroup(SlaveGroup slaveGroup) { 366 385 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 367 trans.UseTransaction(() => {386 DA.TransactionManager.UseTransaction(() => { 368 387 dao.UpdateSlaveGroup(slaveGroup); 369 388 }); … … 372 391 public void DeleteSlave(Guid slaveId) { 373 392 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 374 trans.UseTransaction(() => {393 DA.TransactionManager.UseTransaction(() => { 375 394 dao.DeleteSlave(slaveId); 376 395 }); … … 379 398 public void DeleteSlaveGroup(Guid slaveGroupId) { 380 399 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 381 trans.UseTransaction(() => {400 DA.TransactionManager.UseTransaction(() => { 382 401 dao.DeleteSlaveGroup(slaveGroupId); 383 402 }); … … 386 405 public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) { 387 406 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 388 trans.UseTransaction(() => {407 DA.TransactionManager.UseTransaction(() => { 389 408 var resource = dao.GetResource(resourceId); 390 409 resource.ParentResourceId = slaveGroupId; … … 395 414 public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) { 396 415 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 397 trans.UseTransaction(() => {416 DA.TransactionManager.UseTransaction(() => { 398 417 var resource = dao.GetResource(resourceId); 399 418 resource.ParentResourceId = null; … … 404 423 public Guid GetResourceId(string resourceName) { 405 424 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 406 return trans.UseTransaction(() => {425 return DA.TransactionManager.UseTransaction(() => { 407 426 var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault(); 408 427 if (resource != null) { … … 416 435 public void TriggerLifecycle(bool force) { 417 436 // use a serializable transaction here to ensure not two threads execute this simultaniously (mutex-lock would not work since IIS may use multiple AppDomains) 418 trans.UseTransaction(() => {437 DA.TransactionManager.UseTransaction(() => { 419 438 DateTime lastCleanup = dao.GetLastCleanup(); 420 439 if (force || DateTime.Now - lastCleanup > TimeSpan.FromSeconds(59)) { … … 446 465 public Guid AddAppointment(Appointment appointment) { 447 466 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 448 return trans.UseTransaction(() => dao.AddAppointment(appointment));467 return DA.TransactionManager.UseTransaction(() => dao.AddAppointment(appointment)); 449 468 } 450 469 451 470 public void DeleteAppointment(Guid appointmentId) { 452 471 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 453 trans.UseTransaction(() => {472 DA.TransactionManager.UseTransaction(() => { 454 473 dao.DeleteAppointment(appointmentId); 455 474 }); … … 458 477 public void UpdateAppointment(Appointment appointment) { 459 478 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 460 trans.UseTransaction(() => {479 DA.TransactionManager.UseTransaction(() => { 461 480 dao.UpdateAppointment(appointment); 462 481 }); … … 465 484 public IEnumerable<Appointment> GetScheduleForResource(Guid resourceId) { 466 485 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 467 return trans.UseTransaction(() => dao.GetAppointments(x => x.ResourceId == resourceId));486 return DA.TransactionManager.UseTransaction(() => dao.GetAppointments(x => x.ResourceId == resourceId)); 468 487 } 469 488 470 489 public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) { 471 490 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 472 return trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));491 return DA.TransactionManager.UseTransaction(() => dao.GetJobsByResourceId(resourceId)); 473 492 } 474 493 #endregion -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IServiceLocator.cs
r6369 r6431 28 28 IHiveDao HiveDao { get; } 29 29 ILifecycleManager LifecycleManager { get; } 30 TransactionManager TransactionManager { get; }31 30 HeartbeatManager HeartbeatManager { get; } 32 31 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs
r6367 r6431 33 33 private DataAccess.IHiveDao dao { 34 34 get { return ServiceLocator.Instance.HiveDao; } 35 }36 private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {37 get { return ServiceLocator.Instance.TransactionManager; }38 35 } 39 36 private IAuthorizationManager auth { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Properties/AssemblyInfo.cs.frame
r6372 r6431 7 7 // associated with an assembly. 8 8 [assembly: AssemblyTitle("HeuristicLab.Services.Hive")] 9 [assembly: AssemblyDescription(" ")]9 [assembly: AssemblyDescription("Business logic for HeuristicLab.Hive services")] 10 10 [assembly: AssemblyConfiguration("")] 11 11 [assembly: AssemblyCompany("")] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/ServiceLocator.cs
r6362 r6431 1 using HeuristicLab.Services.Hive.DataAccess; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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 HeuristicLab.Services.Hive.DataAccess; 2 23 3 24 namespace HeuristicLab.Services.Hive { … … 18 39 if (hiveDao == null) hiveDao = new HiveDao(); 19 40 return hiveDao; 20 }21 }22 23 private TransactionManager transactionManager;24 public TransactionManager TransactionManager {25 get {26 if (transactionManager == null) transactionManager = new TransactionManager();27 return transactionManager;28 41 } 29 42 }
Note: See TracChangeset
for help on using the changeset viewer.