- Timestamp:
- 06/21/11 16:51:03 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj
r6452 r6463 115 115 <Compile Include="Jobs\ItemJob.cs" /> 116 116 <Compile Include="RefreshableHiveExperiment.cs" /> 117 <Compile Include="ServiceClients\HiveExperimentPermission.cs" /> 117 118 <Compile Include="StateLogList.cs" /> 118 119 <Compile Include="StateLogListList.cs" /> … … 156 157 <Compile Include="ServiceClients\NamedHiveItem.cs" /> 157 158 <Compile Include="ServiceClients\Heartbeat.cs" /> 158 <Compile Include="ServiceClients\HiveExperimentPermission.cs" />159 159 <Compile Include="ServiceClients\HiveItem.cs" /> 160 160 <Compile Include="ServiceClients\JobData.cs" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs
r6452 r6463 110 110 HiveClient.Instance.UploadExperiment((RefreshableHiveExperiment)item, cancellationToken); 111 111 } 112 if (item is HiveExperimentPermission) { 113 var hep = (HiveExperimentPermission)item; 114 hep.GrantedUserId = ServiceLocator.Instance.CallHiveService((s) => s.GetUserIdByUsername(hep.GrantedUserName)); 115 if (hep.GrantedUserId == Guid.Empty) { 116 throw new ArgumentException(string.Format("The user {0} was not found.", hep.GrantedUserName)); 117 } 118 ServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.HiveExperimentId, hep.GrantedUserId, hep.Permission)); 119 } 112 120 } else { 113 121 if (item is HiveExperiment) … … 138 146 if (item is RefreshableHiveExperiment) 139 147 ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(item.Id)); 148 if (item is HiveExperimentPermission) { 149 var hep = (HiveExperimentPermission)item; 150 ServiceLocator.Instance.CallHiveService(s => s.RevokePermission(hep.HiveExperimentId, hep.GrantedUserId)); 151 } 140 152 item.Id = Guid.Empty; 141 153 } … … 241 253 .ContinueWith((x) => refreshableHiveExperiment.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted)); 242 254 } 243 Task.WaitAll(tasks.ToArray()); 255 try { 256 Task.WaitAll(tasks.ToArray()); 257 } 258 catch (AggregateException ae) { 259 if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it 260 } 244 261 } 245 262 finally { … … 281 298 private void UploadJobWithChildren(IProgress progress, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, int[] jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged, CancellationToken cancellationToken) { 282 299 jobUploadSemaphore.WaitOne(); 300 bool semaphoreReleased = false; 283 301 try { 284 302 cancellationToken.ThrowIfCancellationRequested(); … … 337 355 .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted)); 338 356 } 339 Task.WaitAll(tasks.ToArray()); 357 jobUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall! 358 try { 359 Task.WaitAll(tasks.ToArray()); 360 } 361 catch (AggregateException ae) { 362 if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it 363 } 340 364 } 341 365 finally { 342 jobUploadSemaphore.Release();366 if(!semaphoreReleased) jobUploadSemaphore.Release(); 343 367 } 344 368 } … … 441 465 } 442 466 } 467 468 public static HiveItemCollection<HiveExperimentPermission> GetHiveExperimentPermissions(Guid hiveExperimentId) { 469 return ServiceLocator.Instance.CallHiveService((service) => { 470 IEnumerable<HiveExperimentPermission> heps = service.GetHiveExperimentPermissions(hiveExperimentId); 471 foreach (var hep in heps) { 472 hep.GrantedUserName = service.GetUsernameByUserId(hep.GrantedUserId); 473 } 474 return new HiveItemCollection<HiveExperimentPermission>(heps); 475 }); 476 } 443 477 } 444 478 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveExperimentPermission.cs
r6372 r6463 20 20 #endregion 21 21 22 using System.ComponentModel; 22 23 using HeuristicLab.Common; 23 24 24 25 namespace HeuristicLab.Clients.Hive { 25 26 26 public partial class HiveExperimentPermission : IDeepCloneable, IContent { 27 27 28 p ublic HiveExperimentPermission() { }29 30 protected HiveExperimentPermission(HiveExperimentPermission original, Cloner cloner) {31 cloner.RegisterClonedObject(original, this);28 private string grantedUserName; 29 public string GrantedUserName { 30 get { return grantedUserName; } 31 set { grantedUserName = value; OnPropertyChanged(new PropertyChangedEventArgs("GrantedUserName")); } 32 32 } 33 33 34 public object Clone() { 35 return Clone(new Cloner()); 34 #region Constructors and Cloning 35 public HiveExperimentPermission() { 36 this.Permission = Hive.Permission.ReadOnly; 37 this.PropertyChanged += new PropertyChangedEventHandler(HiveExperimentPermission_PropertyChanged); 36 38 } 37 39 38 public IDeepCloneable Clone(Cloner cloner) { 40 protected HiveExperimentPermission(HiveExperimentPermission original, Cloner cloner) 41 : base(original, cloner) { 42 this.GrantedByUserId = original.GrantedByUserId; 43 this.GrantedUserId = original.GrantedUserId; 44 this.HiveExperimentId = original.HiveExperimentId; 45 this.Permission = original.Permission; 46 } 47 public override IDeepCloneable Clone(Cloner cloner) { 39 48 return new HiveExperimentPermission(this, cloner); 49 } 50 #endregion 51 52 private void HiveExperimentPermission_PropertyChanged(object sender, PropertyChangedEventArgs e) { 53 OnToStringChanged(); 54 } 55 56 public override string ToString() { 57 return string.Format("{0}: {1}", GrantedUserName, Permission.ToString()); 40 58 } 41 59 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveServiceClient.cs
r6454 r6463 214 214 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.SlaveGroup))] 215 215 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Plugin))] 216 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.HiveExperimentPermission))] 216 217 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))] 217 218 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.LightweightJob))] … … 606 607 607 608 [System.Runtime.Serialization.OptionalFieldAttribute()] 609 private HeuristicLab.Clients.Hive.Permission PermissionField; 610 611 [System.Runtime.Serialization.OptionalFieldAttribute()] 608 612 private string ResourceNamesField; 609 613 … … 706 710 this.OwnerUserIdField = value; 707 711 this.RaisePropertyChanged("OwnerUserId"); 712 } 713 } 714 } 715 716 [System.Runtime.Serialization.DataMemberAttribute()] 717 public HeuristicLab.Clients.Hive.Permission Permission 718 { 719 get 720 { 721 return this.PermissionField; 722 } 723 set 724 { 725 if ((this.PermissionField.Equals(value) != true)) 726 { 727 this.PermissionField = value; 728 this.RaisePropertyChanged("Permission"); 708 729 } 709 730 } … … 1088 1109 [System.Diagnostics.DebuggerStepThroughAttribute()] 1089 1110 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] 1111 [System.Runtime.Serialization.DataContractAttribute(Name="HiveExperimentPermission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common.DataTra" + 1112 "nsfer")] 1113 [System.SerializableAttribute()] 1114 public partial class HiveExperimentPermission : HeuristicLab.Clients.Hive.HiveItem 1115 { 1116 1117 [System.Runtime.Serialization.OptionalFieldAttribute()] 1118 private System.Guid GrantedByUserIdField; 1119 1120 [System.Runtime.Serialization.OptionalFieldAttribute()] 1121 private System.Guid GrantedUserIdField; 1122 1123 [System.Runtime.Serialization.OptionalFieldAttribute()] 1124 private System.Guid HiveExperimentIdField; 1125 1126 [System.Runtime.Serialization.OptionalFieldAttribute()] 1127 private HeuristicLab.Clients.Hive.Permission PermissionField; 1128 1129 [System.Runtime.Serialization.DataMemberAttribute()] 1130 public System.Guid GrantedByUserId 1131 { 1132 get 1133 { 1134 return this.GrantedByUserIdField; 1135 } 1136 set 1137 { 1138 if ((this.GrantedByUserIdField.Equals(value) != true)) 1139 { 1140 this.GrantedByUserIdField = value; 1141 this.RaisePropertyChanged("GrantedByUserId"); 1142 } 1143 } 1144 } 1145 1146 [System.Runtime.Serialization.DataMemberAttribute()] 1147 public System.Guid GrantedUserId 1148 { 1149 get 1150 { 1151 return this.GrantedUserIdField; 1152 } 1153 set 1154 { 1155 if ((this.GrantedUserIdField.Equals(value) != true)) 1156 { 1157 this.GrantedUserIdField = value; 1158 this.RaisePropertyChanged("GrantedUserId"); 1159 } 1160 } 1161 } 1162 1163 [System.Runtime.Serialization.DataMemberAttribute()] 1164 public System.Guid HiveExperimentId 1165 { 1166 get 1167 { 1168 return this.HiveExperimentIdField; 1169 } 1170 set 1171 { 1172 if ((this.HiveExperimentIdField.Equals(value) != true)) 1173 { 1174 this.HiveExperimentIdField = value; 1175 this.RaisePropertyChanged("HiveExperimentId"); 1176 } 1177 } 1178 } 1179 1180 [System.Runtime.Serialization.DataMemberAttribute()] 1181 public HeuristicLab.Clients.Hive.Permission Permission 1182 { 1183 get 1184 { 1185 return this.PermissionField; 1186 } 1187 set 1188 { 1189 if ((this.PermissionField.Equals(value) != true)) 1190 { 1191 this.PermissionField = value; 1192 this.RaisePropertyChanged("Permission"); 1193 } 1194 } 1195 } 1196 } 1197 1198 [System.Diagnostics.DebuggerStepThroughAttribute()] 1199 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] 1090 1200 [System.Runtime.Serialization.DataContractAttribute(Name="PluginData", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common.DataTra" + 1091 1201 "nsfer")] … … 1330 1440 [System.Runtime.Serialization.EnumMemberAttribute()] 1331 1441 Failed = 7, 1442 } 1443 1444 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] 1445 [System.Runtime.Serialization.DataContractAttribute(Name="Permission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common.DataTra" + 1446 "nsfer")] 1447 public enum Permission : int 1448 { 1449 1450 [System.Runtime.Serialization.EnumMemberAttribute()] 1451 NotAllowed = 0, 1452 1453 [System.Runtime.Serialization.EnumMemberAttribute()] 1454 ReadOnly = 1, 1455 1456 [System.Runtime.Serialization.EnumMemberAttribute()] 1457 Full = 2, 1332 1458 } 1333 1459 … … 1783 1909 { 1784 1910 1911 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlave", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveResponse")] 1912 void DeleteSlave(System.Guid slaveId); 1913 1914 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlaveGroup", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveGroupResponse")] 1915 void DeleteSlaveGroup(System.Guid slaveGroupId); 1916 1917 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddResourceToGroup", ReplyAction="http://tempuri.org/IHiveService/AddResourceToGroupResponse")] 1918 void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId); 1919 1785 1920 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/RemoveResourceFromGroup", ReplyAction="http://tempuri.org/IHiveService/RemoveResourceFromGroupResponse")] 1786 1921 void RemoveResourceFromGroup(System.Guid slaveGroupId, System.Guid resourceId); … … 1807 1942 System.Collections.Generic.List<HeuristicLab.Clients.Hive.Downtime> GetDowntimesForResource(System.Guid resourceId); 1808 1943 1944 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetUsernameByUserId", ReplyAction="http://tempuri.org/IHiveService/GetUsernameByUserIdResponse")] 1945 string GetUsernameByUserId(System.Guid userId); 1946 1947 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetUserIdByUsername", ReplyAction="http://tempuri.org/IHiveService/GetUserIdByUsernameResponse")] 1948 System.Guid GetUserIdByUsername(string username); 1949 1809 1950 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddJob", ReplyAction="http://tempuri.org/IHiveService/AddJobResponse")] 1810 1951 System.Guid AddJob(HeuristicLab.Clients.Hive.Job job, HeuristicLab.Clients.Hive.JobData jobData, System.Collections.Generic.List<System.Guid> resourceIds); … … 1872 2013 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteHiveExperiment", ReplyAction="http://tempuri.org/IHiveService/DeleteHiveExperimentResponse")] 1873 2014 void DeleteHiveExperiment(System.Guid hiveExperimentId); 2015 2016 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GrantPermission", ReplyAction="http://tempuri.org/IHiveService/GrantPermissionResponse")] 2017 void GrantPermission(System.Guid hiveExperimentId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission); 2018 2019 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/RevokePermission", ReplyAction="http://tempuri.org/IHiveService/RevokePermissionResponse")] 2020 void RevokePermission(System.Guid hiveExperimentId, System.Guid grantedUserId); 2021 2022 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetHiveExperimentPermissions", ReplyAction="http://tempuri.org/IHiveService/GetHiveExperimentPermissionsResponse")] 2023 System.Collections.Generic.List<HeuristicLab.Clients.Hive.HiveExperimentPermission> GetHiveExperimentPermissions(System.Guid hiveExperimentId); 1874 2024 1875 2025 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/Hello", ReplyAction="http://tempuri.org/IHiveService/HelloResponse")] … … 1924 2074 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateSlaveGroup", ReplyAction="http://tempuri.org/IHiveService/UpdateSlaveGroupResponse")] 1925 2075 void UpdateSlaveGroup(HeuristicLab.Clients.Hive.SlaveGroup slaveGroup); 1926 1927 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlave", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveResponse")]1928 void DeleteSlave(System.Guid slaveId);1929 1930 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlaveGroup", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveGroupResponse")]1931 void DeleteSlaveGroup(System.Guid slaveGroupId);1932 1933 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddResourceToGroup", ReplyAction="http://tempuri.org/IHiveService/AddResourceToGroupResponse")]1934 void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId);1935 2076 } 1936 2077 … … 1969 2110 } 1970 2111 2112 public void DeleteSlave(System.Guid slaveId) 2113 { 2114 base.Channel.DeleteSlave(slaveId); 2115 } 2116 2117 public void DeleteSlaveGroup(System.Guid slaveGroupId) 2118 { 2119 base.Channel.DeleteSlaveGroup(slaveGroupId); 2120 } 2121 2122 public void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId) 2123 { 2124 base.Channel.AddResourceToGroup(slaveGroupId, resourceId); 2125 } 2126 1971 2127 public void RemoveResourceFromGroup(System.Guid slaveGroupId, System.Guid resourceId) 1972 2128 { … … 2009 2165 } 2010 2166 2167 public string GetUsernameByUserId(System.Guid userId) 2168 { 2169 return base.Channel.GetUsernameByUserId(userId); 2170 } 2171 2172 public System.Guid GetUserIdByUsername(string username) 2173 { 2174 return base.Channel.GetUserIdByUsername(username); 2175 } 2176 2011 2177 public System.Guid AddJob(HeuristicLab.Clients.Hive.Job job, HeuristicLab.Clients.Hive.JobData jobData, System.Collections.Generic.List<System.Guid> resourceIds) 2012 2178 { … … 2119 2285 } 2120 2286 2287 public void GrantPermission(System.Guid hiveExperimentId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission) 2288 { 2289 base.Channel.GrantPermission(hiveExperimentId, grantedUserId, permission); 2290 } 2291 2292 public void RevokePermission(System.Guid hiveExperimentId, System.Guid grantedUserId) 2293 { 2294 base.Channel.RevokePermission(hiveExperimentId, grantedUserId); 2295 } 2296 2297 public System.Collections.Generic.List<HeuristicLab.Clients.Hive.HiveExperimentPermission> GetHiveExperimentPermissions(System.Guid hiveExperimentId) 2298 { 2299 return base.Channel.GetHiveExperimentPermissions(hiveExperimentId); 2300 } 2301 2121 2302 public void Hello(HeuristicLab.Clients.Hive.Slave slave) 2122 2303 { … … 2203 2384 base.Channel.UpdateSlaveGroup(slaveGroup); 2204 2385 } 2205 2206 public void DeleteSlave(System.Guid slaveId)2207 {2208 base.Channel.DeleteSlave(slaveId);2209 }2210 2211 public void DeleteSlaveGroup(System.Guid slaveGroupId)2212 {2213 base.Channel.DeleteSlaveGroup(slaveGroupId);2214 }2215 2216 public void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId)2217 {2218 base.Channel.AddResourceToGroup(slaveGroupId, resourceId);2219 }2220 2386 } 2221 2387 }
Note: See TracChangeset
for help on using the changeset viewer.