- Timestamp:
- 09/12/11 18:04:25 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Convert.cs
r6725 r6743 27 27 using DT = HeuristicLab.Services.Hive.DataTransfer; 28 28 29 30 29 namespace HeuristicLab.Services.Hive.DataTransfer { 31 30 public static class Convert { 32 #region Job31 #region Task 33 32 public static DT.Task ToDto(DB.Task source) { 34 33 if (source == null) return null; … … 47 46 FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished, 48 47 Command = Convert.ToDto(source.Command), 49 Last JobDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate),48 LastTaskDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate), 50 49 JobId = source.JobId, 51 50 IsPrivileged = source.IsPrivileged … … 150 149 #endregion 151 150 152 #region HiveExperimentPermission151 #region JobPermission 153 152 public static DT.JobPermission ToDto(DB.JobPermission source) { 154 153 if (source == null) return null; … … 363 362 } 364 363 #endregion 365 366 364 367 365 #region TaskData … … 433 431 #endregion 434 432 435 436 433 #region Command 437 434 public static DT.Command? ToDto(DB.Command? source) { … … 462 459 return null; 463 460 } 464 465 461 #endregion 466 462 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Heartbeat.cs
r6717 r6743 35 35 public int FreeCores { get; set; } 36 36 [DataMember] 37 public Dictionary<Guid, TimeSpan> JobProgress { get; set; } // TODO: define Type37 public Dictionary<Guid, TimeSpan> JobProgress { get; set; } 38 38 [DataMember] 39 public bool AssignJob { get; set; } // if false, the server will not assign a new job39 public bool AssignJob { get; set; } // if false, the server will not assign a new task 40 40 [DataMember] 41 41 public float CpuUtilization { get; set; } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/LightweightTask.cs
r6721 r6743 40 40 public Command? Command { get; set; } 41 41 [DataMember] 42 public DateTime Last JobDataUpdate { get; set; }42 public DateTime LastTaskDataUpdate { get; set; } 43 43 44 44 public StateLog CurrentStateLog { get { return StateLog.LastOrDefault(); } } … … 50 50 } 51 51 52 public LightweightTask(Task job) {53 this.Id = job.Id;54 this.ExecutionTime = job.ExecutionTime;55 this.ParentTaskId = job.ParentTaskId;56 this.StateLog = new List<StateLog>( job.StateLog);57 this.State = job.State;58 this.Command = job.Command;59 this.Last JobDataUpdate = job.LastJobDataUpdate;52 public LightweightTask(Task task) { 53 this.Id = task.Id; 54 this.ExecutionTime = task.ExecutionTime; 55 this.ParentTaskId = task.ParentTaskId; 56 this.StateLog = new List<StateLog>(task.StateLog); 57 this.State = task.State; 58 this.Command = task.Command; 59 this.LastTaskDataUpdate = task.LastTaskDataUpdate; 60 60 } 61 61 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Permission.cs
r6717 r6743 28 28 29 29 /// <summary> 30 /// User can only download and view experiments30 /// User can only download and view jobs 31 31 /// </summary> 32 32 Read, 33 33 34 34 /// <summary> 35 /// User can pause, stop, restart, delete experiment. can also grant other35 /// User can pause, stop, restart, delete job. can also grant other 36 36 /// </summary> 37 37 Full -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/TaskState.cs
r6721 r6743 26 26 public enum TaskState { 27 27 /// <summary> 28 /// A task is offline as long as heis not yet submitted to the hive28 /// A task is offline as long as job is not yet submitted to the hive 29 29 /// </summary> 30 30 Offline, … … 68 68 public static class TaskStateExtensions { 69 69 /// <summary> 70 /// This jobis not yet done70 /// This task is not yet done 71 71 /// </summary> 72 72 public static bool IsActive(this TaskState taskState) { … … 75 75 76 76 /// <summary> 77 /// This jobis Waiting77 /// This task is Waiting 78 78 /// </summary> 79 79 public static bool IsWaiting(this TaskState taskState) { … … 82 82 83 83 /// <summary> 84 /// This jobis Finished || Failed || Aborted84 /// This task is Finished || Failed || Aborted 85 85 /// </summary> 86 86 public static bool IsDone(this TaskState taskState) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj
r6723 r6743 74 74 <Reference Include="HeuristicLab.Common-3.3"> 75 75 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath> 76 </Reference>77 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">78 <SpecificVersion>False</SpecificVersion>79 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath>80 76 </Reference> 81 77 <Reference Include="HeuristicLab.Core-3.3"> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLabServicesHivePlugin.cs.frame
r6717 r6743 29 29 [Plugin("HeuristicLab.Services.Hive", "3.3.5.$WCREV$")] 30 30 [PluginFile("HeuristicLab.Services.Hive-3.3.dll", PluginFileType.Assembly)] 31 [PluginDependency("HeuristicLab.Common", "3.3")] 32 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 31 [PluginDependency("HeuristicLab.Common", "3.3")] 33 32 [PluginDependency("HeuristicLab.Core", "3.3")] 34 33 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs
r6725 r6743 36 36 public HiveDao() { } 37 37 38 #region JobMethods39 public DT.Task Get Job(Guid id) {38 #region Task Methods 39 public DT.Task GetTask(Guid id) { 40 40 using (var db = CreateContext()) { 41 41 return DT.Convert.ToDto(db.Tasks.SingleOrDefault(x => x.TaskId == id)); … … 43 43 } 44 44 45 public IEnumerable<DT.Task> Get Jobs(Expression<Func<Task, bool>> predicate) {45 public IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate) { 46 46 using (var db = CreateContext()) { 47 47 return db.Tasks.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); … … 49 49 } 50 50 51 public Guid Add Job(DT.Task dto) {51 public Guid AddTask(DT.Task dto) { 52 52 using (var db = CreateContext()) { 53 53 var entity = DT.Convert.ToEntity(dto); … … 62 62 } 63 63 64 public void Update Job(DT.Task dto) {64 public void UpdateTask(DT.Task dto) { 65 65 using (var db = CreateContext()) { 66 66 var entity = db.Tasks.FirstOrDefault(x => x.TaskId == dto.Id); … … 76 76 } 77 77 78 public void Delete Job(Guid id) {78 public void DeleteTask(Guid id) { 79 79 using (var db = CreateContext()) { 80 80 var entity = db.Tasks.FirstOrDefault(x => x.TaskId == id); 81 81 if (entity != null) db.Tasks.DeleteOnSubmit(entity); 82 db.SubmitChanges(); // JobData and child jobs are deleted by db-trigger82 db.SubmitChanges(); // taskData and child tasks are deleted by db-trigger 83 83 } 84 84 } 85 85 86 86 /// <summary> 87 /// returns all parent jobs which are waiting for their child jobs to finish87 /// returns all parent tasks which are waiting for their child tasks to finish 88 88 /// </summary> 89 /// <param name="resourceIds">list of resourceids which for which the jobsshould be valid</param>90 /// <param name="count">maximum number of jobsto return</param>91 /// <param name="finished">if true, all parent jobswhich have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>89 /// <param name="resourceIds">list of resourceids which for which the task should be valid</param> 90 /// <param name="count">maximum number of task to return</param> 91 /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param> 92 92 /// <returns></returns> 93 public IEnumerable<DT.Task> GetParent Jobs(IEnumerable<Guid> resourceIds, int count, bool finished) {93 public IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) { 94 94 using (var db = CreateContext()) { 95 95 var query = from ar in db.AssignedResources … … 103 103 || child.State == TaskState.Aborted 104 104 || child.State == TaskState.Failed).All(x => x) 105 && (from child in db.Tasks // avoid returning WaitForChild Jobs jobs where no child-jobsexist (yet)105 && (from child in db.Tasks // avoid returning WaitForChildTasks task where no child-task exist (yet) 106 106 where child.ParentTaskId == ar.Task.TaskId 107 107 select child).Count() > 0 … … 112 112 } 113 113 114 public IEnumerable<DT.Task> GetWaiting Jobs(DT.Slave slave, int count) {114 public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count) { 115 115 using (var db = CreateContext()) { 116 116 var resourceIds = GetParentResources(slave.Id).Select(r => r.Id); 117 var waitingParentJobs = GetParent Jobs(resourceIds, count, false);117 var waitingParentJobs = GetParentTasks(resourceIds, count, false); 118 118 if (count > 0 && waitingParentJobs.Count() >= count) return waitingParentJobs.Take(count).ToArray(); 119 119 … … 124 124 && ar.Task.CoresNeeded <= slave.FreeCores 125 125 && ar.Task.MemoryNeeded <= slave.FreeMemory 126 orderby ar.Task.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same jobwould be returned)126 orderby ar.Task.Priority descending, db.Random() // take random task to avoid the race condition that occurs when this method is called concurrently (the same task would be returned) 127 127 select DT.Convert.ToDto(ar.Task); 128 var waiting Jobs = (count == 0 ? query : query.Take(count)).ToArray();129 return waiting Jobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority);130 } 131 } 132 133 public DT.Task Update JobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {134 using (var db = CreateContext()) { 135 var job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);136 job.State = jobState;128 var waitingTasks = (count == 0 ? query : query.Take(count)).ToArray(); 129 return waitingTasks.Union(waitingParentJobs).OrderByDescending(x => x.Priority); 130 } 131 } 132 133 public DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) { 134 using (var db = CreateContext()) { 135 var job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId); 136 job.State = taskState; 137 137 db.StateLogs.InsertOnSubmit(new StateLog { 138 TaskId = jobId,139 State = jobState,138 TaskId = taskId, 139 State = taskState, 140 140 SlaveId = slaveId, 141 141 UserId = userId, … … 144 144 }); 145 145 db.SubmitChanges(); 146 job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);146 job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId); 147 147 return DT.Convert.ToDto(job); 148 148 } … … 151 151 152 152 #region TaskData Methods 153 public DT.TaskData Get JobData(Guid id) {153 public DT.TaskData GetTaskData(Guid id) { 154 154 using (var db = CreateContext(true)) { 155 155 return DT.Convert.ToDto(db.TaskDatas.SingleOrDefault(x => x.TaskId == id)); … … 157 157 } 158 158 159 public IEnumerable<DT.TaskData> Get JobDatas(Expression<Func<TaskData, bool>> predicate) {159 public IEnumerable<DT.TaskData> GetTaskDatas(Expression<Func<TaskData, bool>> predicate) { 160 160 using (var db = CreateContext(true)) { 161 161 return db.TaskDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); … … 163 163 } 164 164 165 public Guid Add JobData(DT.TaskData dto) {165 public Guid AddTaskData(DT.TaskData dto) { 166 166 using (var db = CreateContext(true)) { 167 167 var entity = DT.Convert.ToEntity(dto); … … 172 172 } 173 173 174 public void Update JobData(DT.TaskData dto) {174 public void UpdateTaskData(DT.TaskData dto) { 175 175 using (var db = CreateContext(true)) { 176 176 var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == dto.TaskId); … … 181 181 } 182 182 183 public void Delete JobData(Guid id) {183 public void DeleteTaskData(Guid id) { 184 184 using (var db = CreateContext()) { 185 185 var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it … … 231 231 232 232 #region Job Methods 233 public DT.Job Get HiveExperiment(Guid id) {233 public DT.Job GetJob(Guid id) { 234 234 using (var db = CreateContext()) { 235 235 return AddStatsToExperiment(db, DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id))); … … 248 248 } 249 249 250 public IEnumerable<DT.Job> Get HiveExperiments(Expression<Func<Job, bool>> predicate) {250 public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) { 251 251 using (var db = CreateContext()) { 252 252 return db.Jobs.Where(predicate).Select(x => AddStatsToExperiment(db, DT.Convert.ToDto(x))).ToArray(); … … 254 254 } 255 255 256 public Guid Add HiveExperiment(DT.Job dto) {256 public Guid AddJob(DT.Job dto) { 257 257 using (var db = CreateContext()) { 258 258 var entity = DT.Convert.ToEntity(dto); … … 263 263 } 264 264 265 public void Update HiveExperiment(DT.Job dto) {265 public void UpdateJob(DT.Job dto) { 266 266 using (var db = CreateContext()) { 267 267 var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id); … … 272 272 } 273 273 274 public void Delete HiveExperiment(Guid id) {274 public void DeleteJob(Guid id) { 275 275 using (var db = CreateContext()) { 276 276 var entity = db.Jobs.FirstOrDefault(x => x.JobId == id); … … 282 282 283 283 #region JobPermission Methods 284 public DT.JobPermission Get HiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {285 using (var db = CreateContext()) { 286 return DT.Convert.ToDto(db.JobPermissions.SingleOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId));287 } 288 } 289 290 public IEnumerable<DT.JobPermission> Get HiveExperimentPermissions(Expression<Func<JobPermission, bool>> predicate) {284 public DT.JobPermission GetJobPermission(Guid jobId, Guid grantedUserId) { 285 using (var db = CreateContext()) { 286 return DT.Convert.ToDto(db.JobPermissions.SingleOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId)); 287 } 288 } 289 290 public IEnumerable<DT.JobPermission> GetJobPermissions(Expression<Func<JobPermission, bool>> predicate) { 291 291 using (var db = CreateContext()) { 292 292 return db.JobPermissions.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); … … 294 294 } 295 295 296 public void Add HiveExperimentPermission(DT.JobPermission dto) {296 public void AddJobPermission(DT.JobPermission dto) { 297 297 using (var db = CreateContext()) { 298 298 var entity = DT.Convert.ToEntity(dto); … … 302 302 } 303 303 304 public void Update HiveExperimentPermission(DT.JobPermission dto) {304 public void UpdateJobPermission(DT.JobPermission dto) { 305 305 using (var db = CreateContext()) { 306 306 var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == dto.JobId && x.GrantedUserId == dto.GrantedUserId); … … 311 311 } 312 312 313 public void Delete HiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {314 using (var db = CreateContext()) { 315 var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId);313 public void DeleteJobPermission(Guid jobId, Guid grantedUserId) { 314 using (var db = CreateContext()) { 315 var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId); 316 316 if (entity != null) db.JobPermissions.DeleteOnSubmit(entity); 317 317 db.SubmitChanges(); … … 322 322 /// Sets the permissions for a experiment. makes sure that only one permission per user exists. 323 323 /// </summary> 324 public void Set HiveExperimentPermission(Guid hiveExperimentId, Guid grantedByUserId, Guid grantedUserId, Permission permission) {325 using (var db = CreateContext()) { 326 JobPermission hiveExperimentPermission = db.JobPermissions.SingleOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId);327 if ( hiveExperimentPermission != null) {324 public void SetJobPermission(Guid jobId, Guid grantedByUserId, Guid grantedUserId, Permission permission) { 325 using (var db = CreateContext()) { 326 JobPermission jobPermission = db.JobPermissions.SingleOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId); 327 if (jobPermission != null) { 328 328 if (permission == Permission.NotAllowed) { 329 329 // not allowed, delete 330 db.JobPermissions.DeleteOnSubmit( hiveExperimentPermission);330 db.JobPermissions.DeleteOnSubmit(jobPermission); 331 331 } else { 332 332 // update 333 hiveExperimentPermission.Permission = permission;334 hiveExperimentPermission.GrantedByUserId = grantedByUserId; // update grantedByUserId, always the last "granter" is stored333 jobPermission.Permission = permission; 334 jobPermission.GrantedByUserId = grantedByUserId; // update grantedByUserId, always the last "granter" is stored 335 335 } 336 336 } else { 337 337 // insert 338 338 if (permission != Permission.NotAllowed) { 339 hiveExperimentPermission = new JobPermission() { JobId = hiveExperimentId, GrantedByUserId = grantedByUserId, GrantedUserId = grantedUserId, Permission = permission };340 db.JobPermissions.InsertOnSubmit( hiveExperimentPermission);339 jobPermission = new JobPermission() { JobId = jobId, GrantedByUserId = grantedByUserId, GrantedUserId = grantedUserId, Permission = permission }; 340 db.JobPermissions.InsertOnSubmit(jobPermission); 341 341 } 342 342 } … … 613 613 614 614 #region Authorization Methods 615 public Permission GetPermissionForTask(Guid taskId, Guid userId) { 616 using (var db = CreateContext()) { 617 return GetPermissionForJob(GetJobForTask(taskId), userId); 618 } 619 } 620 615 621 public Permission GetPermissionForJob(Guid jobId, Guid userId) { 616 622 using (var db = CreateContext()) { 617 return GetPermissionForExperiment(GetExperimentForJob(jobId), userId); 618 } 619 } 620 621 public Permission GetPermissionForExperiment(Guid experimentId, Guid userId) { 622 using (var db = CreateContext()) { 623 Job hiveExperiment = db.Jobs.SingleOrDefault(x => x.JobId == experimentId); 624 if (hiveExperiment == null) return Permission.NotAllowed; 625 if (hiveExperiment.OwnerUserId == userId) return Permission.Full; 626 JobPermission permission = db.JobPermissions.SingleOrDefault(p => p.JobId == experimentId && p.GrantedUserId == userId); 623 Job job = db.Jobs.SingleOrDefault(x => x.JobId == jobId); 624 if (job == null) return Permission.NotAllowed; 625 if (job.OwnerUserId == userId) return Permission.Full; 626 JobPermission permission = db.JobPermissions.SingleOrDefault(p => p.JobId == jobId && p.GrantedUserId == userId); 627 627 return permission != null ? permission.Permission : Permission.NotAllowed; 628 628 } 629 629 } 630 630 631 public Guid Get ExperimentForJob(Guid jobId) {632 using (var db = CreateContext()) { 633 return db.Tasks.Single(j => j.TaskId == jobId).JobId;631 public Guid GetJobForTask(Guid taskId) { 632 using (var db = CreateContext()) { 633 return db.Tasks.Single(j => j.TaskId == taskId).JobId; 634 634 } 635 635 } … … 765 765 } 766 766 767 // execution times only of finished jobs- necessary to compute efficieny767 // execution times only of finished task - necessary to compute efficieny 768 768 var executionTimesFinishedJobs = from job in db.Tasks 769 769 where job.State == TaskState.Finished … … 778 778 } 779 779 780 // start to end times only of finished jobs- necessary to compute efficiency780 // start to end times only of finished task - necessary to compute efficiency 781 781 var startToEndTimesFinishedJobs = from job in db.Tasks 782 782 where job.State == TaskState.Finished … … 817 817 818 818 #region Helpers 819 private void CollectChild Jobs(HiveDataContext db, Guid parentJobId, List<Task> collection) {820 var jobs = db.Tasks.Where(j => j.ParentTaskId == parentJobId);821 foreach (var job in jobs) {822 collection.Add( job);823 if ( job.IsParentTask)824 CollectChild Jobs(db, job.TaskId, collection);819 private void CollectChildTasks(HiveDataContext db, Guid parentTaskId, List<Task> collection) { 820 var tasks = db.Tasks.Where(j => j.ParentTaskId == parentTaskId); 821 foreach (var task in tasks) { 822 collection.Add(task); 823 if (task.IsParentTask) 824 CollectChildTasks(db, task.TaskId, collection); 825 825 } 826 826 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs
r6725 r6743 61 61 62 62 #region Job Methods 63 public Guid Add Job(Task job, TaskData jobData, IEnumerable<Guid> resourceIds) {64 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 65 return trans.UseTransaction(() => { 66 job.Id = dao.AddJob(job);67 jobData.TaskId = job.Id;68 jobData.LastUpdate = DateTime.Now;63 public Guid AddTask(Task task, TaskData taskData, IEnumerable<Guid> resourceIds) { 64 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 65 return trans.UseTransaction(() => { 66 task.Id = dao.AddTask(task); 67 taskData.TaskId = task.Id; 68 taskData.LastUpdate = DateTime.Now; 69 69 foreach (Guid slaveGroupId in resourceIds) { 70 dao.AssignJobToResource( job.Id, slaveGroupId);71 } 72 dao.Add JobData(jobData);73 dao.Update JobState(job.Id, DA.TaskState.Waiting, null, userManager.CurrentUserId, null);74 return jobData.TaskId;70 dao.AssignJobToResource(task.Id, slaveGroupId); 71 } 72 dao.AddTaskData(taskData); 73 dao.UpdateTaskState(task.Id, DA.TaskState.Waiting, null, userManager.CurrentUserId, null); 74 return taskData.TaskId; 75 75 }, false, true); 76 76 } 77 77 78 public Guid AddChild Job(Guid parentJobId, Task job, TaskData jobData) {79 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 80 return trans.UseTransaction(() => { 81 job.ParentTaskId = parentJobId;82 return Add Job(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));78 public Guid AddChildTask(Guid parentTaskId, Task task, TaskData taskData) { 79 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 80 return trans.UseTransaction(() => { 81 task.ParentTaskId = parentTaskId; 82 return AddTask(task, taskData, dao.GetAssignedResources(parentTaskId).Select(x => x.Id)); 83 83 }, false, true); 84 84 } 85 85 86 public Task GetJob(Guid jobId) { 87 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 86 public Task GetTask(Guid taskId) { 87 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 88 author.AuthorizeForTask(taskId, Permission.Read); 89 return dao.GetTask(taskId); 90 } 91 92 public IEnumerable<Task> GetTasks() { 93 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 94 var tasks = dao.GetTasks(x => true); 95 foreach (var task in tasks) 96 author.AuthorizeForTask(task.Id, Permission.Read); 97 return tasks; 98 } 99 100 public IEnumerable<LightweightTask> GetLightweightTasks(IEnumerable<Guid> taskIds) { 101 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 102 var tasks = dao.GetTasks(x => taskIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray(); 103 foreach (var task in tasks) 104 author.AuthorizeForTask(task.Id, Permission.Read); 105 return tasks; 106 } 107 108 public IEnumerable<LightweightTask> GetLightweightChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) { 109 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 110 var tasks = GetChildTasks(parentTaskId, recursive, includeParent).Select(x => new LightweightTask(x)).ToArray(); 111 foreach (var task in tasks) 112 author.AuthorizeForTask(task.Id, Permission.Read); 113 return tasks; 114 } 115 116 public IEnumerable<LightweightTask> GetLightweightJobTasks(Guid jobId) { 117 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 88 118 author.AuthorizeForJob(jobId, Permission.Read); 89 return dao.GetJob(jobId); 90 } 91 92 public IEnumerable<Task> GetJobs() { 93 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 94 var jobs = dao.GetJobs(x => true); 95 foreach (var job in jobs) 96 author.AuthorizeForJob(job.Id, Permission.Read); 97 return jobs; 98 } 99 100 public IEnumerable<LightweightTask> GetLightweightJobs(IEnumerable<Guid> jobIds) { 101 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 102 var jobs = dao.GetJobs(x => jobIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray(); 103 foreach (var job in jobs) 104 author.AuthorizeForJob(job.Id, Permission.Read); 105 return jobs; 106 } 107 108 public IEnumerable<LightweightTask> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) { 109 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 110 var jobs = GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightTask(x)).ToArray(); 111 foreach (var job in jobs) 112 author.AuthorizeForJob(job.Id, Permission.Read); 113 return jobs; 114 } 115 116 public IEnumerable<LightweightTask> GetLightweightExperimentJobs(Guid experimentId) { 117 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 118 author.AuthorizeForExperiment(experimentId, Permission.Read); 119 return dao.GetJobs(x => x.JobId == experimentId).Select(x => new LightweightTask(x)).ToArray(); 120 } 121 122 public TaskData GetJobData(Guid jobId) { 123 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 124 author.AuthorizeForJob(jobId, Permission.Read); 125 return dao.GetJobData(jobId); 126 } 127 128 public void UpdateJob(Task job) { 129 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 130 author.AuthorizeForJob(job.Id, Permission.Full); 131 trans.UseTransaction(() => { 132 dao.UpdateJob(job); 133 }); 134 } 135 136 public void UpdateJobData(Task job, TaskData jobData) { 137 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 138 author.AuthorizeForJob(job.Id, Permission.Full); 139 author.AuthorizeForJob(jobData.TaskId, Permission.Full); 119 return dao.GetTasks(x => x.JobId == jobId).Select(x => new LightweightTask(x)).ToArray(); 120 } 121 122 public TaskData GetTaskData(Guid taskId) { 123 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 124 author.AuthorizeForTask(taskId, Permission.Read); 125 return dao.GetTaskData(taskId); 126 } 127 128 public void UpdateTask(Task taskDto) { 129 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 130 author.AuthorizeForTask(taskDto.Id, Permission.Full); 131 trans.UseTransaction(() => { 132 dao.UpdateTask(taskDto); 133 }); 134 } 135 136 public void UpdateTaskData(Task task, TaskData taskData) { 137 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 138 author.AuthorizeForTask(task.Id, Permission.Full); 139 author.AuthorizeForTask(taskData.TaskId, Permission.Full); 140 140 //trans.UseTransaction(() => { // cneumuel: try without transaction 141 jobData.LastUpdate = DateTime.Now;142 dao.Update Job(job);143 dao.Update JobData(jobData);141 taskData.LastUpdate = DateTime.Now; 142 dao.UpdateTask(task); 143 dao.UpdateTaskData(taskData); 144 144 //}, false, true); 145 145 } 146 146 147 public void Delete Job(Guid jobId) {148 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 149 author.AuthorizeFor Job(jobId, Permission.Full);150 trans.UseTransaction(() => { 151 dao.Delete Job(jobId);152 }); 153 } 154 155 public void DeleteChild Jobs(Guid parentJobId) {156 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 157 author.AuthorizeFor Job(parentJobId, Permission.Full);158 trans.UseTransaction(() => { 159 var jobs = GetChildJobs(parentJobId, true, false);160 foreach (var job in jobs) {161 dao.Delete Job(job.Id);162 dao.Delete JobData(job.Id);147 public void DeleteTask(Guid taskId) { 148 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 149 author.AuthorizeForTask(taskId, Permission.Full); 150 trans.UseTransaction(() => { 151 dao.DeleteTask(taskId); 152 }); 153 } 154 155 public void DeleteChildTasks(Guid parentTaskId) { 156 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 157 author.AuthorizeForTask(parentTaskId, Permission.Full); 158 trans.UseTransaction(() => { 159 var tasks = GetChildTasks(parentTaskId, true, false); 160 foreach (var task in tasks) { 161 dao.DeleteTask(task.Id); 162 dao.DeleteTaskData(task.Id); 163 163 }; 164 164 }); 165 165 } 166 166 167 public Task Update JobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {168 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 169 author.AuthorizeFor Job(jobId, Permission.Full);170 return trans.UseTransaction(() => { 171 Task job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(jobState), slaveId, userId, exception);172 173 if ( job.Command.HasValue && job.Command.Value == Command.Pause && job.State == TaskState.Paused) {174 job.Command = null;175 } else if ( job.Command.HasValue && job.Command.Value == Command.Abort && job.State == TaskState.Aborted) {176 job.Command = null;177 } else if ( job.Command.HasValue && job.Command.Value == Command.Stop && job.State == TaskState.Aborted) {178 job.Command = null;179 } else if ( jobState == TaskState.Paused && !job.Command.HasValue) {180 // slave paused and uploaded the job(no user-command) -> set waiting.181 job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(TaskState.Waiting), slaveId, userId, exception);182 } 183 184 dao.Update Job(job);185 return job;186 }); 187 } 188 189 public IEnumerable<Task> Get JobsByResourceId(Guid resourceId) {190 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 191 var jobs = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));192 foreach (var job in jobs)193 author.AuthorizeFor Job(job.Id, Permission.Read);194 return jobs;167 public Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) { 168 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 169 author.AuthorizeForTask(taskId, Permission.Full); 170 return trans.UseTransaction(() => { 171 Task task = dao.UpdateTaskState(taskId, DataTransfer.Convert.ToEntity(taskState), slaveId, userId, exception); 172 173 if (task.Command.HasValue && task.Command.Value == Command.Pause && task.State == TaskState.Paused) { 174 task.Command = null; 175 } else if (task.Command.HasValue && task.Command.Value == Command.Abort && task.State == TaskState.Aborted) { 176 task.Command = null; 177 } else if (task.Command.HasValue && task.Command.Value == Command.Stop && task.State == TaskState.Aborted) { 178 task.Command = null; 179 } else if (taskState == TaskState.Paused && !task.Command.HasValue) { 180 // slave paused and uploaded the task (no user-command) -> set waiting. 181 task = dao.UpdateTaskState(taskId, DataTransfer.Convert.ToEntity(TaskState.Waiting), slaveId, userId, exception); 182 } 183 184 dao.UpdateTask(task); 185 return task; 186 }); 187 } 188 189 public IEnumerable<Task> GetTasksByResourceId(Guid resourceId) { 190 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 191 var tasks = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId)); 192 foreach (var task in tasks) 193 author.AuthorizeForTask(task.Id, Permission.Read); 194 return tasks; 195 195 } 196 196 #endregion 197 197 198 198 #region Task Control Methods 199 public void Stop Job(Guid jobId) {200 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 201 author.AuthorizeFor Job(jobId, Permission.Full);202 trans.UseTransaction(() => { 203 var job = dao.GetJob(jobId);204 if ( job.State == TaskState.Calculating || job.State == TaskState.Transferring) {205 job.Command = Command.Stop;206 dao.Update Job(job);199 public void StopTask(Guid taskId) { 200 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 201 author.AuthorizeForTask(taskId, Permission.Full); 202 trans.UseTransaction(() => { 203 var task = dao.GetTask(taskId); 204 if (task.State == TaskState.Calculating || task.State == TaskState.Transferring) { 205 task.Command = Command.Stop; 206 dao.UpdateTask(task); 207 207 } else { 208 if ( job.State != TaskState.Aborted && job.State != TaskState.Finished && job.State != TaskState.Failed) {209 job = UpdateJobState(jobId, TaskState.Aborted, null, null, string.Empty);208 if (task.State != TaskState.Aborted && task.State != TaskState.Finished && task.State != TaskState.Failed) { 209 task = UpdateTaskState(taskId, TaskState.Aborted, null, null, string.Empty); 210 210 } 211 211 } … … 213 213 } 214 214 215 public void Pause Job(Guid jobId) {216 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 217 author.AuthorizeFor Job(jobId, Permission.Full);218 trans.UseTransaction(() => { 219 var job = dao.Get Job(jobId);215 public void PauseTask(Guid taskId) { 216 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 217 author.AuthorizeForTask(taskId, Permission.Full); 218 trans.UseTransaction(() => { 219 var job = dao.GetTask(taskId); 220 220 if (job.State == TaskState.Calculating || job.State == TaskState.Transferring) { 221 221 job.Command = Command.Pause; 222 dao.Update Job(job);222 dao.UpdateTask(job); 223 223 } else { 224 job = Update JobState(jobId, TaskState.Paused, null, null, string.Empty);225 } 226 }); 227 } 228 229 public void Restart Job(Guid jobId) {230 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 231 author.AuthorizeFor Job(jobId, Permission.Full);232 trans.UseTransaction(() => { 233 Task job = dao.UpdateJobState(jobId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty);234 job.Command = null;235 dao.Update Job(job);224 job = UpdateTaskState(taskId, TaskState.Paused, null, null, string.Empty); 225 } 226 }); 227 } 228 229 public void RestartTask(Guid taskId) { 230 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); 231 author.AuthorizeForTask(taskId, Permission.Full); 232 trans.UseTransaction(() => { 233 Task task = dao.UpdateTaskState(taskId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty); 234 task.Command = null; 235 dao.UpdateTask(task); 236 236 }); 237 237 } … … 239 239 240 240 #region Job Methods 241 public Job Get HiveExperiment(Guid id) {242 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 243 author.AuthorizeFor Experiment(id, Permission.Read);244 var hiveExperiment = dao.GetHiveExperiments(x =>241 public Job GetJob(Guid id) { 242 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 243 author.AuthorizeForJob(id, Permission.Read); 244 var job = dao.GetJobs(x => 245 245 x.JobId == id 246 246 && (x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0) 247 247 ).FirstOrDefault(); 248 if ( hiveExperiment!= null) {249 hiveExperiment.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId));250 hiveExperiment.OwnerUsername = userManager.GetUserById(hiveExperiment.OwnerUserId).UserName;248 if (job != null) { 249 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 250 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 251 251 } 252 return hiveExperiment;253 } 254 255 public IEnumerable<Job> Get HiveExperiments() {256 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 257 var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);258 foreach (var he in hiveExperiments) {259 author.AuthorizeFor Experiment(he.Id, Permission.Read);260 he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));261 he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName;252 return job; 253 } 254 255 public IEnumerable<Job> GetJobs() { 256 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 257 var jobs = dao.GetJobs(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0); 258 foreach (var job in jobs) { 259 author.AuthorizeForJob(job.Id, Permission.Read); 260 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 261 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 262 262 } 263 return hiveExperiments;264 } 265 266 public IEnumerable<Job> GetAll HiveExperiments() {267 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 268 var hiveExperiments = dao.GetHiveExperiments(x => true);269 foreach (var he in hiveExperiments) { // no authorization here, since this method is admin-only! (admin is allowed to read all jobs)270 he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));271 he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName;263 return jobs; 264 } 265 266 public IEnumerable<Job> GetAllJobs() { 267 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 268 var jobs = dao.GetJobs(x => true); 269 foreach (var job in jobs) { // no authorization here, since this method is admin-only! (admin is allowed to read all task) 270 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 271 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 272 272 } 273 return hiveExperiments;274 } 275 276 public Guid Add HiveExperiment(Job hiveExperimentDto) {277 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 278 return trans.UseTransaction(() => { 279 hiveExperimentDto.OwnerUserId = userManager.CurrentUserId;280 hiveExperimentDto.DateCreated = DateTime.Now;281 return dao.Add HiveExperiment(hiveExperimentDto);282 }); 283 } 284 285 public void Update HiveExperiment(Job hiveExperimentDto) {286 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 287 author.AuthorizeFor Experiment(hiveExperimentDto.Id, Permission.Full);288 trans.UseTransaction(() => { 289 dao.Update HiveExperiment(hiveExperimentDto);290 }); 291 } 292 293 public void Delete HiveExperiment(Guid hiveExperimentId) {294 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 295 author.AuthorizeFor Experiment(hiveExperimentId, Permission.Full);296 trans.UseTransaction(() => { 297 dao.Delete HiveExperiment(hiveExperimentId); // child jobswill be deleted by db-trigger298 }); 299 } 300 #endregion 301 302 #region HiveExperimentPermission Methods303 public void GrantPermission(Guid hiveExperimentId, Guid grantedUserId, Permission permission) {304 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 305 trans.UseTransaction(() => { 306 Job he = dao.GetHiveExperiment(hiveExperimentId);307 if ( he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));308 Permission perm = DT.Convert.ToDto(dao.GetPermissionFor Experiment(he.Id, userManager.CurrentUserId));273 return jobs; 274 } 275 276 public Guid AddJob(Job jobDto) { 277 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 278 return trans.UseTransaction(() => { 279 jobDto.OwnerUserId = userManager.CurrentUserId; 280 jobDto.DateCreated = DateTime.Now; 281 return dao.AddJob(jobDto); 282 }); 283 } 284 285 public void UpdateJob(Job jobDto) { 286 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 287 author.AuthorizeForJob(jobDto.Id, Permission.Full); 288 trans.UseTransaction(() => { 289 dao.UpdateJob(jobDto); 290 }); 291 } 292 293 public void DeleteJob(Guid jobId) { 294 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 295 author.AuthorizeForJob(jobId, Permission.Full); 296 trans.UseTransaction(() => { 297 dao.DeleteJob(jobId); // child task will be deleted by db-trigger 298 }); 299 } 300 #endregion 301 302 #region JobPermission Methods 303 public void GrantPermission(Guid jobId, Guid grantedUserId, Permission permission) { 304 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 305 trans.UseTransaction(() => { 306 Job job = dao.GetJob(jobId); 307 if (job == null) throw new FaultException<FaultReason>(new FaultReason("Could not find task with id " + jobId)); 308 Permission perm = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 309 309 if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment")); 310 dao.Set HiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission));311 }); 312 } 313 314 public void RevokePermission(Guid hiveExperimentId, Guid grantedUserId) {315 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 316 trans.UseTransaction(() => { 317 Job he = dao.GetHiveExperiment(hiveExperimentId);318 if ( he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));319 DA.Permission perm = dao.GetPermissionFor Experiment(he.Id, userManager.CurrentUserId);310 dao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission)); 311 }); 312 } 313 314 public void RevokePermission(Guid jobId, Guid grantedUserId) { 315 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 316 trans.UseTransaction(() => { 317 Job job = dao.GetJob(jobId); 318 if (job == null) throw new FaultException<FaultReason>(new FaultReason("Could not find task with id " + jobId)); 319 DA.Permission perm = dao.GetPermissionForJob(job.Id, userManager.CurrentUserId); 320 320 if (perm != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment")); 321 dao.Set HiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed);322 }); 323 } 324 public IEnumerable<JobPermission> Get HiveExperimentPermissions(Guid hiveExperimentId) {325 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 326 return trans.UseTransaction(() => { 327 DA.Permission currentUserPermission = dao.GetPermissionFor Experiment(hiveExperimentId, userManager.CurrentUserId);321 dao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed); 322 }); 323 } 324 public IEnumerable<JobPermission> GetJobPermissions(Guid jobId) { 325 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 326 return trans.UseTransaction(() => { 327 DA.Permission currentUserPermission = dao.GetPermissionForJob(jobId, userManager.CurrentUserId); 328 328 if (currentUserPermission != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment")); 329 return dao.Get HiveExperimentPermissions(x => x.JobId == hiveExperimentId);329 return dao.GetJobPermissions(x => x.JobId == jobId); 330 330 }); 331 331 } … … 591 591 592 592 #region Helper Methods 593 private IEnumerable<Task> GetChild Jobs(Guid? parentJobId, bool recursive, bool includeParent) {594 var jobs = new List<Task>(dao.GetJobs(x => parentJobId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentJobId));593 private IEnumerable<Task> GetChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) { 594 var tasks = new List<Task>(dao.GetTasks(x => parentTaskId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentTaskId)); 595 595 596 596 if (recursive) { 597 597 var childs = new List<Task>(); 598 foreach (var job in jobs) {599 childs.AddRange(GetChild Jobs(job.Id, recursive, false));600 } 601 jobs.AddRange(childs);598 foreach (var task in tasks) { 599 childs.AddRange(GetChildTasks(task.Id, recursive, false)); 600 } 601 tasks.AddRange(childs); 602 602 } 603 603 604 if (includeParent) jobs.Add(GetJob(parentJobId.Value));605 return jobs;604 if (includeParent) tasks.Add(GetTask(parentTaskId.Value)); 605 return tasks; 606 606 } 607 607 #endregion -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IAuthorizationManager.cs
r6717 r6743 30 30 void Authorize(Guid userId); 31 31 32 void AuthorizeForTask(Guid taskId, Permission requiredPermission); 33 32 34 void AuthorizeForJob(Guid jobId, Permission requiredPermission); 33 34 void AuthorizeForExperiment(Guid experimentId, Permission requiredPermission);35 35 } 36 36 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IEventManager.cs
r6698 r6743 22 22 namespace HeuristicLab.Services.Hive { 23 23 /// <summary> 24 /// The only object in hive which holds a state. Must allow restarts without resetting all jobs24 /// The only object in hive which holds a state. Must allow restarts without resetting all task 25 25 /// </summary> 26 26 public interface IEventManager { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs
r6725 r6743 29 29 public interface IHiveDao { 30 30 #region Task Methods 31 DT.Task Get Job(Guid id);32 IEnumerable<DT.Task> Get Jobs(Expression<Func<Task, bool>> predicate);33 Guid Add Job(DT.Task dto);34 void Update Job(DT.Task dto);35 void Delete Job(Guid id);36 IEnumerable<DT.Task> GetWaiting Jobs(DT.Slave slave, int count);37 IEnumerable<DT.Task> GetParent Jobs(IEnumerable<Guid> resourceIds, int count, bool finished);38 DT.Task Update JobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception);31 DT.Task GetTask(Guid id); 32 IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate); 33 Guid AddTask(DT.Task dto); 34 void UpdateTask(DT.Task dto); 35 void DeleteTask(Guid id); 36 IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count); 37 IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished); 38 DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception); 39 39 #endregion 40 40 41 41 #region TaskData Methods 42 DT.TaskData Get JobData(Guid id);43 IEnumerable<DT.TaskData> Get JobDatas(Expression<Func<TaskData, bool>> predicate);44 Guid Add JobData(DT.TaskData dto);45 void Update JobData(DT.TaskData dto);46 void Delete JobData(Guid id);42 DT.TaskData GetTaskData(Guid id); 43 IEnumerable<DT.TaskData> GetTaskDatas(Expression<Func<TaskData, bool>> predicate); 44 Guid AddTaskData(DT.TaskData dto); 45 void UpdateTaskData(DT.TaskData dto); 46 void DeleteTaskData(Guid id); 47 47 #endregion 48 48 … … 55 55 #endregion 56 56 57 #region HiveExperimentMethods58 DT.Job Get HiveExperiment(Guid id);59 IEnumerable<DT.Job> Get HiveExperiments(Expression<Func<Job, bool>> predicate);60 Guid Add HiveExperiment(DT.Job dto);61 void Update HiveExperiment(DT.Job dto);62 void Delete HiveExperiment(Guid id);57 #region Job Methods 58 DT.Job GetJob(Guid id); 59 IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate); 60 Guid AddJob(DT.Job dto); 61 void UpdateJob(DT.Job dto); 62 void DeleteJob(Guid id); 63 63 #endregion 64 64 65 #region HiveExperimentPermission Methods66 DT.JobPermission Get HiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId);67 IEnumerable<DT.JobPermission> Get HiveExperimentPermissions(Expression<Func<JobPermission, bool>> predicate);68 void Add HiveExperimentPermission(DT.JobPermission dto);69 void Update HiveExperimentPermission(DT.JobPermission dto);70 void Delete HiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId);71 void Set HiveExperimentPermission(Guid hiveExperimentId, Guid grantedByUserId, Guid grantedUserId, Permission permission);65 #region JobPermission Methods 66 DT.JobPermission GetJobPermission(Guid jobId, Guid grantedUserId); 67 IEnumerable<DT.JobPermission> GetJobPermissions(Expression<Func<JobPermission, bool>> predicate); 68 void AddJobPermission(DT.JobPermission dto); 69 void UpdateJobPermission(DT.JobPermission dto); 70 void DeleteJobPermission(Guid jobId, Guid grantedUserId); 71 void SetJobPermission(Guid jobId, Guid grantedByUserId, Guid grantedUserId, Permission permission); 72 72 #endregion 73 73 … … 86 86 void UpdatePluginData(DT.PluginData dto); 87 87 void DeletePluginData(Guid id); 88 #endregion89 90 #region Calendar Methods91 88 #endregion 92 89 … … 121 118 122 119 #region Authorization Methods 120 Permission GetPermissionForTask(Guid taskId, Guid userId); 123 121 Permission GetPermissionForJob(Guid jobId, Guid userId); 124 Permission GetPermissionForExperiment(Guid experimentId, Guid userId); 125 Guid GetExperimentForJob(Guid jobId); 122 Guid GetJobForTask(Guid taskId); 126 123 #endregion 127 124 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs
r6717 r6743 33 33 } 34 34 35 public void AuthorizeForTask(Guid taskId, DT.Permission requiredPermission) { 36 if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks 37 38 Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId); 39 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 40 throw new SecurityException("Current user is not authorized to access task"); 41 } 42 35 43 public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) { 36 if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all jobs37 38 44 Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId); 39 45 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 40 throw new SecurityException("Current user is not authorized to access job"); 41 } 42 43 public void AuthorizeForExperiment(Guid experimentId, DT.Permission requiredPermission) { 44 Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForExperiment(experimentId, ServiceLocator.Instance.UserManager.CurrentUserId); 45 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 46 throw new SecurityException("Current user is not authorized to access experiment"); 46 throw new SecurityException("Current user is not authorized to access task"); 47 47 } 48 48 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs
r6721 r6743 29 29 namespace HeuristicLab.Services.Hive { 30 30 /// <summary> 31 /// This class offers methods for cleaning up offline slaves and jobs31 /// This class offers methods for cleaning up offline slaves and task 32 32 /// </summary> 33 33 public class EventManager : IEventManager { … … 45 45 log.Log("EventManager.Cleanup()"); 46 46 SetTimeoutSlavesOffline(); 47 SetTimeout JobsWaiting();48 FinishParent Jobs();47 SetTimeoutTasksWaiting(); 48 FinishParentTasks(); 49 49 UpdateStatistics(); 50 50 } … … 72 72 73 73 /// <summary> 74 /// Searches for slaves which are timed out, puts them and their jobsoffline74 /// Searches for slaves which are timed out, puts them and their task offline 75 75 /// </summary> 76 76 private void SetTimeoutSlavesOffline() { … … 79 79 if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > HeuristicLab.Services.Hive.Properties.Settings.Default.SlaveHeartbeatTimeout) { 80 80 slave.SlaveState = DT.SlaveState.Offline; 81 Set JobsWaiting(slave.Id);81 SetTasksWaiting(slave.Id); 82 82 dao.UpdateSlave(slave); 83 83 } … … 86 86 87 87 /// <summary> 88 /// Looks for parent jobs which have FinishWhenChildJobsFinished and set their state to finished88 /// Looks for parent tasks which have FinishWhenChildJobsFinished and set their state to finished 89 89 /// </summary> 90 private void FinishParent Jobs() {91 var parent JobsToFinish = dao.GetParentJobs(dao.GetResources(x => true).Select(x => x.Id), 0, true);92 foreach (var job in parentJobsToFinish) {93 dao.Update JobState(job.Id, TaskState.Finished, null, null, string.Empty);90 private void FinishParentTasks() { 91 var parentTasksToFinish = dao.GetParentTasks(dao.GetResources(x => true).Select(x => x.Id), 0, true); 92 foreach (var task in parentTasksToFinish) { 93 dao.UpdateTaskState(task.Id, TaskState.Finished, null, null, string.Empty); 94 94 } 95 95 } 96 96 97 private void Set JobsWaiting(Guid slaveId) {98 var jobs = dao.GetJobs(x => x.State == TaskState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);99 foreach (var j in jobs) {100 DT.Task job = dao.UpdateJobState(j.Id, TaskState.Waiting, slaveId, null, "Slave timed out.");101 job.Command = null;102 dao.Update Job(job);97 private void SetTasksWaiting(Guid slaveId) { 98 var tasks = dao.GetTasks(x => x.State == TaskState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId); 99 foreach (var j in tasks) { 100 DT.Task task = dao.UpdateTaskState(j.Id, TaskState.Waiting, slaveId, null, "Slave timed out."); 101 task.Command = null; 102 dao.UpdateTask(task); 103 103 } 104 104 } 105 105 106 106 /// <summary> 107 /// Looks for jobswhich have not sent heartbeats for some time and reschedules them for calculation107 /// Looks for task which have not sent heartbeats for some time and reschedules them for calculation 108 108 /// </summary> 109 private void SetTimeout JobsWaiting() {110 var jobs = dao.GetJobs(x => (x.State == TaskState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout)109 private void SetTimeoutTasksWaiting() { 110 var tasks = dao.GetTasks(x => (x.State == TaskState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout) 111 111 || (x.State == TaskState.Transferring && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.TransferringJobHeartbeatTimeout)); 112 foreach (var j in jobs) {113 DT.Task job = dao.UpdateJobState(j.Id, TaskState.Waiting, null, null, "Slave timed out.");114 job.Command = null;115 dao.Update Job(job);112 foreach (var j in tasks) { 113 DT.Task task = dao.UpdateTaskState(j.Id, TaskState.Waiting, null, null, "Slave timed out."); 114 task.Command = null; 115 dao.UpdateTask(task); 116 116 } 117 117 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r6725 r6743 54 54 dao.UpdateSlave(slave); 55 55 56 // update jobdata57 actions.AddRange(Update Jobs(heartbeat, slave.IsAllowedToCalculate));56 // update task data 57 actions.AddRange(UpdateTasks(heartbeat, slave.IsAllowedToCalculate)); 58 58 59 // assign new job59 // assign new task 60 60 if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) { 61 var availableJobs = dao.GetWaiting Jobs(slave, 1);61 var availableJobs = dao.GetWaitingTasks(slave, 1); 62 62 if (availableJobs.Count() > 0) { 63 63 var job = availableJobs.First(); … … 71 71 72 72 // returns true if assignment was successful 73 private bool AssignJob(Slave slave, Task job) {74 // load job again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same jobassigned)75 if (dao.Get Job(job.Id).State != TaskState.Waiting) return false;73 private bool AssignJob(Slave slave, Task task) { 74 // load task again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same task assigned) 75 if (dao.GetTask(task.Id).State != TaskState.Waiting) return false; 76 76 77 job = dao.UpdateJobState(job.Id, DataAccess.TaskState.Transferring, slave.Id, null, null);77 task = dao.UpdateTaskState(task.Id, DataAccess.TaskState.Transferring, slave.Id, null, null); 78 78 79 // from now on the jobhas some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)80 job.LastHeartbeat = DateTime.Now;81 dao.Update Job(job);79 // from now on the task has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout) 80 task.LastHeartbeat = DateTime.Now; 81 dao.UpdateTask(task); 82 82 return true; 83 83 } 84 84 85 85 /// <summary> 86 /// Update the progress of each job87 /// Checks if all the jobssent by heartbeat are supposed to be calculated by this slave86 /// Update the progress of each task 87 /// Checks if all the task sent by heartbeat are supposed to be calculated by this slave 88 88 /// </summary> 89 private IEnumerable<MessageContainer> Update Jobs(Heartbeat heartbeat, bool IsAllowedToCalculate) {89 private IEnumerable<MessageContainer> UpdateTasks(Heartbeat heartbeat, bool IsAllowedToCalculate) { 90 90 List<MessageContainer> actions = new List<MessageContainer>(); 91 91 … … 98 98 // process the jobProgresses 99 99 foreach (var jobProgress in heartbeat.JobProgress) { 100 Task curJob = dao.Get Job(jobProgress.Key);100 Task curJob = dao.GetTask(jobProgress.Key); 101 101 if (curJob == null) { 102 // jobdoes not exist in db102 // task does not exist in db 103 103 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, jobProgress.Key)); 104 104 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key); … … 108 108 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curJob.Id)); 109 109 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob); 110 } else if (! JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {111 // assigned resources ids of jobdo not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group110 } else if (!TaskIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) { 111 // assigned resources ids of task do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group 112 112 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseTask, curJob.Id)); 113 113 } else { 114 // save jobexecution time114 // save task execution time 115 115 curJob.ExecutionTime = jobProgress.Value; 116 116 curJob.LastHeartbeat = DateTime.Now; … … 127 127 break; 128 128 } 129 dao.Update Job(curJob);129 dao.UpdateTask(curJob); 130 130 } 131 131 } … … 135 135 } 136 136 137 private bool JobIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curJob) {138 var assignedResourceIds = dao.GetAssignedResources(cur Job.Id).Select(x => x.Id);137 private bool TaskIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curTask) { 138 var assignedResourceIds = dao.GetAssignedResources(curTask.Id).Select(x => x.Id); 139 139 var slaveResourceIds = dao.GetParentResources(slaveId).Select(x => x.Id); 140 140 return assignedResourceIds.Any(x => slaveResourceIds.Contains(x)); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/MessageContainer.cs
r6725 r6743 37 37 public enum MessageType { 38 38 // *** commands from hive server *** 39 CalculateTask, // slave should calculate a job. the jobis already assigned to the slave40 StopTask, // slave should stop the joband submit results39 CalculateTask, // slave should calculate a task. the task is already assigned to the slave 40 StopTask, // slave should stop the task and submit results 41 41 StopAll, // stop all and submit results 42 AbortTask, // slave should shut the jobdown immediately without submitting results43 AbortAll, // slave should abort all jobsimmediately44 PauseTask, // pause the joband submit the results45 PauseAll, // pause all jobsand submit results42 AbortTask, // slave should shut the task down immediately without submitting results 43 AbortAll, // slave should abort all task immediately 44 PauseTask, // pause the task and submit the results 45 PauseAll, // pause all task and submit results 46 46 Restart, // restart operation after Sleep 47 47 Sleep, // disconnect from server, but don't shutdown 48 48 ShutdownSlave, // slave should shutdown immediately without submitting results 49 SayHello, // Slave should say hello, because heis unknown to the server49 SayHello, // Slave should say hello, because job is unknown to the server 50 50 }; 51 51 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r6725 r6743 33 33 #region Task Methods 34 34 [OperationContract] 35 Guid Add Job(Task job, TaskData jobData, IEnumerable<Guid> resourceIds);36 37 [OperationContract] 38 Guid AddChild Job(Guid parentJobId, Task job, TaskData jobData);39 40 [OperationContract] 41 Task Get Job(Guid jobId);42 43 [OperationContract] 44 IEnumerable<Task> Get Jobs();45 46 [OperationContract] 47 IEnumerable<LightweightTask> GetLightweight Jobs(IEnumerable<Guid> jobIds);48 49 [OperationContract] 50 IEnumerable<LightweightTask> GetLightweightChild Jobs(Guid? parentJobId, bool recursive, bool includeParent);51 52 [OperationContract] 53 IEnumerable<LightweightTask> GetLightweight ExperimentJobs(Guid experimentId);54 55 [OperationContract] 56 TaskData Get JobData(Guid jobId);57 58 [OperationContract] 59 void Update Job(Task jobDto);60 61 [OperationContract] 62 void Update JobData(Task jobDto, TaskData jobDataDto);63 64 [OperationContract] 65 void Delete Job(Guid jobId);66 67 [OperationContract] 68 void DeleteChild Jobs(Guid parentJobId);69 70 [OperationContract] 71 Task Update JobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception);72 #endregion 73 74 #region JobControl Methods75 [OperationContract] 76 void Stop Job(Guid jobId);77 78 [OperationContract] 79 void Pause Job(Guid jobId);80 81 [OperationContract] 82 void Restart Job(Guid jobId);35 Guid AddTask(Task task, TaskData taskData, IEnumerable<Guid> resourceIds); 36 37 [OperationContract] 38 Guid AddChildTask(Guid parentTaskId, Task task, TaskData taskData); 39 40 [OperationContract] 41 Task GetTask(Guid taskId); 42 43 [OperationContract] 44 IEnumerable<Task> GetTasks(); 45 46 [OperationContract] 47 IEnumerable<LightweightTask> GetLightweightTasks(IEnumerable<Guid> taskIds); 48 49 [OperationContract] 50 IEnumerable<LightweightTask> GetLightweightChildTasks(Guid? parentTaskId, bool recursive, bool includeParent); 51 52 [OperationContract] 53 IEnumerable<LightweightTask> GetLightweightJobTasks(Guid jobId); 54 55 [OperationContract] 56 TaskData GetTaskData(Guid taskId); 57 58 [OperationContract] 59 void UpdateTask(Task taskDto); 60 61 [OperationContract] 62 void UpdateTaskData(Task taskDto, TaskData taskDataDto); 63 64 [OperationContract] 65 void DeleteTask(Guid taskId); 66 67 [OperationContract] 68 void DeleteChildTasks(Guid parentTaskId); 69 70 [OperationContract] 71 Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception); 72 #endregion 73 74 #region Task Control Methods 75 [OperationContract] 76 void StopTask(Guid taskId); 77 78 [OperationContract] 79 void PauseTask(Guid taskId); 80 81 [OperationContract] 82 void RestartTask(Guid taskId); 83 83 #endregion 84 84 85 85 #region Job Methods 86 86 [OperationContract] 87 Job Get HiveExperiment(Guid id);87 Job GetJob(Guid id); 88 88 89 89 /// <summary> 90 /// Returns all experimentsfor the current user90 /// Returns all task for the current user 91 91 /// </summary> 92 92 [OperationContract] 93 IEnumerable<Job> Get HiveExperiments();93 IEnumerable<Job> GetJobs(); 94 94 95 95 /// <summary> 96 /// Returns all experimentsin the hive (only for admins)96 /// Returns all task in the hive (only for admins) 97 97 /// </summary> 98 98 /// <returns></returns> 99 99 [OperationContract] 100 IEnumerable<Job> GetAll HiveExperiments();101 102 [OperationContract] 103 Guid Add HiveExperiment(Job hiveExperimentDto);104 105 [OperationContract] 106 void Update HiveExperiment(Job hiveExperimentDto);107 108 [OperationContract] 109 void Delete HiveExperiment(Guid hiveExperimentId);110 #endregion 111 112 #region HiveExperimentPermission Methods113 [OperationContract] 114 void GrantPermission(Guid hiveExperimentId, Guid grantedUserId, Permission permission);100 IEnumerable<Job> GetAllJobs(); 101 102 [OperationContract] 103 Guid AddJob(Job jobDto); 104 105 [OperationContract] 106 void UpdateJob(Job jobDto); 107 108 [OperationContract] 109 void DeleteJob(Guid JobId); 110 #endregion 111 112 #region JobPermission Methods 113 [OperationContract] 114 void GrantPermission(Guid jobId, Guid grantedUserId, Permission permission); 115 115 116 116 [OperationContract] … … 118 118 119 119 [OperationContract] 120 IEnumerable<JobPermission> Get HiveExperimentPermissions(Guid hiveExperimentId);121 122 [OperationContract] 123 bool IsAllowedPrivileged(); // current user may execute privileged jobs120 IEnumerable<JobPermission> GetJobPermissions(Guid jobId); 121 122 [OperationContract] 123 bool IsAllowedPrivileged(); // current user may execute privileged task 124 124 #endregion 125 125 … … 140 140 [OperationContract] 141 141 Plugin GetPlugin(Guid pluginId); 142 142 143 [OperationContract] 143 144 Plugin GetPluginByHash(byte[] hash); 145 144 146 [OperationContract] 145 147 [FaultContract(typeof(PluginAlreadyExistsFault))] 146 148 Guid AddPlugin(Plugin plugin, List<PluginData> pluginData); 149 147 150 [OperationContract] 148 151 IEnumerable<Plugin> GetPlugins(); 152 149 153 [OperationContract] 150 154 IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds); 155 151 156 [OperationContract] 152 157 void DeletePlugin(Guid pluginId); … … 194 199 195 200 [OperationContract] 196 IEnumerable<Task> Get JobsByResourceId(Guid resourceId);201 IEnumerable<Task> GetTasksByResourceId(Guid resourceId); 197 202 198 203 [OperationContract]
Note: See TracChangeset
for help on using the changeset viewer.