Changeset 7597
- Timestamp:
- 03/12/12 16:35:53 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/AzureProvider.cs
r7563 r7597 186 186 } 187 187 188 public string DeleteDeployment(Subscription subscription, string serviceName, string deploymentName) { 189 if (subscription == null) { 190 throw new ArgumentNullException("Subscription must not be null.", "subscription"); 191 } 192 if (serviceName.Length == 0) { 193 throw new ArgumentException("Servicename is not valid.", "serviceName"); 194 } 195 if (deploymentName.Length == 0) { 196 throw new ArgumentException("Deploymentname is not valid.", "deploymentName"); 197 } 198 199 return ServiceManagementOperation.DeleteDeployment(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName, deploymentName); 200 } 201 188 202 public List<HostedService> DiscoverSlaveService(Subscription subscription) { 189 203 if (subscription == null) { … … 206 220 return ServiceManagementOperation.ChangeInstanceCount(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName, deploymentSlot, roleName, instanceCount); 207 221 } 222 223 public Constants.OperationResult PollGetOperationStatus(Subscription subscription, string requestId, int pollIntervallSeconds, int timeoutSeconds) { 224 if (subscription == null) { 225 throw new ArgumentNullException("Subscription must not be null.", "subscription"); 226 } 227 return ServiceManagementOperation.PollGetOperationStatus(subscription.SubscriptionID, subscription.CertificateThumbprint, requestId, pollIntervallSeconds, timeoutSeconds); 228 } 208 229 } 209 230 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/Constants.cs
r7563 r7597 20 20 #endregion 21 21 22 using System; 23 using System.Net; 22 24 using System.Xml.Linq; 23 25 namespace HeuristicLab.Clients.Hive.CloudManager.Azure { … … 114 116 } 115 117 118 public enum OperationStatus { 119 InProgress, 120 Failed, 121 Succeeded, 122 TimedOut 123 } 124 125 #endregion 126 127 #region Structs 128 129 public struct OperationResult { 130 public Constants.OperationStatus Status { get; set; } 131 public HttpStatusCode StatusCode { get; set; } 132 public TimeSpan RunningTime { get; set; } 133 public string Code { get; set; } 134 public string Message { get; set; } 135 } 136 116 137 #endregion 117 138 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/IAzureProvider.cs
r7563 r7597 40 40 string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, FileInfo configuration, string label, int instanceCount); 41 41 string DeleteHostedService(Subscription subscription, string serviceName); 42 string DeleteDeployment(Subscription subscription, string serviceName, string deploymentName); 43 Constants.OperationResult PollGetOperationStatus(Subscription subscription, string requestId, int pollIntervallSeconds, int timeoutSeconds); 42 44 43 45 List<HostedService> DiscoverSlaveService(Subscription subscription); -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/ServiceManagementOperation.cs
r7545 r7597 25 25 using System.Linq; 26 26 using System.Net; 27 using System.Threading; 27 28 using System.Xml.Linq; 28 29 using HeuristicLab.Clients.Hive.CloudManager.Model; … … 260 261 } 261 262 263 public static string DeleteDeployment(string subscriptionId, string thumbprint, string serviceName, string deploymentName) { 264 string uri = string.Format(Constants.URISpecificDeploymentFormat, subscriptionId, serviceName, deploymentName); 265 ServiceWebRequest operation = new ServiceWebRequest(thumbprint); 266 string requestId = operation.Invoke(uri, Constants.HttpMethodDELETE); 267 return requestId; 268 } 269 262 270 public static string ChangeInstanceCount(string subscriptionId, string thumbprint, string serviceName, string deploymentSlot, string roleName, int instanceCount) { 263 271 string requestId = string.Empty; … … 270 278 } 271 279 272 public static string GetOperationStatus(string subscriptionId, string thumbprint, string requestId) { 280 public static string GetOperationStatusString(string subscriptionId, string thumbprint, string requestId) { 281 string status = GetOperationStatus(subscriptionId, thumbprint, requestId).Element(wa + "Status").Value; 282 return status; 283 } 284 285 public static XElement GetOperationStatus(string subscriptionId, string thumbprint, string requestId) { 273 286 string uri = string.Format(Constants.URIGetOperationStatusFormat, subscriptionId, requestId); 274 287 ServiceWebRequest operation = new ServiceWebRequest(thumbprint); 275 288 XDocument operationStatus = operation.Invoke(uri); 276 string status = operationStatus.Element(wa + "Operation").Element(wa + "Status").Value; 277 return status; 289 return operationStatus.Element(wa + "Operation"); 290 } 291 292 public static Constants.OperationResult PollGetOperationStatus(string subscriptionId, string thumbprint, string requestId, int pollIntervallSeconds, int timeoutSeconds) { 293 Constants.OperationResult result = new Constants.OperationResult(); 294 DateTime beginPollTime = DateTime.UtcNow; 295 TimeSpan pollInterval = new TimeSpan(0, 0, pollIntervallSeconds); 296 DateTime endPollTime = beginPollTime + new TimeSpan(0, 0, timeoutSeconds); 297 298 bool done = false; 299 while (!done) { 300 XElement operationStatus = GetOperationStatus(subscriptionId, thumbprint, requestId); 301 result.RunningTime = DateTime.UtcNow - beginPollTime; 302 try { 303 result.Status = (Constants.OperationStatus)Enum.Parse(typeof(Constants.OperationStatus), operationStatus.Element(wa + "Status").Value); 304 } 305 catch (Exception ex) { 306 throw new ApplicationException(string.Format("Get Operation Status {0} returned unexpected status: {1}{2}", requestId, Environment.NewLine, operationStatus.ToString(SaveOptions.OmitDuplicateNamespaces))); 307 } 308 309 switch (result.Status) { 310 case Constants.OperationStatus.InProgress: 311 Thread.Sleep((int)pollInterval.TotalMilliseconds); 312 break; 313 case Constants.OperationStatus.Failed: 314 result.StatusCode = (HttpStatusCode)Convert.ToInt32(operationStatus.Element(wa + "HttpStatusCode").Value); 315 XElement error = operationStatus.Element(wa + "Error"); 316 result.Code = error.Element(wa + "Code").Value; 317 result.Message = error.Element(wa + "Message").Value; 318 done = true; 319 break; 320 case Constants.OperationStatus.Succeeded: 321 result.StatusCode = (HttpStatusCode)Convert.ToInt32(operationStatus.Element(wa + "HttpStatusCode").Value); 322 done = true; 323 break; 324 } 325 326 if (!done && DateTime.UtcNow > endPollTime) { 327 result.Status = Constants.OperationStatus.TimedOut; 328 done = true; 329 } 330 } 331 return result; 278 332 } 279 333
Note: See TracChangeset
for help on using the changeset viewer.