collection has multiple disk types

This commit is contained in:
chrislu
2025-07-01 20:27:42 -07:00
parent b2849ec435
commit 757c436a82
5 changed files with 196 additions and 66 deletions

View File

@@ -141,15 +141,15 @@ type ClusterVolumesData struct {
}
type CollectionInfo struct {
Name string `json:"name"`
DataCenter string `json:"datacenter"`
Replication string `json:"replication"`
VolumeCount int `json:"volume_count"`
FileCount int64 `json:"file_count"`
TotalSize int64 `json:"total_size"`
TTL string `json:"ttl"`
DiskType string `json:"disk_type"`
Status string `json:"status"`
Name string `json:"name"`
DataCenter string `json:"datacenter"`
Replication string `json:"replication"`
VolumeCount int `json:"volume_count"`
FileCount int64 `json:"file_count"`
TotalSize int64 `json:"total_size"`
TTL string `json:"ttl"`
DiskTypes []string `json:"disk_types"`
Status string `json:"status"`
}
type ClusterCollectionsData struct {
@@ -879,6 +879,12 @@ func (s *AdminServer) GetClusterCollections() (*ClusterCollectionsData, error) {
collectionName = "default" // Default collection for volumes without explicit collection
}
// Get disk type from volume info, default to hdd if empty
diskType := volInfo.DiskType
if diskType == "" {
diskType = "hdd"
}
// Get or create collection info
if collection, exists := collectionMap[collectionName]; exists {
collection.VolumeCount++
@@ -890,6 +896,18 @@ func (s *AdminServer) GetClusterCollections() (*ClusterCollectionsData, error) {
collection.DataCenter = "multi"
}
// Add disk type if not already present
diskTypeExists := false
for _, existingDiskType := range collection.DiskTypes {
if existingDiskType == diskType {
diskTypeExists = true
break
}
}
if !diskTypeExists {
collection.DiskTypes = append(collection.DiskTypes, diskType)
}
totalVolumes++
totalFiles += int64(volInfo.FileCount)
totalSize += int64(volInfo.Size)
@@ -910,7 +928,7 @@ func (s *AdminServer) GetClusterCollections() (*ClusterCollectionsData, error) {
FileCount: int64(volInfo.FileCount),
TotalSize: int64(volInfo.Size),
TTL: ttlStr,
DiskType: "hdd", // Default disk type
DiskTypes: []string{diskType},
Status: "active",
}
collectionMap[collectionName] = &newCollection