diff --git a/pkg/ddc/alluxio/const.go b/pkg/ddc/alluxio/const.go index 29cc49fa77c..833988ec453 100644 --- a/pkg/ddc/alluxio/const.go +++ b/pkg/ddc/alluxio/const.go @@ -35,10 +35,6 @@ const ( metricsPrefixBytesReadUfsThroughput = "Cluster.BytesReadUfsThroughput " - summaryPrefixTotalCapacity = "Total Capacity: " - - summaryPrefixUsedCapacity = "Used Capacity: " - metadataSyncNotDoneMsg = "[Calculating]" alluxioRuntimeMetricsLabel = "alluxio_runtime_metrics" diff --git a/pkg/ddc/alluxio/report.go b/pkg/ddc/alluxio/report.go index 44a321a9976..417cf9ca06e 100644 --- a/pkg/ddc/alluxio/report.go +++ b/pkg/ddc/alluxio/report.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/fluid-cloudnative/fluid/pkg/ddc/alluxio/operations" + ddctypes "github.com/fluid-cloudnative/fluid/pkg/ddc/types" "github.com/fluid-cloudnative/fluid/pkg/utils" ) @@ -40,14 +41,14 @@ func (e AlluxioEngine) parseReportSummary(s string) cacheStates { strs := strings.Split(s, "\n") for _, str := range strs { str = strings.TrimSpace(str) - if strings.HasPrefix(str, summaryPrefixTotalCapacity) { - totalCacheCapacityAlluxio, _ := utils.FromHumanSize(strings.TrimPrefix(str, summaryPrefixTotalCapacity)) + if strings.HasPrefix(str, ddctypes.SummaryPrefixTotalCapacity) { + totalCacheCapacityAlluxio, _ := utils.FromHumanSize(strings.TrimPrefix(str, ddctypes.SummaryPrefixTotalCapacity)) // Convert Alluxio's binary byte units to Fluid's binary byte units // e.g. 10KB -> 10KiB, 2GB -> 2GiB states.cacheCapacity = utils.BytesSize(float64(totalCacheCapacityAlluxio)) } - if strings.HasPrefix(str, summaryPrefixUsedCapacity) { - usedCacheCapacityAlluxio, _ := utils.FromHumanSize(strings.TrimPrefix(str, summaryPrefixUsedCapacity)) + if strings.HasPrefix(str, ddctypes.SummaryPrefixUsedCapacity) { + usedCacheCapacityAlluxio, _ := utils.FromHumanSize(strings.TrimPrefix(str, ddctypes.SummaryPrefixUsedCapacity)) // Convert Alluxio's binary byte units to Fluid's binary byte units // e.g. 10KB -> 10KiB, 2GB -> 2GiB states.cached = utils.BytesSize(float64(usedCacheCapacityAlluxio)) diff --git a/pkg/ddc/goosefs/const.go b/pkg/ddc/goosefs/const.go index bf06cd3ea8c..a8461c0c5da 100644 --- a/pkg/ddc/goosefs/const.go +++ b/pkg/ddc/goosefs/const.go @@ -33,10 +33,6 @@ const ( METRICS_PREFIX_BYTES_READ_UFS_THROUGHPUT = "Cluster.BytesReadUfsThroughput " - SUMMARY_PREFIX_TOTAL_CAPACITY = "Total Capacity: " - - SUMMARY_PREFIX_USED_CAPACITY = "Used Capacity: " - METADATA_SYNC_NOT_DONE_MSG = "[Calculating]" GOOSEFS_RUNTIME_METRICS_LABEL = "goosefs_runtime_metrics" diff --git a/pkg/ddc/goosefs/report.go b/pkg/ddc/goosefs/report.go index 875fb4a7237..ca4c0e9be0b 100644 --- a/pkg/ddc/goosefs/report.go +++ b/pkg/ddc/goosefs/report.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/fluid-cloudnative/fluid/pkg/ddc/goosefs/operations" + ddctypes "github.com/fluid-cloudnative/fluid/pkg/ddc/types" "github.com/fluid-cloudnative/fluid/pkg/utils" ) @@ -40,14 +41,14 @@ func (e GooseFSEngine) ParseReportSummary(s string) cacheStates { strs := strings.Split(s, "\n") for _, str := range strs { str = strings.TrimSpace(str) - if strings.HasPrefix(str, SUMMARY_PREFIX_TOTAL_CAPACITY) { - totalCacheCapacityGooseFS, _ := utils.FromHumanSize(strings.TrimPrefix(str, SUMMARY_PREFIX_TOTAL_CAPACITY)) + if strings.HasPrefix(str, ddctypes.SummaryPrefixTotalCapacity) { + totalCacheCapacityGooseFS, _ := utils.FromHumanSize(strings.TrimPrefix(str, ddctypes.SummaryPrefixTotalCapacity)) // Convert GooseFS's binary byte units to Fluid's binary byte units // e.g. 10KB -> 10KiB, 2GB -> 2GiB states.cacheCapacity = utils.BytesSize(float64(totalCacheCapacityGooseFS)) } - if strings.HasPrefix(str, SUMMARY_PREFIX_USED_CAPACITY) { - usedCacheCapacityGooseFS, _ := utils.FromHumanSize(strings.TrimPrefix(str, SUMMARY_PREFIX_USED_CAPACITY)) + if strings.HasPrefix(str, ddctypes.SummaryPrefixUsedCapacity) { + usedCacheCapacityGooseFS, _ := utils.FromHumanSize(strings.TrimPrefix(str, ddctypes.SummaryPrefixUsedCapacity)) // Convert GooseFS's binary byte units to Fluid's binary byte units // e.g. 10KB -> 10KiB, 2GB -> 2GiB states.cached = utils.BytesSize(float64(usedCacheCapacityGooseFS)) diff --git a/pkg/ddc/jindo/cache.go b/pkg/ddc/jindo/cache.go index ff7d35593f5..35ead5a0a5c 100644 --- a/pkg/ddc/jindo/cache.go +++ b/pkg/ddc/jindo/cache.go @@ -22,6 +22,7 @@ import ( "time" "github.com/fluid-cloudnative/fluid/pkg/ddc/jindo/operations" + ddctypes "github.com/fluid-cloudnative/fluid/pkg/ddc/types" "github.com/fluid-cloudnative/fluid/pkg/utils" "github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient" ) @@ -37,14 +38,14 @@ func (e *JindoEngine) queryCacheStatus() (states cacheStates, err error) { strs := strings.Split(summary, "\n") for _, str := range strs { str = strings.TrimSpace(str) - if strings.HasPrefix(str, SUMMARY_PREFIX_TOTAL_CAPACITY) { - totalCacheCapacityJindo, _ := utils.FromHumanSize(strings.TrimPrefix(str, SUMMARY_PREFIX_TOTAL_CAPACITY)) + if strings.HasPrefix(str, ddctypes.SummaryPrefixTotalCapacity) { + totalCacheCapacityJindo, _ := utils.FromHumanSize(strings.TrimPrefix(str, ddctypes.SummaryPrefixTotalCapacity)) // Convert JindoFS's binary byte units to Fluid's binary byte units // e.g. 10KB -> 10KiB, 2GB -> 2GiB states.cacheCapacity = utils.BytesSize(float64(totalCacheCapacityJindo)) } - if strings.HasPrefix(str, SUMMARY_PREFIX_USED_CAPACITY) { - usedCacheCapacityJindo, _ := utils.FromHumanSize(strings.TrimPrefix(str, SUMMARY_PREFIX_USED_CAPACITY)) + if strings.HasPrefix(str, ddctypes.SummaryPrefixUsedCapacity) { + usedCacheCapacityJindo, _ := utils.FromHumanSize(strings.TrimPrefix(str, ddctypes.SummaryPrefixUsedCapacity)) // Convert JindoFS's binary byte units to Fluid's binary byte units // e.g. 10KB -> 10KiB, 2GB -> 2GiB states.cached = utils.BytesSize(float64(usedCacheCapacityJindo)) diff --git a/pkg/ddc/jindo/const.go b/pkg/ddc/jindo/const.go index 4ec44ec274f..f4ddb68db9e 100644 --- a/pkg/ddc/jindo/const.go +++ b/pkg/ddc/jindo/const.go @@ -17,10 +17,6 @@ limitations under the License. package jindo const ( - SUMMARY_PREFIX_TOTAL_CAPACITY = "Total Capacity: " - - SUMMARY_PREFIX_USED_CAPACITY = "Used Capacity: " - METADATA_SYNC_NOT_DONE_MSG = "[Calculating]" CHECK_METADATA_SYNC_DONE_TIMEOUT_MILLISEC = 500 diff --git a/pkg/ddc/jindocache/cache.go b/pkg/ddc/jindocache/cache.go index 66798315062..8898ae343e8 100644 --- a/pkg/ddc/jindocache/cache.go +++ b/pkg/ddc/jindocache/cache.go @@ -22,6 +22,7 @@ import ( "time" "github.com/fluid-cloudnative/fluid/pkg/ddc/jindocache/operations" + ddctypes "github.com/fluid-cloudnative/fluid/pkg/ddc/types" "github.com/fluid-cloudnative/fluid/pkg/utils" "github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient" ) @@ -40,8 +41,8 @@ func (e *JindoCacheEngine) queryCacheStatus() (states cacheStates, err error) { totalCapacityLabel = SUMMARY_PREFIX_TOTAL_MEM_CAPACITY usedCapacityLabel = SUMMARY_PREFIX_USED_MEM_CAPACITY } else { - totalCapacityLabel = SUMMARY_PREFIX_TOTAL_CAPACITY - usedCapacityLabel = SUMMARY_PREFIX_USED_CAPACITY + totalCapacityLabel = ddctypes.SummaryPrefixTotalDiskCapacity + usedCapacityLabel = ddctypes.SummaryPrefixUsedDiskCapacity } strs := strings.Split(summary, "\n") for _, str := range strs { diff --git a/pkg/ddc/jindocache/const.go b/pkg/ddc/jindocache/const.go index 309f90ed2ea..4bca663d350 100644 --- a/pkg/ddc/jindocache/const.go +++ b/pkg/ddc/jindocache/const.go @@ -23,10 +23,6 @@ const ( Mount_TYPE = "mount_type" - SUMMARY_PREFIX_TOTAL_CAPACITY = "Total Disk Capacity: " - - SUMMARY_PREFIX_USED_CAPACITY = "Used Disk Capacity: " - SUMMARY_PREFIX_TOTAL_MEM_CAPACITY = "Total MEM Capacity: " SUMMARY_PREFIX_USED_MEM_CAPACITY = "Used MEM Capacity: " diff --git a/pkg/ddc/jindofsx/cache.go b/pkg/ddc/jindofsx/cache.go index fce1c9714f3..4edf2aaae02 100644 --- a/pkg/ddc/jindofsx/cache.go +++ b/pkg/ddc/jindofsx/cache.go @@ -22,6 +22,7 @@ import ( "time" "github.com/fluid-cloudnative/fluid/pkg/ddc/jindofsx/operations" + ddctypes "github.com/fluid-cloudnative/fluid/pkg/ddc/types" "github.com/fluid-cloudnative/fluid/pkg/utils" "github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient" ) @@ -40,8 +41,8 @@ func (e *JindoFSxEngine) queryCacheStatus() (states cacheStates, err error) { totalCapacityLabel = SUMMARY_PREFIX_TOTAL_MEM_CAPACITY usedCapacityLabel = SUMMARY_PREFIX_USED_MEM_CAPACITY } else { - totalCapacityLabel = SUMMARY_PREFIX_TOTAL_CAPACITY - usedCapacityLabel = SUMMARY_PREFIX_USED_CAPACITY + totalCapacityLabel = ddctypes.SummaryPrefixTotalDiskCapacity + usedCapacityLabel = ddctypes.SummaryPrefixUsedDiskCapacity } strs := strings.Split(summary, "\n") for _, str := range strs { diff --git a/pkg/ddc/jindofsx/const.go b/pkg/ddc/jindofsx/const.go index 0f63d864f98..f3c1dcbb3b8 100644 --- a/pkg/ddc/jindofsx/const.go +++ b/pkg/ddc/jindofsx/const.go @@ -23,10 +23,6 @@ const ( Mount_TYPE = "mount_type" - SUMMARY_PREFIX_TOTAL_CAPACITY = "Total Disk Capacity: " - - SUMMARY_PREFIX_USED_CAPACITY = "Used Disk Capacity: " - SUMMARY_PREFIX_TOTAL_MEM_CAPACITY = "Total MEM Capacity: " SUMMARY_PREFIX_USED_MEM_CAPACITY = "Used MEM Capacity: " diff --git a/pkg/ddc/types/constants.go b/pkg/ddc/types/constants.go new file mode 100644 index 00000000000..a16f8aa4d6f --- /dev/null +++ b/pkg/ddc/types/constants.go @@ -0,0 +1,27 @@ +/* +Copyright 2024 The Fluid Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package types + +const ( + SummaryPrefixTotalCapacity = "Total Capacity: " + + SummaryPrefixUsedCapacity = "Used Capacity: " + + SummaryPrefixTotalDiskCapacity = "Total Disk Capacity: " + + SummaryPrefixUsedDiskCapacity = "Used Disk Capacity: " +)