|
7 | 7 | import com.microsoft.azure.batch.protocol.models.BatchErrorException;
|
8 | 8 | import com.microsoft.azure.batch.protocol.models.ComputeNode;
|
9 | 9 | import com.microsoft.azure.batch.protocol.models.ComputeNodeAddUserOptions;
|
| 10 | +import com.microsoft.azure.batch.protocol.models.ComputeNodeDeallocateOption; |
| 11 | +import com.microsoft.azure.batch.protocol.models.ComputeNodeDeallocateOptions; |
10 | 12 | import com.microsoft.azure.batch.protocol.models.ComputeNodeDeleteUserOptions;
|
11 | 13 | import com.microsoft.azure.batch.protocol.models.ComputeNodeDisableSchedulingOptions;
|
12 | 14 | import com.microsoft.azure.batch.protocol.models.ComputeNodeEnableSchedulingOptions;
|
13 | 15 | import com.microsoft.azure.batch.protocol.models.ComputeNodeGetOptions;
|
14 |
| -import com.microsoft.azure.batch.protocol.models.ComputeNodeGetRemoteDesktopOptions; |
15 | 16 | import com.microsoft.azure.batch.protocol.models.ComputeNodeGetRemoteLoginSettingsOptions;
|
16 | 17 | import com.microsoft.azure.batch.protocol.models.ComputeNodeGetRemoteLoginSettingsResult;
|
17 | 18 | import com.microsoft.azure.batch.protocol.models.ComputeNodeListOptions;
|
18 | 19 | import com.microsoft.azure.batch.protocol.models.ComputeNodeRebootOption;
|
19 | 20 | import com.microsoft.azure.batch.protocol.models.ComputeNodeRebootOptions;
|
20 | 21 | import com.microsoft.azure.batch.protocol.models.ComputeNodeReimageOption;
|
21 | 22 | import com.microsoft.azure.batch.protocol.models.ComputeNodeReimageOptions;
|
| 23 | +import com.microsoft.azure.batch.protocol.models.ComputeNodeStartOptions; |
22 | 24 | import com.microsoft.azure.batch.protocol.models.ComputeNodeUpdateUserOptions;
|
23 | 25 | import com.microsoft.azure.batch.protocol.models.ComputeNodeUploadBatchServiceLogsOptions;
|
24 | 26 | import com.microsoft.azure.batch.protocol.models.ComputeNodeUser;
|
|
28 | 30 | import com.microsoft.azure.batch.protocol.models.UploadBatchServiceLogsResult;
|
29 | 31 | import org.joda.time.DateTime;
|
30 | 32 |
|
31 |
| -import java.io.ByteArrayOutputStream; |
32 | 33 | import java.io.IOException;
|
33 | 34 | import java.util.Collection;
|
34 | 35 |
|
@@ -429,41 +430,6 @@ public void enableComputeNodeScheduling(String poolId, String nodeId, Iterable<B
|
429 | 430 | this.parentBatchClient.protocolLayer().computeNodes().enableScheduling(poolId, nodeId, options);
|
430 | 431 | }
|
431 | 432 |
|
432 |
| - /** |
433 |
| - * Gets a Remote Desktop Protocol (RDP) file for the specified node. |
434 |
| - * |
435 |
| - * @param poolId The ID of the pool that contains the compute node. |
436 |
| - * @param nodeId The ID of the compute node for which to get a Remote Desktop file. |
437 |
| - * @return The RDP file contents. |
438 |
| - * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
439 |
| - * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
440 |
| - */ |
441 |
| - public String getComputeNodeRemoteDesktop(String poolId, String nodeId) throws BatchErrorException, IOException { |
442 |
| - return getComputeNodeRemoteDesktop(poolId, nodeId, null); |
443 |
| - } |
444 |
| - |
445 |
| - /** |
446 |
| - * Gets a Remote Desktop Protocol (RDP) file for the specified node. |
447 |
| - * |
448 |
| - * @param poolId The ID of the pool that contains the compute node. |
449 |
| - * @param nodeId The ID of the compute node for which to get a Remote Desktop file. |
450 |
| - * @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request. |
451 |
| - * @return The RDP file contents. |
452 |
| - * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
453 |
| - * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
454 |
| - */ |
455 |
| - public String getComputeNodeRemoteDesktop(String poolId, String nodeId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException { |
456 |
| - ComputeNodeGetRemoteDesktopOptions options = new ComputeNodeGetRemoteDesktopOptions(); |
457 |
| - BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors); |
458 |
| - bhMgr.applyRequestBehaviors(options); |
459 |
| - |
460 |
| - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
461 |
| - this.parentBatchClient.protocolLayer().computeNodes().getRemoteDesktop(poolId, nodeId, options, outputStream); |
462 |
| - String rdpContent = outputStream.toString("UTF-8"); |
463 |
| - outputStream.close(); |
464 |
| - return rdpContent; |
465 |
| - } |
466 |
| - |
467 | 433 | /**
|
468 | 434 | * Gets the settings required for remote login to a compute node.
|
469 | 435 | *
|
@@ -582,4 +548,83 @@ public UploadBatchServiceLogsResult uploadBatchServiceLogs(String poolId, String
|
582 | 548 |
|
583 | 549 | return this.parentBatchClient.protocolLayer().computeNodes().uploadBatchServiceLogs(poolId, nodeId, configuration, options);
|
584 | 550 | }
|
| 551 | + |
| 552 | + /** |
| 553 | + * Deallocates the specified compute node. |
| 554 | + * <p>You can deallocate a compute node only when it is in the {@link com.microsoft.azure.batch.protocol.models.ComputeNodeState#IDLE Idle} or {@link com.microsoft.azure.batch.protocol.models.ComputeNodeState#RUNNING Running} state.</p> |
| 555 | + * |
| 556 | + * @param poolId The ID of the pool that contains the compute node. |
| 557 | + * @param nodeId The ID of the compute node to deallocate. |
| 558 | + * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
| 559 | + * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
| 560 | + */ |
| 561 | + public void deallocateComputeNode(String poolId, String nodeId) throws BatchErrorException, IOException { |
| 562 | + deallocateComputeNode(poolId, nodeId, null, null); |
| 563 | + } |
| 564 | + |
| 565 | + /** |
| 566 | + * Deallocates the specified compute node. |
| 567 | + * <p>You can deallocate a compute node only when it is in the {@link com.microsoft.azure.batch.protocol.models.ComputeNodeState#IDLE Idle} or {@link com.microsoft.azure.batch.protocol.models.ComputeNodeState#RUNNING Running} state.</p> |
| 568 | + * |
| 569 | + * @param poolId The ID of the pool that contains the compute node. |
| 570 | + * @param nodeId The ID of the compute node to deallocate. |
| 571 | + * @param nodeDeallocateOption Specifies when to deallocate the node and what to do with currently running tasks. |
| 572 | + * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
| 573 | + * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
| 574 | + */ |
| 575 | + public void deallocateComputeNode(String poolId, String nodeId, ComputeNodeDeallocateOption nodeDeallocateOption) throws BatchErrorException, IOException { |
| 576 | + deallocateComputeNode(poolId, nodeId, nodeDeallocateOption, null); |
| 577 | + } |
| 578 | + |
| 579 | + /** |
| 580 | + * Deallocates the specified compute node. |
| 581 | + * <p>You can deallocate a compute node only when it is in the {@link com.microsoft.azure.batch.protocol.models.ComputeNodeState#IDLE Idle} or {@link com.microsoft.azure.batch.protocol.models.ComputeNodeState#RUNNING Running} state.</p> |
| 582 | + * |
| 583 | + * @param poolId The ID of the pool that contains the compute node. |
| 584 | + * @param nodeId The ID of the compute node to deallocate. |
| 585 | + * @param nodeDeallocateOption Specifies when to deallocate the node and what to do with currently running tasks. |
| 586 | + * @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request. |
| 587 | + * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
| 588 | + * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
| 589 | + */ |
| 590 | + public void deallocateComputeNode(String poolId, String nodeId, ComputeNodeDeallocateOption nodeDeallocateOption, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException { |
| 591 | + ComputeNodeDeallocateOptions options = new ComputeNodeDeallocateOptions(); |
| 592 | + BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors); |
| 593 | + bhMgr.applyRequestBehaviors(options); |
| 594 | + |
| 595 | + this.parentBatchClient.protocolLayer().computeNodes().deallocate(poolId, nodeId, nodeDeallocateOption, options); |
| 596 | + } |
| 597 | + |
| 598 | + /** |
| 599 | + * Starts the specified compute node. |
| 600 | + * <p>You can start a compute node only if it has been deallocated.</p> |
| 601 | + * |
| 602 | + * @param poolId The ID of the pool that contains the compute node. |
| 603 | + * @param nodeId The ID of the compute node to start. |
| 604 | + * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
| 605 | + * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
| 606 | + */ |
| 607 | + public void startComputeNode(String poolId, String nodeId) throws BatchErrorException, IOException { |
| 608 | + startComputeNode(poolId, nodeId, null); |
| 609 | + } |
| 610 | + |
| 611 | + /** |
| 612 | + * Starts the specified compute node. |
| 613 | + * <p>You can start a compute node only if it has been deallocated.</p> |
| 614 | + * |
| 615 | + * @param poolId The ID of the pool that contains the compute node. |
| 616 | + * @param nodeId The ID of the compute node to start. |
| 617 | + * @param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request. |
| 618 | + * @throws BatchErrorException Exception thrown when an error response is received from the Batch service. |
| 619 | + * @throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. |
| 620 | + */ |
| 621 | + public void startComputeNode(String poolId, String nodeId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException { |
| 622 | + ComputeNodeStartOptions options = new ComputeNodeStartOptions(); |
| 623 | + BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors); |
| 624 | + bhMgr.applyRequestBehaviors(options); |
| 625 | + |
| 626 | + this.parentBatchClient.protocolLayer().computeNodes().start(poolId, nodeId, options); |
| 627 | + } |
| 628 | + |
| 629 | + |
585 | 630 | }
|
0 commit comments