Skip to content

Commit 353b009

Browse files
mgtm, compute, support disk IOPS and throughput (#45339)
1 parent 60a9a2e commit 353b009

File tree

6 files changed

+354
-4
lines changed

6 files changed

+354
-4
lines changed

sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
### Features Added
66

7+
- Supported setting disk IOPS and throughput for `Disk`.
8+
- Supported setting maximum shares for `Disk`.
9+
710
### Breaking Changes
811

912
### Bugs Fixed

sdk/resourcemanager/azure-resourcemanager-compute/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/resourcemanager/azure-resourcemanager-compute",
5-
"Tag": "java/resourcemanager/azure-resourcemanager-compute_78176bbe81"
5+
"Tag": "java/resourcemanager/azure-resourcemanager-compute_db05ab8f85"
66
}

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/DiskImpl.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.ArrayList;
3636
import java.util.Collections;
3737
import java.util.HashSet;
38+
import java.util.List;
3839
import java.util.Set;
3940

4041
import reactor.core.publisher.Flux;
@@ -70,6 +71,17 @@ public String virtualMachineId() {
7071
return this.innerModel().managedBy();
7172
}
7273

74+
@Override
75+
public List<String> virtualMachineIds() {
76+
if (innerModel().managedByExtended() != null) {
77+
return Collections.unmodifiableList(innerModel().managedByExtended());
78+
} else if (this.virtualMachineId() != null) {
79+
return Collections.singletonList(this.virtualMachineId());
80+
} else {
81+
return Collections.emptyList();
82+
}
83+
}
84+
7385
@Override
7486
public int sizeInGB() {
7587
return ResourceManagerUtils.toPrimitiveInt(this.innerModel().diskSizeGB());
@@ -158,6 +170,31 @@ public PublicNetworkAccess publicNetworkAccess() {
158170
return this.innerModel().publicNetworkAccess();
159171
}
160172

173+
@Override
174+
public Long diskIopsReadWrite() {
175+
return innerModel().diskIopsReadWrite();
176+
}
177+
178+
@Override
179+
public Long diskMBpsReadWrite() {
180+
return innerModel().diskMBpsReadWrite();
181+
}
182+
183+
@Override
184+
public Long diskIopsReadOnly() {
185+
return innerModel().diskIopsReadOnly();
186+
}
187+
188+
@Override
189+
public Long diskMBpsReadOnly() {
190+
return innerModel().diskMBpsReadOnly();
191+
}
192+
193+
@Override
194+
public int maximumShares() {
195+
return innerModel().maxShares() == null ? 1 : innerModel().maxShares();
196+
}
197+
161198
@Override
162199
public DiskImpl withLinuxFromVhd(String vhdUrl) {
163200
this.innerModel()
@@ -464,4 +501,34 @@ public DiskImpl disablePublicNetworkAccess() {
464501
this.innerModel().withPublicNetworkAccess(PublicNetworkAccess.DISABLED);
465502
return this;
466503
}
504+
505+
@Override
506+
public DiskImpl withIopsReadWrite(long diskIopsReadWrite) {
507+
this.innerModel().withDiskIopsReadWrite(diskIopsReadWrite);
508+
return this;
509+
}
510+
511+
@Override
512+
public DiskImpl withMBpsReadWrite(long diskMBpsReadWrite) {
513+
this.innerModel().withDiskMBpsReadWrite(diskMBpsReadWrite);
514+
return this;
515+
}
516+
517+
@Override
518+
public DiskImpl withIopsReadOnly(long diskIopsReadOnly) {
519+
this.innerModel().withDiskIopsReadOnly(diskIopsReadOnly);
520+
return this;
521+
}
522+
523+
@Override
524+
public DiskImpl withMBpsReadOnly(long diskMBpsReadOnly) {
525+
this.innerModel().withDiskMBpsReadOnly(diskMBpsReadOnly);
526+
return this;
527+
}
528+
529+
@Override
530+
public DiskImpl withMaximumShares(int maximumShares) {
531+
this.innerModel().withMaxShares(maximumShares);
532+
return this;
533+
}
467534
}

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/Disk.java

Lines changed: 151 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.azure.resourcemanager.resources.fluentcore.model.Refreshable;
1616
import com.azure.resourcemanager.resources.fluentcore.model.Updatable;
1717
import com.azure.resourcemanager.storage.models.StorageAccount;
18+
19+
import java.util.List;
1820
import java.util.Set;
1921
import reactor.core.publisher.Mono;
2022

@@ -44,12 +46,23 @@ public interface Disk extends GroupableResource<ComputeManager, DiskInner>, Refr
4446

4547
/**
4648
* Gets the resource ID of the virtual machine this disk is attached to.
49+
* <p>
50+
* If the disk can be shared, use {@link #virtualMachineIds()} to get the list of all virtual machines.
4751
*
4852
* @return the resource ID of the virtual machine this disk is attached to, or null if the disk is in a detached
4953
* state
5054
*/
5155
String virtualMachineId();
5256

57+
/**
58+
* Gets the list of the virtual machines that this disk is attached to.
59+
* <p>
60+
* A disk could be attached to multiple virtual machines.
61+
*
62+
* @return the resource ID of the virtual machines this disk is attached to
63+
*/
64+
List<String> virtualMachineIds();
65+
5366
/**
5467
* Gets disk size in GB.
5568
*
@@ -153,6 +166,41 @@ public interface Disk extends GroupableResource<ComputeManager, DiskInner>, Refr
153166
*/
154167
PublicNetworkAccess publicNetworkAccess();
155168

169+
/**
170+
* Gets the number of IOPS allowed for this disk.
171+
*
172+
* @return the number of IOPS allowed for this disk.
173+
*/
174+
Long diskIopsReadWrite();
175+
176+
/**
177+
* Gets the throughput (MBps) allowed for this disk.
178+
*
179+
* @return the throughput (MBps) allowed for this disk.
180+
*/
181+
Long diskMBpsReadWrite();
182+
183+
/**
184+
* Gets the total number of IOPS allowed across all VMs mounting this shared disk as read-only.
185+
*
186+
* @return the total number of IOPS allowed for this shared read-only disk.
187+
*/
188+
Long diskIopsReadOnly();
189+
190+
/**
191+
* Gets the total throughput (MBps) allowed across all VMs mounting this shared disk as read-only.
192+
*
193+
* @return the total throughput (MBps) allowed for this shared read-only disk.
194+
*/
195+
Long diskMBpsReadOnly();
196+
197+
/**
198+
* Gets the maximum number of VMs that can attach to the disk at the same time.
199+
*
200+
* @return the maximum number of VMs that can attach to the disk at the same time.
201+
*/
202+
int maximumShares();
203+
156204
/** The entirety of the managed disk definition. */
157205
interface Definition extends DefinitionStages.Blank, DefinitionStages.WithGroup, DefinitionStages.WithDiskSource,
158206
DefinitionStages.WithWindowsDiskSource, DefinitionStages.WithLinuxDiskSource, DefinitionStages.WithData,
@@ -521,13 +569,63 @@ interface WithPublicNetworkAccess {
521569
WithCreate disablePublicNetworkAccess();
522570
}
523571

572+
/** The stage of disk definition allowing to configure IOPS and throughput settings. */
573+
interface WithIopsThroughput {
574+
/**
575+
* Sets the number of IOPS allowed for this disk.
576+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
577+
*
578+
* @param diskIopsReadWrite The number of IOPS allowed for this disk. One operation can transfer between 4k and 256k bytes.
579+
* @return the next stage of the definition
580+
*/
581+
WithCreate withIopsReadWrite(long diskIopsReadWrite);
582+
583+
/**
584+
* Sets the throughput (MBps) allowed for this disk.
585+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
586+
*
587+
* @param diskMBpsReadWrite The bandwidth allowed for this disk.
588+
* @return the next stage of the definition
589+
*/
590+
WithCreate withMBpsReadWrite(long diskMBpsReadWrite);
591+
592+
/**
593+
* Sets the total number of IOPS allowed across all VMs mounting this shared disk as read-only.
594+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
595+
*
596+
* @param diskIopsReadOnly The total number of IOPS allowed across all VMs mounting this shared disk as read-only. One operation can transfer between 4k and 256k bytes.
597+
* @return the next stage of the definition
598+
*/
599+
WithCreate withIopsReadOnly(long diskIopsReadOnly);
600+
601+
/**
602+
* Sets the total throughput (MBps) allowed across all VMs mounting this shared disk as read-only.
603+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
604+
*
605+
* @param diskMBpsReadOnly The total throughput (MBps) allowed across all VMs mounting this shared disk as read-only.
606+
* @return the next stage of the definition
607+
*/
608+
WithCreate withMBpsReadOnly(long diskMBpsReadOnly);
609+
}
610+
611+
/** The stage of disk definition allowing to configure managed disk sharing settings. */
612+
interface WithDiskSharing {
613+
/**
614+
* Sets the maximum number of VMs that can attach to the disk at the same time.
615+
*
616+
* @param maximumShares the maximum number of VMs that can attach to the disk at the same time
617+
* @return the next stage of the definition
618+
*/
619+
WithCreate withMaximumShares(int maximumShares);
620+
}
621+
524622
/**
525623
* The stage of the definition which contains all the minimum required inputs for the resource to be created,
526624
* but also allows for any other optional settings to be specified.
527625
*/
528626
interface WithCreate extends Creatable<Disk>, Resource.DefinitionWithTags<Disk.DefinitionStages.WithCreate>,
529627
WithSku, WithAvailabilityZone, WithDiskEncryption, WithHibernationSupport, WithLogicalSectorSize,
530-
WithHyperVGeneration, WithPublicNetworkAccess {
628+
WithHyperVGeneration, WithPublicNetworkAccess, WithIopsThroughput, WithDiskSharing {
531629

532630
/**
533631
* Begins creating the disk resource.
@@ -628,11 +726,62 @@ interface WithPublicNetworkAccess {
628726
*/
629727
Update disablePublicNetworkAccess();
630728
}
729+
730+
/** The stage of disk update allowing to configure IOPS and throughput settings. */
731+
interface WithIopsThroughput {
732+
/**
733+
* Sets the number of IOPS allowed for this disk.
734+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
735+
*
736+
* @param diskIopsReadWrite The number of IOPS allowed for this disk. One operation can transfer between 4k and 256k bytes.
737+
* @return the next stage of the definition
738+
*/
739+
Update withIopsReadWrite(long diskIopsReadWrite);
740+
741+
/**
742+
* Sets the throughput (MBps) allowed for this disk.
743+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
744+
*
745+
* @param diskMBpsReadWrite The bandwidth allowed for this disk.
746+
* @return the next stage of the definition
747+
*/
748+
Update withMBpsReadWrite(long diskMBpsReadWrite);
749+
750+
/**
751+
* Sets the total number of IOPS allowed across all VMs mounting this shared disk as read-only.
752+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
753+
*
754+
* @param diskIopsReadOnly The total number of IOPS allowed across all VMs mounting this shared disk as read-only. One operation can transfer between 4k and 256k bytes.
755+
* @return the next stage of the definition
756+
*/
757+
Update withIopsReadOnly(long diskIopsReadOnly);
758+
759+
/**
760+
* Sets the total throughput (MBps) allowed across all VMs mounting this shared disk as read-only.
761+
* It is only settable for UltraSSD disks or Premium SSD v2 disks.
762+
*
763+
* @param diskMBpsReadOnly The total throughput (MBps) allowed across all VMs mounting this shared disk as read-only.
764+
* @return the next stage of the definition
765+
*/
766+
Update withMBpsReadOnly(long diskMBpsReadOnly);
767+
}
768+
769+
/** The stage of disk update allowing to configure managed disk sharing settings. */
770+
interface WithDiskSharing {
771+
/**
772+
* Sets the maximum number of VMs that can attach to the disk at the same time.
773+
*
774+
* @param maximumShares the maximum number of VMs that can attach to the disk at the same time
775+
* @return the next stage of the update
776+
*/
777+
Update withMaximumShares(int maximumShares);
778+
}
631779
}
632780

633781
/** The template for an update operation, containing all the settings that can be modified. */
634782
interface Update extends Appliable<Disk>, Resource.UpdateWithTags<Disk.Update>, UpdateStages.WithSku,
635783
UpdateStages.WithSize, UpdateStages.WithOSSettings, UpdateStages.WithDiskEncryption,
636-
UpdateStages.WithHibernationSupport, UpdateStages.WithHyperVGeneration, UpdateStages.WithPublicNetworkAccess {
784+
UpdateStages.WithHibernationSupport, UpdateStages.WithHyperVGeneration, UpdateStages.WithPublicNetworkAccess,
785+
UpdateStages.WithIopsThroughput, UpdateStages.WithDiskSharing {
637786
}
638787
}

0 commit comments

Comments
 (0)