Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/16/11 14:20:48 (13 years ago)
Author:
cneumuel
Message:

#1233

  • changed Log to ThreadSafeLog
  • added license information to all files
  • added assembly descriptions
  • using blocks before namespace
  • made TransactionManager static
  • removed DaoException
  • removed TimeSpanExtensions
  • renamed prepareHiveDatabase.sql should be renamed to Prepare Hive Database.sql
  • created Initialize Hive Database.sql
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
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    930    private DataAccess.IHiveDao dao {
    1031      get { return ServiceLocator.Instance.HiveDao; }
    11     }
    12     private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {
    13       get { return ServiceLocator.Instance.TransactionManager; }
    1432    }
    1533    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
     22using System;
    223using System.Collections.Generic;
    324using 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
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    627using HeuristicLab.Services.Hive.Common.DataTransfer;
    728using HeuristicLab.Services.Hive.Common.ServiceContracts;
     29using DA = HeuristicLab.Services.Hive.DataAccess;
    830
    931namespace HeuristicLab.Services.Hive {
     
    1840      get { return ServiceLocator.Instance.HiveDao; }
    1941    }
    20     private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {
    21       get { return ServiceLocator.Instance.TransactionManager; }
    22     }
    2342    private IAuthenticationManager authen {
    2443      get { return ServiceLocator.Instance.AuthenticationManager; }
     
    3756    public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
    3857      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    39       return trans.UseTransaction(() => {
     58      return DA.TransactionManager.UseTransaction(() => {
    4059        job.Id = dao.AddJob(job);
    4160        jobData.JobId = job.Id;
     
    5271    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
    5372      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    54       return trans.UseTransaction(() => {
     73      return DA.TransactionManager.UseTransaction(() => {
    5574        job.ParentJobId = parentJobId;
    5675        return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
     
    90109    public void UpdateJob(Job job) {
    91110      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    92       trans.UseTransaction(() => {
     111      DA.TransactionManager.UseTransaction(() => {
    93112        dao.UpdateJob(job);
    94113      });
     
    97116    public void UpdateJobData(Job job, JobData jobData) {
    98117      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    99       //trans.UseTransaction(() => { // cneumuel: try without transaction
     118      //DA.TransactionManager.UseTransaction(() => { // cneumuel: try without transaction
    100119      jobData.LastUpdate = DateTime.Now;
    101120      dao.UpdateJob(job);
     
    106125    public void DeleteJob(Guid jobId) {
    107126      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    108       trans.UseTransaction(() => {
     127      DA.TransactionManager.UseTransaction(() => {
    109128        dao.DeleteJob(jobId);
    110129      });
     
    113132    public void DeleteChildJobs(Guid parentJobId) {
    114133      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    115       trans.UseTransaction(() => {
     134      DA.TransactionManager.UseTransaction(() => {
    116135        var jobs = GetChildJobs(parentJobId, true, false);
    117136        foreach (var job in jobs) {
     
    124143    public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
    125144      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    126       return trans.UseTransaction(() => {
     145      return DA.TransactionManager.UseTransaction(() => {
    127146        Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
    128147
     
    147166    public void StopJob(Guid jobId) {
    148167      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    149       trans.UseTransaction(() => {
     168      DA.TransactionManager.UseTransaction(() => {
    150169        var job = dao.GetJob(jobId);
    151170        if (job.State == JobState.Calculating || job.State == JobState.Transferring) {
     
    162181    public void PauseJob(Guid jobId) {
    163182      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    164       trans.UseTransaction(() => {
     183      DA.TransactionManager.UseTransaction(() => {
    165184        var job = dao.GetJob(jobId);
    166185        if (job.State == JobState.Calculating || job.State == JobState.Transferring) {
     
    175194    public void RestartJob(Guid jobId) {
    176195      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    177       trans.UseTransaction(() => {
     196      DA.TransactionManager.UseTransaction(() => {
    178197        Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, author.UserId, string.Empty);
    179198        job.Command = null;
     
    204223    public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) {
    205224      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    206       return trans.UseTransaction(() => {
     225      return DA.TransactionManager.UseTransaction(() => {
    207226        hiveExperimentDto.OwnerUserId = author.UserId;
    208227        hiveExperimentDto.DateCreated = DateTime.Now;
     
    213232    public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) {
    214233      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    215       trans.UseTransaction(() => {
     234      DA.TransactionManager.UseTransaction(() => {
    216235        dao.UpdateHiveExperiment(hiveExperimentDto);
    217236      });
     
    220239    public void DeleteHiveExperiment(Guid hiveExperimentId) {
    221240      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    222       trans.UseTransaction(() => {
     241      DA.TransactionManager.UseTransaction(() => {
    223242        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
    224243        dao.DeleteHiveExperiment(hiveExperimentId); // child jobs will be deleted by db-trigger
     
    230249    public void Hello(Slave slaveInfo) {
    231250      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    232       trans.UseTransaction(() => {
     251      DA.TransactionManager.UseTransaction(() => {
    233252        var slave = dao.GetSlave(slaveInfo.Id);
    234253
     
    261280    public void GoodBye(Guid slaveId) {
    262281      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    263       trans.UseTransaction(() => {
     282      DA.TransactionManager.UseTransaction(() => {
    264283        var slave = dao.GetSlave(slaveId);
    265284        if (slave != null) {
     
    275294      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    276295      TriggerLifecycle(false);
    277       return trans.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));
     296      return DA.TransactionManager.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));
    278297    }
    279298    #endregion
     
    282301    public Guid AddPlugin(Plugin plugin, List<PluginData> pluginDatas) {
    283302      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    284       return trans.UseTransaction(() => {
     303      return DA.TransactionManager.UseTransaction(() => {
    285304        plugin.UserId = author.UserId;
    286305        plugin.DateCreated = DateTime.Now;
     
    315334      List<PluginData> pluginDatas = new List<PluginData>();
    316335
    317       return trans.UseTransaction(() => {
     336      return DA.TransactionManager.UseTransaction(() => {
    318337        foreach (Guid guid in pluginIds) {
    319338          pluginDatas.AddRange(dao.GetPluginDatas(x => x.PluginId == guid).ToList());
     
    328347    public Guid AddSlave(Slave slave) {
    329348      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    330       return trans.UseTransaction(() => dao.AddSlave(slave));
     349      return DA.TransactionManager.UseTransaction(() => dao.AddSlave(slave));
    331350    }
    332351
    333352    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
    334353      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    335       return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
     354      return DA.TransactionManager.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
    336355    }
    337356
     
    358377    public void UpdateSlave(Slave slave) {
    359378      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    360       trans.UseTransaction(() => {
     379      DA.TransactionManager.UseTransaction(() => {
    361380        dao.UpdateSlave(slave);
    362381      });
     
    365384    public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
    366385      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    367       trans.UseTransaction(() => {
     386      DA.TransactionManager.UseTransaction(() => {
    368387        dao.UpdateSlaveGroup(slaveGroup);
    369388      });
     
    372391    public void DeleteSlave(Guid slaveId) {
    373392      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    374       trans.UseTransaction(() => {
     393      DA.TransactionManager.UseTransaction(() => {
    375394        dao.DeleteSlave(slaveId);
    376395      });
     
    379398    public void DeleteSlaveGroup(Guid slaveGroupId) {
    380399      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    381       trans.UseTransaction(() => {
     400      DA.TransactionManager.UseTransaction(() => {
    382401        dao.DeleteSlaveGroup(slaveGroupId);
    383402      });
     
    386405    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
    387406      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    388       trans.UseTransaction(() => {
     407      DA.TransactionManager.UseTransaction(() => {
    389408        var resource = dao.GetResource(resourceId);
    390409        resource.ParentResourceId = slaveGroupId;
     
    395414    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
    396415      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    397       trans.UseTransaction(() => {
     416      DA.TransactionManager.UseTransaction(() => {
    398417        var resource = dao.GetResource(resourceId);
    399418        resource.ParentResourceId = null;
     
    404423    public Guid GetResourceId(string resourceName) {
    405424      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    406       return trans.UseTransaction(() => {
     425      return DA.TransactionManager.UseTransaction(() => {
    407426        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
    408427        if (resource != null) {
     
    416435    public void TriggerLifecycle(bool force) {
    417436      // 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(() => {
    419438        DateTime lastCleanup = dao.GetLastCleanup();
    420439        if (force || DateTime.Now - lastCleanup > TimeSpan.FromSeconds(59)) {
     
    446465    public Guid AddAppointment(Appointment appointment) {
    447466      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    448       return trans.UseTransaction(() => dao.AddAppointment(appointment));
     467      return DA.TransactionManager.UseTransaction(() => dao.AddAppointment(appointment));
    449468    }
    450469
    451470    public void DeleteAppointment(Guid appointmentId) {
    452471      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    453       trans.UseTransaction(() => {
     472      DA.TransactionManager.UseTransaction(() => {
    454473        dao.DeleteAppointment(appointmentId);
    455474      });
     
    458477    public void UpdateAppointment(Appointment appointment) {
    459478      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    460       trans.UseTransaction(() => {
     479      DA.TransactionManager.UseTransaction(() => {
    461480        dao.UpdateAppointment(appointment);
    462481      });
     
    465484    public IEnumerable<Appointment> GetScheduleForResource(Guid resourceId) {
    466485      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));
    468487    }
    469488
    470489    public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) {
    471490      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    472       return trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     491      return DA.TransactionManager.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
    473492    }
    474493    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IServiceLocator.cs

    r6369 r6431  
    2828    IHiveDao HiveDao { get; }
    2929    ILifecycleManager LifecycleManager { get; }
    30     TransactionManager TransactionManager { get; }
    3130    HeartbeatManager HeartbeatManager { get; }
    3231  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs

    r6367 r6431  
    3333    private DataAccess.IHiveDao dao {
    3434      get { return ServiceLocator.Instance.HiveDao; }
    35     }
    36     private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {
    37       get { return ServiceLocator.Instance.TransactionManager; }
    3835    }
    3936    private IAuthorizationManager auth {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Properties/AssemblyInfo.cs.frame

    r6372 r6431  
    77// associated with an assembly.
    88[assembly: AssemblyTitle("HeuristicLab.Services.Hive")]
    9 [assembly: AssemblyDescription("")]
     9[assembly: AssemblyDescription("Business logic for HeuristicLab.Hive services")]
    1010[assembly: AssemblyConfiguration("")]
    1111[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
     22using HeuristicLab.Services.Hive.DataAccess;
    223
    324namespace HeuristicLab.Services.Hive {
     
    1839        if (hiveDao == null) hiveDao = new HiveDao();
    1940        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;
    2841      }
    2942    }
Note: See TracChangeset for help on using the changeset viewer.