| | | 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.Text; |
| | | 5 | | |
| | | 6 | | namespace Microsoft.Azure.Batch |
| | | 7 | | { |
| | | 8 | | using System; |
| | | 9 | | using System.Collections.Generic; |
| | | 10 | | using System.IO; |
| | | 11 | | using System.Threading; |
| | | 12 | | using System.Threading.Tasks; |
| | | 13 | | using Microsoft.Rest.Azure; |
| | | 14 | | using Models = Microsoft.Azure.Batch.Protocol.Models; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Summarizes the state of a compute node. |
| | | 18 | | /// </summary> |
| | | 19 | | public partial class ComputeNode : IRefreshable |
| | | 20 | | { |
| | | 21 | | |
| | | 22 | | #region ComputeNode |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Instantiates an unbound ComputeNodeUser object to be populated by the caller and used to create a user accou |
| | | 26 | | /// </summary> |
| | | 27 | | /// <returns>An <see cref="ComputeNodeUser"/> object.</returns> |
| | | 28 | | public ComputeNodeUser CreateComputeNodeUser() |
| | | 29 | | { |
| | 0 | 30 | | ComputeNodeUser newUser = new ComputeNodeUser(this.parentBatchClient, this.CustomBehaviors, this.parentPoolI |
| | | 31 | | |
| | 0 | 32 | | return newUser; |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Begins an asynchronous call to delete the specified ComputeNodeUser. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <param name="userName">The name of the ComputeNodeUser to be deleted.</param> |
| | | 39 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 40 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 41 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 42 | | public Task DeleteComputeNodeUserAsync( |
| | | 43 | | string userName, |
| | | 44 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 45 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 46 | | { |
| | | 47 | | // create the behavior managaer |
| | 1003 | 48 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 49 | | |
| | 1003 | 50 | | Task asyncTask = this.parentBatchClient.ProtocolLayer.DeleteComputeNodeUser(this.parentPoolId, this.Id, user |
| | 1003 | 51 | | |
| | 1003 | 52 | | return asyncTask; |
| | 1003 | 53 | | } |
| | 1003 | 54 | | |
| | 1003 | 55 | | /// <summary> |
| | 1003 | 56 | | /// Blocking call to delete the specified ComputeNodeUser. |
| | 1003 | 57 | | /// </summary> |
| | 1003 | 58 | | /// <param name="userName">The name of the ComputeNodeUser to be deleted.</param> |
| | 1003 | 59 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1003 | 60 | | |
| | 1003 | 61 | | public void DeleteComputeNodeUser(string userName, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1003 | 62 | | { |
| | 1491 | 63 | | Task asyncTask = DeleteComputeNodeUserAsync(userName, additionalBehaviors); |
| | 1003 | 64 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1003 | 65 | | } |
| | 1003 | 66 | | |
| | 1003 | 67 | | /// <summary> |
| | 1003 | 68 | | /// Begins an asynchronous call to get RDP file data targeting the compute node of the current instance and writ |
| | 1003 | 69 | | /// </summary> |
| | 1003 | 70 | | /// <param name="rdpStream">The Stream into which the RDP file data will be written. This stream will not be cl |
| | 1003 | 71 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1003 | 72 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1003 | 73 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | 1003 | 74 | | public Task GetRDPFileAsync(Stream rdpStream, IEnumerable<BatchClientBehavior> additionalBehaviors = null, Cance |
| | 1003 | 75 | | { |
| | 1003 | 76 | | // create the behavior managaer |
| | 1003 | 77 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1003 | 78 | | |
| | 1003 | 79 | | Task asyncTask = this.parentBatchClient.ProtocolLayer.GetComputeNodeRDPFile(this.parentPoolId, this.Id, rdpS |
| | 1003 | 80 | | |
| | 1003 | 81 | | return asyncTask; |
| | 1003 | 82 | | } |
| | 1003 | 83 | | |
| | 1003 | 84 | | /// <summary> |
| | 1003 | 85 | | /// Blocking call to get RDP file data targeting the compute node of the current instance and write them to a sp |
| | 1003 | 86 | | /// </summary> |
| | 1509 | 87 | | /// <param name="rdpStream">The Stream into which the RDP file data will be written. This stream will not be cl |
| | 1003 | 88 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1003 | 89 | | public void GetRDPFile(Stream rdpStream, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1003 | 90 | | { |
| | 1003 | 91 | | Task asyncTask = GetRDPFileAsync(rdpStream, additionalBehaviors); |
| | 1003 | 92 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1003 | 93 | | } |
| | 1003 | 94 | | |
| | 1003 | 95 | | /// <summary> |
| | 1003 | 96 | | /// Begins an asynchronous call to get RDP file data targeting the compute node of the current instance and writ |
| | 1003 | 97 | | /// </summary> |
| | 1003 | 98 | | /// <param name="rdpFileNameToCreate">The name of the RDP file to be created.</param> |
| | 1003 | 99 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1003 | 100 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1003 | 101 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | 1003 | 102 | | public Task GetRDPFileAsync( |
| | 1511 | 103 | | string rdpFileNameToCreate, |
| | 1003 | 104 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1003 | 105 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1003 | 106 | | { |
| | 1506 | 107 | | // create the behavior managaer |
| | 1003 | 108 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1003 | 109 | | |
| | 1003 | 110 | | Task asyncTask = this.parentBatchClient.PoolOperations.GetRDPFileViaFileNameAsyncImpl(this.parentPoolId, thi |
| | 1003 | 111 | | |
| | 1003 | 112 | | return asyncTask; |
| | 1003 | 113 | | } |
| | 1003 | 114 | | |
| | 1003 | 115 | | /// <summary> |
| | 1003 | 116 | | /// Blocking call to get RDP file data targeting the compute node of the current instance and write them to a fi |
| | 1003 | 117 | | /// </summary> |
| | 1003 | 118 | | /// <param name="rdpFileNameToCreate">The name of the RDP file to be created.</param> |
| | 1003 | 119 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1003 | 120 | | public void GetRDPFile(string rdpFileNameToCreate, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 1003 | 121 | | { |
| | 1003 | 122 | | Task asyncTask = GetRDPFileAsync(rdpFileNameToCreate, additionalBehaviors); |
| | 1003 | 123 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 1003 | 124 | | } |
| | 1003 | 125 | | |
| | 1003 | 126 | | /// <summary> |
| | 1003 | 127 | | /// Gets the settings required for remote login to a compute node. |
| | 1003 | 128 | | /// </summary> |
| | 1003 | 129 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1003 | 130 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1003 | 131 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 1003 | 132 | | /// <remarks> |
| | 1003 | 133 | | /// <para>The get remote login settings operation runs asynchronously.</para> |
| | 1003 | 134 | | /// <para>This method can be invoked only if the pool is created with a <see cref="VirtualMachineConfiguration"/ |
| | | 135 | | /// If this method is invoked on pools created with <see cref="CloudServiceConfiguration" />, then Batch service |
| | | 136 | | /// For pools with a <see cref="CloudServiceConfiguration" /> property, one of the GetRDPFileAsync/GetRDPFile me |
| | | 137 | | /// </remarks> |
| | | 138 | | public System.Threading.Tasks.Task<RemoteLoginSettings> GetRemoteLoginSettingsAsync(IEnumerable<BatchClientBehav |
| | | 139 | | { |
| | | 140 | | // create the behavior manager |
| | 0 | 141 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 142 | | |
| | 0 | 143 | | System.Threading.Tasks.Task<RemoteLoginSettings> asyncTask = this.parentBatchClient.PoolOperations.GetRemote |
| | 0 | 144 | | this.parentPoolId, |
| | 0 | 145 | | this.Id, |
| | 0 | 146 | | bhMgr, |
| | 0 | 147 | | cancellationToken); |
| | | 148 | | |
| | 0 | 149 | | return asyncTask; |
| | | 150 | | } |
| | | 151 | | |
| | 1003 | 152 | | /// <summary> |
| | 1003 | 153 | | /// Gets the settings required for remote login to a compute node. |
| | 1003 | 154 | | /// </summary> |
| | 1003 | 155 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 1003 | 156 | | /// <remarks> |
| | | 157 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="Microsoft.Azure.Batch.Comp |
| | 1003 | 158 | | /// <para>This method can be invoked only if the pool is created with a <see cref="Microsoft.Azure.Batch.Virtual |
| | 1003 | 159 | | /// If this method is invoked on pools created with <see cref="Microsoft.Azure.Batch.CloudServiceConfiguration" |
| | 1003 | 160 | | /// For pools with a <see cref="Microsoft.Azure.Batch.CloudServiceConfiguration" /> property, one of the GetRDPF |
| | 1003 | 161 | | /// </remarks> |
| | 1003 | 162 | | public RemoteLoginSettings GetRemoteLoginSettings(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 163 | | { |
| | 0 | 164 | | Task<RemoteLoginSettings> asyncTask = GetRemoteLoginSettingsAsync(additionalBehaviors); |
| | 0 | 165 | | RemoteLoginSettings rls = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | | 166 | | |
| | 0 | 167 | | return rls; |
| | | 168 | | } |
| | | 169 | | |
| | | 170 | | /// <summary> |
| | | 171 | | /// Begins an asynchronous call to remove the compute node from the pool. |
| | | 172 | | /// </summary> |
| | | 173 | | /// <param name="deallocationOption"> |
| | | 174 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 175 | | /// </param> |
| | 0 | 176 | | /// <param name="resizeTimeout">The maximum amount of time which the RemoveFromPool operation can take before be |
| | | 177 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 178 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 179 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 180 | | public Task RemoveFromPoolAsync( |
| | | 181 | | Common.ComputeNodeDeallocationOption? deallocationOption = null, |
| | | 182 | | TimeSpan? resizeTimeout = null, |
| | | 183 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 184 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 185 | | { |
| | | 186 | | // create the behavior managaer |
| | 1001 | 187 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 188 | | |
| | 0 | 189 | | List<string> computeNodeIds = new List<string> {this.Id}; |
| | | 190 | | |
| | 0 | 191 | | Task asyncTask = this.parentBatchClient.PoolOperations.RemoveFromPoolAsyncImpl(this.parentPoolId, computeNod |
| | | 192 | | |
| | 0 | 193 | | return asyncTask; |
| | | 194 | | } |
| | 1001 | 195 | | |
| | | 196 | | /// <summary> |
| | | 197 | | /// Blocking call to remove the compute node from the pool. |
| | | 198 | | /// </summary> |
| | | 199 | | /// <param name="deallocationOption"> |
| | | 200 | | /// Specifies how to handle tasks already running, and when the nodes running them may be removed from the pool. |
| | | 201 | | /// </param> |
| | | 202 | | /// <param name="resizeTimeout">The maximum amount of time which the RemoveFromPool operation can take before be |
| | 1002 | 203 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 204 | | public void RemoveFromPool(Common.ComputeNodeDeallocationOption? deallocationOption = null, TimeSpan? resizeTime |
| | | 205 | | { |
| | 0 | 206 | | Task asyncTask = RemoveFromPoolAsync(deallocationOption, resizeTimeout, additionalBehaviors); |
| | 0 | 207 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 208 | | } |
| | | 209 | | |
| | | 210 | | /// <summary> |
| | 1001 | 211 | | /// Begins an asynchronous call to reboot the compute node. |
| | | 212 | | /// </summary> |
| | | 213 | | /// <param name="rebootOption">The reboot option associated with the reboot.</param> |
| | | 214 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 215 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 216 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 217 | | public Task RebootAsync( |
| | | 218 | | Common.ComputeNodeRebootOption? rebootOption = null, |
| | 1001 | 219 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 220 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 221 | | { |
| | | 222 | | // create the behavior manager |
| | 0 | 223 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 224 | | |
| | 0 | 225 | | Task asyncTask = this.parentBatchClient.ProtocolLayer.RebootComputeNode(this.parentPoolId, this.Id, rebootOp |
| | | 226 | | |
| | 1002 | 227 | | return asyncTask; |
| | | 228 | | } |
| | | 229 | | |
| | | 230 | | /// <summary> |
| | | 231 | | /// Blocking call to reboot the compute node. |
| | | 232 | | /// </summary> |
| | | 233 | | /// <param name="rebootOption">The reboot option associated with the reboot.</param> |
| | | 234 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1001 | 235 | | public void Reboot(Common.ComputeNodeRebootOption? rebootOption = null, IEnumerable<BatchClientBehavior> additio |
| | | 236 | | { |
| | 0 | 237 | | Task asyncTask = RebootAsync(rebootOption, additionalBehaviors); |
| | 0 | 238 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 239 | | } |
| | | 240 | | |
| | | 241 | | /// <summary> |
| | | 242 | | /// Begins an asynchronous call to reimage the compute node. |
| | 1001 | 243 | | /// </summary> |
| | | 244 | | /// <param name="reimageOption">The reimage option associated with the reimage.</param> |
| | | 245 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 246 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 247 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 248 | | public Task ReimageAsync( |
| | | 249 | | Common.ComputeNodeReimageOption? reimageOption = null, |
| | | 250 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 1002 | 251 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 252 | | { |
| | | 253 | | // create the behavior manager |
| | 0 | 254 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 255 | | |
| | 0 | 256 | | Task asyncTask = this.parentBatchClient.ProtocolLayer.ReimageComputeNode(this.parentPoolId, this.Id, reimage |
| | | 257 | | |
| | 0 | 258 | | return asyncTask; |
| | 1001 | 259 | | } |
| | | 260 | | |
| | | 261 | | /// <summary> |
| | | 262 | | /// Blocking call to reimage the compute node. |
| | | 263 | | /// </summary> |
| | | 264 | | /// <param name="reimageOption">The reimage option associated with the reimage.</param> |
| | | 265 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 266 | | public void Reimage(Common.ComputeNodeReimageOption? reimageOption = null, IEnumerable<BatchClientBehavior> addi |
| | | 267 | | { |
| | 0 | 268 | | Task asyncTask = ReimageAsync(reimageOption, additionalBehaviors); |
| | 1001 | 269 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 270 | | } |
| | | 271 | | |
| | | 272 | | /// <summary> |
| | | 273 | | /// Begins an asynchronous request to get the specified NodeFile. |
| | | 274 | | /// </summary> |
| | | 275 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | | 276 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 277 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 1001 | 278 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 279 | | public System.Threading.Tasks.Task<NodeFile> GetNodeFileAsync( |
| | | 280 | | string filePath, |
| | | 281 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 282 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 283 | | { |
| | | 284 | | // create the behavior manager |
| | 0 | 285 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 1001 | 286 | | |
| | 0 | 287 | | Task<NodeFile> asyncTask = this.parentBatchClient.PoolOperations.GetNodeFileAsyncImpl(this.parentPoolId, thi |
| | | 288 | | |
| | 0 | 289 | | return asyncTask; |
| | | 290 | | } |
| | | 291 | | |
| | | 292 | | /// <summary> |
| | | 293 | | /// Blocking call to get the specified NodeFile. |
| | 1001 | 294 | | /// </summary> |
| | | 295 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | | 296 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 297 | | /// <returns>A bound <see cref="NodeFile"/> object.</returns> |
| | | 298 | | public NodeFile GetNodeFile(string filePath, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 299 | | { |
| | 0 | 300 | | Task<NodeFile> asyncTask = this.GetNodeFileAsync(filePath, additionalBehaviors); |
| | 0 | 301 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | | 302 | | } |
| | 1001 | 303 | | |
| | | 304 | | /// <summary> |
| | | 305 | | /// Copies the contents of a file from the node to the given <see cref="Stream"/>. |
| | | 306 | | /// </summary> |
| | | 307 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | | 308 | | /// <param name="stream">The stream to copy the file contents to.</param> |
| | | 309 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | | 310 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | 1002 | 311 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 312 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 313 | | public Task CopyNodeFileContentToStreamAsync( |
| | | 314 | | string filePath, |
| | | 315 | | Stream stream, |
| | | 316 | | GetFileRequestByteRange byteRange = null, |
| | | 317 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 318 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 1001 | 319 | | { |
| | | 320 | | // create the behavior manager |
| | 0 | 321 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 322 | | Task asyncTask = this.parentBatchClient.PoolOperations.CopyNodeFileContentToStreamAsyncImpl( |
| | 0 | 323 | | this.parentPoolId, |
| | 0 | 324 | | this.Id, |
| | 0 | 325 | | filePath, |
| | 0 | 326 | | stream, |
| | 0 | 327 | | byteRange, |
| | 1001 | 328 | | bhMgr, |
| | 0 | 329 | | cancellationToken); |
| | | 330 | | |
| | 0 | 331 | | return asyncTask; |
| | | 332 | | } |
| | | 333 | | |
| | | 334 | | /// <summary> |
| | | 335 | | /// Copies the contents of a file from the node to the given <see cref="Stream"/>. |
| | | 336 | | /// </summary> |
| | 1001 | 337 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | | 338 | | /// <param name="stream">The stream to copy the file contents to.</param> |
| | | 339 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | | 340 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 341 | | /// <returns>A bound <see cref="NodeFile"/> object.</returns> |
| | | 342 | | public void CopyNodeFileContentToStream( |
| | | 343 | | string filePath, |
| | | 344 | | Stream stream, |
| | 1001 | 345 | | GetFileRequestByteRange byteRange = null, |
| | | 346 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 347 | | { |
| | 0 | 348 | | Task asyncTask = this.CopyNodeFileContentToStreamAsync(filePath, stream, byteRange, additionalBehaviors); |
| | 0 | 349 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 350 | | } |
| | | 351 | | |
| | | 352 | | /// <summary> |
| | 1001 | 353 | | /// Reads the contents of a file from the specified node into a string. |
| | | 354 | | /// </summary> |
| | | 355 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | | 356 | | /// <param name="encoding">The encoding to use. If no value or null is specified, UTF8 is used.</param> |
| | | 357 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | | 358 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 359 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 360 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret |
| | | 361 | | public Task<string> CopyNodeFileContentToStringAsync( |
| | 0 | 362 | | string filePath, |
| | | 363 | | Encoding encoding = null, |
| | | 364 | | GetFileRequestByteRange byteRange = null, |
| | | 365 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 366 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 0 | 367 | | { |
| | 2 | 368 | | // create the behavior manager |
| | 0 | 369 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 370 | | return this.parentBatchClient.PoolOperations.CopyNodeFileContentToStringAsyncImpl( |
| | 0 | 371 | | this.parentPoolId, |
| | 0 | 372 | | this.Id, |
| | 0 | 373 | | filePath, |
| | 0 | 374 | | encoding, |
| | 0 | 375 | | byteRange, |
| | 0 | 376 | | bhMgr, |
| | 0 | 377 | | cancellationToken); |
| | | 378 | | } |
| | | 379 | | |
| | | 380 | | /// <summary> |
| | | 381 | | /// Reads the contents of a file from the specified node into a string. |
| | | 382 | | /// </summary> |
| | | 383 | | /// <param name="filePath">The path of the file to retrieve.</param> |
| | | 384 | | /// <param name="encoding">The encoding to use. If no value or null is specified, UTF8 is used.</param> |
| | | 385 | | /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file |
| | | 386 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 387 | | /// <returns>A bound <see cref="NodeFile"/> object.</returns> |
| | | 388 | | public string CopyNodeFileContentToString( |
| | | 389 | | string filePath, |
| | | 390 | | Encoding encoding = null, |
| | | 391 | | GetFileRequestByteRange byteRange = null, |
| | | 392 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 393 | | { |
| | 0 | 394 | | Task<string> asyncTask = this.CopyNodeFileContentToStringAsync(filePath, encoding, byteRange, additionalBeha |
| | 0 | 395 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | | 396 | | } |
| | | 397 | | |
| | | 398 | | /// <summary> |
| | | 399 | | /// Exposes synchronous and asynchronous enumeration of the files for the node. |
| | | 400 | | /// </summary> |
| | | 401 | | /// <param name="recursive">If true, performs a recursive list of all files of the node. If false, returns only |
| | | 402 | | /// <param name="detailLevel">Controls the detail level of the data returned by a call to the Azure Batch Servic |
| | | 403 | | /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C |
| | | 404 | | /// <returns>An instance of IPagedEnumerable that can be used to enumerate objects using either synchronous or a |
| | | 405 | | public IPagedEnumerable<NodeFile> ListNodeFiles(bool? recursive = null, DetailLevel detailLevel = null, IEnumera |
| | | 406 | | { |
| | | 407 | | // craft the behavior manager for this call |
| | 0 | 408 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 409 | | |
| | 0 | 410 | | IPagedEnumerable<NodeFile> enumerator = this.parentBatchClient.PoolOperations.ListNodeFilesImpl(this.parentP |
| | | 411 | | |
| | 0 | 412 | | return enumerator; |
| | | 413 | | } |
| | | 414 | | |
| | | 415 | | /// <summary> |
| | | 416 | | /// Enables task scheduling on the compute node. |
| | | 417 | | /// </summary> |
| | | 418 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 419 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 420 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 421 | | /// <remarks>This operation runs asynchronously.</remarks> |
| | | 422 | | public System.Threading.Tasks.Task EnableSchedulingAsync( |
| | | 423 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 424 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 425 | | { |
| | 0 | 426 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.EnableComputeNodeSchedulingAsy |
| | | 427 | | |
| | 0 | 428 | | return asyncTask; |
| | | 429 | | } |
| | | 430 | | |
| | | 431 | | /// <summary> |
| | | 432 | | /// Enables task scheduling on the compute node. |
| | | 433 | | /// </summary> |
| | | 434 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 435 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="EnableScheduling"/>.</r |
| | | 436 | | public void EnableScheduling(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 437 | | { |
| | 0 | 438 | | Task asyncTask = EnableSchedulingAsync(additionalBehaviors, CancellationToken.None); |
| | 0 | 439 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 440 | | } |
| | | 441 | | |
| | | 442 | | /// <summary> |
| | | 443 | | /// Disables task scheduling on the compute node. |
| | | 444 | | /// </summary> |
| | | 445 | | /// <param name="disableComputeNodeSchedulingOption">Specifies what to do with currently running tasks. The defa |
| | | 446 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 447 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 448 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 449 | | /// <remarks>This operation runs asynchronously.</remarks> |
| | | 450 | | public System.Threading.Tasks.Task DisableSchedulingAsync( |
| | | 451 | | Common.DisableComputeNodeSchedulingOption? disableComputeNodeSchedulingOption, |
| | | 452 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 453 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 454 | | { |
| | 0 | 455 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.PoolOperations.DisableComputeNodeSchedulingAs |
| | | 456 | | |
| | 0 | 457 | | return asyncTask; |
| | | 458 | | } |
| | | 459 | | |
| | | 460 | | /// <summary> |
| | | 461 | | /// Disables task scheduling on the compute node. |
| | | 462 | | /// </summary> |
| | | 463 | | /// <param name="disableComputeNodeSchedulingOption">Specifies what to do with currently running tasks. The defa |
| | | 464 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 465 | | /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="DisableSchedulingAsync" |
| | | 466 | | public void DisableScheduling( |
| | | 467 | | Common.DisableComputeNodeSchedulingOption? disableComputeNodeSchedulingOption, |
| | | 468 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 469 | | { |
| | 0 | 470 | | Task asyncTask = DisableSchedulingAsync(disableComputeNodeSchedulingOption, additionalBehaviors, Cancellatio |
| | 0 | 471 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 472 | | } |
| | | 473 | | |
| | | 474 | | /// <summary> |
| | | 475 | | /// Upload Azure Batch service log files from the compute node. |
| | | 476 | | /// </summary> |
| | | 477 | | /// <param name="containerUrl"> |
| | | 478 | | /// The URL of the container within Azure Blob Storage to which to upload the Batch Service log file(s). The URL |
| | | 479 | | /// </param> |
| | | 480 | | /// <param name="startTime"> |
| | | 481 | | /// The start of the time range from which to upload Batch Service log file(s). Any log file containing a log me |
| | | 482 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | | 483 | | /// </param> |
| | | 484 | | /// <param name="endTime"> |
| | | 485 | | /// The end of the time range from which to upload Batch Service log file(s). Any log file containing a log mess |
| | | 486 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | | 487 | | /// </param> |
| | | 488 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 489 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 490 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | | 491 | | /// <remarks> |
| | | 492 | | /// This is for gathering Azure Batch service log files in an automated fashion from nodes if you are experienci |
| | | 493 | | /// The Azure Batch service log files should be shared with Azure support to aid in debugging issues with the Ba |
| | | 494 | | /// </remarks> |
| | | 495 | | public System.Threading.Tasks.Task<UploadBatchServiceLogsResult> UploadComputeNodeBatchServiceLogsAsync( |
| | | 496 | | string containerUrl, |
| | | 497 | | DateTime startTime, |
| | | 498 | | DateTime? endTime = null, |
| | | 499 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | | 500 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 501 | | { |
| | | 502 | | // craft the behavior manager for this call |
| | 0 | 503 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | | 504 | | |
| | 0 | 505 | | return this.parentBatchClient.PoolOperations.UploadComputeNodeBatchServiceLogsAsyncImpl( |
| | 0 | 506 | | this.parentPoolId, |
| | 0 | 507 | | this.Id, |
| | 0 | 508 | | containerUrl, |
| | 0 | 509 | | startTime, |
| | 0 | 510 | | endTime, |
| | 0 | 511 | | bhMgr, |
| | 0 | 512 | | cancellationToken); |
| | | 513 | | } |
| | | 514 | | |
| | | 515 | | /// <summary> |
| | | 516 | | /// Upload Azure Batch service log files from the specified compute node. |
| | | 517 | | /// </summary> |
| | | 518 | | /// <param name="containerUrl"> |
| | | 519 | | /// The URL of the container within Azure Blob Storage to which to upload the Batch Service log file(s). The URL |
| | | 520 | | /// </param> |
| | | 521 | | /// <param name="startTime"> |
| | | 522 | | /// The start of the time range from which to upload Batch Service log file(s). Any log file containing a log me |
| | | 523 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | | 524 | | /// </param> |
| | | 525 | | /// <param name="endTime"> |
| | | 526 | | /// The end of the time range from which to upload Batch Service log file(s). Any log file containing a log mess |
| | | 527 | | /// This means that the operation might retrieve more logs than have been requested since the entire log file is |
| | | 528 | | /// </param> |
| | | 529 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 530 | | /// <remarks> |
| | | 531 | | /// This is for gathering Azure Batch service log files in an automated fashion from nodes if you are experienci |
| | | 532 | | /// The Azure Batch service log files should be shared with Azure support to aid in debugging issues with the Ba |
| | | 533 | | /// </remarks> |
| | | 534 | | /// <returns>The result of uploading the batch service logs.</returns> |
| | | 535 | | public UploadBatchServiceLogsResult UploadComputeNodeBatchServiceLogs( |
| | | 536 | | string containerUrl, |
| | | 537 | | DateTime startTime, |
| | | 538 | | DateTime? endTime = null, |
| | | 539 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 540 | | { |
| | 0 | 541 | | var asyncTask = this.UploadComputeNodeBatchServiceLogsAsync( |
| | 0 | 542 | | containerUrl, |
| | 0 | 543 | | startTime, |
| | 0 | 544 | | endTime, |
| | 0 | 545 | | additionalBehaviors); |
| | 0 | 546 | | return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | | 547 | | } |
| | | 548 | | |
| | | 549 | | #endregion ComputeNode |
| | | 550 | | |
| | | 551 | | #region IRefreshable |
| | | 552 | | |
| | | 553 | | /// <summary> |
| | | 554 | | /// Refreshes the current <see cref="ComputeNode"/>. |
| | | 555 | | /// </summary> |
| | | 556 | | /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Id" |
| | | 557 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 558 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | | 559 | | /// <returns>A <see cref="Task"/> representing the asynchronous refresh operation.</returns> |
| | | 560 | | public async Task RefreshAsync(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> additionalBehavi |
| | | 561 | | { |
| | | 562 | | // create the behavior managaer |
| | 0 | 563 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); |
| | | 564 | | |
| | 0 | 565 | | System.Threading.Tasks.Task<AzureOperationResponse<Models.ComputeNode, Models.ComputeNodeGetHeaders>> asyncT |
| | 0 | 566 | | this.parentBatchClient.ProtocolLayer.GetComputeNode(this.parentPoolId, this.Id, bhMgr, cancellationToken |
| | | 567 | | |
| | 0 | 568 | | AzureOperationResponse<Models.ComputeNode, Models.ComputeNodeGetHeaders> response = await asyncTask.Configur |
| | | 569 | | |
| | | 570 | | // get pool from response |
| | 0 | 571 | | Models.ComputeNode newProtocolComputeNode = response.Body; |
| | | 572 | | |
| | 0 | 573 | | this.propertyContainer = new PropertyContainer(newProtocolComputeNode); |
| | 0 | 574 | | } |
| | | 575 | | |
| | | 576 | | /// <summary> |
| | | 577 | | /// Refreshes the <see cref="ComputeNode"/>. |
| | | 578 | | /// </summary> |
| | | 579 | | /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Id" |
| | | 580 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | | 581 | | public void Refresh(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | | 582 | | { |
| | 0 | 583 | | Task asyncTask = RefreshAsync(detailLevel, additionalBehaviors); |
| | 0 | 584 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 0 | 585 | | } |
| | | 586 | | |
| | | 587 | | #endregion |
| | | 588 | | } |
| | | 589 | | |
| | | 590 | | } |