Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12857


Ignore:
Timestamp:
08/13/15 14:51:54 (9 years ago)
Author:
ascheibe
Message:

#2388

  • cleaned up sql scripts
  • cleaned up hive service
  • made performance logger optional
  • removed unused web service methods
Location:
branches/HiveStatistics/sources
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.cs

    r12012 r12857  
    3030      throw new NotImplementedException();
    3131    }
     32
     33    partial void OnCreated() {
     34      LogFactory.GetLogger(this.GetType().Namespace).Log("HiveDataContext created");
     35    }
    3236  }
    3337}
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql

    r12768 r12857  
    1 USE [HeuristicLab.Hive-3.3]
    2 /* create and initialize hive database tables */
     1/* HeuristicLab
     2 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 *
     4 * This file is part of HeuristicLab.
     5 *
     6 * HeuristicLab is free software: you can redistribute it and/or modify
     7 * it under the terms of the GNU General Public License as published by
     8 * the Free Software Foundation, either version 3 of the License, or
     9 * (at your option) any later version.
     10 *
     11 * HeuristicLab is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 * GNU General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU General Public License
     17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     18 */
     19USE [HeuristicLab.Hive-3.3]
    320
    421EXEC sp_configure filestream_access_level, 2
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql

    r12768 r12857  
     1/* HeuristicLab
     2 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 *
     4 * This file is part of HeuristicLab.
     5 *
     6 * HeuristicLab is free software: you can redistribute it and/or modify
     7 * it under the terms of the GNU General Public License as published by
     8 * the Free Software Foundation, either version 3 of the License, or
     9 * (at your option) any later version.
     10 *
     11 * HeuristicLab is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 * GNU General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU General Public License
     17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     18 */
     19
     20/* this script is supposed to be executed after the plain DB is generated by the linq-to-sql schema */
    121USE [HeuristicLab.Hive-3.3]
    2 /* this script is supposed to be executed after the plain DB is generated by the linq-to-sql schema */
    3 /* adds default values */
    4 /* creates delete and update cascades */
    5 /* creates indices */
    6 /* creates views */
    7 /* creates triggers */
    8 
    922
    1023ALTER TABLE [dbo].[AssignedResources]  DROP  CONSTRAINT [Task_AssignedResource]
     
    97110GO
    98111
    99 /* views */
    100 -- =============================================
    101 -- Author:    cneumuel
    102 -- Description: Returns the first StateLog entry for each job
    103 -- =============================================
    104 CREATE VIEW [dbo].[view_FirstState]
    105 AS
    106 SELECT     sl.TaskId, sl.DateTime, sl.State
    107 FROM         dbo.StateLog AS sl INNER JOIN
    108                           (SELECT     TaskId, MIN(DateTime) AS DateTime
    109                             FROM          dbo.StateLog
    110                             GROUP BY TaskId) AS minDate ON sl.DateTime = minDate.DateTime AND sl.TaskId = minDate.TaskId
    111 
     112-- speed up joins between Job and Task
     113CREATE NONCLUSTERED INDEX [TaskJobIdIndex]
     114ON [dbo].[Task] ([JobId])
     115INCLUDE ([TaskId],[TaskState],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[CoresNeeded],[MemoryNeeded],[IsParentTask],[FinishWhenChildJobsFinished],[Command],[IsPrivileged])
    112116GO
    113117
    114 -- =============================================
    115 -- Author:    cneumuel
    116 -- Description: Returns the last StateLog entry for each job
    117 -- =============================================
    118 CREATE VIEW [dbo].[view_LastState]
    119 AS
    120 SELECT     sl.TaskId, sl.DateTime, sl.State
    121 FROM         dbo.StateLog AS sl INNER JOIN
    122                           (SELECT     TaskId, MAX(DateTime) AS DateTime
    123                             FROM          dbo.StateLog
    124                             GROUP BY TaskId) AS minDate ON sl.DateTime = minDate.DateTime AND sl.TaskId = minDate.TaskId
     118-- this is an index to speed up the GetWaitingTasks() method
     119CREATE NONCLUSTERED INDEX [TaskGetWaitingTasksIndex]
     120ON [dbo].[Task] ([TaskState],[IsParentTask],[FinishWhenChildJobsFinished],[CoresNeeded],[MemoryNeeded])
     121INCLUDE ([TaskId],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[Command],[JobId],[IsPrivileged])
    125122GO
     123
    126124
    127125/****** Object:  Trigger [dbo].[tr_JobDeleteCascade]    Script Date: 04/19/2011 16:31:53 ******/
     
    152150CREATE TRIGGER [dbo].[tr_TaskDeleteCascade] ON [dbo].[Task] INSTEAD OF DELETE AS
    153151BEGIN
    154     SELECT
    155         he.OwnerUserId AS UserId,
    156         ROUND(SUM(j.ExecutionTimeMs) / 1000, 0) AS ExecutionTimeS, 
    157         ROUND(ISNULL(SUM(CASE ls.State WHEN 'Finished' THEN j.ExecutionTimeMs END), 0) / 1000, 0) AS ExecutionTimeSFinishedJobs,
    158         ISNULL(SUM(CASE ls.State WHEN 'Finished' THEN DATEDIFF(s, fs.DateTime, ls.DateTime) ELSE 0 END), 0) AS StartToEndTimeS
    159     FROM
    160         deleted j,
    161         Job he,
    162         view_FirstState fs,
    163         view_LastState ls
    164     WHERE
    165         he.JobId = j.JobId AND
    166         fs.TaskId = j.TaskId AND
    167         ls.TaskId = j.TaskId
    168     GROUP BY he.OwnerUserId
    169 
    170152    -- recursively delete jobs
    171153    CREATE TABLE #Table(
     
    194176GO
    195177
    196 -- ============================================================
    197 -- Description: Create indices to speed up execution of queries
    198 -- ============================================================
    199178
    200 -- speed up joins between Job and Task
    201 CREATE NONCLUSTERED INDEX [TaskJobIdIndex]
    202 ON [dbo].[Task] ([JobId])
    203 INCLUDE ([TaskId],[TaskState],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[CoresNeeded],[MemoryNeeded],[IsParentTask],[FinishWhenChildJobsFinished],[Command],[IsPrivileged])
    204 GO
    205 
    206 -- this is an index to speed up the GetWaitingTasks() method
    207 CREATE NONCLUSTERED INDEX [TaskGetWaitingTasksIndex]
    208 ON [dbo].[Task] ([TaskState],[IsParentTask],[FinishWhenChildJobsFinished],[CoresNeeded],[MemoryNeeded])
    209 INCLUDE ([TaskId],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[Command],[JobId],[IsPrivileged])
    210 GO
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r12789 r12857  
    158158    <Compile Include="Scheduler\JobInfoForScheduler.cs" />
    159159    <Compile Include="Scheduler\RoundRobinTaskScheduler.cs" />
    160     <Compile Include="Settings.cs" />
    161160    <None Include="app.config" />
    162161    <None Include="Plugin.cs.frame" />
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/NewHiveService.cs

    r12776 r12857  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Diagnostics;
    2524using System.Linq;
    26 using System.Runtime.CompilerServices;
    2725using System.Security;
    2826using System.ServiceModel;
     
    7068    public Guid AddTask(DT.Task task, DT.TaskData taskData, IEnumerable<Guid> resourceIds) {
    7169      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    72       using (var pm = PersistenceManager)
     70      var pm = PersistenceManager;
    7371      using (new PerformanceLogger("AddTask")) {
    7472        var taskDao = pm.TaskDao;
     
    102100      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    103101      IEnumerable<Guid> resourceIds;
    104       using (var pm = PersistenceManager)
     102      var pm = PersistenceManager;
    105103      using (new PerformanceLogger("AddChildTask")) {
    106104        var assignedResourceDao = pm.AssignedResourceDao;
     
    118116      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    119117      AuthorizationManager.AuthorizeForTask(taskId, Permission.Read);
    120       using (var pm = PersistenceManager)
     118      var pm = PersistenceManager;
    121119      using (new PerformanceLogger("GetTask")) {
    122120        var taskDao = pm.TaskDao;
     
    128126    }
    129127
    130     public IEnumerable<DT.Task> GetTasks() {
    131       // unused
    132       throw new NotImplementedException();
    133     }
    134 
    135     public IEnumerable<DT.LightweightTask> GetLightweightTasks(IEnumerable<Guid> taskIds) {
    136       // unused
    137       throw new NotImplementedException();
    138     }
    139 
    140     public IEnumerable<DT.LightweightTask> GetLightweightChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) {
    141       // unused
    142       throw new NotImplementedException();
    143     }
    144 
    145128    public IEnumerable<DT.LightweightTask> GetLightweightJobTasks(Guid jobId) {
    146129      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    147130      AuthorizationManager.AuthorizeForJob(jobId, Permission.Read);
    148       using (var pm = PersistenceManager)
     131      var pm = PersistenceManager;
    149132      using (new PerformanceLogger("GetLightweightJobTasks")) {
    150133        var taskDao = pm.TaskDao;
     
    171154      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    172155      AuthorizationManager.AuthorizeForJob(jobId, Permission.Read);
    173       using (var pm = PersistenceManager)
     156      var pm = PersistenceManager;
    174157      using (new PerformanceLogger("GetLightweightJobTasksWithoutStateLog")) {
    175158        var taskDao = pm.TaskDao;
     
    194177      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    195178      AuthorizationManager.AuthorizeForTask(taskId, Permission.Read);
    196       using (var pm = PersistenceManager)
     179      var pm = PersistenceManager;
    197180      using (new PerformanceLogger("GetTaskData")) {
    198181        var taskDataDao = pm.TaskDataDao;
     
    204187      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    205188      AuthorizationManager.AuthorizeForTask(taskDto.Id, Permission.Full);
    206       using (var pm = PersistenceManager)
     189      var pm = PersistenceManager;
    207190      using (new PerformanceLogger("UpdateTask")) {
    208191        var taskDao = pm.TaskDao;
     
    218201      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    219202      AuthorizationManager.AuthorizeForTask(taskDto.Id, Permission.Full);
    220       using (var pm = PersistenceManager)
     203      var pm = PersistenceManager;
    221204      using (new PerformanceLogger("UpdateTaskData")) {
    222205        var taskDao = pm.TaskDao;
     
    233216    }
    234217
    235     public void DeleteTask(Guid taskId) {
    236       // unused
    237       throw new NotImplementedException();
    238     }
    239 
    240     public void DeleteChildTasks(Guid parentTaskId) {
    241       // unused
    242       throw new NotImplementedException();
    243     }
    244 
    245218    public DT.Task UpdateTaskState(Guid taskId, DT.TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
    246219      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    247220      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
    248       using (var pm = PersistenceManager)
     221      var pm = PersistenceManager;
    249222      using (new PerformanceLogger("UpdateTaskState")) {
    250223        var taskDao = pm.TaskDao;
    251         var stateLogDao = pm.StateLogDao;
    252224        return pm.UseTransaction(() => {
    253225          var task = taskDao.GetById(taskId);
     
    264236      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    265237      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
    266       using (var pm = PersistenceManager)
     238      var pm = PersistenceManager;
    267239      using (new PerformanceLogger("StopTask")) {
    268240        var taskDao = pm.TaskDao;
     
    284256      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    285257      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
    286       using (var pm = PersistenceManager)
     258      var pm = PersistenceManager;
    287259      using (new PerformanceLogger("PauseTask")) {
    288260        var taskDao = pm.TaskDao;
     
    301273      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    302274      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
    303       using (var pm = PersistenceManager)
     275      var pm = PersistenceManager;
    304276      using (new PerformanceLogger("RestartTask")) {
    305277        var taskDao = pm.TaskDao;
     
    318290      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    319291      AuthorizationManager.AuthorizeForJob(id, DT.Permission.Read);
    320       using (var pm = PersistenceManager)
     292      var pm = PersistenceManager;
    321293      using (new PerformanceLogger("GetJob")) {
    322294        var jobDao = pm.JobDao;
     
    354326    public IEnumerable<DT.Job> GetJobs() {
    355327      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    356       using (var pm = PersistenceManager)
     328      var pm = PersistenceManager;
    357329      using (new PerformanceLogger("GetJobs")) {
    358330        var jobDao = pm.JobDao;
     
    377349              .ToList();
    378350          foreach (var job in jobs) {
    379             // TODO: improve performance of authorization (batch authorization)
    380             AuthorizationManager.AuthorizeForJob(job.Id, DT.Permission.Read);
    381351            var statistic = statistics.FirstOrDefault(x => x.Key == job.Id);
    382352            if (statistic != null) {
     
    398368    }
    399369
    400     public IEnumerable<DT.Job> GetAllJobs() {
    401       // unused
    402       throw new NotImplementedException();
    403     }
    404 
    405370    public Guid AddJob(DT.Job jobDto) {
    406371      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    407       using (var pm = PersistenceManager)
     372      var pm = PersistenceManager;
    408373      using (new PerformanceLogger("AddJob")) {
    409374        var jobDao = pm.JobDao;
     
    428393      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    429394      AuthorizationManager.AuthorizeForJob(jobDto.Id, DT.Permission.Full);
    430       using (var pm = PersistenceManager)
     395      var pm = PersistenceManager;
    431396      using (new PerformanceLogger("UpdateJob")) {
    432397        bool exists = true;
     
    450415      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    451416      AuthorizationManager.AuthorizeForJob(jobId, DT.Permission.Full);
    452       using (var pm = PersistenceManager)
     417      var pm = PersistenceManager;
    453418      using (new PerformanceLogger("DeleteJob")) {
    454419        var jobDao = pm.JobDao;
     
    466431      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    467432      AuthorizationManager.AuthorizeForJob(jobId, Permission.Full);
    468       using (var pm = PersistenceManager)
     433      var pm = PersistenceManager;
    469434      using (new PerformanceLogger("GrantPermission")) {
    470435        var jobPermissionDao = pm.JobPermissionDao;
     
    480445      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    481446      AuthorizationManager.AuthorizeForJob(jobId, Permission.Full);
    482       using (var pm = PersistenceManager)
     447      var pm = PersistenceManager;
    483448      using (new PerformanceLogger("RevokePermission")) {
    484449        var jobPermissionDao = pm.JobPermissionDao;
     
    494459      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    495460      AuthorizationManager.AuthorizeForJob(jobId, Permission.Full);
    496       using (var pm = PersistenceManager)
     461      var pm = PersistenceManager;
    497462      using (new PerformanceLogger("GetJobPermissions")) {
    498463        var jobPermissionDao = pm.JobPermissionDao;
     
    516481        slaveInfo.OwnerUserId = UserManager.CurrentUserId;
    517482      }
    518       using (var pm = PersistenceManager)
     483      var pm = PersistenceManager;
    519484      using (new PerformanceLogger("Hello")) {
    520485        var slaveDao = pm.SlaveDao;
     
    539504    public void GoodBye(Guid slaveId) {
    540505      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
    541       using (var pm = PersistenceManager)
     506      var pm = PersistenceManager;
    542507      using (new PerformanceLogger("GoodBye")) {
    543508        var slaveDao = pm.SlaveDao;
     
    575540    public DT.Plugin GetPlugin(Guid pluginId) {
    576541      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    577       using (var pm = PersistenceManager)
     542      var pm = PersistenceManager;
    578543      using (new PerformanceLogger("GetPlugin")) {
    579544        var pluginDao = pm.PluginDao;
     
    582547    }
    583548
    584     public DT.Plugin GetPluginByHash(byte[] hash) {
    585       // unused
    586       throw new NotImplementedException();
    587     }
    588 
    589549    public Guid AddPlugin(DT.Plugin plugin, List<DT.PluginData> pluginData) {
    590550      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    591       using (var pm = PersistenceManager)
     551      var pm = PersistenceManager;
    592552      using (new PerformanceLogger("AddPlugin")) {
    593553        var pluginDao = pm.PluginDao;
     
    613573    public IEnumerable<DT.Plugin> GetPlugins() {
    614574      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    615       using (var pm = PersistenceManager)
     575      var pm = PersistenceManager;
    616576      using (new PerformanceLogger("GetPlugins")) {
    617577        var pluginDao = pm.PluginDao;
     
    626586    public IEnumerable<DT.PluginData> GetPluginDatas(List<Guid> pluginIds) {
    627587      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    628       using (var pm = PersistenceManager)
     588      var pm = PersistenceManager;
    629589      using (new PerformanceLogger("GetPluginDatas")) {
    630590        var pluginDataDao = pm.PluginDataDao;
     
    636596      }
    637597    }
    638 
    639     public void DeletePlugin(Guid pluginId) {
    640       // unused
    641       throw new NotImplementedException();
    642     }
    643598    #endregion
    644599
     
    646601    public void GrantResourcePermissions(Guid resourceId, Guid[] grantedUserIds) {
    647602      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    648       using (var pm = PersistenceManager)
     603      var pm = PersistenceManager;
    649604      using (new PerformanceLogger("GrantResourcePermissions")) {
    650605        pm.UseTransaction(() => {
     
    666621    public void RevokeResourcePermissions(Guid resourceId, Guid[] grantedUserIds) {
    667622      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    668       using (var pm = PersistenceManager)
     623      var pm = PersistenceManager;
    669624      using (new PerformanceLogger("RevokeResourcePermissions")) {
    670625        var resourcePermissionDao = pm.ResourcePermissionDao;
     
    678633    public IEnumerable<DT.ResourcePermission> GetResourcePermissions(Guid resourceId) {
    679634      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    680       using (var pm = PersistenceManager)
     635      var pm = PersistenceManager;
    681636      using (new PerformanceLogger("GetResourcePermissions")) {
    682637        var resourcePermissionDao = pm.ResourcePermissionDao;
     
    689644    #endregion
    690645
    691     #region Resource Methods
    692     public IEnumerable<DT.Resource> GetChildResources(Guid resourceId) {
    693       // unused
    694       throw new NotImplementedException();
    695     }
    696     #endregion
    697 
    698646    #region Slave Methods
    699647    public Guid AddSlave(DT.Slave slaveDto) {
    700648      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
    701       using (var pm = PersistenceManager)
     649      var pm = PersistenceManager;
    702650      using (new PerformanceLogger("AddSlave")) {
    703651        var slaveDao = pm.SlaveDao;
     
    712660    public Guid AddSlaveGroup(DT.SlaveGroup slaveGroupDto) {
    713661      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    714       using (var pm = PersistenceManager)
     662      var pm = PersistenceManager;
    715663      using (new PerformanceLogger("AddSlaveGroup")) {
    716664        var slaveGroupDao = pm.SlaveGroupDao;
     
    728676    public DT.Slave GetSlave(Guid slaveId) {
    729677      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
    730       using (var pm = PersistenceManager)
     678      var pm = PersistenceManager;
    731679      using (new PerformanceLogger("GetSlave")) {
    732680        var slaveDao = pm.SlaveDao;
     
    735683    }
    736684
    737     public DT.SlaveGroup GetSlaveGroup(Guid slaveGroupId) {
    738       // unused
    739       throw new NotImplementedException();
    740     }
    741 
    742685    public IEnumerable<DT.Slave> GetSlaves() {
    743686      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    744687      bool isAdministrator = RoleVerifier.IsInRole(HiveRoles.Administrator);
    745       using (var pm = PersistenceManager)
     688      var pm = PersistenceManager;
    746689      using (new PerformanceLogger("GetSlaves")) {
    747690        var slaveDao = pm.SlaveDao;
     
    768711      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    769712      bool isAdministrator = RoleVerifier.IsInRole(HiveRoles.Administrator);
    770       using (var pm = PersistenceManager)
     713      var pm = PersistenceManager;
    771714      using (new PerformanceLogger("GetSlaveGroups")) {
    772715        var slaveGroupDao = pm.SlaveGroupDao;
     
    792735    public void UpdateSlave(DT.Slave slaveDto) {
    793736      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    794       using (var pm = PersistenceManager)
     737      var pm = PersistenceManager;
    795738      using (new PerformanceLogger("UpdateSlave")) {
    796739        var slaveDao = pm.SlaveDao;
     
    809752    public void UpdateSlaveGroup(DT.SlaveGroup slaveGroupDto) {
    810753      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    811       using (var pm = PersistenceManager)
     754      var pm = PersistenceManager;
    812755      using (new PerformanceLogger("UpdateSlaveGroup")) {
    813756        var slaveGroupDao = pm.SlaveGroupDao;
     
    827770      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    828771      AuthorizationManager.AuthorizeForResourceAdministration(slaveId);
    829       using (var pm = PersistenceManager)
     772      var pm = PersistenceManager;
    830773      using (new PerformanceLogger("DeleteSlave")) {
    831774        var slaveDao = pm.SlaveDao;
     
    839782      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    840783      AuthorizationManager.AuthorizeForResourceAdministration(slaveGroupId);
    841       using (var pm = PersistenceManager)
     784      var pm = PersistenceManager;
    842785      using (new PerformanceLogger("DeleteSlaveGroup")) {
    843786        var slaveGroupDao = pm.SlaveGroupDao;
     
    850793    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
    851794      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
    852       using (var pm = PersistenceManager)
     795      var pm = PersistenceManager;
    853796      using (new PerformanceLogger("AddResourceToGroup")) {
    854797        var resourceDao = pm.ResourceDao;
     
    863806    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
    864807      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
    865       using (var pm = PersistenceManager)
     808      var pm = PersistenceManager;
    866809      using (new PerformanceLogger("RemoveResourceFromGroup")) {
    867810        var resourceDao = pm.ResourceDao;
     
    876819    public Guid GetResourceId(string resourceName) {
    877820      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    878       using (var pm = PersistenceManager)
     821      var pm = PersistenceManager;
    879822      using (new PerformanceLogger("GetResourceId")) {
    880823        var resourceDao = pm.ResourceDao;
     
    886829    }
    887830
    888     public IEnumerable<DT.Task> GetTasksByResourceId(Guid resourceId) {
    889       // unused
    890       throw new NotImplementedException();
    891     }
    892 
    893831    public void TriggerEventManager(bool force) {
    894       RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Slave);
     832      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
    895833      // use a serializable transaction here to ensure not two threads execute this simultaniously (mutex-lock would not work since IIS may use multiple AppDomains)
    896834      bool cleanup;
    897       using (var pm = PersistenceManager)
     835      var pm = PersistenceManager;
    898836      using (new PerformanceLogger("TriggerEventManager")) {
    899837        cleanup = false;
     
    916854    public int GetNewHeartbeatInterval(Guid slaveId) {
    917855      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
    918       using (var pm = PersistenceManager)
     856      var pm = PersistenceManager;
    919857      using (new PerformanceLogger("GetNewHeartbeatInterval")) {
    920858        var slaveDao = pm.SlaveDao;
     
    934872      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    935873      AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId);
    936       using (var pm = PersistenceManager)
     874      var pm = PersistenceManager;
    937875      using (new PerformanceLogger("AddDowntime")) {
    938876        var downtimeDao = pm.DowntimeDao;
     
    947885    public void DeleteDowntime(Guid downtimeId) {
    948886      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    949       using (var pm = PersistenceManager)
     887      var pm = PersistenceManager;
    950888      using (new PerformanceLogger("DeleteDowntime")) {
    951889        var downtimeDao = pm.DowntimeDao;
     
    960898      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    961899      AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId);
    962       using (var pm = PersistenceManager)
     900      var pm = PersistenceManager;
    963901      using (new PerformanceLogger("UpdateDowntime")) {
    964902        var downtimeDao = pm.DowntimeDao;
     
    977915    public IEnumerable<DT.Downtime> GetDowntimesForResource(Guid resourceId) {
    978916      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    979       using (var pm = PersistenceManager)
     917      var pm = PersistenceManager;
    980918      using (new PerformanceLogger("GetDowntimesForResource")) {
    981919        var downtimeDao = pm.DowntimeDao;
     
    1004942    #region UserPriorities Methods
    1005943    public IEnumerable<DT.UserPriority> GetUserPriorities() {
    1006       using (var pm = PersistenceManager)
     944      var pm = PersistenceManager;
    1007945      using (new PerformanceLogger("GetUserPriorities")) {
    1008946        var userPriorityDao = pm.UserPriorityDao;
     
    1024962        task.Command = null;
    1025963      } else if (taskStateEntity == DA.TaskState.Paused && task.Command != null) {
     964        // slave paused and uploaded the task (no user-command) -> set waiting.
    1026965        taskStateEntity = DA.TaskState.Waiting;
    1027966      }
     
    1047986      return resource;
    1048987    }
    1049 
    1050     [MethodImpl(MethodImplOptions.NoInlining)]
    1051     public string GetCurrentMethod() {
    1052       StackTrace st = new StackTrace();
    1053       StackFrame sf = st.GetFrame(1);
    1054       return sf.GetMethod().Name;
    1055     }
    1056988    #endregion
    1057989  }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/PerformanceLogger.cs

    r12691 r12857  
    3232    public PerformanceLogger(string name) {
    3333      this.name = name;
    34       stopwatch = new Stopwatch();
    35       stopwatch.Start();
     34      if (Properties.Settings.Default.ProfileServicePerformance) {
     35        stopwatch = new Stopwatch();
     36        stopwatch.Start();
     37      }
    3638    }
    3739    public void Dispose() {
    38       stopwatch.Stop();
    39       LogFactory.GetLogger(this.GetType().Namespace).Log(string.Format("{0} took {1}ms", name, stopwatch.ElapsedMilliseconds));
     40      if (Properties.Settings.Default.ProfileServicePerformance) {
     41        stopwatch.Stop();
     42        LogFactory.GetLogger(this.GetType().Namespace)
     43          .Log(string.Format("{0} took {1}ms", name, stopwatch.ElapsedMilliseconds));
     44      }
    4045    }
    4146  }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Properties/Settings.Designer.cs

    r12477 r12857  
    11//------------------------------------------------------------------------------
    22// <auto-generated>
    3 //     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.34014
     3//     Dieser Code wurde von einem Tool generiert.
     4//     Laufzeitversion:4.0.30319.42000
    55//
    6 //     Changes to this file may cause incorrect behavior and will be lost if
    7 //     the code is regenerated.
     6//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
     7//     der Code erneut generiert wird.
    88// </auto-generated>
    99//------------------------------------------------------------------------------
    1010
    1111namespace HeuristicLab.Services.Hive.Properties {
    12 
    13 
    14   [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    15   [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
    16   public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
    17 
    18     private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
    19 
    20     public static Settings Default {
    21       get {
    22         return defaultInstance;
    23       }
     12   
     13   
     14    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     15    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
     16    public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
     17       
     18        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
     19       
     20        public static Settings Default {
     21            get {
     22                return defaultInstance;
     23            }
     24        }
     25       
     26        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     27        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     28        [global::System.Configuration.DefaultSettingValueAttribute("00:03:00")]
     29        public global::System.TimeSpan SlaveHeartbeatTimeout {
     30            get {
     31                return ((global::System.TimeSpan)(this["SlaveHeartbeatTimeout"]));
     32            }
     33        }
     34       
     35        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     36        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     37        [global::System.Configuration.DefaultSettingValueAttribute("00:05:30")]
     38        public global::System.TimeSpan CalculatingJobHeartbeatTimeout {
     39            get {
     40                return ((global::System.TimeSpan)(this["CalculatingJobHeartbeatTimeout"]));
     41            }
     42        }
     43       
     44        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     45        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     46        [global::System.Configuration.DefaultSettingValueAttribute("00:15:00")]
     47        public global::System.TimeSpan TransferringJobHeartbeatTimeout {
     48            get {
     49                return ((global::System.TimeSpan)(this["TransferringJobHeartbeatTimeout"]));
     50            }
     51        }
     52       
     53        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     54        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     55        [global::System.Configuration.DefaultSettingValueAttribute("False")]
     56        public bool TriggerEventManagerInHeartbeat {
     57            get {
     58                return ((bool)(this["TriggerEventManagerInHeartbeat"]));
     59            }
     60        }
     61       
     62        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     63        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     64        [global::System.Configuration.DefaultSettingValueAttribute("00:03:00")]
     65        public global::System.TimeSpan CleanupInterval {
     66            get {
     67                return ((global::System.TimeSpan)(this["CleanupInterval"]));
     68            }
     69        }
     70       
     71        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     72        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     73        [global::System.Configuration.DefaultSettingValueAttribute("3.00:00:00")]
     74        public global::System.TimeSpan SweepInterval {
     75            get {
     76                return ((global::System.TimeSpan)(this["SweepInterval"]));
     77            }
     78        }
     79       
     80        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     81        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     82        [global::System.Configuration.DefaultSettingValueAttribute("00:00:20")]
     83        public global::System.TimeSpan SchedulingPatience {
     84            get {
     85                return ((global::System.TimeSpan)(this["SchedulingPatience"]));
     86            }
     87        }
     88       
     89        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     90        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     91        [global::System.Configuration.DefaultSettingValueAttribute("True")]
     92        public bool ProfileServicePerformance {
     93            get {
     94                return ((bool)(this["ProfileServicePerformance"]));
     95            }
     96        }
     97       
     98        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     99        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     100        [global::System.Configuration.DefaultSettingValueAttribute("00:03:00")]
     101        public global::System.TimeSpan GenerateStatisticsInterval {
     102            get {
     103                return ((global::System.TimeSpan)(this["GenerateStatisticsInterval"]));
     104            }
     105        }
    24106    }
    25 
    26     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    27     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    28     [global::System.Configuration.DefaultSettingValueAttribute("00:03:00")]
    29     public global::System.TimeSpan SlaveHeartbeatTimeout {
    30       get {
    31         return ((global::System.TimeSpan)(this["SlaveHeartbeatTimeout"]));
    32       }
    33     }
    34 
    35     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    36     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    37     [global::System.Configuration.DefaultSettingValueAttribute("00:05:30")]
    38     public global::System.TimeSpan CalculatingJobHeartbeatTimeout {
    39       get {
    40         return ((global::System.TimeSpan)(this["CalculatingJobHeartbeatTimeout"]));
    41       }
    42     }
    43 
    44     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    45     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    46     [global::System.Configuration.DefaultSettingValueAttribute("00:15:00")]
    47     public global::System.TimeSpan TransferringJobHeartbeatTimeout {
    48       get {
    49         return ((global::System.TimeSpan)(this["TransferringJobHeartbeatTimeout"]));
    50       }
    51     }
    52 
    53     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    54     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    55     [global::System.Configuration.DefaultSettingValueAttribute("False")]
    56     public bool TriggerEventManagerInHeartbeat {
    57       get {
    58         return ((bool)(this["TriggerEventManagerInHeartbeat"]));
    59       }
    60     }
    61 
    62     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    63     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    64     [global::System.Configuration.DefaultSettingValueAttribute("00:03:00")]
    65     public global::System.TimeSpan CleanupInterval {
    66       get {
    67         return ((global::System.TimeSpan)(this["CleanupInterval"]));
    68       }
    69     }
    70 
    71     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    72     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    73     [global::System.Configuration.DefaultSettingValueAttribute("3.00:00:00")]
    74     public global::System.TimeSpan SweepInterval {
    75       get {
    76         return ((global::System.TimeSpan)(this["SweepInterval"]));
    77       }
    78     }
    79 
    80     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    81     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    82     [global::System.Configuration.DefaultSettingValueAttribute("00:00:20")]
    83     public global::System.TimeSpan SchedulingPatience {
    84       get {
    85         return ((global::System.TimeSpan)(this["SchedulingPatience"]));
    86       }
    87     }
    88 
    89     [global::System.Configuration.ApplicationScopedSettingAttribute()]
    90     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    91     [global::System.Configuration.DefaultSettingValueAttribute("00:01:00")]
    92     public global::System.TimeSpan GenerateStatisticsInterval {
    93       get {
    94         return ((global::System.TimeSpan)(this["GenerateStatisticsInterval"]));
    95       }
    96     }
    97   }
    98107}
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Properties/Settings.settings

    r9123 r12857  
    2424      <Value Profile="(Default)">00:00:20</Value>
    2525    </Setting>
     26    <Setting Name="ProfileServicePerformance" Type="System.Boolean" Scope="Application">
     27      <Value Profile="(Default)">True</Value>
     28    </Setting>
     29    <Setting Name="GenerateStatisticsInterval" Type="System.TimeSpan" Scope="Application">
     30      <Value Profile="(Default)">00:03:00</Value>
     31    </Setting>
    2632  </Settings>
    2733</SettingsFile>
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r12768 r12857  
    4141
    4242    [OperationContract]
    43     IEnumerable<Task> GetTasks();
    44 
    45     [OperationContract]
    46     IEnumerable<LightweightTask> GetLightweightTasks(IEnumerable<Guid> taskIds);
    47 
    48     [OperationContract]
    49     IEnumerable<LightweightTask> GetLightweightChildTasks(Guid? parentTaskId, bool recursive, bool includeParent);
    50 
    51     [OperationContract]
    5243    IEnumerable<LightweightTask> GetLightweightJobTasks(Guid jobId);
    5344
     
    6556
    6657    [OperationContract]
    67     void DeleteTask(Guid taskId);
    68 
    69     [OperationContract]
    70     void DeleteChildTasks(Guid parentTaskId);
    71 
    72     [OperationContract]
    7358    Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception);
    7459    #endregion
     
    8974    Job GetJob(Guid id);
    9075
    91     /// <summary>
    92     /// Returns all task for the current user
    93     /// </summary>
    9476    [OperationContract]
    9577    IEnumerable<Job> GetJobs();
    9678
    97     /// <summary>
    98     /// Returns all task in the hive (only for admins)
    99     /// </summary>
    100     /// <returns></returns>
    101     [OperationContract]
    102     IEnumerable<Job> GetAllJobs();
    103 
    10479    [OperationContract]
    10580    Guid AddJob(Job jobDto);
     
    142117    [OperationContract]
    143118    Plugin GetPlugin(Guid pluginId);
    144 
    145     [OperationContract]
    146     Plugin GetPluginByHash(byte[] hash);
    147119
    148120    [OperationContract]
     
    155127    [OperationContract]
    156128    IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds);
    157 
    158     [OperationContract]
    159     void DeletePlugin(Guid pluginId);
    160129    #endregion
    161130
     
    171140    #endregion
    172141
    173     #region Resource Methods
    174     [OperationContract]
    175     IEnumerable<Resource> GetChildResources(Guid resourceId);
    176     #endregion
    177 
    178142    #region Slave Methods
    179143    [OperationContract]
     
    187151
    188152    [OperationContract]
    189     SlaveGroup GetSlaveGroup(Guid slaveGroupId);
    190 
    191     [OperationContract]
    192153    IEnumerable<Slave> GetSlaves();
    193154
     
    215176    [OperationContract]
    216177    Guid GetResourceId(string resourceName);
    217 
    218     [OperationContract]
    219     IEnumerable<Task> GetTasksByResourceId(Guid resourceId);
    220178
    221179    [OperationContract]
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs

    r12789 r12857  
    131131      }
    132132    }
     133
    133134    private ITaskScheduler newtaskScheduler;
    134135    public ITaskScheduler NewTaskScheduler {
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/app.config

    r11623 r12857  
    2929                <value>00:00:20</value>
    3030            </setting>
     31            <setting name="ProfileServicePerformance" serializeAs="String">
     32                <value>True</value>
     33            </setting>
     34            <setting name="GenerateStatisticsInterval" serializeAs="String">
     35                <value>00:03:00</value>
     36            </setting>
    3137        </HeuristicLab.Services.Hive.Properties.Settings>
    3238    </applicationSettings>
    33 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
     39<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
     40</configuration>
Note: See TracChangeset for help on using the changeset viewer.