| | 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 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Text; |
| | 7 | | using System.Threading; |
| | 8 | | using System.Threading.Tasks; |
| | 9 | | using System.IO; |
| | 10 | | using Common = Microsoft.Azure.Batch.Common; |
| | 11 | |
|
| | 12 | | namespace Microsoft.Azure.Batch |
| | 13 | | { |
| | 14 | | using Models = Microsoft.Azure.Batch.Protocol.Models; |
| | 15 | | using Microsoft.Rest.Azure; |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Performs pool-related operations on an Azure Batch account. |
| | 19 | | /// </summary> |
| | 20 | | public class PoolOperations : IInheritedBehaviors |
| | 21 | | { |
| | 22 | | private readonly BatchClient _parentBatchClient; |
| | 23 | |
|
| | 24 | | #region // constructors |
| | 25 | |
|
| 0 | 26 | | private PoolOperations() |
| | 27 | | { |
| 0 | 28 | | } |
| | 29 | |
|
| 47 | 30 | | internal PoolOperations(BatchClient parentBC, IEnumerable<BatchClientBehavior> inheritedBehaviors) |
| | 31 | | { |
| 47 | 32 | | _parentBatchClient = parentBC; |
| | 33 | |
|
| | 34 | | // implement inheritance of behaviors |
| 47 | 35 | | InheritUtil.InheritClientBehaviorsAndSetPublicProperty(this, inheritedBehaviors); |
| 47 | 36 | | } |
| | 37 | |
|
| | 38 | | #endregion // constructors |
| | 39 | |
|
| | 40 | | #region // internal properties/methods |
| | 41 | |
|
| | 42 | | internal BatchClient ParentBatchClient |
| | 43 | | { |
| 89 | 44 | | get { return _parentBatchClient; } |
| | 45 | | } |
| | 46 | |
|
| | 47 | | #endregion // internal properties/methods |
| | 48 | |
|
| | 49 | | #region IInheritedBehaviors |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Gets or sets a list of behaviors that modify or customize requests to the Batch service |
| | 53 | | /// made via this <see cref="PoolOperations"/>. |
| | 54 | | /// </summary> |
| | 55 | | /// <remarks> |
| | 56 | | /// <para>These behaviors are inherited by child objects.</para> |
| | 57 | | /// <para>Modifications are applied in the order of the collection. The last write wins.</para> |
| | 58 | | /// </remarks> |
| 267 | 59 | | public IList<BatchClientBehavior> CustomBehaviors { get; set; } |
| | 60 | |
|
| | 61 | | #endregion IInheeritedBehaviors |
| | 62 | |
|
| | 63 | | #region // PoolOperations |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// Enumerates the <see cref="CloudPool">pools</see> in the Batch account. |
| | 67 | | /// </summary> |
| | 68 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 69 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 70 | | /// <returns>An <see cref="IPagedEnumerable{CloudPool}"/> that can be used to enumerate pools asynchronously or |
| | 71 | | /// <remarks>This method returns immediately; the pools are retrieved from the Batch service only when the colle |
| | 72 | | /// Retrieval is non-atomic; pools are retrieved in pages during enumeration of the collection.</remarks> |
| | 73 | | public IPagedEnumerable<CloudPool> ListPools(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> ad |
| | 74 | | { |
| | 75 | | // craft the behavior manager for this call |
| 3 | 76 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 77 | |
|
| 3 | 78 | | PagedEnumerable<CloudPool> enumerable = new PagedEnumerable<CloudPool>( // the lamda will be the enumerator |
| 3 | 79 | | () => |
| 3 | 80 | | { |
| 3 | 81 | | // here is the actual strongly typed enumerator |
| 6 | 82 | | AsyncListPoolsEnumerator typedEnumerator = new AsyncListPoolsEnumerator(this, bhMgr, detailLevel); |
| 3 | 83 | |
|
| 3 | 84 | | // here is the base |
| 3 | 85 | | PagedEnumeratorBase<CloudPool> enumeratorBase = typedEnumerator; |
| 3 | 86 | |
|
| 6 | 87 | | return enumeratorBase; |
| 3 | 88 | | }); |
| | 89 | |
|
| 3 | 90 | | return enumerable; |
| | 91 | | } |
| | 92 | |
|
| | 93 | | /// <summary> |
| | 94 | | /// Gets the specified <see cref="CloudPool"/>. |
| | 95 | | /// </summary> |
| | 96 | | /// <param name="poolId">The id of the pool to get.</param> |
| | 97 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr |
| | 98 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 99 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 100 | | /// <returns>A <see cref="CloudPool"/> containing information about the specified Azure Batch pool.</returns> |
| | 101 | | /// <remarks>The get pool operation runs asynchronously.</remarks> |
| | 102 | | public async System.Threading.Tasks.Task<CloudPool> GetPoolAsync( |
| | 103 | | string poolId, |
| | 104 | | DetailLevel detailLevel = null, |
| | 105 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 106 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 107 | | { |
| | 108 | | // create the behavior manager |
| 29 | 109 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); |
| | 110 | |
|
| | 111 | | // start call to server |
| 29 | 112 | | System.Threading.Tasks.Task<AzureOperationResponse<Models.CloudPool, Models.PoolGetHeaders>> asyncTask = |
| 29 | 113 | | this.ParentBatchClient.ProtocolLayer.GetPool(poolId, bhMgr, cancellationToken); |
| | 114 | |
|
| 29 | 115 | | AzureOperationResponse<Models.CloudPool, Models.PoolGetHeaders> response = await asyncTask.ConfigureAwait(co |
| | 116 | |
|
| | 117 | | // construct object model Pool |
| 23 | 118 | | CloudPool bcPool = new CloudPool(this.ParentBatchClient, response.Body, this.CustomBehaviors); |
| | 119 | |
|
| 23 | 120 | | return bcPool; |
| 23 | 121 | | } |
| | 122 | |
|
| | 123 | | /// <summary> |
| | 124 | | /// Gets the specified <see cref="CloudPool"/>. |
| | 125 | | /// </summary> |
| | 126 | | /// <param name="poolId">The id of the pool to get.</param> |
| | 127 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr |
| | 128 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 129 | | /// <returns>A <see cref="CloudPool"/> containing information about the specified Azure Batch pool.</returns> |
| | 130 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetPoolAsync"/>.</remar |
| | 131 | | public CloudPool GetPool( |
| | 132 | | string poolId, |
| | 133 | | DetailLevel detailLevel = null, |
| | 134 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 135 | | { |
| 13 | 136 | | Task<CloudPool> asyncTask = GetPoolAsync(poolId, detailLevel, additionalBehaviors); |
| 13 | 137 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 138 | | } |
| | 139 | |
|
| | 140 | | internal async System.Threading.Tasks.Task DeletePoolAsyncImpl(string poolIdToDelete, BehaviorManager bhMgr, Can |
| | 141 | | { |
| 5 | 142 | | System.Threading.Tasks.Task<AzureOperationHeaderResponse<Models.PoolDeleteHeaders>> asyncTask = _parentBatch |
| | 143 | |
|
| 5 | 144 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 4 | 145 | | } |
| | 146 | |
|
| | 147 | | /// <summary> |
| | 148 | | /// Deletes the specified pool. |
| | 149 | | /// </summary> |
| | 150 | | /// <param name="poolId">The id of the pool to delete.</param> |
| | 151 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 152 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 153 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | 154 | | /// <remarks> |
| | 155 | | /// <para>The delete operation requests that the pool be deleted. The request puts the pool in the <see cref="C |
| | 156 | | /// The Batch service will requeue any running tasks and perform the actual pool deletion without any further cl |
| | 157 | | /// <para>The delete operation runs asynchronously.</para> |
| | 158 | | /// </remarks> |
| | 159 | | public async System.Threading.Tasks.Task DeletePoolAsync( |
| | 160 | | string poolId, |
| | 161 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 162 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 163 | | { |
| | 164 | | // create the behavior manager |
| 5 | 165 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 166 | |
|
| 5 | 167 | | System.Threading.Tasks.Task asyncTask = DeletePoolAsyncImpl(poolId, bhMgr, cancellationToken); |
| | 168 | |
|
| 5 | 169 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 4 | 170 | | } |
| | 171 | |
|
| | 172 | | /// <summary> |
| | 173 | | /// Deletes the specified pool. |
| | 174 | | /// </summary> |
| | 175 | | /// <param name="poolId">The id of the pool to delete.</param> |
| | 176 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 177 | | /// <remarks> |
| | 178 | | /// <para>The delete operation requests that the pool be deleted. The request puts the pool in the <see cref="C |
| | 179 | | /// The Batch service will requeue any running tasks and perform the actual pool deletion without any further cl |
| | 180 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="DeletePoolAsync"/>.</re |
| | 181 | | /// </remarks> |
| | 182 | | public void DeletePool(string poolId, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 183 | | { |
| 0 | 184 | | Task asyncTask = DeletePoolAsync(poolId, additionalBehaviors); |
| 0 | 185 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 186 | | } |
| | 187 | |
|
| | 188 | | /// <summary> |
| | 189 | | /// Creates an instance of CloudPool that is unbound and does not have a consistency relationship to any pool in |
| | 190 | | /// </summary> |
| | 191 | | /// <returns>A <see cref="CloudPool"/> representing a new pool that has not been added to the Batch service. |
| | 192 | | /// To add the pool to the Batch account, call <see cref="CloudPool.CommitAsync"/>.</returns> |
| | 193 | | public CloudPool CreatePool() |
| | 194 | | { |
| 2 | 195 | | CloudPool unboundPool = new CloudPool(this.ParentBatchClient, this.CustomBehaviors); |
| | 196 | |
|
| 2 | 197 | | return unboundPool; |
| | 198 | | } |
| | 199 | |
|
| | 200 | | /// <summary> |
| | 201 | | /// Creates an instance of CloudPool that is unbound and does not have a consistency relationship to any pool in |
| | 202 | | /// </summary> |
| | 203 | | /// <param name="poolId">The id of the pool.</param> |
| | 204 | | /// <param name="virtualMachineSize"> |
| | 205 | | /// The size of virtual machines in the pool. See https://azure.microsoft.com/documentation/articles/cloud-serv |
| | 206 | | /// <param name="cloudServiceConfiguration">The <see cref="CloudServiceConfiguration"/> for the pool.</param> |
| | 207 | | /// <param name="targetDedicatedComputeNodes"> |
| | 208 | | /// The desired number of dedicated compute nodes in the pool. |
| | 209 | | /// If <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeNodes"/> are o |
| | 210 | | /// you must set the <see cref="CloudPool.AutoScaleEnabled"/> and <see cref="CloudPool.AutoScaleFormula"/> prope |
| | 211 | | /// </param> |
| | 212 | | /// <param name="targetLowPriorityComputeNodes"> |
| | 213 | | /// The desired number of low-priority compute nodes in the pool. |
| | 214 | | /// If <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeNodes"/> are o |
| | 215 | | /// you must set the <see cref="CloudPool.AutoScaleEnabled"/> and <see cref="CloudPool.AutoScaleFormula"/> prope |
| | 216 | | /// </param> |
| | 217 | | /// <returns>A <see cref="CloudPool"/> representing a new pool that has not been added to the Batch service. |
| | 218 | | /// To add the pool to the Batch account, call <see cref="CloudPool.CommitAsync"/>.</returns> |
| | 219 | | /// <remarks> |
| | 220 | | /// <para>For information about Azure Guest OS families, see https://azure.microsoft.com/documentation/articles/ |
| | 221 | | /// </remarks> |
| | 222 | | public CloudPool CreatePool( |
| | 223 | | string poolId, |
| | 224 | | string virtualMachineSize, |
| | 225 | | CloudServiceConfiguration cloudServiceConfiguration, |
| | 226 | | int? targetDedicatedComputeNodes = null, |
| | 227 | | int? targetLowPriorityComputeNodes = null) |
| | 228 | | { |
| 3 | 229 | | CloudPool unboundPool = new CloudPool(this.ParentBatchClient, this.CustomBehaviors) |
| 3 | 230 | | { |
| 3 | 231 | | CloudServiceConfiguration = cloudServiceConfiguration, |
| 3 | 232 | | Id = poolId, |
| 3 | 233 | | VirtualMachineSize = virtualMachineSize, |
| 3 | 234 | | TargetDedicatedComputeNodes = targetDedicatedComputeNodes, |
| 3 | 235 | | TargetLowPriorityComputeNodes = targetLowPriorityComputeNodes, |
| 3 | 236 | | }; |
| | 237 | |
|
| 3 | 238 | | return unboundPool; |
| | 239 | | } |
| | 240 | |
|
| | 241 | | /// <summary> |
| | 242 | | /// Creates an instance of CloudPool that is unbound and does not have a consistency relationship to any pool in |
| | 243 | | /// </summary> |
| | 244 | | /// <param name="poolId">The id of the pool.</param> |
| | 245 | | /// <param name="virtualMachineSize">The size of virtual machines in the pool. |
| | 246 | | /// See https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/ for windows sizes and |
| | 247 | | /// </param> |
| | 248 | | /// <param name="virtualMachineConfiguration">The <see cref="VirtualMachineConfiguration"/> for the pool.</param |
| | 249 | | /// <param name="targetDedicatedComputeNodes"> |
| | 250 | | /// The desired number of dedicated compute nodes in the pool. |
| | 251 | | /// If <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeNodes"/> are o |
| | 252 | | /// you must set the <see cref="CloudPool.AutoScaleEnabled"/> and <see cref="CloudPool.AutoScaleFormula"/> prope |
| | 253 | | /// </param> |
| | 254 | | /// <param name="targetLowPriorityComputeNodes"> |
| | 255 | | /// The desired number of low-priority compute nodes in the pool. |
| | 256 | | /// If <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeNodes"/> are o |
| | 257 | | /// you must set the <see cref="CloudPool.AutoScaleEnabled"/> and <see cref="CloudPool.AutoScaleFormula"/> prope |
| | 258 | | /// </param> |
| | 259 | | /// <returns>A <see cref="CloudPool"/> representing a new pool that has not been added to the Batch service. |
| | 260 | | /// To add the pool to the Batch account, call <see cref="CloudPool.CommitAsync"/>.</returns> |
| | 261 | | public CloudPool CreatePool( |
| | 262 | | string poolId, |
| | 263 | | string virtualMachineSize, |
| | 264 | | VirtualMachineConfiguration virtualMachineConfiguration, |
| | 265 | | int? targetDedicatedComputeNodes = null, |
| | 266 | | int? targetLowPriorityComputeNodes = null) |
| | 267 | | { |
| 0 | 268 | | CloudPool unboundPool = new CloudPool(this.ParentBatchClient, this.CustomBehaviors) |
| 0 | 269 | | { |
| 0 | 270 | | Id = poolId, |
| 0 | 271 | | VirtualMachineConfiguration = virtualMachineConfiguration, |
| 0 | 272 | | VirtualMachineSize = virtualMachineSize, |
| 0 | 273 | | TargetDedicatedComputeNodes = targetDedicatedComputeNodes, |
| 0 | 274 | | TargetLowPriorityComputeNodes = targetLowPriorityComputeNodes, |
| 0 | 275 | | }; |
| | 276 | |
|
| 0 | 277 | | return unboundPool; |
| | 278 | | } |
| | 279 | |
|
| | 280 | | internal System.Threading.Tasks.Task ResizePoolAsyncImpl( |
| | 281 | | string poolId, |
| | 282 | | int? targetDedicatedComputeNodes, |
| | 283 | | int? targetLowPriorityComputeNodes, |
| | 284 | | TimeSpan? resizeTimeout, |
| | 285 | | Common.ComputeNodeDeallocationOption? deallocationOption, |
| | 286 | | BehaviorManager bhMgr, |
| | 287 | | CancellationToken cancellationToken) |
| | 288 | | { |
| 1 | 289 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.ResizePool( |
| 1 | 290 | | poolId, |
| 1 | 291 | | targetDedicatedComputeNodes, |
| 1 | 292 | | targetLowPriorityComputeNodes, |
| 1 | 293 | | resizeTimeout, |
| 1 | 294 | | deallocationOption, |
| 1 | 295 | | bhMgr, |
| 1 | 296 | | cancellationToken); |
| | 297 | |
|
| 1 | 298 | | return asyncTask; |
| | 299 | | } |
| | 300 | |
|
| | 301 | | /// <summary> |
| | 302 | | /// Resizes the specified pool. |
| | 303 | | /// </summary> |
| | 304 | | /// <param name="poolId">The id of the pool.</param> |
| | 305 | | /// <param name="targetDedicatedComputeNodes"> |
| | 306 | | /// The desired number of dedicated compute nodes in the pool. |
| | 307 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 308 | | /// </param> |
| | 309 | | /// <param name="targetLowPriorityComputeNodes"> |
| | 310 | | /// The desired number of low-priority compute nodes in the pool. |
| | 311 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 312 | | /// </param> |
| | 313 | | /// <param name="resizeTimeout">The timeout for allocation of compute nodes to the pool or removal of compute no |
| | 314 | | /// <param name="deallocationOption"> |
| | 315 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool, |
| | 316 | | /// </param> |
| | 317 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 318 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 319 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 320 | | /// <remarks> |
| | 321 | | /// <para>The resize operation requests that the pool be resized. The request puts the pool in the <see cref="C |
| | 322 | | /// The Batch service will perform the actual resize without any further client action, and set the allocation s |
| | 323 | | /// <para> |
| | 324 | | /// You can only resize a pool when its <see cref="CloudPool.AllocationState"/> is <see cref="Common.AllocationS |
| | 325 | | /// You cannot resize pools which are configured for automatic scaling (that is, the <see cref="CloudPool.AutoSc |
| | 326 | | /// If you decrease the pool size, the Batch service chooses which nodes to remove. To remove specific nodes, c |
| | 327 | | /// </para> |
| | 328 | | /// <para>The resize operation runs asynchronously.</para> |
| | 329 | | /// </remarks> |
| | 330 | | public System.Threading.Tasks.Task ResizePoolAsync( |
| | 331 | | string poolId, |
| | 332 | | int? targetDedicatedComputeNodes = null, |
| | 333 | | int? targetLowPriorityComputeNodes = null, |
| | 334 | | TimeSpan? resizeTimeout = null, |
| | 335 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 336 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 337 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 338 | | { |
| | 339 | | // create the behavior manager |
| 1 | 340 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 341 | |
|
| 1 | 342 | | System.Threading.Tasks.Task asyncTask = ResizePoolAsyncImpl( |
| 1 | 343 | | poolId, |
| 1 | 344 | | targetDedicatedComputeNodes, |
| 1 | 345 | | targetLowPriorityComputeNodes, |
| 1 | 346 | | resizeTimeout, |
| 1 | 347 | | deallocationOption, |
| 1 | 348 | | bhMgr, |
| 1 | 349 | | cancellationToken); |
| | 350 | |
|
| 1 | 351 | | return asyncTask; |
| | 352 | | } |
| | 353 | |
|
| | 354 | |
|
| | 355 | | /// <summary> |
| | 356 | | /// Resizes the specified pool. |
| | 357 | | /// </summary> |
| | 358 | | /// <param name="poolId">The id of the pool.</param> |
| | 359 | | /// <param name="targetDedicatedComputeNodes"> |
| | 360 | | /// The desired number of dedicated compute nodes in the pool. |
| | 361 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 362 | | /// </param> |
| | 363 | | /// <param name="targetLowPriorityComputeNodes"> |
| | 364 | | /// The desired number of low-priority compute nodes in the pool. |
| | 365 | | /// At least one of <paramref name="targetDedicatedComputeNodes"/> and <paramref name="targetLowPriorityComputeN |
| | 366 | | /// </param> |
| | 367 | | /// <param name="resizeTimeout">The timeout for allocation of compute nodes to the pool or removal of compute no |
| | 368 | | /// <param name="deallocationOption"> |
| | 369 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool, |
| | 370 | | /// </param> |
| | 371 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 372 | | /// <remarks> |
| | 373 | | /// <para>The resize operation requests that the pool be resized. The request puts the pool in the <see cref="C |
| | 374 | | /// The Batch service will perform the actual resize without any further client action, and set the allocation s |
| | 375 | | /// <para> |
| | 376 | | /// You can only resize a pool when its <see cref="CloudPool.AllocationState"/> is <see cref="Common.AllocationS |
| | 377 | | /// You cannot resize pools which are configured for automatic scaling (that is, the <see cref="CloudPool.AutoSc |
| | 378 | | /// If you decrease the pool size, the Batch service chooses which nodes to remove. To remove specific nodes, c |
| | 379 | | /// </para> |
| | 380 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="ResizePoolAsync"/>.</para> |
| | 381 | | /// </remarks> |
| | 382 | | public void ResizePool( |
| | 383 | | string poolId, |
| | 384 | | int? targetDedicatedComputeNodes = null, |
| | 385 | | int? targetLowPriorityComputeNodes = null, |
| | 386 | | TimeSpan? resizeTimeout = null, |
| | 387 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 388 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 389 | | { |
| 0 | 390 | | Task asyncTask = ResizePoolAsync( |
| 0 | 391 | | poolId, |
| 0 | 392 | | targetDedicatedComputeNodes, |
| 0 | 393 | | targetLowPriorityComputeNodes, |
| 0 | 394 | | resizeTimeout, |
| 0 | 395 | | deallocationOption, |
| 0 | 396 | | additionalBehaviors); |
| 0 | 397 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 398 | | } |
| | 399 | |
|
| | 400 | | internal System.Threading.Tasks.Task StopResizePoolAsyncImpl(string poolId, BehaviorManager bhMgr, CancellationT |
| | 401 | | { |
| 1 | 402 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.StopResizePool(poolId, bhMgr, cance |
| | 403 | |
|
| 1 | 404 | | return asyncTask; |
| | 405 | | } |
| | 406 | |
|
| | 407 | | /// <summary> |
| | 408 | | /// Stops a pool resize operation. |
| | 409 | | /// </summary> |
| | 410 | | /// <param name="poolId">The id of the pool.</param> |
| | 411 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 412 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 413 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 414 | | /// <remarks> |
| | 415 | | /// <para> |
| | 416 | | /// This operation stops an ongoing resize operation on the pool. The pool size will stabilize at the number of |
| | 417 | | /// when the stop operation is done. During the stop operation, the pool <see cref="CloudPool.AllocationState"/ |
| | 418 | | /// to <see cref="Common.AllocationState.Stopping"/> and then to <see cref="Common.AllocationState.Steady"/>. |
| | 419 | | /// </para> |
| | 420 | | /// <para>The stop resize operation runs asynchronously.</para> |
| | 421 | | /// </remarks> |
| | 422 | | public System.Threading.Tasks.Task StopResizePoolAsync( |
| | 423 | | string poolId, |
| | 424 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 425 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 426 | | { |
| | 427 | | // create the behavior manager |
| 1 | 428 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 429 | |
|
| 1 | 430 | | System.Threading.Tasks.Task asyncTask = StopResizePoolAsyncImpl(poolId, bhMgr, cancellationToken); |
| | 431 | |
|
| 1 | 432 | | return asyncTask; |
| | 433 | | } |
| | 434 | |
|
| | 435 | | /// <summary> |
| | 436 | | /// Stops a pool resize operation. |
| | 437 | | /// </summary> |
| | 438 | | /// <param name="poolId">The id of the pool.</param> |
| | 439 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 440 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 441 | | /// <remarks> |
| | 442 | | /// <para> |
| | 443 | | /// This operation stops an ongoing resize operation on the pool. The pool size will stabilize at the number of |
| | 444 | | /// when the stop operation is done. During the stop operation, the pool <see cref="CloudPool.AllocationState"/ |
| | 445 | | /// to <see cref="Common.AllocationState.Stopping"/> and then to <see cref="Common.AllocationState.Steady"/>. |
| | 446 | | /// </para> |
| | 447 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="StopResizePoolAsync"/>.</p |
| | 448 | | /// </remarks> |
| | 449 | | public void StopResizePool(string poolId, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 450 | | { |
| 0 | 451 | | Task asyncTask = StopResizePoolAsync(poolId, additionalBehaviors); |
| 0 | 452 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 453 | | } |
| | 454 | |
|
| | 455 | |
|
| | 456 | | internal IPagedEnumerable<ComputeNode> ListComputeNodesImpl(string poolId, BehaviorManager bhMgr, DetailLevel de |
| | 457 | | { |
| 3 | 458 | | PagedEnumerable<ComputeNode> enumerable = new PagedEnumerable<ComputeNode>( // the lamda will be the enumera |
| 3 | 459 | | () => |
| 3 | 460 | | { |
| 3 | 461 | | // here is the actual strongly typed enumerator |
| 6 | 462 | | AsyncListComputeNodesEnumerator typedEnumerator = new AsyncListComputeNodesEnumerator( |
| 6 | 463 | | this, |
| 6 | 464 | | poolId, |
| 6 | 465 | | bhMgr, |
| 6 | 466 | | detailLevel); |
| 3 | 467 | |
|
| 3 | 468 | | // here is the base |
| 3 | 469 | |
|
| 3 | 470 | | PagedEnumeratorBase<ComputeNode> enumeratorBase = typedEnumerator; |
| 3 | 471 | |
|
| 6 | 472 | | return enumeratorBase; |
| 3 | 473 | | }); |
| | 474 | |
|
| 3 | 475 | | return enumerable; |
| | 476 | | } |
| | 477 | |
|
| | 478 | | /// <summary> |
| | 479 | | /// Enumerates the <see cref="ComputeNode">compute nodes</see> of the specified pool. |
| | 480 | | /// </summary> |
| | 481 | | /// <param name="poolId">The id of the pool.</param> |
| | 482 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 483 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 484 | | /// <returns>An <see cref="IPagedEnumerable{ComputeNode}"/> that can be used to enumerate compute nodes asynchro |
| | 485 | | /// <remarks>This method returns immediately; the nodes are retrieved from the Batch service only when the colle |
| | 486 | | /// Retrieval is non-atomic; nodes are retrieved in pages during enumeration of the collection.</remarks> |
| | 487 | | public IPagedEnumerable<ComputeNode> ListComputeNodes(string poolId, DetailLevel detailLevel = null, |
| | 488 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 489 | | { |
| | 490 | | // create the behavior manager |
| 3 | 491 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 492 | |
|
| | 493 | | // get enumerable |
| 3 | 494 | | IPagedEnumerable<ComputeNode> enumerable = ListComputeNodesImpl(poolId, bhMgr, detailLevel); |
| | 495 | |
|
| 3 | 496 | | return enumerable; |
| | 497 | | } |
| | 498 | |
|
| | 499 | |
|
| | 500 | | internal async System.Threading.Tasks.Task<ComputeNode> GetComputeNodeAsyncImpl( |
| | 501 | | string poolId, |
| | 502 | | string computeNodeId, |
| | 503 | | BehaviorManager bhMgr, |
| | 504 | | CancellationToken cancellationToken) |
| | 505 | | { |
| 2 | 506 | | Task<AzureOperationResponse<Models.ComputeNode, Models.ComputeNodeGetHeaders>> asyncTask = |
| 2 | 507 | | this.ParentBatchClient.ProtocolLayer.GetComputeNode(poolId, computeNodeId, bhMgr, cancellationToken); |
| 2 | 508 | | AzureOperationResponse<Models.ComputeNode, Models.ComputeNodeGetHeaders> result = await asyncTask.ConfigureA |
| | 509 | |
|
| | 510 | | // construct a new object bound to the protocol layer object |
| 1 | 511 | | ComputeNode newComputeNode = new ComputeNode(this.ParentBatchClient, poolId, result.Body, bhMgr.BaseBehavior |
| | 512 | |
|
| 1 | 513 | | return newComputeNode; |
| 1 | 514 | | } |
| | 515 | |
|
| | 516 | | /// <summary> |
| | 517 | | /// Gets the specified compute node. |
| | 518 | | /// </summary> |
| | 519 | | /// <param name="poolId">The id of the pool.</param> |
| | 520 | | /// <param name="computeNodeId">The id of the compute node to get from the pool.</param> |
| | 521 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr |
| | 522 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 523 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 524 | | /// <returns>A <see cref="ComputeNode"/> containing information about the specified compute node.</returns> |
| | 525 | | /// <remarks>The get node operation runs asynchronously.</remarks> |
| | 526 | | public System.Threading.Tasks.Task<ComputeNode> GetComputeNodeAsync( |
| | 527 | | string poolId, |
| | 528 | | string computeNodeId, |
| | 529 | | DetailLevel detailLevel = null, |
| | 530 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 531 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 532 | | { |
| | 533 | | // create the behavior manager |
| 2 | 534 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); |
| | 535 | |
|
| 2 | 536 | | System.Threading.Tasks.Task<ComputeNode> asyncTask = GetComputeNodeAsyncImpl(poolId, computeNodeId, bhMgr, c |
| | 537 | |
|
| 2 | 538 | | return asyncTask; |
| | 539 | | } |
| | 540 | |
|
| | 541 | | /// <summary> |
| | 542 | | /// Gets the specified compute node. |
| | 543 | | /// </summary> |
| | 544 | | /// <param name="poolId">The id of the pool.</param> |
| | 545 | | /// <param name="computeNodeId">The id of the compute node to get from the pool.</param> |
| | 546 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr |
| | 547 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 548 | | /// <returns>A <see cref="ComputeNode"/> containing information about the specified compute node.</returns> |
| | 549 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetComputeNodeAsync"/>. |
| | 550 | | public ComputeNode GetComputeNode( |
| | 551 | | string poolId, |
| | 552 | | string computeNodeId, |
| | 553 | | DetailLevel detailLevel = null, |
| | 554 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 555 | | { |
| 1 | 556 | | Task<ComputeNode> asyncTask = GetComputeNodeAsync(poolId, computeNodeId, detailLevel, additionalBehaviors); |
| 1 | 557 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 558 | | } |
| | 559 | |
|
| | 560 | | /// <summary> |
| | 561 | | /// Enables task scheduling on the specified compute node. |
| | 562 | | /// </summary> |
| | 563 | | /// <param name="poolId">The id of the pool.</param> |
| | 564 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 565 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 566 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 567 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 568 | | /// <remarks>This operation runs asynchronously.</remarks> |
| | 569 | | public System.Threading.Tasks.Task EnableComputeNodeSchedulingAsync( |
| | 570 | | string poolId, |
| | 571 | | string computeNodeId, |
| | 572 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 573 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 574 | | { |
| | 575 | | // create the behavior manager |
| 1 | 576 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 577 | |
|
| 1 | 578 | | System.Threading.Tasks.Task asyncTask = this.ParentBatchClient.ProtocolLayer.EnableComputeNodeScheduling(poo |
| | 579 | |
|
| 1 | 580 | | return asyncTask; |
| | 581 | | } |
| | 582 | |
|
| | 583 | | /// <summary> |
| | 584 | | /// Enables task scheduling on the specified compute node. |
| | 585 | | /// </summary> |
| | 586 | | /// <param name="poolId">The id of the pool.</param> |
| | 587 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 588 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 589 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="EnableComputeNodeSchedu |
| | 590 | | public void EnableComputeNodeScheduling( |
| | 591 | | string poolId, |
| | 592 | | string computeNodeId, |
| | 593 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 594 | | { |
| 0 | 595 | | Task asyncTask = EnableComputeNodeSchedulingAsync(poolId, computeNodeId, additionalBehaviors, CancellationTo |
| 0 | 596 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 597 | | } |
| | 598 | |
|
| | 599 | | /// <summary> |
| | 600 | | /// Disables task scheduling on the specified compute node. |
| | 601 | | /// </summary> |
| | 602 | | /// <param name="poolId">The id of the pool.</param> |
| | 603 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 604 | | /// <param name="disableComputeNodeSchedulingOption">Specifies what to do with currently running tasks. The defa |
| | 605 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 606 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 607 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 608 | | /// <remarks>This operation runs asynchronously.</remarks> |
| | 609 | | public System.Threading.Tasks.Task DisableComputeNodeSchedulingAsync( |
| | 610 | | string poolId, |
| | 611 | | string computeNodeId, |
| | 612 | | Common.DisableComputeNodeSchedulingOption? disableComputeNodeSchedulingOption, |
| | 613 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 614 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 615 | | { |
| | 616 | | // create the behavior manager |
| 1 | 617 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 618 | |
|
| 1 | 619 | | System.Threading.Tasks.Task asyncTask = this.ParentBatchClient.ProtocolLayer.DisableComputeNodeScheduling(po |
| | 620 | |
|
| 1 | 621 | | return asyncTask; |
| | 622 | | } |
| | 623 | |
|
| | 624 | | /// <summary> |
| | 625 | | /// Disables task scheduling on the specified compute node. |
| | 626 | | /// </summary> |
| | 627 | | /// <param name="poolId">The id of the pool.</param> |
| | 628 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 629 | | /// <param name="disableComputeNodeSchedulingOption">Specifies what to do with currently running tasks. The defa |
| | 630 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 631 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="DisableComputeNodeSched |
| | 632 | | public void DisableComputeNodeScheduling( |
| | 633 | | string poolId, |
| | 634 | | string computeNodeId, |
| | 635 | | Common.DisableComputeNodeSchedulingOption? disableComputeNodeSchedulingOption, |
| | 636 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 637 | | { |
| 0 | 638 | | Task asyncTask = DisableComputeNodeSchedulingAsync(poolId, computeNodeId, disableComputeNodeSchedulingOption |
| 0 | 639 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 640 | | } |
| | 641 | |
|
| | 642 | | internal async System.Threading.Tasks.Task EnableAutoScaleAsyncImpl( |
| | 643 | | string poolId, |
| | 644 | | string autoscaleFormula, |
| | 645 | | TimeSpan? autoscaleEvaluationInterval, |
| | 646 | | BehaviorManager bhMgr, |
| | 647 | | CancellationToken cancellationToken) |
| | 648 | | { |
| | 649 | | // start call |
| 1 | 650 | | System.Threading.Tasks.Task asyncTask = this.ParentBatchClient.ProtocolLayer.EnableAutoScale( |
| 1 | 651 | | poolId, |
| 1 | 652 | | autoscaleFormula, |
| 1 | 653 | | autoscaleEvaluationInterval, |
| 1 | 654 | | bhMgr, |
| 1 | 655 | | cancellationToken); |
| | 656 | |
|
| 1 | 657 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 658 | | } |
| | 659 | |
|
| | 660 | | /// <summary> |
| | 661 | | /// Enables automatic scaling on the specified pool. |
| | 662 | | /// </summary> |
| | 663 | | /// <param name="poolId">The id of the pool.</param> |
| | 664 | | /// <param name="autoscaleFormula">The formula for the desired number of compute nodes in the pool.</param> |
| | 665 | | /// <param name="autoscaleEvaluationInterval">The time interval at which to automatically adjust the pool size a |
| | 666 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 667 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 668 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 669 | | /// <remarks> |
| | 670 | | /// <para>The formula is checked for validity before it is applied to the pool. If the formula is not valid, an |
| | 671 | | /// <para>You cannot enable automatic scaling on a pool if a resize operation is in progress on the pool.</para> |
| | 672 | | /// <para>The enable autoscale operation runs asynchronously.</para> |
| | 673 | | /// </remarks> |
| | 674 | | public async System.Threading.Tasks.Task EnableAutoScaleAsync( |
| | 675 | | string poolId, |
| | 676 | | string autoscaleFormula = null, |
| | 677 | | TimeSpan? autoscaleEvaluationInterval = null, |
| | 678 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 679 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 680 | | { |
| | 681 | | // create the behavior manager |
| 1 | 682 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 683 | |
|
| | 684 | | // start call |
| 1 | 685 | | System.Threading.Tasks.Task asyncTask = EnableAutoScaleAsyncImpl(poolId, autoscaleFormula, autoscaleEvaluati |
| | 686 | |
|
| 1 | 687 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 688 | | } |
| | 689 | |
|
| | 690 | | /// <summary> |
| | 691 | | /// Enables automatic scaling on the specified pool. |
| | 692 | | /// </summary> |
| | 693 | | /// <param name="poolId">The id of the pool.</param> |
| | 694 | | /// <param name="autoscaleFormula">The formula for the desired number of compute nodes in the pool.</param> |
| | 695 | | /// <param name="autoscaleEvaluationInterval">The time interval at which to automatically adjust the pool size a |
| | 696 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 697 | | /// <remarks> |
| | 698 | | /// <para>The formula is checked for validity before it is applied to the pool. If the formula is not valid, an |
| | 699 | | /// <para>You cannot enable automatic scaling on a pool if a resize operation is in progress on the pool.</para> |
| | 700 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="EnableAutoScaleAsync"/>.</ |
| | 701 | | /// </remarks> |
| | 702 | | public void EnableAutoScale( |
| | 703 | | string poolId, |
| | 704 | | string autoscaleFormula = null, |
| | 705 | | TimeSpan? autoscaleEvaluationInterval = null, |
| | 706 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 707 | | { |
| 0 | 708 | | Task asyncTask = EnableAutoScaleAsync(poolId, autoscaleFormula, autoscaleEvaluationInterval, additionalBehav |
| 0 | 709 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 710 | | } |
| | 711 | |
|
| | 712 | | internal async System.Threading.Tasks.Task DisableAutoScaleAsyncImpl(string poolId, BehaviorManager bhMgr, Cance |
| | 713 | | { |
| | 714 | | // start call |
| 1 | 715 | | System.Threading.Tasks.Task asyncTask = this.ParentBatchClient.ProtocolLayer.DisableAutoScale(poolId, bhMgr, |
| | 716 | |
|
| 1 | 717 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 718 | | } |
| | 719 | |
|
| | 720 | | /// <summary> |
| | 721 | | /// Disables automatic scaling on the specified pool. |
| | 722 | | /// </summary> |
| | 723 | | /// <param name="poolId">The id of the pool.</param> |
| | 724 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 725 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 726 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 727 | | /// <remarks> |
| | 728 | | /// <para>The disable autoscale operation runs asynchronously.</para> |
| | 729 | | /// </remarks> |
| | 730 | | public async System.Threading.Tasks.Task DisableAutoScaleAsync( |
| | 731 | | string poolId, |
| | 732 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 733 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 734 | | { |
| | 735 | | // create the behavior manager |
| 1 | 736 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 737 | |
|
| | 738 | | // start call |
| 1 | 739 | | System.Threading.Tasks.Task asyncTask = DisableAutoScaleAsyncImpl(poolId, bhMgr, cancellationToken); |
| | 740 | |
|
| 1 | 741 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 742 | | } |
| | 743 | |
|
| | 744 | |
|
| | 745 | | /// <summary> |
| | 746 | | /// Disables automatic scaling on the specified pool. |
| | 747 | | /// </summary> |
| | 748 | | /// <param name="poolId">The id of the pool.</param> |
| | 749 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 750 | | /// <remarks> |
| | 751 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="DisableAutoScaleAsync"/>.< |
| | 752 | | /// </remarks> |
| | 753 | | public void DisableAutoScale(string poolId, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 754 | | { |
| 0 | 755 | | Task asyncTask = DisableAutoScaleAsync(poolId, additionalBehaviors); |
| 0 | 756 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 757 | | } |
| | 758 | |
|
| | 759 | | internal async System.Threading.Tasks.Task<AutoScaleRun> EvaluateAutoScaleAsyncImpl( |
| | 760 | | string poolId, |
| | 761 | | string autoscaleFormula, |
| | 762 | | BehaviorManager bhMgr, |
| | 763 | | CancellationToken cancellationToken) |
| | 764 | | { |
| | 765 | | // start call |
| 1 | 766 | | System.Threading.Tasks.Task<AzureOperationResponse<Models.AutoScaleRun, Models.PoolEvaluateAutoScaleHeaders> |
| 1 | 767 | | this._parentBatchClient.ProtocolLayer.EvaluateAutoScale(poolId, autoscaleFormula, bhMgr, cancellationTok |
| | 768 | |
|
| 1 | 769 | | var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 770 | |
|
| 0 | 771 | | return new AutoScaleRun(response.Body); |
| 0 | 772 | | } |
| | 773 | |
|
| | 774 | | /// <summary> |
| | 775 | | /// Gets the result of evaluating an automatic scaling formula on the specified pool. This |
| | 776 | | /// is primarily for validating an autoscale formula, as it simply returns the result |
| | 777 | | /// without applying the formula to the pool. |
| | 778 | | /// </summary> |
| | 779 | | /// <param name="poolId">The id of the pool.</param> |
| | 780 | | /// <param name="autoscaleFormula">The formula to be evaluated on the pool.</param> |
| | 781 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 782 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 783 | | /// <returns>The result of evaluating the <paramref name="autoscaleFormula"/> on the specified pool.</returns> |
| | 784 | | /// <remarks> |
| | 785 | | /// <para>The formula is validated and its results calculated, but is not applied to the pool. To apply the for |
| | 786 | | /// <para>This method does not change any state of the pool, and does not affect the <see cref="CloudPool.LastMo |
| | 787 | | /// <para>The evaluate operation runs asynchronously.</para> |
| | 788 | | /// </remarks> |
| | 789 | | public async System.Threading.Tasks.Task<AutoScaleRun> EvaluateAutoScaleAsync( |
| | 790 | | string poolId, |
| | 791 | | string autoscaleFormula, |
| | 792 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 793 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 794 | | { |
| | 795 | | // create the behavior manager |
| 1 | 796 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 797 | |
|
| | 798 | | // start call |
| 1 | 799 | | System.Threading.Tasks.Task<AutoScaleRun> asyncTask = EvaluateAutoScaleAsyncImpl( |
| 1 | 800 | | poolId, |
| 1 | 801 | | autoscaleFormula, |
| 1 | 802 | | bhMgr, |
| 1 | 803 | | cancellationToken); |
| | 804 | |
|
| 1 | 805 | | AutoScaleRun evaluation = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 806 | |
|
| 0 | 807 | | return evaluation; |
| 0 | 808 | | } |
| | 809 | |
|
| | 810 | | /// <summary> |
| | 811 | | /// Gets the result of evaluating an automatic scaling formula on the specified pool. This |
| | 812 | | /// is primarily for validating an autoscale formula, as it simply returns the result |
| | 813 | | /// without applying the formula to the pool. |
| | 814 | | /// </summary> |
| | 815 | | /// <param name="poolId">The id of the pool.</param> |
| | 816 | | /// <param name="autoscaleFormula">The formula to be evaluated on the pool.</param> |
| | 817 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 818 | | /// <returns>The result of evaluating the <paramref name="autoscaleFormula"/> on the specified pool.</returns> |
| | 819 | | /// <remarks> |
| | 820 | | /// <para>The formula is validated and its results calculated, but is not applied to the pool. To apply the for |
| | 821 | | /// <para>This method does not change any state of the pool, and does not affect the <see cref="CloudPool.LastMo |
| | 822 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="EvaluateAutoScaleAsync"/>. |
| | 823 | | /// </remarks> |
| | 824 | | public AutoScaleRun EvaluateAutoScale( |
| | 825 | | string poolId, |
| | 826 | | string autoscaleFormula, |
| | 827 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 828 | | { |
| 0 | 829 | | Task<AutoScaleRun> asyncTask = EvaluateAutoScaleAsync(poolId, autoscaleFormula, additionalBehaviors); |
| 0 | 830 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 831 | | } |
| | 832 | |
|
| | 833 | | /// <summary> |
| | 834 | | /// Removes the specified compute node from the specified pool. |
| | 835 | | /// </summary> |
| | 836 | | /// <param name="poolId">The id of the pool.</param> |
| | 837 | | /// <param name="computeNodeId">The id of the compute node to remove from the pool.</param> |
| | 838 | | /// <param name="deallocationOption"> |
| | 839 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 840 | | /// </param> |
| | 841 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 842 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 843 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 844 | | /// <remarks> |
| | 845 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | 846 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 847 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 848 | | /// <para>The remove operation runs asynchronously.</para> |
| | 849 | | /// </remarks> |
| | 850 | | public System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | 851 | | string poolId, |
| | 852 | | string computeNodeId, |
| | 853 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 854 | | TimeSpan? resizeTimeout = null, |
| | 855 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 856 | | { |
| | 857 | | //Create a dummy compute node id list with just one element |
| 0 | 858 | | List<string> computeNodeIdList = new List<string> {computeNodeId}; |
| | 859 | |
|
| 0 | 860 | | System.Threading.Tasks.Task asyncTask = RemoveFromPoolAsync(poolId, computeNodeIdList, deallocationOption, |
| 0 | 861 | | resizeTimeout, additionalBehaviors); |
| | 862 | |
|
| 0 | 863 | | return asyncTask; |
| | 864 | | } |
| | 865 | |
|
| | 866 | | /// <summary> |
| | 867 | | /// Removes the specified compute node from the specified pool. |
| | 868 | | /// </summary> |
| | 869 | | /// <param name="poolId">The id of the pool.</param> |
| | 870 | | /// <param name="computeNodeId">The id of the compute node to remove from the pool.</param> |
| | 871 | | /// <param name="deallocationOption"> |
| | 872 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 873 | | /// </param> |
| | 874 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 875 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 876 | | /// <remarks> |
| | 877 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | 878 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 879 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 880 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(string |
| | 881 | | /// </remarks> |
| | 882 | | public void RemoveFromPool( |
| | 883 | | string poolId, |
| | 884 | | string computeNodeId, |
| | 885 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 886 | | TimeSpan? resizeTimeout = null, |
| | 887 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 888 | | { |
| 0 | 889 | | Task asyncTask = RemoveFromPoolAsync(poolId, computeNodeId, deallocationOption, resizeTimeout, additionalBeh |
| 0 | 890 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 891 | | } |
| | 892 | |
|
| | 893 | | internal System.Threading.Tasks.Task RemoveFromPoolAsyncImpl( |
| | 894 | | string poolId, |
| | 895 | | IEnumerable<string> computeNodeIds, |
| | 896 | | Common.ComputeNodeDeallocationOption? deallocationOption, |
| | 897 | | TimeSpan? resizeTimeout, |
| | 898 | | BehaviorManager bhMgr, |
| | 899 | | CancellationToken cancellationToken) |
| | 900 | | { |
| | 901 | | // start call |
| 2 | 902 | | System.Threading.Tasks.Task asyncTask = this._parentBatchClient.ProtocolLayer.RemovePoolComputeNodes( |
| 2 | 903 | | poolId, |
| 2 | 904 | | computeNodeIds, |
| 2 | 905 | | deallocationOption, |
| 2 | 906 | | resizeTimeout, |
| 2 | 907 | | bhMgr, |
| 2 | 908 | | cancellationToken); |
| | 909 | |
|
| 2 | 910 | | return asyncTask; |
| | 911 | | } |
| | 912 | |
|
| | 913 | | /// <summary> |
| | 914 | | /// Removes the specified compute nodes from the specified pool. |
| | 915 | | /// </summary> |
| | 916 | | /// <param name="poolId">The id of the pool.</param> |
| | 917 | | /// <param name="computeNodeIds">The ids of the compute nodes to remove from the pool.</param> |
| | 918 | | /// <param name="deallocationOption"> |
| | 919 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 920 | | /// </param> |
| | 921 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 922 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 923 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 924 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 925 | | /// <remarks> |
| | 926 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 927 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 928 | | /// <para>The remove operation runs asynchronously.</para> |
| | 929 | | /// </remarks> |
| | 930 | | public System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | 931 | | string poolId, |
| | 932 | | IEnumerable<string> computeNodeIds, |
| | 933 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 934 | | TimeSpan? resizeTimeout = null, |
| | 935 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 936 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 937 | | { |
| | 938 | | // create the behavior manager |
| 1 | 939 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 940 | |
|
| | 941 | | // start call |
| 1 | 942 | | System.Threading.Tasks.Task asyncTask = RemoveFromPoolAsyncImpl( |
| 1 | 943 | | poolId, |
| 1 | 944 | | computeNodeIds, |
| 1 | 945 | | deallocationOption, |
| 1 | 946 | | resizeTimeout, |
| 1 | 947 | | bhMgr, |
| 1 | 948 | | cancellationToken); |
| | 949 | |
|
| 1 | 950 | | return asyncTask; |
| | 951 | | } |
| | 952 | |
|
| | 953 | | /// <summary> |
| | 954 | | /// Removes the specified compute nodes from the specified pool. |
| | 955 | | /// </summary> |
| | 956 | | /// <param name="poolId">The id of the pool.</param> |
| | 957 | | /// <param name="computeNodeIds">The ids of the compute nodes to remove from the pool.</param> |
| | 958 | | /// <param name="deallocationOption"> |
| | 959 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 960 | | /// </param> |
| | 961 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 962 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 963 | | /// <remarks> |
| | 964 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 965 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 966 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(string |
| | 967 | | /// </remarks> |
| | 968 | | public void RemoveFromPool( |
| | 969 | | string poolId, |
| | 970 | | IEnumerable<string> computeNodeIds, |
| | 971 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 972 | | TimeSpan? resizeTimeout = null, |
| | 973 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 974 | | { |
| 0 | 975 | | Task asyncTask = RemoveFromPoolAsync(poolId, computeNodeIds, deallocationOption, resizeTimeout, additionalBe |
| 0 | 976 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 977 | | } |
| | 978 | |
|
| | 979 | | /// <summary> |
| | 980 | | /// Removes the specified compute node from the specified pool. |
| | 981 | | /// </summary> |
| | 982 | | /// <param name="poolId">The id of the pool.</param> |
| | 983 | | /// <param name="computeNode">The <see cref="ComputeNode"/> to remove from the pool.</param> |
| | 984 | | /// <param name="deallocationOption"> |
| | 985 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 986 | | /// </param> |
| | 987 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 988 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 989 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 990 | | /// <remarks> |
| | 991 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | 992 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 993 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 994 | | /// <para>The remove operation runs asynchronously.</para> |
| | 995 | | /// </remarks> |
| | 996 | | public System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | 997 | | string poolId, |
| | 998 | | ComputeNode computeNode, |
| | 999 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 1000 | | TimeSpan? resizeTimeout = null, |
| | 1001 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1002 | | { |
| | 1003 | | //Create a dummy ComputeNode list with just one element |
| 0 | 1004 | | List<ComputeNode> computeNodeList = new List<ComputeNode> {computeNode}; |
| | 1005 | |
|
| 0 | 1006 | | System.Threading.Tasks.Task asyncTask = RemoveFromPoolAsync(poolId, computeNodeList, deallocationOption, |
| 0 | 1007 | | resizeTimeout, additionalBehaviors); |
| | 1008 | |
|
| 0 | 1009 | | return asyncTask; |
| | 1010 | | } |
| | 1011 | |
|
| | 1012 | | /// <summary> |
| | 1013 | | /// Removes the specified compute node from the specified pool. |
| | 1014 | | /// </summary> |
| | 1015 | | /// <param name="poolId">The id of the pool.</param> |
| | 1016 | | /// <param name="computeNode">The <see cref="ComputeNode"/> to remove from the pool.</param> |
| | 1017 | | /// <param name="deallocationOption"> |
| | 1018 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 1019 | | /// </param> |
| | 1020 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 1021 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1022 | | /// <remarks> |
| | 1023 | | /// <para>If you need to remove multiple compute nodes from a pool, it is more efficient to use the <see cref="R |
| | 1024 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 1025 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 1026 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(string |
| | 1027 | | /// </remarks> |
| | 1028 | | public void RemoveFromPool( |
| | 1029 | | string poolId, |
| | 1030 | | ComputeNode computeNode, |
| | 1031 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 1032 | | TimeSpan? resizeTimeout = null, |
| | 1033 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1034 | | { |
| 0 | 1035 | | Task asyncTask = RemoveFromPoolAsync(poolId, computeNode, deallocationOption, resizeTimeout, additionalBehav |
| 0 | 1036 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1037 | | } |
| | 1038 | |
|
| | 1039 | | internal System.Threading.Tasks.Task RemoveFromPoolAsyncImpl( |
| | 1040 | | string poolId, |
| | 1041 | | IEnumerable<ComputeNode> computeNodes, |
| | 1042 | | Common.ComputeNodeDeallocationOption? deallocationOption, |
| | 1043 | | TimeSpan? resizeTimeout, |
| | 1044 | | BehaviorManager bhMgr, |
| | 1045 | | CancellationToken cancellationToken) |
| | 1046 | | { |
| | 1047 | | // Process the list of compute nodes to ensure that they have names |
| 1 | 1048 | | List<string> computeNodeIds = new List<string>(); |
| 0 | 1049 | | foreach (ComputeNode computeNode in computeNodes) |
| | 1050 | | { |
| 0 | 1051 | | computeNodeIds.Add(computeNode.Id); |
| | 1052 | | } |
| | 1053 | |
|
| | 1054 | | // start call |
| 1 | 1055 | | System.Threading.Tasks.Task asyncTask = RemoveFromPoolAsyncImpl( |
| 1 | 1056 | | poolId, |
| 1 | 1057 | | computeNodeIds, |
| 1 | 1058 | | deallocationOption, |
| 1 | 1059 | | resizeTimeout, |
| 1 | 1060 | | bhMgr, |
| 1 | 1061 | | cancellationToken); |
| | 1062 | |
|
| 1 | 1063 | | return asyncTask; |
| | 1064 | | } |
| | 1065 | |
|
| | 1066 | | /// <summary> |
| | 1067 | | /// Removes the specified compute nodes from the specified pool. |
| | 1068 | | /// </summary> |
| | 1069 | | /// <param name="poolId">The id of the pool.</param> |
| | 1070 | | /// <param name="computeNodes">The <see cref="ComputeNode">compute nodes</see> to remove from the pool.</param> |
| | 1071 | | /// <param name="deallocationOption"> |
| | 1072 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 1073 | | /// </param> |
| | 1074 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 1075 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1076 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1077 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1078 | | /// <remarks> |
| | 1079 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 1080 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 1081 | | /// <para>The remove operation runs asynchronously.</para> |
| | 1082 | | /// </remarks> |
| | 1083 | | public async System.Threading.Tasks.Task RemoveFromPoolAsync( |
| | 1084 | | string poolId, |
| | 1085 | | IEnumerable<ComputeNode> computeNodes, |
| | 1086 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 1087 | | TimeSpan? resizeTimeout = null, |
| | 1088 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1089 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1090 | | { |
| | 1091 | | // create the behavior manager |
| 1 | 1092 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1093 | |
|
| | 1094 | | // start call |
| 1 | 1095 | | System.Threading.Tasks.Task asyncTask = RemoveFromPoolAsyncImpl( |
| 1 | 1096 | | poolId, |
| 1 | 1097 | | computeNodes, |
| 1 | 1098 | | deallocationOption, |
| 1 | 1099 | | resizeTimeout, |
| 1 | 1100 | | bhMgr, |
| 1 | 1101 | | cancellationToken); |
| | 1102 | |
|
| 1 | 1103 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 1104 | | } |
| | 1105 | |
|
| | 1106 | | /// <summary> |
| | 1107 | | /// Removes the specified compute nodes from the specified pool. |
| | 1108 | | /// </summary> |
| | 1109 | | /// <param name="poolId">The id of the pool.</param> |
| | 1110 | | /// <param name="computeNodes">The <see cref="ComputeNode">compute nodes</see> to remove from the pool.</param> |
| | 1111 | | /// <param name="deallocationOption"> |
| | 1112 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | 1113 | | /// </param> |
| | 1114 | | /// <param name="resizeTimeout">Specifies the timeout for removal of compute nodes from the pool. The default va |
| | 1115 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1116 | | /// <remarks> |
| | 1117 | | /// <para>You can only remove nodes from a pool when the <see cref="CloudPool.AllocationState"/> of the pool is |
| | 1118 | | /// <para>When you remove nodes from a pool, the pool's AllocationState changes from Steady to <see cref="Common |
| | 1119 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RemoveFromPoolAsync(string |
| | 1120 | | /// </remarks> |
| | 1121 | | public void RemoveFromPool( |
| | 1122 | | string poolId, |
| | 1123 | | IEnumerable<ComputeNode> computeNodes, |
| | 1124 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | 1125 | | TimeSpan? resizeTimeout = null, |
| | 1126 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1127 | | { |
| 0 | 1128 | | Task asyncTask = RemoveFromPoolAsync(poolId, computeNodes, deallocationOption, resizeTimeout, additionalBeha |
| 0 | 1129 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1130 | | } |
| | 1131 | |
|
| | 1132 | | /// <summary> |
| | 1133 | | /// Creates a <see cref="ComputeNodeUser"/> representing a new compute node user account that |
| | 1134 | | /// does not yet exist in the Batch service. |
| | 1135 | | /// </summary> |
| | 1136 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1137 | | /// <param name="computeNodeId">The id of the compute node where the user account will be created.</param> |
| | 1138 | | /// <returns>An unbound <see cref="ComputeNodeUser"/> representing a new user account that has not been added to |
| | 1139 | | /// <remarks>To add the new user, call <see cref="ComputeNodeUser.CommitAsync"/>.</remarks> |
| | 1140 | | public ComputeNodeUser CreateComputeNodeUser(string poolId, string computeNodeId) |
| | 1141 | | { |
| 0 | 1142 | | ComputeNodeUser newUser = new ComputeNodeUser(this.ParentBatchClient, this.CustomBehaviors, poolId, computeN |
| | 1143 | |
|
| 0 | 1144 | | return newUser; |
| | 1145 | | } |
| | 1146 | |
|
| | 1147 | | /// <summary> |
| | 1148 | | /// Deletes the specified user account from the specified compute node. |
| | 1149 | | /// </summary> |
| | 1150 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1151 | | /// <param name="computeNodeId">The id of the compute node from which you want to delete the user account.</para |
| | 1152 | | /// <param name="userName">The name of the user account to be deleted.</param> |
| | 1153 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1154 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1155 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1156 | | /// <remarks> |
| | 1157 | | /// <para>You can delete a user account from a compute node only when it is in the <see cref="Common.ComputeNode |
| | 1158 | | /// <para>The delete operation runs asynchronously.</para> |
| | 1159 | | /// </remarks> |
| | 1160 | | public System.Threading.Tasks.Task DeleteComputeNodeUserAsync( |
| | 1161 | | string poolId, |
| | 1162 | | string computeNodeId, |
| | 1163 | | string userName, |
| | 1164 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1165 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1166 | | { |
| | 1167 | | // create the behavior manager |
| 1 | 1168 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1169 | |
|
| 1 | 1170 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.DeleteComputeNodeUser( |
| 1 | 1171 | | poolId, |
| 1 | 1172 | | computeNodeId, |
| 1 | 1173 | | userName, |
| 1 | 1174 | | bhMgr, |
| 1 | 1175 | | cancellationToken); |
| | 1176 | |
|
| 1 | 1177 | | return asyncTask; |
| | 1178 | | } |
| | 1179 | |
|
| | 1180 | | /// <summary> |
| | 1181 | | /// Deletes the specified user account from the specified compute node. |
| | 1182 | | /// </summary> |
| | 1183 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1184 | | /// <param name="computeNodeId">The id of the compute node from which you want to delete the user account.</para |
| | 1185 | | /// <param name="userName">The name of the user account to be deleted.</param> |
| | 1186 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1187 | | /// <remarks> |
| | 1188 | | /// <para>You can delete a user account from a compute node only when it is in the <see cref="Common.ComputeNode |
| | 1189 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="DeleteComputeNodeUserAsync |
| | 1190 | | /// </remarks> |
| | 1191 | | public void DeleteComputeNodeUser(string poolId, string computeNodeId, string userName, |
| | 1192 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1193 | | { |
| 0 | 1194 | | Task asyncTask = DeleteComputeNodeUserAsync(poolId, computeNodeId, userName, additionalBehaviors); |
| 0 | 1195 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1196 | | } |
| | 1197 | |
|
| | 1198 | | /// <summary> |
| | 1199 | | /// Gets a Remote Desktop Protocol (RDP) file for the specified node. |
| | 1200 | | /// </summary> |
| | 1201 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1202 | | /// <param name="computeNodeId">The id of the compute node for which to get a Remote Desktop file.</param> |
| | 1203 | | /// <param name="rdpStream">The <see cref="Stream"/> into which the RDP file contents will be written.</param> |
| | 1204 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1205 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1206 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1207 | | /// <remarks> |
| | 1208 | | /// <para>This method does not close the <paramref name="rdpStream"/> stream, and it does not reset the position |
| | 1209 | | /// It is the caller's responsibility to close the stream, or to reset the position if required.</para> |
| | 1210 | | /// <para>The get RDP file operation runs asynchronously.</para> |
| | 1211 | | /// <para>This method can be invoked only if the pool is created with a <see cref="CloudServiceConfiguration" /> |
| | 1212 | | /// If this method is invoked on pools created with <see cref="VirtualMachineConfiguration"/>, then Batch servic |
| | 1213 | | /// For pools with <see cref="VirtualMachineConfiguration"/> property, the new method <see cref="GetRemoteLoginS |
| | 1214 | | /// </remarks> |
| | 1215 | | public System.Threading.Tasks.Task GetRDPFileAsync( |
| | 1216 | | string poolId, |
| | 1217 | | string computeNodeId, |
| | 1218 | | Stream rdpStream, |
| | 1219 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1220 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1221 | | { |
| | 1222 | | // create the behavior manager |
| 1 | 1223 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1224 | |
|
| 1 | 1225 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.GetComputeNodeRDPFile( |
| 1 | 1226 | | poolId, |
| 1 | 1227 | | computeNodeId, |
| 1 | 1228 | | rdpStream, |
| 1 | 1229 | | bhMgr, |
| 1 | 1230 | | cancellationToken); |
| | 1231 | |
|
| 1 | 1232 | | return asyncTask; |
| | 1233 | | } |
| | 1234 | |
|
| | 1235 | |
|
| | 1236 | | /// <summary> |
| | 1237 | | /// Gets a Remote Desktop Protocol (RDP) file for the specified node. |
| | 1238 | | /// </summary> |
| | 1239 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1240 | | /// <param name="computeNodeId">The id of the compute node for which to get a Remote Desktop file.</param> |
| | 1241 | | /// <param name="rdpStream">The <see cref="Stream"/> into which the RDP file contents will be written.</param> |
| | 1242 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1243 | | /// <remarks> |
| | 1244 | | /// <para>This method does not close the <paramref name="rdpStream"/> stream, and it does not reset the position |
| | 1245 | | /// It is the caller's responsibility to close the stream, or to reset the position if required.</para> |
| | 1246 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetRDPFileAsync(string, st |
| | 1247 | | /// <para>This method can be invoked only if the pool is created with a <see cref="CloudServiceConfiguration" /> |
| | 1248 | | /// If this method is invoked on pools created with <see cref="VirtualMachineConfiguration"/>, then Batch servic |
| | 1249 | | /// For pools with <see cref="VirtualMachineConfiguration"/> property, the new method <see cref="GetRemoteLoginS |
| | 1250 | | /// </remarks> |
| | 1251 | | public void GetRDPFile(string poolId, string computeNodeId, Stream rdpStream, |
| | 1252 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1253 | | { |
| 0 | 1254 | | Task asyncTask = GetRDPFileAsync(poolId, computeNodeId, rdpStream, additionalBehaviors); |
| 0 | 1255 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1256 | | } |
| | 1257 | |
|
| | 1258 | | internal async System.Threading.Tasks.Task GetRDPFileViaFileNameAsyncImpl( |
| | 1259 | | string poolId, |
| | 1260 | | string computeNodeId, |
| | 1261 | | string rdpFileNameToCreate, |
| | 1262 | | BehaviorManager bhMgr, |
| | 1263 | | CancellationToken cancellationToken) |
| | 1264 | | { |
| | 1265 | | // create the file |
| 1 | 1266 | | using (FileStream rdpStream = File.Create(rdpFileNameToCreate)) |
| | 1267 | | { |
| 1 | 1268 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.GetComputeNodeRDPFile(poolId, |
| 1 | 1269 | | computeNodeId, rdpStream, bhMgr, cancellationToken); |
| | 1270 | |
|
| 1 | 1271 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 1272 | |
|
| | 1273 | | // stream has rdp contents, flush |
| 0 | 1274 | | await rdpStream.FlushAsync().ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 1275 | | } |
| 0 | 1276 | | } |
| | 1277 | |
|
| | 1278 | | /// <summary> |
| | 1279 | | /// Gets a Remote Desktop Protocol file for the specified node. |
| | 1280 | | /// </summary> |
| | 1281 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1282 | | /// <param name="computeNodeId">The id of the compute node for which to get a Remote Desktop file.</param> |
| | 1283 | | /// <param name="rdpFileNameToCreate">The file path at which to create the RDP file.</param> |
| | 1284 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1285 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1286 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1287 | | /// <remarks> |
| | 1288 | | /// <para>If the file specified by <paramref name="rdpFileNameToCreate"/> already exists, it is overwritten.</pa |
| | 1289 | | /// <para>The get RDP file operation runs asynchronously.</para> |
| | 1290 | | /// <para>This method can be invoked only if the pool is created with a <see cref="CloudServiceConfiguration" /> |
| | 1291 | | /// If this method is invoked on pools created with <see cref="VirtualMachineConfiguration"/>, then Batch servic |
| | 1292 | | /// For pools with <see cref="VirtualMachineConfiguration"/> property, the new method <see cref="GetRemoteLoginS |
| | 1293 | | /// </remarks> |
| | 1294 | | public System.Threading.Tasks.Task GetRDPFileAsync( |
| | 1295 | | string poolId, |
| | 1296 | | string computeNodeId, |
| | 1297 | | string rdpFileNameToCreate, |
| | 1298 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1299 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1300 | | { |
| | 1301 | | // create the behavior manager |
| 1 | 1302 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1303 | |
|
| 1 | 1304 | | System.Threading.Tasks.Task asyncTask = GetRDPFileViaFileNameAsyncImpl( |
| 1 | 1305 | | poolId, |
| 1 | 1306 | | computeNodeId, |
| 1 | 1307 | | rdpFileNameToCreate, |
| 1 | 1308 | | bhMgr, |
| 1 | 1309 | | cancellationToken); |
| | 1310 | |
|
| 1 | 1311 | | return asyncTask; |
| | 1312 | | } |
| | 1313 | |
|
| | 1314 | | /// <summary> |
| | 1315 | | /// Gets a Remote Desktop Protocol file for the specified node. |
| | 1316 | | /// </summary> |
| | 1317 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1318 | | /// <param name="computeNodeId">The id of the compute node for which to get a Remote Desktop file.</param> |
| | 1319 | | /// <param name="rdpFileNameToCreate">The file path at which to create the RDP file.</param> |
| | 1320 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1321 | | /// <remarks> |
| | 1322 | | /// <para>If the file specified by <paramref name="rdpFileNameToCreate"/> already exists, it is overwritten.</pa |
| | 1323 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetRDPFileAsync(string, st |
| | 1324 | | /// <para>This method can be invoked only if the pool is created with a <see cref="CloudServiceConfiguration" /> |
| | 1325 | | /// If this method is invoked on pools created with <see cref="VirtualMachineConfiguration"/>, then Batch servic |
| | 1326 | | /// For pools with <see cref="VirtualMachineConfiguration"/> property, the new method <see cref="GetRemoteLoginS |
| | 1327 | | /// </remarks> |
| | 1328 | | public void GetRDPFile(string poolId, string computeNodeId, string rdpFileNameToCreate, |
| | 1329 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1330 | | { |
| 0 | 1331 | | Task asyncTask = GetRDPFileAsync(poolId, computeNodeId, rdpFileNameToCreate, additionalBehaviors); |
| 0 | 1332 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1333 | | } |
| | 1334 | |
|
| | 1335 | | internal async System.Threading.Tasks.Task<RemoteLoginSettings> GetRemoteLoginSettingsImpl(string poolId, string |
| | 1336 | | { |
| 1 | 1337 | | var asyncTask = _parentBatchClient.ProtocolLayer.GetRemoteLoginSettings(poolId, computeNodeId, bhMgr, cancel |
| | 1338 | |
|
| 1 | 1339 | | var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 1340 | |
|
| 0 | 1341 | | Models.ComputeNodeGetRemoteLoginSettingsResult rlSettings = response.Body; |
| | 1342 | |
|
| 0 | 1343 | | RemoteLoginSettings rls = new RemoteLoginSettings(rlSettings); |
| | 1344 | |
|
| 0 | 1345 | | return rls; |
| 0 | 1346 | | } |
| | 1347 | |
|
| | 1348 | | /// <summary> |
| | 1349 | | /// Gets the settings required for remote login to a compute node. |
| | 1350 | | /// </summary> |
| | 1351 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1352 | | /// <param name="computeNodeId">The id of the compute node for which to get a Remote Desktop file.</param> |
| | 1353 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1354 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1355 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1356 | | /// <remarks> |
| | 1357 | | /// <para>The get remote login settings operation runs asynchronously.</para> |
| | 1358 | | /// <para>This method can be invoked only if the pool is created with a <see cref="VirtualMachineConfiguration"/ |
| | 1359 | | /// If this method is invoked on pools created with <see cref="Microsoft.Azure.Batch.CloudServiceConfiguration" |
| | 1360 | | /// For pools with a <see cref="Microsoft.Azure.Batch.CloudServiceConfiguration" /> property, one of the GetRDPF |
| | 1361 | | /// </remarks> |
| | 1362 | | public System.Threading.Tasks.Task<RemoteLoginSettings> GetRemoteLoginSettingsAsync( |
| | 1363 | | string poolId, |
| | 1364 | | string computeNodeId, |
| | 1365 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1366 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1367 | | { |
| | 1368 | | // create the behavior manager |
| 1 | 1369 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1370 | |
|
| 1 | 1371 | | System.Threading.Tasks.Task<RemoteLoginSettings> asyncTask = GetRemoteLoginSettingsImpl( |
| 1 | 1372 | | poolId, |
| 1 | 1373 | | computeNodeId, |
| 1 | 1374 | | bhMgr, |
| 1 | 1375 | | cancellationToken); |
| | 1376 | |
|
| 1 | 1377 | | return asyncTask; |
| | 1378 | | } |
| | 1379 | |
|
| | 1380 | | /// <summary> |
| | 1381 | | /// Gets the settings required for remote login to a compute node. |
| | 1382 | | /// </summary> |
| | 1383 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1384 | | /// <param name="computeNodeId">The id of the compute node for which to get a Remote Desktop file.</param> |
| | 1385 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1386 | | /// <remarks> |
| | 1387 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetRemoteLoginSettingsAsyn |
| | 1388 | | /// <para>This method can be invoked only if the pool is created with a <see cref="VirtualMachineConfiguration"/ |
| | 1389 | | /// If this method is invoked on pools created with <see cref="CloudServiceConfiguration" />, then Batch service |
| | 1390 | | /// For pools with a <see cref="CloudServiceConfiguration" /> property, one of the GetRDPFileAsync/GetRDPFile me |
| | 1391 | | /// </remarks> |
| | 1392 | | public RemoteLoginSettings GetRemoteLoginSettings( |
| | 1393 | | string poolId, |
| | 1394 | | string computeNodeId, |
| | 1395 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1396 | | { |
| 0 | 1397 | | Task<RemoteLoginSettings> asyncTask = GetRemoteLoginSettingsAsync(poolId, computeNodeId, additionalBehaviors |
| 0 | 1398 | | RemoteLoginSettings rls = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1399 | |
|
| 0 | 1400 | | return rls; |
| | 1401 | | } |
| | 1402 | |
|
| | 1403 | | /// <summary> |
| | 1404 | | /// Reboots the specified compute node. |
| | 1405 | | /// </summary> |
| | 1406 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1407 | | /// <param name="computeNodeId">The id of the compute node to reboot.</param> |
| | 1408 | | /// <param name="rebootOption">Specifies when to reboot the node and what to do with currently running tasks. Th |
| | 1409 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1410 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1411 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1412 | | /// <remarks> |
| | 1413 | | /// <para>You can reboot a compute node only when it is in the <see cref="Common.ComputeNodeState.Idle"/> or <se |
| | 1414 | | /// <para>The reboot operation runs asynchronously.</para> |
| | 1415 | | /// </remarks> |
| | 1416 | | public System.Threading.Tasks.Task RebootAsync(string poolId, |
| | 1417 | | string computeNodeId, |
| | 1418 | | Common.ComputeNodeRebootOption? rebootOption = null, |
| | 1419 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1420 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1421 | | { |
| | 1422 | | // create the behavior manager |
| 1 | 1423 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1424 | |
|
| 1 | 1425 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.RebootComputeNode( |
| 1 | 1426 | | poolId, |
| 1 | 1427 | | computeNodeId, |
| 1 | 1428 | | rebootOption, |
| 1 | 1429 | | bhMgr, |
| 1 | 1430 | | cancellationToken); |
| | 1431 | |
|
| 1 | 1432 | | return asyncTask; |
| | 1433 | | } |
| | 1434 | |
|
| | 1435 | | /// <summary> |
| | 1436 | | /// Reboots the specified compute node. |
| | 1437 | | /// </summary> |
| | 1438 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1439 | | /// <param name="computeNodeId">The id of the compute node to reboot.</param> |
| | 1440 | | /// <param name="rebootOption">Specifies when to reboot the node and what to do with currently running tasks. Th |
| | 1441 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1442 | | /// <remarks> |
| | 1443 | | /// <para>You can reboot a compute node only when it is in the <see cref="Common.ComputeNodeState.Idle"/> or <se |
| | 1444 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="RebootAsync"/>.</para> |
| | 1445 | | /// </remarks> |
| | 1446 | | public void Reboot(string poolId, string computeNodeId, Common.ComputeNodeRebootOption? rebootOption = null, |
| | 1447 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1448 | | { |
| 0 | 1449 | | Task asyncTask = RebootAsync(poolId, computeNodeId, rebootOption, additionalBehaviors); |
| 0 | 1450 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1451 | | } |
| | 1452 | |
|
| | 1453 | | /// <summary> |
| | 1454 | | /// Reinstalls the operating system on the specified compute node. |
| | 1455 | | /// </summary> |
| | 1456 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1457 | | /// <param name="computeNodeId">The id of the compute node to reimage.</param> |
| | 1458 | | /// <param name="reimageOption">Specifies when to reimage the node and what to do with currently running tasks. |
| | 1459 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1460 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1461 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1462 | | /// <remarks> |
| | 1463 | | /// <para>You can reimage a compute node only when it is in the <see cref="Common.ComputeNodeState.Idle"/> or <s |
| | 1464 | | /// <para>The reimage operation runs asynchronously.</para> |
| | 1465 | | /// </remarks> |
| | 1466 | | public System.Threading.Tasks.Task ReimageAsync( |
| | 1467 | | string poolId, |
| | 1468 | | string computeNodeId, |
| | 1469 | | Common.ComputeNodeReimageOption? reimageOption = null, |
| | 1470 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1471 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1472 | | { |
| | 1473 | | // create the behavior manager |
| 1 | 1474 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1475 | |
|
| 1 | 1476 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.ReimageComputeNode(poolId, computeN |
| | 1477 | |
|
| 1 | 1478 | | return asyncTask; |
| | 1479 | | } |
| | 1480 | |
|
| | 1481 | | /// <summary> |
| | 1482 | | /// Reinstalls the operating system on the specified compute node. |
| | 1483 | | /// </summary> |
| | 1484 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1485 | | /// <param name="computeNodeId">The id of the compute node to reimage.</param> |
| | 1486 | | /// <param name="reimageOption">Specifies when to reimage the node and what to do with currently running tasks. |
| | 1487 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1488 | | /// <remarks> |
| | 1489 | | /// <para>You can reimage a compute node only when it is in the <see cref="Common.ComputeNodeState.Idle"/> or <s |
| | 1490 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="ReimageAsync"/>.</para> |
| | 1491 | | /// </remarks> |
| | 1492 | | public void Reimage(string poolId, string computeNodeId, Common.ComputeNodeReimageOption? reimageOption = null, |
| | 1493 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1494 | | { |
| 0 | 1495 | | Task asyncTask = ReimageAsync(poolId, computeNodeId, reimageOption, additionalBehaviors); |
| 0 | 1496 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1497 | | } |
| | 1498 | |
|
| | 1499 | | internal async System.Threading.Tasks.Task<NodeFile> GetNodeFileAsyncImpl( |
| | 1500 | | string poolId, |
| | 1501 | | string computeNodeId, |
| | 1502 | | string filePath, |
| | 1503 | | BehaviorManager bhMgr, |
| | 1504 | | CancellationToken cancellationToken) |
| | 1505 | | { |
| 4 | 1506 | | var getNodeFilePropertiesTask = await this.ParentBatchClient.ProtocolLayer.GetNodeFilePropertiesByNode( |
| 4 | 1507 | | poolId, |
| 4 | 1508 | | computeNodeId, |
| 4 | 1509 | | filePath, |
| 4 | 1510 | | bhMgr, |
| 4 | 1511 | | cancellationToken).ConfigureAwait(continueOnCapturedContext: false); |
| | 1512 | |
|
| 3 | 1513 | | Models.NodeFile file = getNodeFilePropertiesTask.Body; |
| | 1514 | |
|
| | 1515 | | // wrap protocol object |
| 3 | 1516 | | NodeFile wrapped = new ComputeNodeFile(this, poolId, computeNodeId, file, bhMgr.BaseBehaviors); |
| | 1517 | |
|
| 3 | 1518 | | return wrapped; |
| 3 | 1519 | | } |
| | 1520 | |
|
| | 1521 | | /// <summary> |
| | 1522 | | /// Gets information about a file on a compute node. |
| | 1523 | | /// </summary> |
| | 1524 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1525 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1526 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | 1527 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1528 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1529 | | /// <returns>A <see cref="NodeFile"/> containing information about the file, and which can be used to download t |
| | 1530 | | /// <remarks>The get file operation runs asynchronously.</remarks> |
| | 1531 | | public System.Threading.Tasks.Task<NodeFile> GetNodeFileAsync( |
| | 1532 | | string poolId, |
| | 1533 | | string computeNodeId, |
| | 1534 | | string filePath, |
| | 1535 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1536 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1537 | | { |
| | 1538 | | // set up behavior manager |
| 4 | 1539 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1540 | |
|
| 4 | 1541 | | System.Threading.Tasks.Task<NodeFile> asyncTask = this.GetNodeFileAsyncImpl( |
| 4 | 1542 | | poolId, |
| 4 | 1543 | | computeNodeId, |
| 4 | 1544 | | filePath, |
| 4 | 1545 | | bhMgr, |
| 4 | 1546 | | cancellationToken); |
| | 1547 | |
|
| 4 | 1548 | | return asyncTask; |
| | 1549 | | } |
| | 1550 | |
|
| | 1551 | | /// <summary> |
| | 1552 | | /// Gets information about a file on a compute node. |
| | 1553 | | /// </summary> |
| | 1554 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1555 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1556 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | 1557 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1558 | | /// <returns>A <see cref="NodeFile"/> containing information about the file, and which can be used to download t |
| | 1559 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetNodeFileAsync"/>.</r |
| | 1560 | | public NodeFile GetNodeFile(string poolId, string computeNodeId, string filePath, |
| | 1561 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1562 | | { |
| 0 | 1563 | | Task<NodeFile> asyncTask = this.GetNodeFileAsync(poolId, computeNodeId, filePath, additionalBehaviors); |
| 0 | 1564 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1565 | | } |
| | 1566 | |
|
| | 1567 | | internal async Task CopyNodeFileContentToStreamAsyncImpl( |
| | 1568 | | string poolId, |
| | 1569 | | string computeNodeId, |
| | 1570 | | string filePath, |
| | 1571 | | Stream stream, |
| | 1572 | | GetFileRequestByteRange byteRange, |
| | 1573 | | BehaviorManager bhMgr, |
| | 1574 | | CancellationToken cancellationToken) |
| | 1575 | | { |
| 2 | 1576 | | await this.ParentBatchClient.ProtocolLayer.GetNodeFileByNode( |
| 2 | 1577 | | poolId, |
| 2 | 1578 | | computeNodeId, |
| 2 | 1579 | | filePath, |
| 2 | 1580 | | stream, |
| 2 | 1581 | | byteRange, |
| 2 | 1582 | | bhMgr, |
| 2 | 1583 | | cancellationToken).ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 1584 | | } |
| | 1585 | |
|
| | 1586 | | /// <summary> |
| | 1587 | | /// Copies the contents of a file from the specified node to the given <see cref="Stream"/>. |
| | 1588 | | /// </summary> |
| | 1589 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1590 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1591 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | 1592 | | /// <param name="stream">The stream to copy the file contents to.</param> |
| | 1593 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | 1594 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1595 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1596 | | /// <remarks>The get file operation runs asynchronously.</remarks> |
| | 1597 | | public Task CopyNodeFileContentToStreamAsync( |
| | 1598 | | string poolId, |
| | 1599 | | string computeNodeId, |
| | 1600 | | string filePath, |
| | 1601 | | Stream stream, |
| | 1602 | | GetFileRequestByteRange byteRange = null, |
| | 1603 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1604 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1605 | | { |
| | 1606 | | // set up behavior manager |
| 1 | 1607 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| 1 | 1608 | | return this.CopyNodeFileContentToStreamAsyncImpl(poolId, computeNodeId, filePath, stream, byteRange, bhMgr, |
| | 1609 | | } |
| | 1610 | |
|
| | 1611 | | /// <summary> |
| | 1612 | | /// Copies the contents of a file from the specified node to the given <see cref="Stream"/>. |
| | 1613 | | /// </summary> |
| | 1614 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1615 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1616 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | 1617 | | /// <param name="stream">The stream to copy the file contents to.</param> |
| | 1618 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | 1619 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1620 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="CopyNodeFileContentToS |
| | 1621 | | public void CopyNodeFileContentToStream( |
| | 1622 | | string poolId, |
| | 1623 | | string computeNodeId, |
| | 1624 | | string filePath, |
| | 1625 | | Stream stream, |
| | 1626 | | GetFileRequestByteRange byteRange = null, |
| | 1627 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1628 | | { |
| 0 | 1629 | | Task asyncTask = this.CopyNodeFileContentToStreamAsync(poolId, computeNodeId, filePath, stream, byteRange, a |
| 0 | 1630 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1631 | | } |
| | 1632 | |
|
| | 1633 | | internal Task<string> CopyNodeFileContentToStringAsyncImpl( |
| | 1634 | | string poolId, |
| | 1635 | | string computeNodeId, |
| | 1636 | | string filePath, |
| | 1637 | | Encoding encoding, |
| | 1638 | | GetFileRequestByteRange byteRange, |
| | 1639 | | BehaviorManager bhMgr, |
| | 1640 | | CancellationToken cancellationToken) |
| | 1641 | | { |
| 1 | 1642 | | return UtilitiesInternal.ReadNodeFileAsStringAsync( |
| 1 | 1643 | | // Note that behaviors is purposefully dropped in the below call since it's already managed by the bhMgr |
| 2 | 1644 | | (stream, bRange, behaviors, ct) => this.CopyNodeFileContentToStreamAsyncImpl(poolId, computeNodeId, file |
| 1 | 1645 | | encoding, |
| 1 | 1646 | | byteRange, |
| 1 | 1647 | | additionalBehaviors: null, |
| 1 | 1648 | | cancellationToken: cancellationToken); |
| | 1649 | | } |
| | 1650 | |
|
| | 1651 | | /// <summary> |
| | 1652 | | /// Reads the contents of a file from the specified node into a string. |
| | 1653 | | /// </summary> |
| | 1654 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1655 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1656 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | 1657 | | /// <param name="encoding">The encoding to use. If no value or null is specified, UTF8 is used.</param> |
| | 1658 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | 1659 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1660 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1661 | | /// <returns>The contents of the file, as a string</returns> |
| | 1662 | | public Task<string> CopyNodeFileContentToStringAsync( |
| | 1663 | | string poolId, |
| | 1664 | | string computeNodeId, |
| | 1665 | | string filePath, |
| | 1666 | | Encoding encoding = null, |
| | 1667 | | GetFileRequestByteRange byteRange = null, |
| | 1668 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1669 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1670 | | { |
| | 1671 | | // set up behavior manager |
| 1 | 1672 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| 1 | 1673 | | return CopyNodeFileContentToStringAsyncImpl(poolId, computeNodeId, filePath, encoding, byteRange, bhMgr, can |
| | 1674 | | } |
| | 1675 | |
|
| | 1676 | | /// <summary> |
| | 1677 | | /// Reads the contents of a file from the specified node into a string. |
| | 1678 | | /// </summary> |
| | 1679 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1680 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1681 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | 1682 | | /// <param name="encoding">The encoding to use. If no value or null is specified, UTF8 is used.</param> |
| | 1683 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | 1684 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1685 | | /// <returns>The contents of the file, as a string</returns> |
| | 1686 | | public string CopyNodeFileContentToString( |
| | 1687 | | string poolId, |
| | 1688 | | string computeNodeId, |
| | 1689 | | string filePath, |
| | 1690 | | Encoding encoding = null, |
| | 1691 | | GetFileRequestByteRange byteRange = null, |
| | 1692 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1693 | | { |
| 0 | 1694 | | Task<string> asyncTask = this.CopyNodeFileContentToStringAsync(poolId, computeNodeId, filePath, encoding, by |
| 0 | 1695 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1696 | | } |
| | 1697 | |
|
| | 1698 | | internal IPagedEnumerable<NodeFile> ListNodeFilesImpl( |
| | 1699 | | string poolId, |
| | 1700 | | string computeNodeId, |
| | 1701 | | bool? recursive, |
| | 1702 | | BehaviorManager bhMgr, |
| | 1703 | | DetailLevel detailLevel) |
| | 1704 | | { |
| 1 | 1705 | | PagedEnumerable<NodeFile> enumerable = new PagedEnumerable<NodeFile>( // the lamda will be the enumerator fa |
| 1 | 1706 | | () => |
| 1 | 1707 | | { |
| 1 | 1708 | | // here is the actual strongly typed enumerator |
| 2 | 1709 | | AsyncListNodeFilesByNodeEnumerator typedEnumerator = new AsyncListNodeFilesByNodeEnumerator(this, po |
| 1 | 1710 | |
|
| 1 | 1711 | | // here is the base |
| 1 | 1712 | | PagedEnumeratorBase<NodeFile> enumeratorBase = typedEnumerator; |
| 1 | 1713 | |
|
| 2 | 1714 | | return enumeratorBase; |
| 1 | 1715 | | }); |
| | 1716 | |
|
| 1 | 1717 | | return enumerable; |
| | 1718 | | } |
| | 1719 | |
|
| | 1720 | | /// <summary> |
| | 1721 | | /// Enumerates files on the specified compute node. |
| | 1722 | | /// </summary> |
| | 1723 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1724 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1725 | | /// <param name="recursive">If true, recursively enumerates all files on the compute node. If false, enumerates |
| | 1726 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 1727 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1728 | | /// <returns>An <see cref="IPagedEnumerable{NodeFile}"/> that can be used to enumerate files asynchronously or s |
| | 1729 | | /// <remarks>This method returns immediately; the file data is retrieved from the Batch service only when the co |
| | 1730 | | /// Retrieval is non-atomic; file data is retrieved in pages during enumeration of the collection.</remarks> |
| | 1731 | | public IPagedEnumerable<NodeFile> ListNodeFiles( |
| | 1732 | | string poolId, |
| | 1733 | | string computeNodeId, |
| | 1734 | | bool? recursive = null, |
| | 1735 | | DetailLevel detailLevel = null, |
| | 1736 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1737 | | { |
| | 1738 | | // set up behavior manager |
| 1 | 1739 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1740 | |
|
| | 1741 | | // get the enumerable |
| 1 | 1742 | | IPagedEnumerable<NodeFile> enumerable = this.ListNodeFilesImpl( |
| 1 | 1743 | | poolId, |
| 1 | 1744 | | computeNodeId, |
| 1 | 1745 | | recursive, |
| 1 | 1746 | | bhMgr, |
| 1 | 1747 | | detailLevel); |
| | 1748 | |
|
| 1 | 1749 | | return enumerable; |
| | 1750 | | } |
| | 1751 | |
|
| | 1752 | | /// <summary> |
| | 1753 | | /// Deletes the specified file from the specified compute node. |
| | 1754 | | /// </summary> |
| | 1755 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1756 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1757 | | /// <param name="filePath">The path of the file to delete.</param> |
| | 1758 | | /// <param name="recursive"> |
| | 1759 | | /// If the file-path parameter represents a directory instead of a file, you can set the optional |
| | 1760 | | /// recursive parameter to true to delete the directory and all of the files and subdirectories in it. If recurs |
| | 1761 | | /// then the directory must be empty or deletion will fail. |
| | 1762 | | /// </param> |
| | 1763 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1764 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1765 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1766 | | /// <remarks>The delete operation runs asynchronously.</remarks> |
| | 1767 | | public System.Threading.Tasks.Task DeleteNodeFileAsync( |
| | 1768 | | string poolId, |
| | 1769 | | string computeNodeId, |
| | 1770 | | string filePath, |
| | 1771 | | bool? recursive = null, |
| | 1772 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1773 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1774 | | { |
| | 1775 | | // create the behavior manager |
| 1 | 1776 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1777 | |
|
| 1 | 1778 | | System.Threading.Tasks.Task asyncTask = _parentBatchClient.ProtocolLayer.DeleteNodeFileByNode( |
| 1 | 1779 | | poolId, |
| 1 | 1780 | | computeNodeId, |
| 1 | 1781 | | filePath, |
| 1 | 1782 | | recursive, |
| 1 | 1783 | | bhMgr, |
| 1 | 1784 | | cancellationToken); |
| | 1785 | |
|
| 1 | 1786 | | return asyncTask; |
| | 1787 | | } |
| | 1788 | |
|
| | 1789 | | /// <summary> |
| | 1790 | | /// Deletes the specified file from the specified compute node. |
| | 1791 | | /// </summary> |
| | 1792 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1793 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1794 | | /// <param name="filePath">The path of the file to delete.</param> |
| | 1795 | | /// <param name="recursive"> |
| | 1796 | | /// If the file-path parameter represents a directory instead of a file, you can set the optional |
| | 1797 | | /// recursive parameter to true to delete the directory and all of the files and subdirectories in it. If recurs |
| | 1798 | | /// then the directory must be empty or deletion will fail. |
| | 1799 | | /// </param> |
| | 1800 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1801 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="DeleteNodeFileAsync"/> |
| | 1802 | | public void DeleteNodeFile( |
| | 1803 | | string poolId, |
| | 1804 | | string computeNodeId, |
| | 1805 | | string filePath, |
| | 1806 | | bool? recursive = null, |
| | 1807 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1808 | | { |
| 0 | 1809 | | Task asyncTask = this.DeleteNodeFileAsync(poolId, computeNodeId, filePath, recursive, additionalBehaviors); |
| 0 | 1810 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 1811 | | } |
| | 1812 | |
|
| | 1813 | |
|
| | 1814 | | /// <summary> |
| | 1815 | | /// Gets lifetime summary statistics for all of the pools in the current account. |
| | 1816 | | /// Statistics are aggregated across all pools that have ever existed in the account, from account creation to t |
| | 1817 | | /// Batch service performs periodic roll-up of statistics. The typical delay is about 30 minutes. |
| | 1818 | | /// </summary> |
| | 1819 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1820 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1821 | | /// <returns>The aggregated pool statistics.</returns> |
| | 1822 | | /// <remarks>The get statistics operation runs asynchronously.</remarks> |
| | 1823 | | public async System.Threading.Tasks.Task<PoolStatistics> GetAllLifetimeStatisticsAsync(IEnumerable<BatchClientBe |
| | 1824 | | { |
| | 1825 | | // craft the behavior manager for this call |
| 1 | 1826 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1827 | |
|
| 1 | 1828 | | System.Threading.Tasks.Task<AzureOperationResponse<Models.PoolStatistics, Models.PoolGetAllLifetimeStatistic |
| 1 | 1829 | | this.ParentBatchClient.ProtocolLayer.GetAllPoolLifetimeStats(bhMgr, cancellationToken); |
| | 1830 | |
|
| 1 | 1831 | | var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | 1832 | |
|
| 0 | 1833 | | PoolStatistics statistics = new PoolStatistics(response.Body); |
| | 1834 | |
|
| 0 | 1835 | | return statistics; |
| 0 | 1836 | | } |
| | 1837 | |
|
| | 1838 | | /// <summary> |
| | 1839 | | /// Gets lifetime summary statistics for all of the pools in the current account. |
| | 1840 | | /// Statistics are aggregated across all pools that have ever existed in the account, from account creation to t |
| | 1841 | | /// Batch service performs periodic roll-up of statistics. The typical delay is about 30 minutes. |
| | 1842 | | /// </summary> |
| | 1843 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1844 | | /// <returns>The aggregated pool statistics.</returns> |
| | 1845 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetAllLifetimeStatistic |
| | 1846 | | public PoolStatistics GetAllLifetimeStatistics(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1847 | | { |
| 0 | 1848 | | Task<PoolStatistics> asyncTask = this.GetAllLifetimeStatisticsAsync(additionalBehaviors); |
| 0 | 1849 | | PoolStatistics statistics = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors) |
| | 1850 | |
|
| 0 | 1851 | | return statistics; |
| | 1852 | | } |
| | 1853 | |
|
| | 1854 | | /// <summary> |
| | 1855 | | /// Enumerates pool usage metrics. |
| | 1856 | | /// </summary> |
| | 1857 | | /// <param name="startTime">The start time of the aggregation interval covered by this entry.</param> |
| | 1858 | | /// <param name="endTime">The end time of the aggregation interval for this entry.</param> |
| | 1859 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 1860 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1861 | | /// <returns>An <see cref="IPagedEnumerable{PoolUsageMetrics}"/> that can be used to enumerate metrics asynchron |
| | 1862 | | /// <remarks>This method returns immediately; the metrics data is retrieved from the Batch service only when the |
| | 1863 | | /// Retrieval is non-atomic; metrics data is retrieved in pages during enumeration of the collection.</remarks> |
| | 1864 | | public IPagedEnumerable<PoolUsageMetrics> ListPoolUsageMetrics(DateTime? startTime = null, DateTime? endTime = n |
| | 1865 | | { |
| | 1866 | | // craft the behavior manager for this call |
| 1 | 1867 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1868 | |
|
| 1 | 1869 | | PagedEnumerable<PoolUsageMetrics> enumerable = new PagedEnumerable<PoolUsageMetrics>( // the lamda will be t |
| 1 | 1870 | | () => |
| 1 | 1871 | | { |
| 1 | 1872 | | // here is the actual strongly typed enumerator |
| 2 | 1873 | | AsyncListPoolUsageMetricsEnumerator typedEnumerator = new AsyncListPoolUsageMetricsEnumerator(this, |
| 1 | 1874 | |
|
| 1 | 1875 | | // here is the base |
| 1 | 1876 | | PagedEnumeratorBase<PoolUsageMetrics> enumeratorBase = typedEnumerator; |
| 1 | 1877 | |
|
| 2 | 1878 | | return enumeratorBase; |
| 1 | 1879 | | }); |
| | 1880 | |
|
| 1 | 1881 | | return enumerable; |
| | 1882 | | } |
| | 1883 | |
|
| | 1884 | | /// <summary> |
| | 1885 | | /// Enumerates the node agent Sku values supported by Batch Service. |
| | 1886 | | /// </summary> |
| | 1887 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 1888 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1889 | | /// <returns>An <see cref="IPagedEnumerable{NodeAgentSku}"/> that can be used to enumerate node agent sku values |
| | 1890 | | public IPagedEnumerable<ImageInformation> ListSupportedImages(DetailLevel detailLevel = null, IEnumerable<BatchC |
| | 1891 | | { |
| | 1892 | | // craft the behavior manager for this call |
| 1 | 1893 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1894 | |
|
| 1 | 1895 | | PagedEnumerable<ImageInformation> enumerable = new PagedEnumerable<ImageInformation>( // the lamda will be t |
| 1 | 1896 | | () => |
| 1 | 1897 | | { |
| 1 | 1898 | | // here is the actual strongly typed enumerator |
| 2 | 1899 | | var typedEnumerator = new AsyncListSupportedImagesEnumerator(this, bhMgr, detailLevel); |
| 1 | 1900 | |
|
| 1 | 1901 | | // here is the base |
| 1 | 1902 | | PagedEnumeratorBase<ImageInformation> enumeratorBase = typedEnumerator; |
| 2 | 1903 | | return enumeratorBase; |
| 1 | 1904 | | }); |
| | 1905 | |
|
| 1 | 1906 | | return enumerable; |
| | 1907 | | } |
| | 1908 | |
|
| | 1909 | | internal async System.Threading.Tasks.Task<UploadBatchServiceLogsResult> UploadComputeNodeBatchServiceLogsAsyncI |
| | 1910 | | string poolId, |
| | 1911 | | string computeNodeId, |
| | 1912 | | string containerUrl, |
| | 1913 | | DateTime startTime, |
| | 1914 | | DateTime? endTime, |
| | 1915 | | BehaviorManager bhMgr, |
| | 1916 | | CancellationToken cancellationToken) |
| | 1917 | | { |
| 1 | 1918 | | var task = _parentBatchClient.ProtocolLayer.UploadBatchServiceLogs( |
| 1 | 1919 | | poolId, |
| 1 | 1920 | | computeNodeId, |
| 1 | 1921 | | containerUrl, |
| 1 | 1922 | | startTime, |
| 1 | 1923 | | endTime, |
| 1 | 1924 | | bhMgr, |
| 1 | 1925 | | cancellationToken); |
| | 1926 | |
|
| 1 | 1927 | | var result = await task.ConfigureAwait(false); |
| | 1928 | |
|
| 0 | 1929 | | return new UploadBatchServiceLogsResult(result.Body); |
| 0 | 1930 | | } |
| | 1931 | |
|
| | 1932 | | /// <summary> |
| | 1933 | | /// Upload Azure Batch service log files from the specified compute node. |
| | 1934 | | /// </summary> |
| | 1935 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1936 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1937 | | /// <param name="containerUrl"> |
| | 1938 | | /// The URL of the container within Azure Blob Storage to which to upload the Batch Service log file(s). The URL |
| | 1939 | | /// </param> |
| | 1940 | | /// <param name="startTime"> |
| | 1941 | | /// The start of the time range from which to upload Batch Service log file(s). Any log file containing a log me |
| | 1942 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | 1943 | | /// </param> |
| | 1944 | | /// <param name="endTime"> |
| | 1945 | | /// The end of the time range from which to upload Batch Service log file(s). Any log file containing a log mess |
| | 1946 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | 1947 | | /// </param> |
| | 1948 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1949 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1950 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1951 | | /// <remarks> |
| | 1952 | | /// This is for gathering Azure Batch service log files in an automated fashion from nodes if you are experienci |
| | 1953 | | /// The Azure Batch service log files should be shared with Azure support to aid in debugging issues with the Ba |
| | 1954 | | /// </remarks> |
| | 1955 | | public System.Threading.Tasks.Task<UploadBatchServiceLogsResult> UploadComputeNodeBatchServiceLogsAsync( |
| | 1956 | | string poolId, |
| | 1957 | | string computeNodeId, |
| | 1958 | | string containerUrl, |
| | 1959 | | DateTime startTime, |
| | 1960 | | DateTime? endTime = null, |
| | 1961 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1962 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1963 | | { |
| | 1964 | | // craft the behavior manager for this call |
| 1 | 1965 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1966 | |
|
| 1 | 1967 | | return UploadComputeNodeBatchServiceLogsAsyncImpl( |
| 1 | 1968 | | poolId, |
| 1 | 1969 | | computeNodeId, |
| 1 | 1970 | | containerUrl, |
| 1 | 1971 | | startTime, |
| 1 | 1972 | | endTime, |
| 1 | 1973 | | bhMgr, |
| 1 | 1974 | | cancellationToken); |
| | 1975 | | } |
| | 1976 | |
|
| | 1977 | | /// <summary> |
| | 1978 | | /// Upload Azure Batch service log files from the specified compute node. |
| | 1979 | | /// </summary> |
| | 1980 | | /// <param name="poolId">The id of the pool that contains the compute node.</param> |
| | 1981 | | /// <param name="computeNodeId">The id of the compute node.</param> |
| | 1982 | | /// <param name="containerUrl"> |
| | 1983 | | /// The URL of the container within Azure Blob Storage to which to upload the Batch Service log file(s). The URL |
| | 1984 | | /// </param> |
| | 1985 | | /// <param name="startTime"> |
| | 1986 | | /// The start of the time range from which to upload Batch Service log file(s). Any log file containing a log me |
| | 1987 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | 1988 | | /// </param> |
| | 1989 | | /// <param name="endTime"> |
| | 1990 | | /// The end of the time range from which to upload Batch Service log file(s). Any log file containing a log mess |
| | 1991 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | 1992 | | /// </param> |
| | 1993 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1994 | | /// <remarks> |
| | 1995 | | /// This is for gathering Azure Batch service log files in an automated fashion from nodes if you are experienci |
| | 1996 | | /// The Azure Batch service log files should be shared with Azure support to aid in debugging issues with the Ba |
| | 1997 | | /// </remarks> |
| | 1998 | | /// <returns>The result of uploading the batch service logs.</returns> |
| | 1999 | | public UploadBatchServiceLogsResult UploadComputeNodeBatchServiceLogs( |
| | 2000 | | string poolId, |
| | 2001 | | string computeNodeId, |
| | 2002 | | string containerUrl, |
| | 2003 | | DateTime startTime, |
| | 2004 | | DateTime? endTime = null, |
| | 2005 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 2006 | | { |
| 0 | 2007 | | var asyncTask = this.UploadComputeNodeBatchServiceLogsAsync( |
| 0 | 2008 | | poolId, |
| 0 | 2009 | | computeNodeId, |
| 0 | 2010 | | containerUrl, |
| 0 | 2011 | | startTime, |
| 0 | 2012 | | endTime, |
| 0 | 2013 | | additionalBehaviors); |
| 0 | 2014 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 2015 | | } |
| | 2016 | |
|
| | 2017 | | /// <summary> |
| | 2018 | | /// Lists the number of nodes in each state, grouped by pool. |
| | 2019 | | /// </summary> |
| | 2020 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 2021 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 2022 | | /// <returns>An <see cref="IPagedEnumerable{PoolNodeCounts}"/> that can be used to enumerate pool node count det |
| | 2023 | | /// <remarks>This method returns immediately; the pool counts are retrieved from the Batch service only when the |
| | 2024 | | /// Retrieval is non-atomic; pool counts are retrieved in pages during enumeration of the collection.</remarks> |
| | 2025 | | public IPagedEnumerable<PoolNodeCounts> ListPoolNodeCounts(DetailLevel detailLevel = null, IEnumerable<BatchClie |
| | 2026 | | { |
| | 2027 | | // craft the behavior manager for this call |
| 1 | 2028 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 2029 | |
|
| 1 | 2030 | | PagedEnumerable<PoolNodeCounts> enumerable = new PagedEnumerable<PoolNodeCounts>( // the lamda will be the e |
| 1 | 2031 | | () => |
| 1 | 2032 | | { |
| 1 | 2033 | | // here is the actual strongly typed enumerator |
| 2 | 2034 | | AsyncListPoolNodeCountsEnumerator typedEnumerator = new AsyncListPoolNodeCountsEnumerator(this, bhMg |
| 2 | 2035 | | return typedEnumerator; |
| 1 | 2036 | | }); |
| | 2037 | |
|
| 1 | 2038 | | return enumerable; |
| | 2039 | | } |
| | 2040 | |
|
| | 2041 | | #endregion // PoolOperations |
| | 2042 | | } |
| | 2043 | | } |