- Timestamp:
- 04/23/13 10:37:45 (12 years ago)
- Location:
- branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3
- Property svn:ignore
-
old new 2 2 bin 3 3 obj 4 *.user
-
- Property svn:ignore
-
branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs
r8051 r9391 36 36 if (ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks 37 37 38 Permission permission = ServiceLocator.Instance.HiveD ao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId);38 Permission permission = ServiceLocator.Instance.HiveDtoDao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId); 39 39 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 40 40 throw new SecurityException("Current user is not authorized to access task"); … … 42 42 43 43 public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) { 44 Permission permission = ServiceLocator.Instance.HiveD ao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId);44 Permission permission = ServiceLocator.Instance.HiveDtoDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId); 45 45 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 46 46 throw new SecurityException("Current user is not authorized to access task"); … … 48 48 49 49 public void AuthorizeForResourceAdministration(Guid resourceId) { 50 Resource resource = DT.Convert.ToEntity(ServiceLocator.Instance.HiveD ao.GetResource(resourceId));50 Resource resource = DT.Convert.ToEntity(ServiceLocator.Instance.HiveDtoDao.GetResource(resourceId)); 51 51 if (resource.OwnerUserId != ServiceLocator.Instance.UserManager.CurrentUserId && !ServiceLocator.Instance.RoleVerifier.IsInRole(HiveRoles.Administrator)) 52 52 throw new SecurityException("Current user is not authorized to access resource"); -
branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs
r9257 r9391 32 32 /// </summary> 33 33 public class EventManager : IEventManager { 34 private IHiveD ao dao {35 get { return ServiceLocator.Instance.HiveD ao; }34 private IHiveDtoDao dao { 35 get { return ServiceLocator.Instance.HiveDtoDao; } 36 36 } 37 37 private IAuthorizationManager auth { … … 78 78 //we have to find another way to deal with this. 79 79 //until then the next line is commented out... 80 //stats.UserStatistics = d ao.GetUserStatistics();80 //stats.UserStatistics = dtoDao.GetUserStatistics(); 81 81 dao.AddStatistics(stats); 82 82 } -
branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r9385 r9391 24 24 using System.Linq; 25 25 using System.Threading; 26 using HeuristicLab.Services.Hive.Data Transfer;27 using DA = HeuristicLab.Services.Hive.DataAccess;26 using HeuristicLab.Services.Hive.DataAccess; 27 using Heartbeat = HeuristicLab.Services.Hive.DataTransfer.Heartbeat; 28 28 29 29 namespace HeuristicLab.Services.Hive { … … 48 48 List<MessageContainer> actions = new List<MessageContainer>(); 49 49 50 DA.Slave slave = null;50 Slave slave = null; 51 51 trans.UseTransaction(() => { 52 slave = dao.GetSlave DA(heartbeat.SlaveId);52 slave = dao.GetSlaveById(heartbeat.SlaveId); 53 53 54 54 if (slave == null) { … … 67 67 slave.CpuUtilization = heartbeat.CpuUtilization; 68 68 slave.IsAllowedToCalculate = SlaveIsAllowedToCalculate(slave.ResourceId); 69 slave.SlaveState = (heartbeat.JobProgress != null && heartbeat.JobProgress.Count > 0) ? DA.SlaveState.Calculating : DA.SlaveState.Idle;69 slave.SlaveState = (heartbeat.JobProgress != null && heartbeat.JobProgress.Count > 0) ? SlaveState.Calculating : SlaveState.Idle; 70 70 slave.LastHeartbeat = DateTime.Now; 71 71 72 dao.UpdateSlave DA(slave);72 dao.UpdateSlave(slave); 73 73 } 74 74 }); … … 86 86 mutexAquired = mutex.WaitOne(Properties.Settings.Default.SchedulingPatience); 87 87 if (!mutexAquired) 88 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling could not be aquired.");88 LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling could not be aquired."); 89 89 else { 90 90 trans.UseTransaction(() => { 91 91 IEnumerable<TaskInfoForScheduler> availableTasks = null; 92 availableTasks = taskScheduler.Schedule(dao.GetWaitingTasks DA(slave).ToArray());92 availableTasks = taskScheduler.Schedule(dao.GetWaitingTasks(slave).ToArray()); 93 93 if (availableTasks.Any()) { 94 94 var task = availableTasks.First(); … … 100 100 } 101 101 catch (AbandonedMutexException) { 102 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling has been abandoned.");102 LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling has been abandoned."); 103 103 } 104 104 catch (Exception ex) { 105 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager threw an exception in ProcessHeartbeat: " + ex.ToString());105 LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager threw an exception in ProcessHeartbeat: " + ex.ToString()); 106 106 } 107 107 finally { … … 113 113 } 114 114 115 private void AssignJob( DA.Slave slave, Guid taskId) {116 var task = dao.UpdateTaskState DA(taskId, DataAccess.TaskState.Transferring, slave.ResourceId, null, null);115 private void AssignJob(Slave slave, Guid taskId) { 116 var task = dao.UpdateTaskState(taskId, DataAccess.TaskState.Transferring, slave.ResourceId, null, null); 117 117 118 118 // from now on the task has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout) 119 119 task.LastHeartbeat = DateTime.Now; 120 dao.UpdateTask DA(task);120 dao.UpdateTask(task); 121 121 } 122 122 … … 137 137 foreach (var jobProgress in heartbeat.JobProgress) { 138 138 trans.UseTransaction(() => { 139 var curTask = dao.GetTask DA(jobProgress.Key);139 var curTask = dao.GetTaskById(jobProgress.Key); 140 140 if (curTask == null) { 141 141 // task does not exist in db 142 142 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, jobProgress.Key)); 143 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("Task on slave " + heartbeat.SlaveId + " does not exist in DB: " + jobProgress.Key);143 LogFactory.GetLogger(this.GetType().Namespace).Log("Task on slave " + heartbeat.SlaveId + " does not exist in DB: " + jobProgress.Key); 144 144 } else { 145 145 var currentStateLog = curTask.StateLogs.Last(); … … 147 147 // assigned slave does not match heartbeat 148 148 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curTask.TaskId)); 149 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate task: " + curTask);149 LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate task: " + curTask); 150 150 } else if (!TaskIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curTask)) { 151 151 // assigned resources ids of task do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group … … 157 157 158 158 switch (curTask.Command) { 159 case DA.Command.Stop:159 case Command.Stop: 160 160 actions.Add(new MessageContainer(MessageContainer.MessageType.StopTask, curTask.TaskId)); 161 161 break; 162 case DA.Command.Pause:162 case Command.Pause: 163 163 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseTask, curTask.TaskId)); 164 164 break; 165 case DA.Command.Abort:165 case Command.Abort: 166 166 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curTask.TaskId)); 167 167 break; 168 168 } 169 dao.UpdateTask DA(curTask);169 dao.UpdateTask(curTask); 170 170 } 171 171 } … … 176 176 } 177 177 178 private bool TaskIsAllowedToBeCalculatedBySlave(Guid slaveId, DA.Task curTask) {179 var assignedResourceIds = dao.GetAssignedResourcesIds DA(curTask.TaskId);180 var slaveResourceIds = dao.GetParentResourcesIDs DA(slaveId).ToArray();178 private bool TaskIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curTask) { 179 var assignedResourceIds = dao.GetAssignedResourcesIds(curTask.TaskId); 180 var slaveResourceIds = dao.GetParentResourcesIDs(slaveId).ToArray(); 181 181 return assignedResourceIds.Any(r => slaveResourceIds.Contains(r)); 182 182 } 183 183 184 184 private bool SlaveIsAllowedToCalculate(Guid slaveId) { 185 var downtimes = dao.GetNumberOfDowntimesFromParentResourcesAtCurrentTime DA(slaveId, DA.DowntimeType.Offline);185 var downtimes = dao.GetNumberOfDowntimesFromParentResourcesAtCurrentTime(slaveId, DowntimeType.Offline); 186 186 // the slave may only calculate if there is no downtime right now. this needs to be checked for every parent resource also 187 187 return downtimes.All(x => x == 0); … … 189 189 190 190 private bool ShutdownSlaveComputer(Guid slaveId) { 191 var downtimes = dao.GetNumberOfDowntimesFromParentResourcesAtCurrentTime DA(slaveId, DA.DowntimeType.Shutdown);191 var downtimes = dao.GetNumberOfDowntimesFromParentResourcesAtCurrentTime(slaveId, DowntimeType.Shutdown); 192 192 return downtimes.Any(x => x != 0); 193 193 }
Note: See TracChangeset
for help on using the changeset viewer.