- Timestamp:
- 02/17/11 14:47:56 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/AuthorizationManager.cs
r5264 r5511 21 21 22 22 using System; 23 using System.Linq;24 23 using System.Security; 25 24 using System.Web.Security; … … 35 34 } 36 35 37 public void AuthorizeJobs(params Guid[] jobIds) {38 if (!IsAuthorizedForJobs(jobIds)) {39 throw new SecurityException("User '" + Identity.UserName + "' is not authorized to access job (Id: " + string.Join(", ", jobIds.Select(x => x.ToString()).ToArray()) + ")");40 }41 }36 //public void AuthorizeJobs(params Guid[] jobIds) { 37 // if (!IsAuthorizedForJobs(jobIds)) { 38 // throw new SecurityException("User '" + Identity.UserName + "' is not authorized to access job (Id: " + string.Join(", ", jobIds.Select(x => x.ToString()).ToArray()) + ")"); 39 // } 40 //} 42 41 43 private bool IsAuthorizedForJobs(params Guid[] jobIds) {44 return ServiceLocator.Instance.HiveDao.IsUserAuthorizedForJobs(UserId, jobIds);45 }42 //private bool IsAuthorizedForJobs(params Guid[] jobIds) { 43 // return ServiceLocator.Instance.HiveDao.IsUserAuthorizedForJobs(UserId, jobIds); 44 //} 46 45 47 46 public void Authorize(Guid userId) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs
r5405 r5511 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Text;5 4 using HeuristicLab.Services.Hive.Common; 6 5 using HeuristicLab.Services.Hive.Common.DataTransfer; … … 54 53 55 54 private void AssignJob(Slave slave, Job job) { 56 job.SlaveId = slave.Id; 57 job.JobState = JobState.Calculating; // Todo: Maybe use State = Transferring (?) 58 job.DateCalculated = DateTime.Now; // Todo: use statelog instead 55 job.SetState(JobState.Transferring, slave.Id, ""); 59 56 dao.UpdateJob(job); 60 57 dao.UpdateSlave(slave); … … 79 76 Logger.Error("Job does not exist in DB: " + jobProgress.Key); 80 77 } else { 81 if (curJob. SlaveId == Guid.Empty || curJob.SlaveId != heartbeat.SlaveId) {78 if (curJob.CurrentStateLog.SlaveId == Guid.Empty || curJob.CurrentStateLog.SlaveId != heartbeat.SlaveId) { 82 79 // assigned slave does not match heartbeat 83 80 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); … … 88 85 curJob.LastHeartbeat = DateTime.Now; 89 86 90 if (curJob. JobState == JobState.Aborted) {87 if (curJob.State == JobState.Aborted) { 91 88 // a request to abort the job has been set 92 89 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 90 } else if (curJob.State != JobState.Calculating) { 91 // jobstate was 'Transferring' before, now calculating 92 curJob.SetState(JobState.Calculating, heartbeat.SlaveId, ""); 93 93 } 94 94 dao.UpdateJob(curJob); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs
r5458 r5511 33 33 //[PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)] 34 34 //[PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)] 35 public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> slaveGroupIds) { 36 using (trans.OpenTransaction()) { 37 job.UserId = auth.UserId; 38 job.DateCreated = DateTime.Now; 39 job.JobState = JobState.Waiting; 35 public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) { 36 using (trans.OpenTransaction()) { 37 job.SetState(JobState.Waiting, auth.UserId); 40 38 job.Id = dao.AddJob(job); 41 39 jobData.JobId = job.Id; 42 40 jobData.LastUpdate = DateTime.Now; 43 if ( slaveGroupIds != null) {44 foreach (Guid slaveGroupId in slaveGroupIds) {41 if (resourceIds != null) { 42 foreach (Guid slaveGroupId in resourceIds) { 45 43 dao.AssignJobToResource(job.Id, slaveGroupId); 46 44 } … … 80 78 } 81 79 82 public void UpdateJob(Job job, JobData jobData) { 80 public void UpdateJob(Job job) { 81 using (trans.OpenTransaction()) { 82 dao.UpdateJob(job); 83 } 84 } 85 86 public void UpdateJobData(Job job, JobData jobData) { 83 87 using (trans.OpenTransaction()) { 84 88 jobData.LastUpdate = DateTime.Now; … … 122 126 123 127 public HiveExperiment GetHiveExperiment(Guid id) { 124 return dao.GetHiveExperiments(x => x.UserId == auth.UserId && x.HiveExperimentId == id).FirstOrDefault(); 128 return dao.GetHiveExperiments(x => 129 x.HiveExperimentId == id 130 && (x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0) 131 ).FirstOrDefault(); 125 132 } 126 133 127 134 public IEnumerable<HiveExperiment> GetHiveExperiments() { 128 return dao.GetHiveExperiments(x => x. UserId == auth.UserId);135 return dao.GetHiveExperiments(x => x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0); 129 136 } 130 137 131 138 public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) { 132 139 using (trans.OpenTransaction()) { 133 hiveExperimentDto. UserId = auth.UserId;140 hiveExperimentDto.OwnerUserId = auth.UserId; 134 141 hiveExperimentDto.DateCreated = DateTime.Now; 135 142 return dao.AddHiveExperiment(hiveExperimentDto); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IAuthorizationManager.cs
r5043 r5511 33 33 /// </summary> 34 34 /// <exception cref="SecurityException">thrown when access denied</exception> 35 void AuthorizeJobs(params Guid[] jobId);35 //void AuthorizeJobs(params Guid[] jobId); 36 36 37 37 /// <summary> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs
r5405 r5511 1 1 using System; 2 using System.Collections.Generic;3 2 using System.Linq; 4 using System.Text; 5 using System.Transactions; 3 using HeuristicLab.Core; 6 4 using HeuristicLab.Services.Hive.Common; 7 5 using HeuristicLab.Services.Hive.Common.DataTransfer; 8 using HeuristicLab.Tracing;9 using HeuristicLab.Core;10 6 11 7 namespace HeuristicLab.Services.Hive { … … 27 23 28 24 // Windows-Forms timer is single threaded, so callbacks will be synchron 29 System.Windows.Forms.Timer timer;25 private System.Windows.Forms.Timer timer; 30 26 31 27 public ExecutionState ExecutionState { … … 40 36 public void Start() { 41 37 if (ExecutionState == Core.ExecutionState.Stopped) { 42 this.timer.Interval = (int)new TimeSpan(0, 0, 10).TotalMilliseconds;38 this.timer.Interval = (int)new TimeSpan(0, 0, 30).TotalMilliseconds; 43 39 this.timer.Start(); 44 40 } … … 71 67 72 68 private void AbortJobs(Guid slaveId) { 73 var jobs = dao.GetJobs(x => x.S lave.ResourceId == slaveId);69 var jobs = dao.GetJobs(x => x.StateLogs.Last().SlaveId == slaveId); 74 70 foreach (var j in jobs) { 75 j.JobState = JobState.Waiting; 71 j.StateLog.Add(new StateLog() { 72 UserId = auth.UserId, 73 State = JobState.Waiting, 74 JobId = j.Id, 75 DateTime = DateTime.Now, 76 Exception = "Slave timed out" 77 }); 76 78 dao.UpdateJob(j); 77 79 }
Note: See TracChangeset
for help on using the changeset viewer.