|
| 1 | +package models |
| 2 | + |
| 3 | +import ( |
| 4 | + "encoding/json" |
| 5 | +) |
| 6 | + |
| 7 | +// ComponentInfos defines the interface of all component infos |
| 8 | +type ComponentInfos interface{} |
| 9 | + |
| 10 | +// MarshalComponentInfos returns the json string of ComponentInfos |
| 11 | +func MarshalComponentInfos(infos ComponentInfos) (string, error) { |
| 12 | + binary, err := json.Marshal(infos) |
| 13 | + return string(binary), err |
| 14 | +} |
| 15 | + |
| 16 | +// UnmarshalComponentInfos constructs a ComponentInfos object using a json string |
| 17 | +func UnmarshalComponentInfos(s string, infos ComponentInfos) error { |
| 18 | + return json.Unmarshal([]byte(s), infos) |
| 19 | +} |
| 20 | + |
| 21 | +// HardwareMetrics records the hardware information of nodes. |
| 22 | +type HardwareMetrics struct { |
| 23 | + IP string `json:"ip"` |
| 24 | + CPUCoreCount int `json:"cpu_core_count"` |
| 25 | + CPUCoreUsage float64 `json:"cpu_core_usage"` |
| 26 | + Memory uint64 `json:"memory"` |
| 27 | + MemoryUsage uint64 `json:"memory_usage"` |
| 28 | + |
| 29 | + // how to metric disk & disk usage in distributed storage |
| 30 | + Disk uint64 `json:"disk"` |
| 31 | + DiskUsage uint64 `json:"disk_usage"` |
| 32 | +} |
| 33 | + |
| 34 | +const ( |
| 35 | + // GitCommitEnvKey defines the key to retrieve the commit corresponding to the current milvus version |
| 36 | + // from the metrics information |
| 37 | + GitCommitEnvKey = "MILVUS_GIT_COMMIT" |
| 38 | + |
| 39 | + // DeployModeEnvKey defines the key to retrieve the current milvus deployment mode |
| 40 | + // from the metrics information |
| 41 | + DeployModeEnvKey = "DEPLOY_MODE" |
| 42 | + |
| 43 | + // ClusterDeployMode represents distributed deployment mode |
| 44 | + ClusterDeployMode = "DISTRIBUTED" |
| 45 | + |
| 46 | + // StandaloneDeployMode represents the stand-alone deployment mode |
| 47 | + StandaloneDeployMode = "STANDALONE" |
| 48 | + |
| 49 | + // GitBuildTagsEnvKey build tag |
| 50 | + GitBuildTagsEnvKey = "MILVUS_GIT_BUILD_TAGS" |
| 51 | + |
| 52 | + // MilvusBuildTimeEnvKey build time |
| 53 | + MilvusBuildTimeEnvKey = "MILVUS_BUILD_TIME" |
| 54 | + |
| 55 | + // MilvusUsedGoVersion used go version |
| 56 | + MilvusUsedGoVersion = "MILVUS_USED_GO_VERSION" |
| 57 | +) |
| 58 | + |
| 59 | +// DeployMetrics records the deploy information of nodes. |
| 60 | +type DeployMetrics struct { |
| 61 | + SystemVersion string `json:"system_version"` |
| 62 | + DeployMode string `json:"deploy_mode"` |
| 63 | + BuildVersion string `json:"build_version"` |
| 64 | + BuildTime string `json:"build_time"` |
| 65 | + UsedGoVersion string `json:"used_go_version"` |
| 66 | +} |
| 67 | + |
| 68 | +// BaseComponentInfos contains basic information that all components should have. |
| 69 | +type BaseComponentInfos struct { |
| 70 | + HasError bool `json:"has_error"` |
| 71 | + ErrorReason string `json:"error_reason"` |
| 72 | + Name string `json:"name"` |
| 73 | + HardwareInfos HardwareMetrics `json:"hardware_infos"` |
| 74 | + SystemInfo DeployMetrics `json:"system_info"` |
| 75 | + CreatedTime string `json:"created_time"` |
| 76 | + UpdatedTime string `json:"updated_time"` |
| 77 | + Type string `json:"type"` |
| 78 | + ID int64 `json:"id"` |
| 79 | +} |
| 80 | + |
| 81 | +// QueryNodeConfiguration records the configuration of QueryNode. |
| 82 | +type QueryNodeConfiguration struct { |
| 83 | + SimdType string `json:"simd_type"` |
| 84 | +} |
| 85 | + |
| 86 | +type QueryNodeCollectionMetrics struct { |
| 87 | + CollectionRows map[int64]int64 |
| 88 | +} |
| 89 | + |
| 90 | +// QueryNodeInfos implements ComponentInfos |
| 91 | +type QueryNodeInfos struct { |
| 92 | + BaseComponentInfos |
| 93 | + SystemConfigurations QueryNodeConfiguration `json:"system_configurations"` |
| 94 | + QuotaMetrics *QueryNodeQuotaMetrics `json:"quota_metrics"` |
| 95 | + CollectionMetrics *QueryNodeCollectionMetrics `json:"collection_metrics"` |
| 96 | +} |
| 97 | + |
| 98 | +// QueryCoordConfiguration records the configuration of QueryCoord. |
| 99 | +type QueryCoordConfiguration struct { |
| 100 | + SearchChannelPrefix string `json:"search_channel_prefix"` |
| 101 | + SearchResultChannelPrefix string `json:"search_result_channel_prefix"` |
| 102 | +} |
| 103 | + |
| 104 | +// QueryCoordInfos implements ComponentInfos |
| 105 | +type QueryCoordInfos struct { |
| 106 | + BaseComponentInfos |
| 107 | + SystemConfigurations QueryCoordConfiguration `json:"system_configurations"` |
| 108 | +} |
| 109 | + |
| 110 | +// ProxyConfiguration records the configuration of Proxy. |
| 111 | +type ProxyConfiguration struct { |
| 112 | + DefaultPartitionName string `json:"default_partition_name"` |
| 113 | + DefaultIndexName string `json:"default_index_name"` |
| 114 | +} |
| 115 | + |
| 116 | +// ProxyInfos implements ComponentInfos |
| 117 | +type ProxyInfos struct { |
| 118 | + BaseComponentInfos |
| 119 | + SystemConfigurations ProxyConfiguration `json:"system_configurations"` |
| 120 | + QuotaMetrics *ProxyQuotaMetrics `json:"quota_metrics"` |
| 121 | +} |
| 122 | + |
| 123 | +// IndexNodeConfiguration records the configuration of IndexNode. |
| 124 | +type IndexNodeConfiguration struct { |
| 125 | + MinioBucketName string `json:"minio_bucket_name"` |
| 126 | + |
| 127 | + SimdType string `json:"simd_type"` |
| 128 | +} |
| 129 | + |
| 130 | +// IndexNodeInfos implements ComponentInfos |
| 131 | +type IndexNodeInfos struct { |
| 132 | + BaseComponentInfos |
| 133 | + SystemConfigurations IndexNodeConfiguration `json:"system_configurations"` |
| 134 | +} |
| 135 | + |
| 136 | +// IndexCoordConfiguration records the configuration of IndexCoord. |
| 137 | +type IndexCoordConfiguration struct { |
| 138 | + MinioBucketName string `json:"minio_bucket_name"` |
| 139 | +} |
| 140 | + |
| 141 | +// IndexCoordInfos implements ComponentInfos |
| 142 | +type IndexCoordInfos struct { |
| 143 | + BaseComponentInfos |
| 144 | + SystemConfigurations IndexCoordConfiguration `json:"system_configurations"` |
| 145 | +} |
| 146 | + |
| 147 | +// DataNodeConfiguration records the configuration of DataNode. |
| 148 | +type DataNodeConfiguration struct { |
| 149 | + FlushInsertBufferSize int64 `json:"flush_insert_buffer_size"` |
| 150 | +} |
| 151 | + |
| 152 | +// DataNodeInfos implements ComponentInfos |
| 153 | +type DataNodeInfos struct { |
| 154 | + BaseComponentInfos |
| 155 | + SystemConfigurations DataNodeConfiguration `json:"system_configurations"` |
| 156 | + QuotaMetrics *DataNodeQuotaMetrics `json:"quota_metrics"` |
| 157 | +} |
| 158 | + |
| 159 | +// DataCoordConfiguration records the configuration of DataCoord. |
| 160 | +type DataCoordConfiguration struct { |
| 161 | + SegmentMaxSize float64 `json:"segment_max_size"` |
| 162 | +} |
| 163 | + |
| 164 | +type DataCoordIndexInfo struct { |
| 165 | + NumEntitiesIndexed int64 |
| 166 | + IndexName string |
| 167 | + FieldID int64 |
| 168 | +} |
| 169 | + |
| 170 | +type DataCoordCollectionInfo struct { |
| 171 | + NumEntitiesTotal int64 |
| 172 | + IndexInfo []*DataCoordIndexInfo |
| 173 | +} |
| 174 | + |
| 175 | +type DataCoordCollectionMetrics struct { |
| 176 | + Collections map[int64]*DataCoordCollectionInfo |
| 177 | +} |
| 178 | + |
| 179 | +// DataCoordInfos implements ComponentInfos |
| 180 | +type DataCoordInfos struct { |
| 181 | + BaseComponentInfos |
| 182 | + SystemConfigurations DataCoordConfiguration `json:"system_configurations"` |
| 183 | + QuotaMetrics *DataCoordQuotaMetrics `json:"quota_metrics"` |
| 184 | + CollectionMetrics *DataCoordCollectionMetrics `json:"collection_metrics"` |
| 185 | +} |
| 186 | + |
| 187 | +// RootCoordConfiguration records the configuration of RootCoord. |
| 188 | +type RootCoordConfiguration struct { |
| 189 | + MinSegmentSizeToEnableIndex int64 `json:"min_segment_size_to_enable_index"` |
| 190 | +} |
| 191 | + |
| 192 | +// RootCoordInfos implements ComponentInfos |
| 193 | +type RootCoordInfos struct { |
| 194 | + BaseComponentInfos |
| 195 | + SystemConfigurations RootCoordConfiguration `json:"system_configurations"` |
| 196 | +} |
0 commit comments