Changeset 9434


Ignore:
Timestamp:
05/03/13 13:47:27 (5 years ago)
Author:
pfleck
Message:

#2030
Added SelfHost-Project
Renamed HiveDtoDao back to HiveDao and renamed the optimized HiveDao into OptimizedDao instead.
Optimized AddTask by using compiled queries.

Location:
branches/HivePerformance/sources
Files:
7 added
13 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • branches/HivePerformance/sources/HeuristicLab 3.3 Services.sln

    r8049 r9434  
    11
    2 Microsoft Visual Studio Solution File, Format Version 11.00
    3 # Visual Studio 2010
     2Microsoft Visual Studio Solution File, Format Version 12.00
     3# Visual Studio 2012
    44Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{96396439-A764-4022-A8D2-BE021449B8D1}"
    55  ProjectSection(SolutionItems) = preProject
     
    2424  ProjectSection(WebsiteProperties) = preProject
    2525    TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
    26     ProjectReferences = "{CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE}|HeuristicLab.Services.Hive-3.3.dll;{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}|HeuristicLab.Services.Hive.DataAccess-3.3.dll;"
     26    ProjectReferences = "{CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE}|HeuristicLab.Services.Hive-3.3.dll;{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}|HeuristicLab.Services.Hive.DataAccess-3.3.dll;{9FAC0B23-2730-452A-9BA0-D7CA1746C541}|HeuristicLab.Services.Access.dll;{BE9B0229-9150-49A4-AEA6-BB58E055992F}|HeuristicLab.GeoIP.dll;{0F652437-998A-4EAB-8BF1-444B5FE8CE97}|HeuristicLab.Services.Access.DataAccess.dll;"
    2727    Debug.AspNetCompiler.VirtualPath = "/Hive-3.3"
    2828    Debug.AspNetCompiler.PhysicalPath = "HeuristicLab.Services.Hive.Web\Hive-3.3\"
     
    5757EndProject
    5858Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.OKB-3.3", "HeuristicLab.Services.OKB\3.3\HeuristicLab.Services.OKB-3.3.csproj", "{766DA4B7-2A0E-4CDE-8F90-93D8B1AD62CF}"
     59EndProject
     60Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Hive.SelfHost-3.3", "HeuristicLab.Services.Hive.SelfHost\3.3\HeuristicLab.Services.Hive.SelfHost-3.3.csproj", "{DAACE3EB-5D88-419D-9EEC-5707E273491A}"
    5961EndProject
    6062Global
     
    222224    {766DA4B7-2A0E-4CDE-8F90-93D8B1AD62CF}.Release|x86.ActiveCfg = Release|x86
    223225    {766DA4B7-2A0E-4CDE-8F90-93D8B1AD62CF}.Release|x86.Build.0 = Release|x86
     226    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     227    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Debug|Any CPU.Build.0 = Debug|Any CPU
     228    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Debug|x64.ActiveCfg = Debug|Any CPU
     229    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Debug|x86.ActiveCfg = Debug|Any CPU
     230    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Release|Any CPU.ActiveCfg = Release|Any CPU
     231    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Release|Any CPU.Build.0 = Release|Any CPU
     232    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Release|x64.ActiveCfg = Release|Any CPU
     233    {DAACE3EB-5D88-419D-9EEC-5707E273491A}.Release|x86.ActiveCfg = Release|Any CPU
    224234  EndGlobalSection
    225235  GlobalSection(SolutionProperties) = preSolution
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx.cs

    r9391 r9434  
    3636public partial class Status : System.Web.UI.Page {
    3737  protected void Page_Load(object sender, EventArgs e) {
    38     var dao = ServiceLocator.Instance.HiveDtoDao;
     38    var dao = ServiceLocator.Instance.HiveDao;
    3939    var transactionManager = ServiceLocator.Instance.TransactionManager;
    4040    var resourceName = Request.QueryString["resource"];
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Convert.cs

    r9393 r9434  
    103103    public static DT.TaskData ToDto(DB.TaskData source) {
    104104      if (source == null) return null;
    105       return new DT.TaskData { TaskId = source.TaskId, Data = source.Data.ToArray(), LastUpdate = source.LastUpdate };
     105      return new DT.TaskData { TaskId = source.TaskId, Data = source.Data, LastUpdate = source.LastUpdate };
    106106    }
    107107    public static DB.TaskData ToEntity(DT.TaskData source) {
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r9391 r9434  
    137137    <Compile Include="DataTransfer\Statistics.cs" />
    138138    <Compile Include="DataTransfer\UserStatistics.cs" />
     139    <Compile Include="OptimizedHiveDao.cs" />
    139140    <Compile Include="HiveDao.cs" />
    140     <Compile Include="HiveDtoDao.cs" />
    141141    <Compile Include="HiveJanitor.cs" />
    142142    <Compile Include="HiveOperationContext.cs" />
     143    <Compile Include="Interfaces\IOptimizedHiveDao.cs" />
    143144    <Compile Include="Interfaces\IHiveDao.cs" />
    144     <Compile Include="Interfaces\IHiveDtoDao.cs" />
    145145    <Compile Include="Interfaces\ITaskScheduler.cs" />
    146146    <Compile Include="Scheduler\TaskInfoForScheduler.cs" />
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r9394 r9434  
    2727
    2828namespace HeuristicLab.Services.Hive.DataAccess {
    29   public class HiveDtoDao : IHiveDtoDao {
     29  public class HiveDao : IHiveDao {
    3030    public static HiveDataContext CreateContext(bool longRunning = false) {
    3131      var context = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
     
    3333      return context;
    3434    }
    35 
    36     public HiveDtoDao() { }
    3735
    3836    #region Task Methods
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs

    r9391 r9434  
    3737    }
    3838
    39     private IHiveDtoDao dao {
    40       get { return ServiceLocator.Instance.HiveDtoDao; }
     39    private IHiveDao dao {
     40      get { return ServiceLocator.Instance.HiveDao; }
    4141    }
    4242
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/HiveOperationContext.cs

    r9393 r9434  
    2222using System;
    2323using System.Collections.ObjectModel;
    24 using System.Diagnostics;
    25 using System.IO;
    2624using System.ServiceModel;
    2725using System.ServiceModel.Channels;
    2826using System.ServiceModel.Description;
    2927using System.ServiceModel.Dispatcher;
    30 using System.Text;
    3128using HeuristicLab.Services.Hive.DataAccess;
    3229
    3330namespace HeuristicLab.Services.Hive {
    3431  public class HiveOperationContext : IExtension<OperationContext> {
     32
    3533    public static HiveOperationContext Current {
    3634      get {
     
    4240    public HiveDataContext DataContext {
    4341      get {
    44         if (dataContext == null) {
    45           dataContext = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
    46           //dataContext.Log = new DebugWriter();
    47         }
    48         return dataContext;
     42        return dataContext ?? (dataContext = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString));
    4943      }
    5044    }
     
    6761    }
    6862
    69     public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState) {
     63    public void BeforeSendReply(ref Message reply, object correlationState) {
    7064      OperationContext.Current.Extensions.Remove(HiveOperationContext.Current);
    7165    }
     
    8882    }
    8983  }
    90 
    91   internal class DebugWriter : TextWriter {
    92     public override Encoding Encoding {
    93       get { return Encoding.UTF8; }
    94     }
    95 
    96     public override void Write(char value) {
    97       Debug.Write(value);
    98     }
    99 
    100     public override void Write(string value) {
    101       Debug.Write(value);
    102     }
    103 
    104     public override void WriteLine(string value) {
    105       Debug.WriteLine(value);
    106     }
    107   }
    10884}
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r9399 r9434  
    3939  [HiveOperationContextBehavior]
    4040  public class HiveService : IHiveService {
    41     private IHiveDtoDao dtoDao {
    42       get { return ServiceLocator.Instance.HiveDtoDao; }
    43     }
    4441    private IHiveDao dao {
    4542      get { return ServiceLocator.Instance.HiveDao; }
    4643    }
     44    private IOptimizedHiveDao optimizedDao {
     45      get { return ServiceLocator.Instance.OptimizedHiveDao; }
     46    }
    4747    private Access.IRoleVerifier authen {
    4848      get { return ServiceLocator.Instance.RoleVerifier; }
     
    6868      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    6969      return trans.UseTransaction(() => {
    70         task.Id = dtoDao.AddTask(task);
    71         taskData.TaskId = task.Id;
    72         taskData.LastUpdate = DateTime.Now;
    73         dtoDao.AssignJobToResource(task.Id, resourceIds);
    74         dtoDao.AddTaskData(taskData);
    75         dtoDao.UpdateTaskState(task.Id, DA.TaskState.Waiting, null, userManager.CurrentUserId, null);
    76         return taskData.TaskId;
     70        var t = DT.Convert.ToEntity(task);
     71        t.RequiredPlugins.AddRange(task.PluginsNeededIds.Select(pluginId => new DA.RequiredPlugin { Task = t, PluginId = pluginId }));
     72
     73        t.JobData = DT.Convert.ToEntity(taskData);
     74        t.JobData.LastUpdate = DateTime.Now;
     75
     76        optimizedDao.AddTask(t);
     77
     78        dao.AssignJobToResource(t.TaskId, resourceIds);
     79
     80        optimizedDao.UpdateTaskState(t.TaskId, DA.TaskState.Waiting, null, userManager.CurrentUserId, null);
     81
     82        return t.TaskId;
    7783      }, false, true);
    7884    }
     
    8086    public Guid AddChildTask(Guid parentTaskId, Task task, TaskData taskData) {
    8187      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    82       return trans.UseTransaction(() => {
    83         task.ParentTaskId = parentTaskId;
    84         return AddTask(task, taskData, dtoDao.GetAssignedResources(parentTaskId).Select(x => x.Id));
    85       }, false, true);
     88      task.ParentTaskId = parentTaskId;
     89      return AddTask(task, taskData, optimizedDao.GetAssignedResourceIds(parentTaskId));
    8690    }
    8791
     
    9195
    9296      return trans.UseTransaction(() => {
    93         return DT.Convert.ToDto(dao.GetTaskById(taskId));
     97        return DT.Convert.ToDto(optimizedDao.GetTaskById(taskId));
    9498      }, false, false);
    9599    }
     
    98102      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    99103      return trans.UseTransaction(() => {
    100         var tasks = dtoDao.GetTasks(x => true);
     104        var tasks = dao.GetTasks(x => true);
    101105        foreach (var task in tasks)
    102106          author.AuthorizeForTask(task.Id, Permission.Read);
     
    109113
    110114      return trans.UseTransaction(() => {
    111         var tasks = dtoDao.GetTasks(x => taskIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray();
     115        var tasks = dao.GetTasks(x => taskIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray();
    112116        foreach (var task in tasks)
    113117          author.AuthorizeForTask(task.Id, Permission.Read);
     
    132136
    133137      return trans.UseTransaction(() => {
    134         return dao.GetLightweightTasks(jobId).ToArray();
     138        return optimizedDao.GetLightweightTasks(jobId).ToArray();
    135139      }, false, true);
    136140    }
     
    141145
    142146      return trans.UseTransaction(() => {
    143         return dtoDao.GetLightweightTasksWithoutStateLog(task => task.JobId == jobId).ToArray();
     147        return dao.GetLightweightTasksWithoutStateLog(task => task.JobId == jobId).ToArray();
    144148      }, false, false);
    145149    }
     
    150154
    151155      return trans.UseTransaction(() => {
    152         return dtoDao.GetTaskData(taskId);
     156        return dao.GetTaskData(taskId);
    153157      });
    154158    }
     
    159163
    160164      trans.UseTransaction(() => {
    161         var task = dao.GetTaskByDto(taskDto);
    162         dao.UpdateTask(task);
     165        var task = optimizedDao.GetTaskByDto(taskDto);
     166        optimizedDao.UpdateTask(task);
    163167      });
    164168    }
     
    169173
    170174      trans.UseTransaction(() => {
    171         var t = dao.GetTaskByDto(task);
    172         dao.UpdateTask(t);
    173       });
    174 
    175       trans.UseTransaction(() => {
    176         var data = dao.GetTaskDataByDto(taskData);
     175        var t = optimizedDao.GetTaskByDto(task);
     176        optimizedDao.UpdateTask(t);
     177      });
     178
     179      trans.UseTransaction(() => {
     180        var data = optimizedDao.GetTaskDataByDto(taskData);
    177181        data.LastUpdate = DateTime.Now;
    178         dao.UpdateTaskData(data);
     182        optimizedDao.UpdateTaskData(data);
    179183      });
    180184    }
     
    184188      author.AuthorizeForTask(taskId, Permission.Full);
    185189      trans.UseTransaction(() => {
    186         dtoDao.DeleteTask(taskId);
     190        dao.DeleteTask(taskId);
    187191      });
    188192    }
     
    194198        var tasks = GetChildTasks(parentTaskId, true, false);
    195199        foreach (var task in tasks) {
    196           dtoDao.DeleteTask(task.Id);
    197           dtoDao.DeleteTaskData(task.Id);
     200          dao.DeleteTask(task.Id);
     201          dao.DeleteTaskData(task.Id);
    198202        };
    199203      });
     
    205209
    206210      return trans.UseTransaction(() => {
    207         var task = dao.UpdateTaskState(taskId, DT.Convert.ToEntity(taskState), slaveId, userId, exception);
     211        var task = optimizedDao.UpdateTaskState(taskId, DT.Convert.ToEntity(taskState), slaveId, userId, exception);
    208212
    209213        if (task.Command.HasValue && task.Command.Value == DA.Command.Pause && task.State == DA.TaskState.Paused) {
     
    215219        } else if (taskState == TaskState.Paused && !task.Command.HasValue) {
    216220          // slave paused and uploaded the task (no user-command) -> set waiting.
    217           task = dao.UpdateTaskState(taskId, DA.TaskState.Waiting, slaveId, userId, exception);
    218         }
    219 
    220         //dao.UpdateTaskAndPlugins(task); no idea why this is needed
     221          task = optimizedDao.UpdateTaskState(taskId, DA.TaskState.Waiting, slaveId, userId, exception);
     222        }
     223
     224        //optimizedDao.UpdateTaskAndPlugins(task); no idea why this is needed
    221225        return DT.Convert.ToDto(task);
    222226      });
     
    225229    public IEnumerable<Task> GetTasksByResourceId(Guid resourceId) {
    226230      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    227       var tasks = trans.UseTransaction(() => dtoDao.GetJobsByResourceId(resourceId));
     231      var tasks = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
    228232      foreach (var task in tasks)
    229233        author.AuthorizeForTask(task.Id, Permission.Read);
     
    237241      author.AuthorizeForTask(taskId, Permission.Full);
    238242      trans.UseTransaction(() => {
    239         var task = dtoDao.GetTask(taskId);
     243        var task = dao.GetTask(taskId);
    240244        if (task.State == TaskState.Calculating || task.State == TaskState.Transferring) {
    241245          task.Command = Command.Stop;
    242           dtoDao.UpdateTask(task);
     246          dao.UpdateTask(task);
    243247        } else {
    244248          if (task.State != TaskState.Aborted && task.State != TaskState.Finished && task.State != TaskState.Failed) {
     
    253257      author.AuthorizeForTask(taskId, Permission.Full);
    254258      trans.UseTransaction(() => {
    255         var job = dtoDao.GetTask(taskId);
     259        var job = dao.GetTask(taskId);
    256260        if (job.State == TaskState.Calculating || job.State == TaskState.Transferring) {
    257261          job.Command = Command.Pause;
    258           dtoDao.UpdateTask(job);
     262          dao.UpdateTask(job);
    259263        } else {
    260264          job = UpdateTaskState(taskId, TaskState.Paused, null, null, string.Empty);
     
    267271      author.AuthorizeForTask(taskId, Permission.Full);
    268272      trans.UseTransaction(() => {
    269         Task task = dtoDao.UpdateTaskState(taskId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty);
     273        Task task = dao.UpdateTaskState(taskId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty);
    270274        task.Command = null;
    271         dtoDao.UpdateTask(task);
     275        dao.UpdateTask(task);
    272276      });
    273277    }
     
    279283      author.AuthorizeForJob(id, Permission.Read);
    280284      return trans.UseTransaction(() => {
    281         var job = dtoDao.GetJobs(x =>
     285        var job = dao.GetJobs(x =>
    282286              x.JobId == id
    283287              && (x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0)
    284288            ).FirstOrDefault();
    285289        if (job != null) {
    286           job.Permission = DT.Convert.ToDto(dtoDao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     290          job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
    287291          job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName;
    288292        }
     
    294298      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    295299      return trans.UseTransaction(() => {
    296         var jobs = dtoDao.GetJobs(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
     300        var jobs = dao.GetJobs(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
    297301        foreach (var job in jobs) {
    298302          author.AuthorizeForJob(job.Id, Permission.Read);
    299           job.Permission = DT.Convert.ToDto(dtoDao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     303          job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
    300304          job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName;
    301305        }
     
    307311      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    308312      return trans.UseTransaction(() => {
    309         var jobs = dtoDao.GetJobs(x => true);
     313        var jobs = dao.GetJobs(x => true);
    310314        foreach (var job in jobs) { // no authorization here, since this method is admin-only! (admin is allowed to read all task)
    311           job.Permission = DT.Convert.ToDto(dtoDao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     315          job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
    312316          job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName;
    313317        }
     
    321325        jobDto.OwnerUserId = userManager.CurrentUserId;
    322326        jobDto.DateCreated = DateTime.Now;
    323         return dtoDao.AddJob(jobDto);
     327        return dao.AddJob(jobDto);
    324328      });
    325329    }
     
    329333      author.AuthorizeForJob(jobDto.Id, Permission.Full);
    330334      trans.UseTransaction(() => {
    331         dtoDao.UpdateJob(jobDto);
     335        dao.UpdateJob(jobDto);
    332336      });
    333337    }
     
    337341      author.AuthorizeForJob(jobId, Permission.Full);
    338342      trans.UseTransaction(() => {
    339         dtoDao.DeleteJob(jobId); // child task will be deleted by db-trigger
     343        dao.DeleteJob(jobId); // child task will be deleted by db-trigger
    340344      });
    341345    }
     
    346350      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    347351      trans.UseTransaction(() => {
    348         Job job = dtoDao.GetJob(jobId);
     352        Job job = dao.GetJob(jobId);
    349353        if (job == null) throw new FaultException<FaultReason>(new FaultReason("Could not find task with id " + jobId));
    350         Permission perm = DT.Convert.ToDto(dtoDao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     354        Permission perm = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
    351355        if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    352         dtoDao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission));
     356        dao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission));
    353357      });
    354358    }
     
    357361      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    358362      trans.UseTransaction(() => {
    359         Job job = dtoDao.GetJob(jobId);
     363        Job job = dao.GetJob(jobId);
    360364        if (job == null) throw new FaultException<FaultReason>(new FaultReason("Could not find task with id " + jobId));
    361         DA.Permission perm = dtoDao.GetPermissionForJob(job.Id, userManager.CurrentUserId);
     365        DA.Permission perm = dao.GetPermissionForJob(job.Id, userManager.CurrentUserId);
    362366        if (perm != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    363         dtoDao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed);
     367        dao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed);
    364368      });
    365369    }
     
    368372      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    369373      return trans.UseTransaction(() => {
    370         DA.Permission currentUserPermission = dtoDao.GetPermissionForJob(jobId, userManager.CurrentUserId);
     374        DA.Permission currentUserPermission = dao.GetPermissionForJob(jobId, userManager.CurrentUserId);
    371375        if (currentUserPermission != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment"));
    372         return dtoDao.GetJobPermissions(x => x.JobId == jobId);
     376        return dao.GetJobPermissions(x => x.JobId == jobId);
    373377      });
    374378    }
     
    387391
    388392      trans.UseTransaction(() => {
    389         var slave = dtoDao.GetSlave(slaveInfo.Id);
     393        var slave = dao.GetSlave(slaveInfo.Id);
    390394
    391395        if (slave == null) {
    392           var healGroup = dtoDao.GetResources(x => x.Name == "HEAL").First();
     396          var healGroup = dao.GetResources(x => x.Name == "HEAL").First();
    393397          if (healGroup != null) {
    394398            slaveInfo.ParentResourceId = healGroup.Id;
    395399          }
    396           dtoDao.AddSlave(slaveInfo);
     400          dao.AddSlave(slaveInfo);
    397401        } else {
    398402          slave.Name = slaveInfo.Name;
     
    413417          // don't update those properties: dbSlave.IsAllowedToCalculate, dbSlave.ParentResourceId
    414418
    415           dtoDao.UpdateSlave(slave);
     419          dao.UpdateSlave(slave);
    416420        }
    417421      });
     
    421425      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    422426      trans.UseTransaction(() => {
    423         var slave = dtoDao.GetSlave(slaveId);
     427        var slave = dao.GetSlave(slaveId);
    424428        if (slave != null) {
    425429          slave.SlaveState = SlaveState.Offline;
    426           dtoDao.UpdateSlave(slave);
     430          dao.UpdateSlave(slave);
    427431        }
    428432      });
     
    457461        plugin.DateCreated = DateTime.Now;
    458462
    459         var existing = dtoDao.GetPlugins(x => x.Hash != null).Where(x => x.Hash.SequenceEqual(plugin.Hash));
     463        var existing = dao.GetPlugins(x => x.Hash != null).Where(x => x.Hash.SequenceEqual(plugin.Hash));
    460464        if (existing.Count() > 0) {
    461465          // a plugin already exists.
     
    463467        }
    464468
    465         Guid pluginId = dtoDao.AddPlugin(plugin);
     469        Guid pluginId = dao.AddPlugin(plugin);
    466470        foreach (PluginData pluginData in pluginDatas) {
    467471          pluginData.PluginId = pluginId;
    468           dtoDao.AddPluginData(pluginData);
     472          dao.AddPluginData(pluginData);
    469473        }
    470474        return pluginId;
     
    475479      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    476480      return trans.UseTransaction(() => {
    477         return DT.Convert.ToDto(dao.GetPluginById(pluginId));
     481        return DT.Convert.ToDto(optimizedDao.GetPluginById(pluginId));
    478482      });
    479483    }
     
    482486      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    483487      return trans.UseTransaction(() => {
    484         return dtoDao.GetPlugins(x => x.Hash == hash).FirstOrDefault();
     488        return dao.GetPlugins(x => x.Hash == hash).FirstOrDefault();
    485489      });
    486490    }
     
    491495      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    492496      return trans.UseTransaction(() => {
    493         return dtoDao.GetPlugins(x => x.Hash != null);
     497        return dao.GetPlugins(x => x.Hash != null);
    494498      });
    495499    }
     
    500504      return trans.UseTransaction(() => {
    501505        foreach (Guid guid in pluginIds) {
    502           pluginDatas.AddRange(dtoDao.GetPluginDatas(x => x.PluginId == guid).ToList());
     506          pluginDatas.AddRange(dao.GetPluginDatas(x => x.PluginId == guid).ToList());
    503507        }
    504508        return pluginDatas;
     
    509513      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    510514      trans.UseTransaction(() => {
    511         dtoDao.DeletePlugin(pluginId);
     515        dao.DeletePlugin(pluginId);
    512516      });
    513517    }
     
    518522      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    519523      trans.UseTransaction(() => {
    520         Resource resource = dtoDao.GetResource(resourceId);
     524        Resource resource = dao.GetResource(resourceId);
    521525        if (resource == null) throw new FaultException<FaultReason>(new FaultReason("Could not find resource with id " + resourceId));
    522526        if (resource.OwnerUserId != userManager.CurrentUserId && !authen.IsInRole(HiveRoles.Administrator)) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permission for this resource"));
    523527        foreach (Guid id in grantedUserIds)
    524           dtoDao.AddResourcePermission(new ResourcePermission { ResourceId = resourceId, GrantedByUserId = userManager.CurrentUserId, GrantedUserId = id });
     528          dao.AddResourcePermission(new ResourcePermission { ResourceId = resourceId, GrantedByUserId = userManager.CurrentUserId, GrantedUserId = id });
    525529      });
    526530    }
     
    529533      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    530534      trans.UseTransaction(() => {
    531         Resource resource = dtoDao.GetResource(resourceId);
     535        Resource resource = dao.GetResource(resourceId);
    532536        if (resource == null) throw new FaultException<FaultReason>(new FaultReason("Could not find resource with id " + resourceId));
    533537        if (resource.OwnerUserId != userManager.CurrentUserId && !authen.IsInRole(HiveRoles.Administrator)) throw new FaultException<FaultReason>(new FaultReason("Not allowed to revoke permission for this resource"));
    534538        foreach (Guid id in grantedUserIds)
    535           dtoDao.DeleteResourcePermission(resourceId, id);
     539          dao.DeleteResourcePermission(resourceId, id);
    536540      });
    537541    }
     
    540544      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    541545      return trans.UseTransaction(() => {
    542         Resource resource = dtoDao.GetResource(resourceId);
     546        Resource resource = dao.GetResource(resourceId);
    543547        if (resource == null) throw new FaultException<FaultReason>(new FaultReason("Could not find resource with id " + resourceId));
    544         return dtoDao.GetResourcePermissions(x => x.ResourceId == resourceId);
     548        return dao.GetResourcePermissions(x => x.ResourceId == resourceId);
    545549      });
    546550    }
     
    549553    #region Resource Methods
    550554    public IEnumerable<Resource> GetChildResources(Guid resourceId) {
    551       return trans.UseTransaction(() => { return dtoDao.GetChildResources(resourceId); });
     555      return trans.UseTransaction(() => { return dao.GetChildResources(resourceId); });
    552556    }
    553557    #endregion
     
    557561      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    558562
    559       Slave s = trans.UseTransaction(() => { return dtoDao.GetSlave(slaveId); });
     563      Slave s = trans.UseTransaction(() => { return dao.GetSlave(slaveId); });
    560564      if (s != null) {
    561565        return s.HbInterval;
     
    567571    public Guid AddSlave(Slave slave) {
    568572      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    569       return trans.UseTransaction(() => dtoDao.AddSlave(slave));
     573      return trans.UseTransaction(() => dao.AddSlave(slave));
    570574    }
    571575
    572576    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
    573577      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    574       return trans.UseTransaction(() => dtoDao.AddSlaveGroup(slaveGroup));
     578      return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
    575579    }
    576580
    577581    public Slave GetSlave(Guid slaveId) {
    578582      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    579       return trans.UseTransaction(() => { return dtoDao.GetSlave(slaveId); });
     583      return trans.UseTransaction(() => { return dao.GetSlave(slaveId); });
    580584    }
    581585
    582586    public SlaveGroup GetSlaveGroup(Guid slaveGroupId) {
    583587      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    584       return trans.UseTransaction(() => { return dtoDao.GetSlaveGroup(slaveGroupId); });
     588      return trans.UseTransaction(() => { return dao.GetSlaveGroup(slaveGroupId); });
    585589    }
    586590
     
    588592      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    589593      return trans.UseTransaction(() => {
    590         return dtoDao.GetSlaves(x => true).Where(x => x.OwnerUserId == null
     594        return dao.GetSlaves(x => true).Where(x => x.OwnerUserId == null
    591595                                           || x.OwnerUserId == userManager.CurrentUserId
    592596                                           || userManager.VerifyUser(userManager.CurrentUserId, GetResourcePermissions(x.Id).Select(y => y.GrantedUserId).ToList())
     
    598602      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    599603      return trans.UseTransaction(() => {
    600         return dtoDao.GetSlaveGroups(x => true).Where(x => x.OwnerUserId == null
     604        return dao.GetSlaveGroups(x => true).Where(x => x.OwnerUserId == null
    601605                                                || x.OwnerUserId == userManager.CurrentUserId
    602606                                                || userManager.VerifyUser(userManager.CurrentUserId, GetResourcePermissions(x.Id).Select(y => y.GrantedUserId).ToList())
     
    608612      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    609613      trans.UseTransaction(() => {
    610         dtoDao.UpdateSlave(slave);
     614        dao.UpdateSlave(slave);
    611615      });
    612616    }
     
    615619      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    616620      trans.UseTransaction(() => {
    617         dtoDao.UpdateSlaveGroup(slaveGroup);
     621        dao.UpdateSlaveGroup(slaveGroup);
    618622      });
    619623    }
     
    623627      author.AuthorizeForResourceAdministration(slaveId);
    624628      trans.UseTransaction(() => {
    625         dtoDao.DeleteSlave(slaveId);
     629        dao.DeleteSlave(slaveId);
    626630      });
    627631    }
     
    631635      author.AuthorizeForResourceAdministration(slaveGroupId);
    632636      trans.UseTransaction(() => {
    633         dtoDao.DeleteSlaveGroup(slaveGroupId);
     637        dao.DeleteSlaveGroup(slaveGroupId);
    634638      });
    635639    }
     
    638642      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    639643      trans.UseTransaction(() => {
    640         var resource = dtoDao.GetResource(resourceId);
     644        var resource = dao.GetResource(resourceId);
    641645        resource.ParentResourceId = slaveGroupId;
    642         dtoDao.UpdateResource(resource);
     646        dao.UpdateResource(resource);
    643647      });
    644648    }
     
    647651      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    648652      trans.UseTransaction(() => {
    649         var resource = dtoDao.GetResource(resourceId);
     653        var resource = dao.GetResource(resourceId);
    650654        resource.ParentResourceId = null;
    651         dtoDao.UpdateResource(resource);
     655        dao.UpdateResource(resource);
    652656      });
    653657    }
     
    656660      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    657661      return trans.UseTransaction(() => {
    658         var resource = dtoDao.GetResources(x => x.Name == resourceName).FirstOrDefault();
     662        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
    659663        if (resource != null) {
    660664          return resource.Id;
     
    670674      bool cleanup = false;
    671675      trans.UseTransaction(() => {
    672         DateTime lastCleanup = dtoDao.GetLastCleanup();
     676        DateTime lastCleanup = dao.GetLastCleanup();
    673677        if (force || DateTime.Now - lastCleanup > HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval) {
    674           dtoDao.SetLastCleanup(DateTime.Now);
     678          dao.SetLastCleanup(DateTime.Now);
    675679          cleanup = true;
    676680        }
     
    687691      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    688692      author.AuthorizeForResourceAdministration(downtime.ResourceId);
    689       return trans.UseTransaction(() => dtoDao.AddDowntime(downtime));
     693      return trans.UseTransaction(() => dao.AddDowntime(downtime));
    690694    }
    691695
     
    695699      // author.AuthorizeForResource(resourceId);
    696700      trans.UseTransaction(() => {
    697         dtoDao.DeleteDowntime(downtimeId);
     701        dao.DeleteDowntime(downtimeId);
    698702      });
    699703    }
     
    703707      author.AuthorizeForResourceAdministration(downtime.ResourceId);
    704708      trans.UseTransaction(() => {
    705         dtoDao.UpdateDowntime(downtime);
     709        dao.UpdateDowntime(downtime);
    706710      });
    707711    }
     
    709713    public IEnumerable<Downtime> GetDowntimesForResource(Guid resourceId) {
    710714      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    711       return trans.UseTransaction(() => dtoDao.GetDowntimes(x => x.ResourceId == resourceId));
     715      return trans.UseTransaction(() => dao.GetDowntimes(x => x.ResourceId == resourceId));
    712716    }
    713717    #endregion
     
    732736    #region UserPriority Methods
    733737    public IEnumerable<UserPriority> GetUserPriorities() {
    734       return trans.UseTransaction(() => dtoDao.GetUserPriorities(x => true));
     738      return trans.UseTransaction(() => dao.GetUserPriorities(x => true));
    735739    }
    736740    #endregion
     
    738742    #region Helper Methods
    739743    private IEnumerable<Task> GetChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) {
    740       var tasks = new List<Task>(dtoDao.GetTasks(x => parentTaskId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentTaskId));
     744      var tasks = new List<Task>(dao.GetTasks(x => parentTaskId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentTaskId));
    741745
    742746      if (recursive) {
     
    755759    #region Statistics Methods
    756760    public IEnumerable<Statistics> GetStatistics() {
    757       return trans.UseTransaction(() => { return dtoDao.GetStatistics(x => true); });
     761      return trans.UseTransaction(() => { return dao.GetStatistics(x => true); });
    758762    }
    759763    public IEnumerable<Statistics> GetStatisticsForTimePeriod(DateTime from, DateTime to) {
    760       return trans.UseTransaction(() => { return dtoDao.GetStatistics(x => x.Timestamp >= from && x.Timestamp <= to); });
     764      return trans.UseTransaction(() => { return dao.GetStatistics(x => x.Timestamp >= from && x.Timestamp <= to); });
    761765    }
    762766    #endregion
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r9394 r9434  
    2727
    2828namespace HeuristicLab.Services.Hive {
    29   public interface IHiveDtoDao {
     29  public interface IHiveDao {
    3030    #region Task Methods
    3131    DT.Task GetTask(Guid id);
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IOptimizedHiveDao.cs

    r9399 r9434  
    2727using DT = HeuristicLab.Services.Hive.DataTransfer;
    2828namespace HeuristicLab.Services.Hive {
    29   public interface IHiveDao {
     29  public interface IOptimizedHiveDao {
    3030    #region Task Methods
    3131    Task GetTaskById(Guid task);
     
    3838    void UpdateTask(Task task);
    3939    Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception);
     40
     41    Guid AddTask(Task task);
     42    void AssignJobToResource(Guid taskId, IEnumerable<Guid> resourceIds);
    4043
    4144    bool TaskIsAllowedToBeCalculatedBySlave(Guid taskId, Guid slaveId);
     
    8184
    8285    #region Resource Methods
    83 
     86    IEnumerable<Guid> GetAssignedResourceIds(Guid jobId);
    8487    #endregion
    8588
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IServiceLocator.cs

    r9391 r9434  
    2626    Access.IRoleVerifier RoleVerifier { get; }
    2727    IAuthorizationManager AuthorizationManager { get; }
    28     IHiveDtoDao HiveDtoDao { get; }
    2928    IHiveDao HiveDao { get; }
     29    IOptimizedHiveDao OptimizedHiveDao { get; }
    3030    IEventManager EventManager { get; }
    3131    ITransactionManager TransactionManager { get; }
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r9391 r9434  
    3636      if (ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks
    3737
    38       Permission permission = ServiceLocator.Instance.HiveDtoDao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId);
     38      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId);
    3939      if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
    4040        throw new SecurityException("Current user is not authorized to access task");
     
    4242
    4343    public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) {
    44       Permission permission = ServiceLocator.Instance.HiveDtoDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId);
     44      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId);
    4545      if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
    4646        throw new SecurityException("Current user is not authorized to access task");
     
    4848
    4949    public void AuthorizeForResourceAdministration(Guid resourceId) {
    50       Resource resource = DT.Convert.ToEntity(ServiceLocator.Instance.HiveDtoDao.GetResource(resourceId));
     50      Resource resource = DT.Convert.ToEntity(ServiceLocator.Instance.HiveDao.GetResource(resourceId));
    5151      if (resource.OwnerUserId != ServiceLocator.Instance.UserManager.CurrentUserId && !ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Administrator))
    5252        throw new SecurityException("Current user is not authorized to access resource");
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs

    r9391 r9434  
    3232  /// </summary>
    3333  public class EventManager : IEventManager {
    34     private IHiveDtoDao dao {
    35       get { return ServiceLocator.Instance.HiveDtoDao; }
     34    private IHiveDao dao {
     35      get { return ServiceLocator.Instance.HiveDao; }
    3636    }
    3737    private IAuthorizationManager auth {
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r9397 r9434  
    3131    private const string MutexName = "HiveTaskSchedulingMutex";
    3232
    33     private IHiveDao dao {
    34       get { return ServiceLocator.Instance.HiveDao; }
     33    private IOptimizedHiveDao dao {
     34      get { return ServiceLocator.Instance.OptimizedHiveDao; }
    3535    }
    3636    private ITaskScheduler taskScheduler {
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/OptimizedHiveDao.cs

    r9399 r9434  
    2727
    2828namespace HeuristicLab.Services.Hive.DataAccess {
    29   public class HiveDao : IHiveDao {
    30     private HiveDataContext Db { get { return HiveOperationContext.Current.DataContext; } }
     29  public class OptimizedHiveDao : IOptimizedHiveDao {
     30    private static HiveDataContext Db { get { return HiveOperationContext.Current.DataContext; } }
    3131
    3232    #region Task Methods
     
    3535    }
    3636
    37     private static Func<HiveDataContext, Guid, IQueryable<Task>> GetTaskByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid taskId) =>
     37    private static readonly Func<HiveDataContext, Guid, IQueryable<Task>> GetTaskByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid taskId) =>
    3838      from t in db.Tasks
    3939      where t.TaskId == taskId
     
    5151    }
    5252
    53     private static Func<HiveDataContext, Guid, IQueryable<Tuple<Task, Guid?>>> GetTaskByIdAndLastStateLogSlaveIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid taskId) =>
     53    private static readonly Func<HiveDataContext, Guid, IQueryable<Tuple<Task, Guid?>>> GetTaskByIdAndLastStateLogSlaveIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid taskId) =>
    5454       from t in db.Tasks
    5555       join sl in db.StateLogs on t.TaskId equals sl.TaskId
     
    8989    }
    9090
    91     private static Func<HiveDataContext, Guid, IQueryable<DT.LightweightTask>> GetLightweightTasksQuery = CompiledQuery.Compile((HiveDataContext db, Guid jobId) =>
     91    private static readonly Func<HiveDataContext, Guid, IQueryable<DT.LightweightTask>> GetLightweightTasksQuery = CompiledQuery.Compile((HiveDataContext db, Guid jobId) =>
    9292        from task in db.Tasks
    9393        where task.JobId == jobId
     
    103103    );
    104104
    105     static Func<StateLog, DT.StateLog> ConvertStateLog = sl => DT.Convert.ToDto(sl);
    106     static Func<TaskState, DT.TaskState> ConvertTaskState = ts => DT.Convert.ToDto(ts);
    107     static Func<Command?, DT.Command?> ConvertCommand = c => DT.Convert.ToDto(c);
     105    private static readonly Func<StateLog, DT.StateLog> ConvertStateLog = sl => DT.Convert.ToDto(sl);
     106    private static readonly Func<TaskState, DT.TaskState> ConvertTaskState = ts => DT.Convert.ToDto(ts);
     107    private static readonly Func<Command?, DT.Command?> ConvertCommand = c => DT.Convert.ToDto(c);
    108108
    109109    public void UpdateTask(Task task) {
     
    127127
    128128      return task;
     129    }
     130
     131    public Guid AddTask(Task task) {
     132      Db.Tasks.InsertOnSubmit(task);
     133      Db.SubmitChanges();
     134      return task.TaskId;
     135    }
     136
     137    public void AssignJobToResource(Guid taskId, IEnumerable<Guid> resourceIds) {
     138      Db.AssignedResources.InsertAllOnSubmit(resourceIds.Select(resourceId => new AssignedResource { TaskId = taskId, ResourceId = resourceId }));
     139      Db.SubmitChanges();
    129140    }
    130141
     
    153164    }
    154165
    155     private static Func<HiveDataContext, Guid, IQueryable<TaskData>> GetTaskDataByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid id) =>
     166    private static readonly Func<HiveDataContext, Guid, IQueryable<TaskData>> GetTaskDataByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid id) =>
    156167      from t in db.TaskDatas
    157168      where t.TaskId == id
     
    187198    }
    188199
    189     private static Func<HiveDataContext, Guid, IQueryable<Plugin>> GetPluginByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid pluginId) =>
     200    private static readonly Func<HiveDataContext, Guid, IQueryable<Plugin>> GetPluginByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid pluginId) =>
    190201      from p in db.Plugins
    191202      where p.PluginId == pluginId
     
    204215    }
    205216
    206     private static Func<HiveDataContext, Guid, IQueryable<Slave>> GetSlaveByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid slaveId) =>
     217    private static readonly Func<HiveDataContext, Guid, IQueryable<Slave>> GetSlaveByIdQuery = CompiledQuery.Compile((HiveDataContext db, Guid slaveId) =>
    207218      from s in db.Resources.OfType<Slave>()
    208219      where s.ResourceId == slaveId
     
    243254
    244255    #region Resource Methods
     256    public IEnumerable<Guid> GetAssignedResourceIds(Guid taskId) {
     257      return GetAssignedResourceIdsQuery(Db, taskId);
     258    }
     259
     260    private static readonly Func<HiveDataContext, Guid, IQueryable<Guid>> GetAssignedResourceIdsQuery = CompiledQuery.Compile((HiveDataContext db, Guid taskId) =>
     261      from ar in db.AssignedResources
     262      where ar.TaskId == taskId
     263      select ar.ResourceId
     264    );
    245265    #endregion
    246266
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Scheduler/RoundRobinTaskScheduler.cs

    r9391 r9434  
    2727namespace HeuristicLab.Services.Hive {
    2828  public class RoundRobinTaskScheduler : ITaskScheduler {
    29     private IHiveDtoDao dao {
    30       get { return ServiceLocator.Instance.HiveDtoDao; }
     29    private IHiveDao dao {
     30      get { return ServiceLocator.Instance.HiveDao; }
    3131    }
    3232
  • branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs

    r9391 r9434  
    3434    }
    3535
    36     private IHiveDtoDao hiveDtoDao;
    37     public IHiveDtoDao HiveDtoDao {
    38       get {
    39         if (hiveDtoDao == null) hiveDtoDao = new HiveDtoDao();
    40         return hiveDtoDao;
    41       }
    42     }
    43 
    4436    private IHiveDao hiveDao;
    4537    public IHiveDao HiveDao {
     
    4739        if (hiveDao == null) hiveDao = new HiveDao();
    4840        return hiveDao;
     41      }
     42    }
     43
     44    private IOptimizedHiveDao optimizedHiveDao;
     45    public IOptimizedHiveDao OptimizedHiveDao {
     46      get {
     47        if (optimizedHiveDao == null) optimizedHiveDao = new OptimizedHiveDao();
     48        return optimizedHiveDao;
    4949      }
    5050    }
Note: See TracChangeset for help on using the changeset viewer.