diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-11-18 10:29:22 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-11-18 11:01:17 +0100 |
commit | de69ac37b4df3f1dfce7f442ca9510e778fa1f05 (patch) | |
tree | dd7b949b5d1512de20bce9e2a9285a820e55752b /config-provisioning | |
parent | 2872e68c64605c04147fbf930d76f09078ce5550 (diff) |
Put GPU details in sub-object
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java index f539bc19c49..3973b042bde 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java @@ -49,6 +49,7 @@ public class AllocatedHostsSerializer { private static final String diskSpeedKey = "diskSpeed"; private static final String storageTypeKey = "storageType"; private static final String architectureKey = "architecture"; + private static final String gpuKey = "gpu"; private static final String gpuCountKey = "gpuCount"; private static final String gpuMemoryKey = "gpuMemory"; @@ -98,8 +99,9 @@ public class AllocatedHostsSerializer { resourcesObject.setString(storageTypeKey, storageTypeToString(resources.storageType())); resourcesObject.setString(architectureKey, architectureToString(resources.architecture())); if (!resources.gpuResources().isDefault()) { - resourcesObject.setLong(gpuCountKey, resources.gpuResources().count()); - resourcesObject.setDouble(gpuMemoryKey, resources.gpuResources().memoryGb()); + Cursor gpuObject = resourcesObject.setObject(gpuKey); + gpuObject.setLong(gpuCountKey, resources.gpuResources().count()); + gpuObject.setDouble(gpuMemoryKey, resources.gpuResources().memoryGb()); } } @@ -141,14 +143,13 @@ public class AllocatedHostsSerializer { diskSpeedFromSlime(resources.field(diskSpeedKey)), storageTypeFromSlime(resources.field(storageTypeKey)), architectureFromSlime(resources.field(architectureKey)), - gpuResourcesFromSlime(resources)); + gpuResourcesFromSlime(resources.field(gpuKey))); } - private static NodeResources.GpuResources gpuResourcesFromSlime(Inspector resources) { - Inspector gpuCountField = resources.field(gpuCountKey); - Inspector gpuMemoryField = resources.field(gpuMemoryKey); - if (!gpuCountField.valid() || !gpuMemoryField.valid()) return NodeResources.GpuResources.getDefault(); - return new NodeResources.GpuResources((int) gpuCountField.asLong(), gpuMemoryField.asDouble()); + private static NodeResources.GpuResources gpuResourcesFromSlime(Inspector gpu) { + if (!gpu.valid()) return NodeResources.GpuResources.getDefault(); + return new NodeResources.GpuResources((int) gpu.field(gpuCountKey).asLong(), + gpu.field(gpuMemoryKey).asDouble()); } private static NodeResources optionalNodeResourcesFromSlime(Inspector resources) { |