| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. See License.txt in the project root for license information. |
| | | 3 | | |
| | | 4 | | namespace Microsoft.Azure.Batch |
| | | 5 | | { |
| | | 6 | | using System; |
| | | 7 | | using System.Collections.Generic; |
| | | 8 | | using System.Linq; |
| | | 9 | | using System.Threading; |
| | | 10 | | using System.Threading.Tasks; |
| | | 11 | | using Microsoft.Rest.Azure; |
| | | 12 | | using Models = Microsoft.Azure.Batch.Protocol.Models; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// A pool in the Azure Batch service. |
| | | 16 | | /// </summary> |
| | | 17 | | public partial class CloudPool : IRefreshable |
| | | 18 | | { |
| | | 19 | | #region CloudPool |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// This property is an alias for <see cref="TargetDedicatedComputeNodes"/> and is supported only for backward c |
| | | 23 | | /// </summary> |
| | | 24 | | [Obsolete("Obsolete after 05/2017, use TargetDedicatedComputeNodes instead.")] |
| | | 25 | | public int? TargetDedicated |
| | | 26 | | { |
| | 1 | 27 | | get { return this.TargetDedicatedComputeNodes; } |
| | 105 | 28 | | set { this.TargetDedicatedComputeNodes = value; } |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// This property is an alias for <see cref="CurrentDedicatedComputeNodes"/> and is supported only for backward |
| | | 33 | | /// </summary> |
| | | 34 | | [Obsolete("Obsolete after 05/2017, use CurrentDedicatedComputeNodes instead.")] |
| | | 35 | | public int? CurrentDedicated |
| | | 36 | | { |
| | 1 | 37 | | get { return this.CurrentDedicatedComputeNodes; } |
| | | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Deletes this pool. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <remarks> |
| | | 44 | | /// <para>The delete operation requests that the pool be deleted. The request puts the pool in the <see cref="C |
| | | 45 | | /// The Batch service will requeue any running tasks and perform the actual pool deletion without any further cl |
| | | 46 | | /// <para>The delete operation runs asynchronously.</para> |
| | | 47 | | /// </remarks> |
| | | 48 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 49 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 50 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 51 | | public async System.Threading.Tasks.Task DeleteAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null |
| | | 52 | | { |
| | | 53 | | // throw if if this object is unbound |
| | 0 | 54 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 55 | | |
| | 0 | 56 | | Task asyncDelete = this.parentBatchClient.PoolOperations.DeletePoolAsync( |
| | 0 | 57 | | this.Id, |
| | 0 | 58 | | additionalBehaviors: additionalBehaviors, |
| | 0 | 59 | | cancellationToken: cancellationToken); |
| | 0 | 60 | | await asyncDelete.ConfigureAwait(continueOnCapturedContext: false); |
| | 0 | 61 | | } |
| | | 62 | | |
| | 106 | 63 | | /// <summary> |
| | | 64 | | /// Deletes this pool. |
| | 106 | 65 | | /// </summary> |
| | 106 | 66 | | /// <remarks> |
| | 106 | 67 | | /// <para>The delete operation requests that the pool be deleted. The request puts the pool in the <see cref="C |
| | 106 | 68 | | /// The Batch service will requeue any running tasks and perform the actual pool deletion without any further cl |
| | 106 | 69 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="DeleteAsync"/>.</remark |
| | 106 | 70 | | /// </remarks> |
| | 106 | 71 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 106 | 72 | | public void Delete(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 106 | 73 | | { |
| | 106 | 74 | | Task asyncTask = DeleteAsync(additionalBehaviors); |
| | 106 | 75 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 106 | 76 | | } |
| | 106 | 77 | | |
| | 106 | 78 | | /// <summary> |
| | 106 | 79 | | /// Commits this <see cref="CloudPool" /> to the Azure Batch service. |
| | 106 | 80 | | /// </summary> |
| | 106 | 81 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 106 | 82 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 106 | 83 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 106 | 84 | | /// <remarks> |
| | 106 | 85 | | /// <para>The commit operation runs asynchronously.</para> |
| | 106 | 86 | | /// </remarks> |
| | 106 | 87 | | public async System.Threading.Tasks.Task CommitAsync( |
| | 106 | 88 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 106 | 89 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 106 | 90 | | { |
| | 106 | 91 | | // mark this object readonly |
| | 110 | 92 | | this.propertyContainer.IsReadOnly = true; |
| | 106 | 93 | | |
| | 106 | 94 | | // craft the behavior manager for this call |
| | 110 | 95 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 106 | 96 | | |
| | 106 | 97 | | // hold the tpl task for the server call |
| | 106 | 98 | | System.Threading.Tasks.Task asyncTask; |
| | 106 | 99 | | |
| | 110 | 100 | | if (BindingState.Unbound == this.propertyContainer.BindingState) |
| | | 101 | | { |
| | 1026 | 102 | | // take all property changes and create a pool |
| | 3 | 103 | | Models.PoolAddParameter protoPool = this.GetTransportObject(); |
| | 1026 | 104 | | |
| | 1029 | 105 | | asyncTask = this.parentBatchClient.ProtocolLayer.AddPool(protoPool, bhMgr, cancellationToken); |
| | 1026 | 106 | | } |
| | 1026 | 107 | | else |
| | 1026 | 108 | | { |
| | 1026 | 109 | | // take all property changes and prepare to update a pool |
| | 1026 | 110 | | |
| | 1026 | 111 | | // TODO: Get protcol layer to align the [] to IEnumerable<> for this request |
| | 1027 | 112 | | Models.CertificateReference[] certRefArray = UtilitiesInternal.ConvertToProtocolArray(this.CertificateRe |
| | 3395 | 113 | | Models.MetadataItem[] mdiArray = UtilitiesInternal.ConvertToProtocolArray(this.Metadata); |
| | 1027 | 114 | | Models.ApplicationPackageReference[] applicationPackageArray = UtilitiesInternal.ConvertToProtocolArray( |
| | 1026 | 115 | | Models.StartTask modelStartTask = UtilitiesInternal.CreateObjectWithNullCheck(this.StartTask, item => it |
| | 1026 | 116 | | |
| | 1027 | 117 | | asyncTask = this.parentBatchClient.ProtocolLayer.UpdatePool( |
| | 1027 | 118 | | this.Id, |
| | 1027 | 119 | | modelStartTask, |
| | 1027 | 120 | | certRefArray, |
| | 1027 | 121 | | applicationPackageArray, |
| | 1027 | 122 | | mdiArray, |
| | 1027 | 123 | | bhMgr, |
| | 1027 | 124 | | cancellationToken); |
| | 1026 | 125 | | } |
| | 1026 | 126 | | |
| | 1030 | 127 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 1030 | 128 | | } |
| | 1026 | 129 | | |
| | 1026 | 130 | | /// <summary> |
| | 1026 | 131 | | /// Commits this <see cref="CloudPool" /> to the Azure Batch service. |
| | 1026 | 132 | | /// </summary> |
| | 1543 | 133 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1026 | 134 | | /// <remarks> |
| | 1026 | 135 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="CommitAsync"/>.</para> |
| | 1026 | 136 | | /// </remarks> |
| | 1026 | 137 | | public void Commit(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1026 | 138 | | { |
| | 1027 | 139 | | Task asyncTask = CommitAsync(additionalBehaviors); |
| | 1027 | 140 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1514 | 141 | | } |
| | 1026 | 142 | | |
| | 1026 | 143 | | /// <summary> |
| | 1026 | 144 | | /// Commits all pending changes to this <see cref="CloudPool" /> to the Azure Batch service. |
| | 1026 | 145 | | /// </summary> |
| | 1026 | 146 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1026 | 147 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1026 | 148 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1026 | 149 | | /// <remarks> |
| | 1026 | 150 | | /// <para> |
| | 1026 | 151 | | /// Updates an existing <see cref="CloudPool"/> on the Batch service by replacing its properties with the proper |
| | 1026 | 152 | | /// Unchanged properties are ignored. |
| | 1026 | 153 | | /// All changes since the last time this entity was retrieved from the Batch service (either via <see cref="Refr |
| | 1026 | 154 | | /// or <see cref="PoolOperations.ListPools"/>) are applied. |
| | 1026 | 155 | | /// Properties which are explicitly set to null will cause an exception because the Batch service does not suppo |
| | 1026 | 156 | | /// If you need to set a property to null, use <see cref="Commit"/>. |
| | 1026 | 157 | | /// </para> |
| | 1026 | 158 | | /// <para>This operation runs asynchronously.</para> |
| | 1026 | 159 | | /// </remarks> |
| | 1026 | 160 | | public async System.Threading.Tasks.Task CommitChangesAsync( |
| | 1026 | 161 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1026 | 162 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1026 | 163 | | { |
| | 1033 | 164 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 1026 | 165 | | |
| | 1026 | 166 | | // mark this object readonly |
| | 1032 | 167 | | this.propertyContainer.IsReadOnly = true; |
| | 1026 | 168 | | |
| | 1026 | 169 | | // craft the bahavior manager for this call |
| | 1032 | 170 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1026 | 171 | | |
| | 1026 | 172 | | // hold the tpl task for the server call |
| | 1032 | 173 | | Models.CertificateReference[] certRefArray = |
| | 1032 | 174 | | this.propertyContainer.CertificateReferencesProperty.GetTransportObjectIfChanged<CertificateReference, M |
| | 1032 | 175 | | Models.MetadataItem[] mdiArray = this.propertyContainer.MetadataProperty.GetTransportObjectIfChanged<Metadat |
| | 1032 | 176 | | Models.ApplicationPackageReference[] applicationPackageArray = |
| | 1032 | 177 | | this.propertyContainer.ApplicationPackageReferencesProperty.GetTransportObjectIfChanged<ApplicationPacka |
| | 1032 | 178 | | Models.StartTask modelStartTask = this.propertyContainer.StartTaskProperty.GetTransportObjectIfChanged<Start |
| | 1026 | 179 | | |
| | 1031 | 180 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.PatchPool( |
| | 1031 | 181 | | this.Id, |
| | 1031 | 182 | | modelStartTask, |
| | 1031 | 183 | | certRefArray, |
| | 1031 | 184 | | applicationPackageArray, |
| | 1031 | 185 | | mdiArray, |
| | 1031 | 186 | | bhMgr, |
| | 1031 | 187 | | cancellationToken); |
| | 1026 | 188 | | |
| | 1529 | 189 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 1031 | 190 | | } |
| | 1026 | 191 | | |
| | 1026 | 192 | | /// <summary> |
| | 1026 | 193 | | /// Commits all pending changes to this <see cref="CloudPool" /> to the Azure Batch service. |
| | 1026 | 194 | | /// </summary> |
| | 1026 | 195 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1026 | 196 | | /// <remarks> |
| | 1026 | 197 | | /// <para> |
| | 1026 | 198 | | /// Updates an existing <see cref="CloudPool"/> on the Batch service by replacing its properties with the proper |
| | 1026 | 199 | | /// Unchanged properties are ignored. |
| | 1026 | 200 | | /// All changes since the last time this entity was retrieved from the Batch service (either via <see cref="Refr |
| | 1511 | 201 | | /// or <see cref="PoolOperations.ListPools"/>) are applied. |
| | 1026 | 202 | | /// Properties which are explicitly set to null will cause an exception because the Batch service does not suppo |
| | 1026 | 203 | | /// If you need to set a property to null, use the <see cref="Commit"/> method. |
| | 1026 | 204 | | /// </para> |
| | 1026 | 205 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="CommitChangesAsync"/>.</pa |
| | 1026 | 206 | | /// </remarks> |
| | 1026 | 207 | | public void CommitChanges(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1026 | 208 | | { |
| | 1033 | 209 | | Task asyncTask = this.CommitChangesAsync(additionalBehaviors); |
| | 1033 | 210 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1031 | 211 | | } |
| | 1026 | 212 | | |
| | 1539 | 213 | | /// <summary> |
| | 1026 | 214 | | /// Resizes this pool. |
| | 1026 | 215 | | /// </summary> |
| | 1026 | 216 | | /// <param name="targetDedicatedComputeNodes"> |
| | 1026 | 217 | | /// The desired number of dedicated compute nodes in the pool. |
| | 1026 | 218 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 1026 | 219 | | /// </param> |
| | 1026 | 220 | | /// <param name="targetLowPriorityComputeNodes"> |
| | 1026 | 221 | | /// The desired number of low-priority compute nodes in the pool. |
| | 1026 | 222 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 1026 | 223 | | /// </param> |
| | 1026 | 224 | | /// <param name="resizeTimeout">The timeout for allocation of compute nodes to the pool or removal of compute no |
| | 1519 | 225 | | /// <param name="deallocationOption"> |
| | 1026 | 226 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool, |
| | 1026 | 227 | | /// </param> |
| | 1026 | 228 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1026 | 229 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1026 | 230 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1026 | 231 | | /// <remarks> |
| | 1026 | 232 | | /// <para>The resize operation requests that the pool be resized. The request puts the pool in the <see cref="C |
| | 1026 | 233 | | /// The Batch service will perform the actual resize without any further client action, and set the allocation s |
| | 1026 | 234 | | /// <para> |
| | 1026 | 235 | | /// You can only resize a pool when its <see cref="CloudPool.AllocationState"/> is <see cref="Common.AllocationS |
| | 1026 | 236 | | /// You cannot resize pools which are configured for automatic scaling (that is, the <see cref="CloudPool.AutoSc |
| | 1517 | 237 | | /// If you decrease the pool size, the Batch service chooses which nodes to remove. To remove specific nodes, c |
| | 1026 | 238 | | /// </para> |
| | 1026 | 239 | | /// <para>The resize operation runs asynchronously.</para> |
| | 1026 | 240 | | /// </remarks> |
| | 1026 | 241 | | public System.Threading.Tasks.Task ResizeAsync( |
| | 1026 | 242 | | int? targetDedicatedComputeNodes = null, |
| | 1026 | 243 | | int? targetLowPriorityComputeNodes = null, |
| | 1026 | 244 | | TimeSpan? resizeTimeout = null, |
| | | 245 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 246 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 247 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 248 | | { |
| | | 249 | | // throw if if this object is unbound |
| | 0 | 250 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 251 | | |
| | | 252 | | // create the behavior managaer |
| | 0 | 253 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 254 | | |
| | 0 | 255 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.ResizePoolAsyncImpl( |
| | 0 | 256 | | this.Id, |
| | 0 | 257 | | targetDedicatedComputeNodes, |
| | 106 | 258 | | targetLowPriorityComputeNodes, |
| | 106 | 259 | | resizeTimeout, |
| | 106 | 260 | | deallocationOption, |
| | 0 | 261 | | bhMgr, |
| | 106 | 262 | | cancellationToken); |
| | 106 | 263 | | |
| | 106 | 264 | | return asyncTask; |
| | 106 | 265 | | } |
| | | 266 | | |
| | 1025 | 267 | | |
| | 1025 | 268 | | /// <summary> |
| | 1025 | 269 | | /// Resizes this pool. |
| | 1025 | 270 | | /// </summary> |
| | | 271 | | /// <param name="targetDedicatedComputeNodes"> |
| | 1025 | 272 | | /// The desired number of dedicated compute nodes in the pool. |
| | 1025 | 273 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 1025 | 274 | | /// </param> |
| | 1025 | 275 | | /// <param name="targetLowPriorityComputeNodes"> |
| | | 276 | | /// The desired number of low-priority compute nodes in the pool. |
| | | 277 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | | 278 | | /// </param> |
| | | 279 | | /// <param name="resizeTimeout">The timeout for allocation of compute nodes to the pool or removal of compute no |
| | | 280 | | /// <param name="deallocationOption"> |
| | | 281 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool, |
| | | 282 | | /// </param> |
| | | 283 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 284 | | /// <remarks> |
| | | 285 | | /// <para>The resize operation requests that the pool be resized. The request puts the pool in the <see cref="C |
| | | 286 | | /// The Batch service will perform the actual resize without any further client action, and set the allocation s |
| | | 287 | | /// <para> |
| | | 288 | | /// You can only resize a pool when its <see cref="CloudPool.AllocationState"/> is <see cref="Common.AllocationS |
| | 1197 | 289 | | /// You cannot resize pools which are configured for automatic scaling (that is, the <see cref="CloudPool.AutoSc |
| | | 290 | | /// If you decrease the pool size, the Batch service chooses which nodes to remove. To remove specific nodes, c |
| | | 291 | | /// </para> |
| | | 292 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="ResizeAsync"/>.</para> |
| | | 293 | | /// </remarks> |
| | | 294 | | public void Resize( |
| | | 295 | | int? targetDedicatedComputeNodes = null, |
| | | 296 | | int? targetLowPriorityComputeNodes = null, |
| | | 297 | | TimeSpan? resizeTimeout = null, |
| | | 298 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 299 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 300 | | { |
| | 1003 | 301 | | Task asyncTask = ResizeAsync(targetDedicatedComputeNodes, targetLowPriorityComputeNodes, resizeTimeout, deal |
| | 0 | 302 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 303 | | } |
| | | 304 | | |
| | | 305 | | |
| | | 306 | | /// <summary> |
| | | 307 | | /// Stops a resize operation on this pool. |
| | | 308 | | /// </summary> |
| | 1002 | 309 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 310 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 311 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 312 | | /// <remarks> |
| | | 313 | | /// <para> |
| | | 314 | | /// This operation stops an ongoing resize operation on the pool. The pool size will stabilize at the number of |
| | | 315 | | /// when the stop operation is done. During the stop operation, the pool <see cref="CloudPool.AllocationState"/ |
| | | 316 | | /// to <see cref="Common.AllocationState.Stopping"/> and then to <see cref="Common.AllocationState.Steady"/>. |
| | | 317 | | /// </para> |
| | | 318 | | /// <para>The stop resize operation runs asynchronously.</para> |
| | | 319 | | /// </remarks> |
| | | 320 | | public System.Threading.Tasks.Task StopResizeAsync( |
| | | 321 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 322 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1204 | 323 | | { |
| | | 324 | | // throw if if this object is unbound |
| | 0 | 325 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 48 | 326 | | |
| | 47 | 327 | | // create the behavior managaer |
| | 0 | 328 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 329 | | |
| | 0 | 330 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.StopResizePoolAsyncImpl(this.I |
| | | 331 | | |
| | 0 | 332 | | return asyncTask; |
| | | 333 | | } |
| | | 334 | | |
| | | 335 | | /// <summary> |
| | | 336 | | /// Stops a resize operation on this pool. |
| | | 337 | | /// </summary> |
| | | 338 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 339 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1213 | 340 | | /// <remarks> |
| | | 341 | | /// <para> |
| | | 342 | | /// This operation stops an ongoing resize operation on the pool. The pool size will stabilize at the number of |
| | 53 | 343 | | /// when the stop operation is done. During the stop operation, the pool <see cref="CloudPool.AllocationState"/ |
| | 52 | 344 | | /// to <see cref="Common.AllocationState.Stopping"/> and then to <see cref="Common.AllocationState.Steady"/>. |
| | | 345 | | /// </para> |
| | | 346 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="StopResizeAsync"/>.</para> |
| | | 347 | | /// </remarks> |
| | | 348 | | public void StopResize(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 349 | | { |
| | 0 | 350 | | Task asyncTask = StopResizeAsync(additionalBehaviors); |
| | 0 | 351 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 352 | | } |
| | | 353 | | |
| | | 354 | | /// <summary> |
| | | 355 | | /// Enumerates the <see cref="ComputeNode">compute nodes</see> of this pool. |
| | | 356 | | /// </summary> |
| | | 357 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 1206 | 358 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 99 | 359 | | /// <returns>An <see cref="IPagedEnumerable{ComputeNode}"/> that can be used to enumerate compute nodes asynchro |
| | | 360 | | /// <remarks>This method returns immediately; the nodes are retrieved from the Batch service only when the colle |
| | | 361 | | /// Retrieval is non-atomic; nodes are retrieved in pages during enumeration of the collection.</remarks> |
| | | 362 | | public IPagedEnumerable<ComputeNode> ListComputeNodes(DetailLevel detailLevel = null, IEnumerable<BatchClientBeh |
| | | 363 | | { |
| | | 364 | | // throw if if this object is unbound |
| | 0 | 365 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 366 | | |
| | | 367 | | // create the behavior managaer |
| | 0 | 368 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 369 | | |
| | 1204 | 370 | | IPagedEnumerable<ComputeNode> computeNodeList = this.parentBatchClient.PoolOperations.ListComputeNodesImpl(t |
| | 101 | 371 | | return computeNodeList; |
| | | 372 | | } |
| | | 373 | | |
| | | 374 | | /// <summary> |
| | | 375 | | /// Gets the specified compute node from this pool. |
| | | 376 | | /// </summary> |
| | | 377 | | /// <param name="computeNodeId">The id of the compute node to get from the pool.</param> |
| | | 378 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr |
| | | 379 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 380 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 381 | | /// <returns>A <see cref="ComputeNode"/> containing information about the specified compute node.</returns> |
| | | 382 | | /// <remarks>The get node operation runs asynchronously.</remarks> |
| | | 383 | | public System.Threading.Tasks.Task<ComputeNode> GetComputeNodeAsync( |
| | | 384 | | string computeNodeId, |
| | 1205 | 385 | | DetailLevel detailLevel = null, |
| | 82 | 386 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 387 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 388 | | { |
| | | 389 | | // throw if if this object is unbound |
| | 0 | 390 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 391 | | |
| | | 392 | | // craft the behavior manager for this call |
| | 0 | 393 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); |
| | 1005 | 394 | | |
| | 0 | 395 | | System.Threading.Tasks.Task<ComputeNode> asyncTask = this.parentBatchClient.PoolOperations.GetComputeNodeAsy |
| | | 396 | | |
| | 0 | 397 | | return asyncTask; |
| | | 398 | | } |
| | | 399 | | |
| | | 400 | | /// <summary> |
| | | 401 | | /// Gets the specified compute node from this pool. |
| | 1206 | 402 | | /// </summary> |
| | | 403 | | /// <param name="computeNodeId">The id of the compute node to get from the pool.</param> |
| | | 404 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr |
| | 49 | 405 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 48 | 406 | | /// <returns>A <see cref="ComputeNode"/> containing information about the specified compute node.</returns> |
| | | 407 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetComputeNodeAsync"/>. |
| | | 408 | | public ComputeNode GetComputeNode(string computeNodeId, DetailLevel detailLevel = null, IEnumerable<BatchClientB |
| | | 409 | | { |
| | 0 | 410 | | Task<ComputeNode> asyncTask = GetComputeNodeAsync(computeNodeId, detailLevel, additionalBehaviors); |
| | | 411 | | |
| | 0 | 412 | | ComputeNode result = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 413 | | return result; |
| | 1208 | 414 | | } |
| | 100 | 415 | | |
| | | 416 | | /// <summary> |
| | | 417 | | /// Enables automatic scaling on this pool. |
| | | 418 | | /// </summary> |
| | | 419 | | /// <param name="autoscaleFormula">The formula for the desired number of compute nodes in the pool.</param> |
| | | 420 | | /// <param name="autoscaleEvaluationInterval">The time interval at which to automatically adjust the pool size a |
| | | 421 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 422 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1002 | 423 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 424 | | /// <remarks> |
| | | 425 | | /// <para>The formula is checked for validity before it is applied to the pool. If the formula is not valid, an |
| | | 426 | | /// <para>You cannot enable automatic scaling on a pool if a resize operation is in progress on the pool.</para> |
| | | 427 | | /// <para>The enable autoscale operation runs asynchronously.</para> |
| | | 428 | | /// </remarks> |
| | | 429 | | public async System.Threading.Tasks.Task EnableAutoScaleAsync( |
| | | 430 | | string autoscaleFormula = null, |
| | 1003 | 431 | | TimeSpan? autoscaleEvaluationInterval = null, |
| | | 432 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 433 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 434 | | { |
| | | 435 | | // throw if if this object is unbound |
| | 0 | 436 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 437 | | |
| | | 438 | | // create the behavior managaer |
| | 0 | 439 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 440 | | |
| | 0 | 441 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.EnableAutoScaleAsyncImpl(this. |
| | 1001 | 442 | | |
| | 0 | 443 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 0 | 444 | | } |
| | | 445 | | |
| | | 446 | | /// <summary> |
| | | 447 | | /// Enables automatic scaling on this pool. |
| | | 448 | | /// </summary> |
| | | 449 | | /// <param name="autoscaleFormula">The formula for the desired number of compute nodes in the pool.</param> |
| | 1211 | 450 | | /// <param name="autoscaleEvaluationInterval">The time interval at which to automatically adjust the pool size a |
| | 103 | 451 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 452 | | /// <remarks> |
| | | 453 | | /// <para>The formula is checked for validity before it is applied to the pool. If the formula is not valid, an |
| | | 454 | | /// <para>You cannot enable automatic scaling on a pool if a resize operation is in progress on the pool.</para> |
| | | 455 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="EnableAutoScaleAsync"/>.</ |
| | | 456 | | /// </remarks> |
| | | 457 | | public void EnableAutoScale( |
| | | 458 | | string autoscaleFormula = null, |
| | 1001 | 459 | | TimeSpan? autoscaleEvaluationInterval = null, |
| | | 460 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 461 | | { |
| | 0 | 462 | | Task asyncTask = EnableAutoScaleAsync(autoscaleFormula, autoscaleEvaluationInterval, additionalBehaviors); |
| | 0 | 463 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 464 | | } |
| | | 465 | | |
| | | 466 | | /// <summary> |
| | 1219 | 467 | | /// Disables automatic scaling on this pool. |
| | 112 | 468 | | /// </summary> |
| | | 469 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 470 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 471 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 472 | | /// <remarks> |
| | | 473 | | /// <para>The disable autoscale operation runs asynchronously.</para> |
| | | 474 | | /// </remarks> |
| | | 475 | | public async System.Threading.Tasks.Task DisableAutoScaleAsync(IEnumerable<BatchClientBehavior> additionalBehavi |
| | | 476 | | { |
| | | 477 | | // throw if if this object is unbound |
| | 0 | 478 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 479 | | |
| | 1204 | 480 | | // create the behavior managaer |
| | 99 | 481 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 482 | | |
| | 0 | 483 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.DisableAutoScaleAsyncImpl(this |
| | | 484 | | |
| | 0 | 485 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 0 | 486 | | } |
| | | 487 | | |
| | | 488 | | /// <summary> |
| | 1002 | 489 | | /// Disables automatic scaling on this pool. |
| | | 490 | | /// </summary> |
| | | 491 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 492 | | /// <remarks> |
| | | 493 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="DisableAutoScaleAsync"/>.< |
| | | 494 | | /// </remarks> |
| | | 495 | | public void DisableAutoScale(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 496 | | { |
| | 0 | 497 | | Task asyncTask = DisableAutoScaleAsync(additionalBehaviors); |
| | 0 | 498 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 499 | | } |
| | | 500 | | |
| | 1205 | 501 | | /// <summary> |
| | 103 | 502 | | /// Gets the result of evaluating an automatic scaling formula on this pool. This |
| | | 503 | | /// is primarily for validating an autoscale formula, as it simply returns the result |
| | | 504 | | /// without applying the formula to the pool. |
| | | 505 | | /// </summary> |
| | | 506 | | /// <param name="autoscaleFormula">The formula to be evaluated on the pool.</param> |
| | | 507 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 508 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 509 | | /// <returns>The result of evaluating the <paramref name="autoscaleFormula"/> on this pool.</returns> |
| | 1211 | 510 | | /// <remarks> |
| | | 511 | | /// <para>The formula is validated and its results calculated, but is not applied to the pool. To apply the for |
| | | 512 | | /// <para>This method does not change any state of the pool, and does not affect the <see cref="CloudPool.LastMo |
| | 54 | 513 | | /// <para>The evaluate operation runs asynchronously.</para> |
| | 47 | 514 | | /// </remarks> |
| | | 515 | | public async System.Threading.Tasks.Task<AutoScaleRun> EvaluateAutoScaleAsync( |
| | | 516 | | string autoscaleFormula, |
| | | 517 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 518 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 519 | | { |
| | | 520 | | // throw if if this object is unbound |
| | 0 | 521 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 522 | | |
| | | 523 | | // create the behavior managaer |
| | 0 | 524 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1204 | 525 | | |
| | 0 | 526 | | System.Threading.Tasks.Task<AutoScaleRun> asyncTask = this.parentBatchClient.PoolOperations.EvaluateAutoScal |
| | | 527 | | |
| | 54 | 528 | | return await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 53 | 529 | | } |
| | | 530 | | |
| | | 531 | | /// <summary> |
| | | 532 | | /// Gets the result of evaluating an automatic scaling formula on this pool. This |
| | | 533 | | /// is primarily for validating an autoscale formula, as it simply returns the result |
| | | 534 | | /// without applying the formula to the pool. |
| | | 535 | | /// </summary> |
| | | 536 | | /// <param name="autoscaleFormula">The formula to be evaluated on the pool.</param> |
| | 1204 | 537 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 111 | 538 | | /// <returns>The result of evaluating the <paramref name="autoscaleFormula"/> on this pool.</returns> |
| | | 539 | | /// <remarks> |
| | | 540 | | /// <para>The formula is validated and its results calculated, but is not applied to the pool. To apply the for |
| | | 541 | | /// <para>This method does not change any state of the pool, and does not affect the <see cref="CloudPool.LastMo |
| | | 542 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="EvaluateAutoScaleAsync"/>. |
| | | 543 | | /// </remarks> |
| | | 544 | | public AutoScaleRun EvaluateAutoScale(string autoscaleFormula, IEnumerable<BatchClientBehavior> additionalBehavi |
| | | 545 | | { |
| | 0 | 546 | | Task<AutoScaleRun> asyncTask = EvaluateAutoScaleAsync(autoscaleFormula, additionalBehaviors); |
| | 0 | 547 | | AutoScaleRun autoScaleRun = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors) |
| | 1001 | 548 | | |
| | 0 | 549 | | return autoScaleRun; |
| | | 550 | | } |
| | | 551 | | |
| | | 552 | | /// <summary> |
| | | 553 | | /// Removes the specified compute node from this pool. |
| | | 554 | | /// </summary> |
| | | 555 | | /// <param name="computeNodeId">The id of the compute node to remove from the pool.</param> |
| | 1205 | 556 | | /// <param name="deallocationOption"> |
| | 102 | 557 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 558 | | /// </param> |
| | | 559 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | | 560 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 561 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 562 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 563 | | /// <remarks> |
| | | 564 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | | 565 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 1214 | 566 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | 87 | 567 | | /// <para>The remove operation runs asynchronously.</para> |
| | | 568 | | /// </remarks> |
| | | 569 | | public async System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | | 570 | | string computeNodeId, |
| | | 571 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 572 | | TimeSpan? resizeTimeout = null, |
| | | 573 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 574 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1002 | 575 | | { |
| | 0 | 576 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 577 | | |
| | | 578 | | // create the behavior managaer |
| | 0 | 579 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 580 | | |
| | 0 | 581 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.RemoveFromPoolAsyncImpl(this.I |
| | | 582 | | |
| | 1002 | 583 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 0 | 584 | | } |
| | | 585 | | |
| | | 586 | | /// <summary> |
| | | 587 | | /// Removes the specified compute node from this pool. |
| | | 588 | | /// </summary> |
| | | 589 | | /// <param name="computeNodeId">The id of the compute node to remove from the pool.</param> |
| | | 590 | | /// <param name="deallocationOption"> |
| | | 591 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 592 | | /// </param> |
| | | 593 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | | 594 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 595 | | /// <remarks> |
| | 1001 | 596 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | | 597 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | | 598 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | | 599 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(string |
| | | 600 | | /// </remarks> |
| | | 601 | | public void RemoveFromPool( |
| | | 602 | | string computeNodeId, |
| | | 603 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 604 | | TimeSpan? resizeTimeout = null, |
| | | 605 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 606 | | { |
| | 0 | 607 | | Task asyncTask = RemoveFromPoolAsync(computeNodeId, deallocationOption, resizeTimeout, additionalBehaviors); |
| | 0 | 608 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1207 | 609 | | } |
| | 212 | 610 | | |
| | | 611 | | /// <summary> |
| | | 612 | | /// Removes the specified compute nodes from this pool. |
| | | 613 | | /// </summary> |
| | | 614 | | /// <param name="computeNodeIds">The ids of the compute nodes to remove from the pool.</param> |
| | | 615 | | /// <param name="deallocationOption"> |
| | | 616 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 617 | | /// </param> |
| | | 618 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | | 619 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 620 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 621 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 622 | | /// <remarks> |
| | 1204 | 623 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 121 | 624 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | | 625 | | /// <para>The remove operation runs asynchronously.</para> |
| | | 626 | | /// </remarks> |
| | | 627 | | public async System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | | 628 | | IEnumerable<string> computeNodeIds, |
| | | 629 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 630 | | TimeSpan? resizeTimeout = null, |
| | | 631 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1205 | 632 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 107 | 633 | | { |
| | 0 | 634 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 635 | | |
| | | 636 | | // create the behavior managaer |
| | 0 | 637 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 638 | | |
| | 0 | 639 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.RemoveFromPoolAsyncImpl(this.I |
| | | 640 | | |
| | 1002 | 641 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 0 | 642 | | } |
| | | 643 | | |
| | | 644 | | /// <summary> |
| | | 645 | | /// Removes the specified compute nodes from this pool. |
| | | 646 | | /// </summary> |
| | | 647 | | /// <param name="computeNodeIds">The ids of the compute nodes to remove from the pool.</param> |
| | | 648 | | /// <param name="deallocationOption"> |
| | 1204 | 649 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 650 | | /// </param> |
| | | 651 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 45 | 652 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 44 | 653 | | /// <remarks> |
| | | 654 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | | 655 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | | 656 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(IEnume |
| | | 657 | | /// </remarks> |
| | | 658 | | public void RemoveFromPool( |
| | | 659 | | IEnumerable<string> computeNodeIds, |
| | | 660 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 1205 | 661 | | TimeSpan? resizeTimeout = null, |
| | 98 | 662 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 663 | | { |
| | 0 | 664 | | Task asyncTask = RemoveFromPoolAsync(computeNodeIds, deallocationOption, resizeTimeout, additionalBehaviors) |
| | 0 | 665 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 666 | | } |
| | | 667 | | |
| | | 668 | | /// <summary> |
| | | 669 | | /// Removes the specified compute node from this pool. |
| | | 670 | | /// </summary> |
| | | 671 | | /// <param name="computeNode">The <see cref="ComputeNode"/> to remove from the pool.</param> |
| | | 672 | | /// <param name="deallocationOption">Specifies when nodes may be removed from the pool. The default is <see cref |
| | | 673 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 1205 | 674 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 113 | 675 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 676 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 677 | | /// <remarks> |
| | | 678 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | | 679 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | | 680 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | | 681 | | /// <para>The remove operation runs asynchronously.</para> |
| | | 682 | | /// </remarks> |
| | | 683 | | public async System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | 0 | 684 | | ComputeNode computeNode, |
| | | 685 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 686 | | TimeSpan? resizeTimeout = null, |
| | | 687 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 688 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 0 | 689 | | { |
| | 2 | 690 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 691 | | |
| | | 692 | | // create the behavior managaer |
| | 0 | 693 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 694 | | |
| | 0 | 695 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.RemoveFromPoolAsyncImpl( |
| | 0 | 696 | | this.Id, |
| | 0 | 697 | | new List<ComputeNode> { computeNode }, |
| | 0 | 698 | | deallocationOption, |
| | 0 | 699 | | resizeTimeout, |
| | 0 | 700 | | bhMgr, |
| | 0 | 701 | | cancellationToken); |
| | 103 | 702 | | |
| | 103 | 703 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 103 | 704 | | } |
| | 103 | 705 | | |
| | 103 | 706 | | /// <summary> |
| | 103 | 707 | | /// Removes the specified compute node from this pool. |
| | 103 | 708 | | /// </summary> |
| | 103 | 709 | | /// <param name="computeNode">The <see cref="ComputeNode"/> to remove from the pool.</param> |
| | 151 | 710 | | /// <param name="deallocationOption"> |
| | 103 | 711 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 103 | 712 | | /// </param> |
| | 103 | 713 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 103 | 714 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 103 | 715 | | /// <remarks> |
| | 103 | 716 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | 158 | 717 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 103 | 718 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | 144 | 719 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(Comput |
| | 103 | 720 | | /// </remarks> |
| | 103 | 721 | | public void RemoveFromPool( |
| | 156 | 722 | | ComputeNode computeNode, |
| | 103 | 723 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 151 | 724 | | TimeSpan? resizeTimeout = null, |
| | 103 | 725 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 103 | 726 | | { |
| | 0 | 727 | | Task asyncTask = RemoveFromPoolAsync(computeNode, deallocationOption, resizeTimeout, additionalBehaviors); |
| | 103 | 728 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 729 | | } |
| | | 730 | | |
| | | 731 | | /// <summary> |
| | | 732 | | /// Removes the specified compute nodes from this pool. |
| | | 733 | | /// </summary> |
| | | 734 | | /// <param name="computeNodes">The <see cref="ComputeNode">compute nodes</see> to remove from the pool.</param> |
| | | 735 | | /// <param name="deallocationOption"> |
| | | 736 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 737 | | /// </param> |
| | | 738 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | | 739 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 740 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 741 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 742 | | /// <remarks> |
| | | 743 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | | 744 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | | 745 | | /// <para>The remove operation runs asynchronously.</para> |
| | | 746 | | /// </remarks> |
| | | 747 | | public async System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | | 748 | | IEnumerable<ComputeNode> computeNodes, |
| | | 749 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 750 | | TimeSpan? resizeTimeout = null, |
| | | 751 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 752 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 753 | | { |
| | 0 | 754 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | | 755 | | |
| | | 756 | | // create the behavior managaer |
| | 0 | 757 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 758 | | |
| | 0 | 759 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.RemoveFromPoolAsyncImpl(this.I |
| | | 760 | | |
| | 0 | 761 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 0 | 762 | | } |
| | | 763 | | |
| | | 764 | | |
| | | 765 | | /// <summary> |
| | | 766 | | /// Removes the specified compute nodes from this pool. |
| | | 767 | | /// </summary> |
| | | 768 | | /// <param name="computeNodes">The <see cref="ComputeNode">compute nodes</see> to remove from the pool.</param> |
| | | 769 | | /// <param name="deallocationOption"> |
| | | 770 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 771 | | /// </param> |
| | | 772 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | | 773 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 774 | | /// <remarks> |
| | | 775 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | | 776 | | /// <para>When you remove nodes from a pool, the pool's <see cref="CloudPool.AllocationState"/> changes from <se |
| | | 777 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(IEnume |
| | | 778 | | /// </remarks> |
| | | 779 | | public void RemoveFromPool( |
| | | 780 | | IEnumerable<ComputeNode> computeNodes, |
| | | 781 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 782 | | TimeSpan? resizeTimeout = null, |
| | | 783 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 784 | | { |
| | | 785 | | |
| | 0 | 786 | | Task asyncTask = RemoveFromPoolAsync(computeNodes, deallocationOption, resizeTimeout, additionalBehaviors); |
| | 0 | 787 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 788 | | } |
| | | 789 | | |
| | | 790 | | #endregion CloudPool |
| | | 791 | | |
| | | 792 | | #region IRefreshable |
| | | 793 | | |
| | | 794 | | /// <summary> |
| | | 795 | | /// Refreshes the current <see cref="CloudPool"/>. |
| | | 796 | | /// </summary> |
| | | 797 | | /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Id |
| | | 798 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 799 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 800 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> representing the asynchronous refresh operation.</retur |
| | | 801 | | public async System.Threading.Tasks.Task RefreshAsync( |
| | | 802 | | DetailLevel detailLevel = null, |
| | | 803 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 804 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 805 | | { |
| | | 806 | | // create the behavior managaer |
| | 2 | 807 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); |
| | | 808 | | |
| | 2 | 809 | | System.Threading.Tasks.Task<AzureOperationResponse<Models.CloudPool, Models.PoolGetHeaders>> asyncTask = thi |
| | 2 | 810 | | this.Id, |
| | 2 | 811 | | bhMgr, |
| | 2 | 812 | | cancellationToken); |
| | | 813 | | |
| | 2 | 814 | | AzureOperationResponse<Models.CloudPool, Models.PoolGetHeaders> response = await asyncTask.ConfigureAwait(co |
| | | 815 | | |
| | | 816 | | // get pool from response |
| | 1 | 817 | | Models.CloudPool newProtocolPool = response.Body; |
| | | 818 | | |
| | 1 | 819 | | PropertyContainer newContainer = new PropertyContainer(newProtocolPool); |
| | 1 | 820 | | this.propertyContainer = newContainer; |
| | 1 | 821 | | } |
| | | 822 | | |
| | | 823 | | /// <summary> |
| | | 824 | | /// Refreshes the current <see cref="CloudPool"/>. |
| | | 825 | | /// </summary> |
| | | 826 | | /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Id |
| | | 827 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 828 | | public void Refresh(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 829 | | { |
| | 0 | 830 | | Task asyncTask = RefreshAsync(detailLevel, additionalBehaviors); |
| | 0 | 831 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 832 | | } |
| | | 833 | | |
| | | 834 | | |
| | | 835 | | #endregion Irefreshable |
| | | 836 | | |
| | | 837 | | |
| | | 838 | | } |
| | | 839 | | } |