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