Skip to content

Commit

Permalink
Refactor constraints to improve reuse, To #60096268
Browse files Browse the repository at this point in the history
Signed-off-by: cheyang <[email protected]>
  • Loading branch information
cheyang committed Nov 3, 2024
1 parent 5e7f9e1 commit 6a18123
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 18 deletions.
2 changes: 0 additions & 2 deletions pkg/ddc/alluxio/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ const (

metricsPrefixBytesReadUfsThroughput = "Cluster.BytesReadUfsThroughput "

summaryPrefixUsedCapacity = "Used Capacity: "

metadataSyncNotDoneMsg = "[Calculating]"

alluxioRuntimeMetricsLabel = "alluxio_runtime_metrics"
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddc/alluxio/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (e AlluxioEngine) parseReportSummary(s string) cacheStates {
// 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))
Expand Down
2 changes: 0 additions & 2 deletions pkg/ddc/goosefs/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const (

METRICS_PREFIX_BYTES_READ_UFS_THROUGHPUT = "Cluster.BytesReadUfsThroughput "

SUMMARY_PREFIX_USED_CAPACITY = "Used Capacity: "

METADATA_SYNC_NOT_DONE_MSG = "[Calculating]"

GOOSEFS_RUNTIME_METRICS_LABEL = "goosefs_runtime_metrics"
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddc/goosefs/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (e GooseFSEngine) ParseReportSummary(s string) cacheStates {
// 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))
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddc/jindo/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (e *JindoEngine) queryCacheStatus() (states cacheStates, err error) {
// 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))
Expand Down
2 changes: 0 additions & 2 deletions pkg/ddc/jindo/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package jindo

const (
SUMMARY_PREFIX_USED_CAPACITY = "Used Capacity: "

METADATA_SYNC_NOT_DONE_MSG = "[Calculating]"

CHECK_METADATA_SYNC_DONE_TIMEOUT_MILLISEC = 500
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/jindocache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (e *JindoCacheEngine) queryCacheStatus() (states cacheStates, err error) {
usedCapacityLabel = SUMMARY_PREFIX_USED_MEM_CAPACITY
} else {
totalCapacityLabel = ddctypes.SummaryPrefixTotalDiskCapacity
usedCapacityLabel = SUMMARY_PREFIX_USED_CAPACITY
usedCapacityLabel = ddctypes.SummaryPrefixUsedDiskCapacity
}
strs := strings.Split(summary, "\n")
for _, str := range strs {
Expand Down
2 changes: 0 additions & 2 deletions pkg/ddc/jindocache/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const (

Mount_TYPE = "mount_type"

SUMMARY_PREFIX_USED_CAPACITY = "Used Disk Capacity: "

SUMMARY_PREFIX_TOTAL_MEM_CAPACITY = "Total MEM Capacity: "

SUMMARY_PREFIX_USED_MEM_CAPACITY = "Used MEM Capacity: "
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/jindofsx/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (e *JindoFSxEngine) queryCacheStatus() (states cacheStates, err error) {
usedCapacityLabel = SUMMARY_PREFIX_USED_MEM_CAPACITY
} else {
totalCapacityLabel = ddctypes.SummaryPrefixTotalDiskCapacity
usedCapacityLabel = SUMMARY_PREFIX_USED_CAPACITY
usedCapacityLabel = ddctypes.SummaryPrefixUsedDiskCapacity
}
strs := strings.Split(summary, "\n")
for _, str := range strs {
Expand Down
2 changes: 0 additions & 2 deletions pkg/ddc/jindofsx/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const (

Mount_TYPE = "mount_type"

SUMMARY_PREFIX_USED_CAPACITY = "Used Disk Capacity: "

SUMMARY_PREFIX_TOTAL_MEM_CAPACITY = "Total MEM Capacity: "

SUMMARY_PREFIX_USED_MEM_CAPACITY = "Used MEM Capacity: "
Expand Down
4 changes: 4 additions & 0 deletions pkg/ddc/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ package types
const (
SummaryPrefixTotalCapacity = "Total Capacity: "

SummaryPrefixUsedCapacity = "Used Capacity: "

SummaryPrefixTotalDiskCapacity = "Total Disk Capacity: "

SummaryPrefixUsedDiskCapacity = "Used Disk Capacity: "
)

0 comments on commit 6a18123

Please sign in to comment.