Skip to content

Commit 06ba381

Browse files
authored
refactor: Optimize the naming of goodefs variables (#4406)
Signed-off-by: wjp <wjp_199502@163.com>
1 parent 4f1e7f0 commit 06ba381

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

pkg/ddc/goosefs/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (e GooseFSEngine) patchDatasetStatus(dataset *v1alpha1.Dataset, states *cac
6767
return
6868
}
6969
// skip when `dataset.Status.UfsTotal` is "[Calculating]"
70-
if dataset.Status.UfsTotal == METADATA_SYNC_NOT_DONE_MSG {
70+
if dataset.Status.UfsTotal == MetadataSyncNotDoneMsg {
7171
return
7272
}
7373

@@ -82,7 +82,7 @@ func (e GooseFSEngine) patchDatasetStatus(dataset *v1alpha1.Dataset, states *cac
8282
func (e *GooseFSEngine) GetCacheHitStates() (cacheHitStates cacheHitStates) {
8383
// get cache hit states every 1 minute(CACHE_HIT_QUERY_INTERVAL_MIN * 20s)
8484
cacheHitStates.timestamp = time.Now()
85-
if e.lastCacheHitStates != nil && cacheHitStates.timestamp.Sub(e.lastCacheHitStates.timestamp).Minutes() < CACHE_HIT_QUERY_INTERVAL_MIN {
85+
if e.lastCacheHitStates != nil && cacheHitStates.timestamp.Sub(e.lastCacheHitStates.timestamp).Minutes() < CacheHitQueryIntervalMin {
8686
return *e.lastCacheHitStates
8787
}
8888

pkg/ddc/goosefs/const.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ const (
2121
// goosefsHome string = "/opt/goosefs"
2222

2323
// goosefsUser string = "fluid"
24-
METRICS_PREFIX_BYTES_READ_LOCAL = "Cluster.BytesReadLocal "
24+
MetricsPrefixBytesReadLocal = "Cluster.BytesReadLocal "
2525

26-
METRICS_PREFIX_BYTES_READ_REMOTE = "Cluster.BytesReadRemote "
26+
MetricsPrefixBytesReadRemote = "Cluster.BytesReadRemote "
2727

28-
METRICS_PREFIX_BYTES_READ_UFS_ALL = "Cluster.BytesReadUfsAll "
28+
MetricsPrefixBytesReadUfsAll = "Cluster.BytesReadUfsAll "
2929

30-
METRICS_PREFIX_BYTES_READ_LOCAL_THROUGHPUT = "Cluster.BytesReadLocalThroughput "
30+
MetricsPrefixBytesReadLocalThroughput = "Cluster.BytesReadLocalThroughput "
3131

32-
METRICS_PREFIX_BYTES_READ_REMOTE_THROUGHPUT = "Cluster.BytesReadRemoteThroughput "
32+
MetricsPrefixBytesReadRemoteThroughput = "Cluster.BytesReadRemoteThroughput "
3333

34-
METRICS_PREFIX_BYTES_READ_UFS_THROUGHPUT = "Cluster.BytesReadUfsThroughput "
34+
MetricsPrefixBytesReadUfsThroughput = "Cluster.BytesReadUfsThroughput "
3535

36-
METADATA_SYNC_NOT_DONE_MSG = "[Calculating]"
36+
MetadataSyncNotDoneMsg = "[Calculating]"
3737

38-
GOOSEFS_RUNTIME_METRICS_LABEL = "goosefs_runtime_metrics"
38+
GooseFSRuntimeMetricsLabel = "goosefs_runtime_metrics"
3939

40-
CHECK_METADATA_SYNC_DONE_TIMEOUT_MILLISEC = 500
40+
CheckMetadataSyncDoneTimeoutMillisec = 500
4141

4242
AUTO_SELECT_PORT_MIN = 20000
4343
AUTO_SELECT_PORT_MAX = 30000
4444

45-
PORT_NUM = 9
45+
PortNum = 9
4646

47-
CACHE_HIT_QUERY_INTERVAL_MIN = 1
47+
CacheHitQueryIntervalMin = 1
4848

49-
HADOOP_CONF_HDFS_SITE_FILENAME = "hdfs-site.xml"
49+
HadoopConfHdfsSiteFilename = "hdfs-site.xml"
5050

51-
HADOOP_CONF_CORE_SITE_FILENAME = "core-site.xml"
51+
HadoopConfCoreSiteFilename = "core-site.xml"
5252

53-
HADOOP_CONF_MOUNT_PATH = "/hdfs-config"
53+
HadoopConfMountPath = "/hdfs-config"
5454

55-
WOKRER_POD_ROLE = "goosefs-worker"
55+
WokrerPodRole = "goosefs-worker"
5656
)

pkg/ddc/goosefs/metadata.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (e *GooseFSEngine) shouldSyncMetadata() (should bool, err error) {
7070

7171
//todo(xuzhihao): option to enable/disable automatic metadata sync
7272
//todo: periodical metadata sync
73-
if dataset.Status.UfsTotal != "" && dataset.Status.UfsTotal != METADATA_SYNC_NOT_DONE_MSG {
73+
if dataset.Status.UfsTotal != "" && dataset.Status.UfsTotal != MetadataSyncNotDoneMsg {
7474
e.Log.V(1).Info("dataset ufs is ready",
7575
"dataset name", dataset.Name,
7676
"dataset namespace", dataset.Namespace,
@@ -206,7 +206,7 @@ func (e *GooseFSEngine) syncMetadataInternal() (err error) {
206206
e.Log.Error(result.Err, "Metadata sync failed")
207207
return result.Err
208208
}
209-
case <-time.After(CHECK_METADATA_SYNC_DONE_TIMEOUT_MILLISEC * time.Millisecond):
209+
case <-time.After(CheckMetadataSyncDoneTimeoutMillisec * time.Millisecond):
210210
e.Log.V(1).Info("Metadata sync still in progress")
211211
}
212212
} else {
@@ -217,8 +217,8 @@ func (e *GooseFSEngine) syncMetadataInternal() (err error) {
217217
return
218218
}
219219
datasetToUpdate := dataset.DeepCopy()
220-
datasetToUpdate.Status.UfsTotal = METADATA_SYNC_NOT_DONE_MSG
221-
datasetToUpdate.Status.FileNum = METADATA_SYNC_NOT_DONE_MSG
220+
datasetToUpdate.Status.UfsTotal = MetadataSyncNotDoneMsg
221+
datasetToUpdate.Status.FileNum = MetadataSyncNotDoneMsg
222222
if !reflect.DeepEqual(dataset, datasetToUpdate) {
223223
err = e.Client.Status().Update(context.TODO(), datasetToUpdate)
224224
if err != nil {

pkg/ddc/goosefs/report.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,32 @@ func (e GooseFSEngine) ParseReportMetric(metrics string, cacheHitStates, lastCac
7474
str = strings.TrimSpace(str)
7575
counterPattern := regexp.MustCompile(`\(Type:\sCOUNTER,\sValue:\s(.*)\)`)
7676
gaugePattern := regexp.MustCompile(`\(Type:\sGAUGE,\sValue:\s(.*)/MIN\)`)
77-
if strings.HasPrefix(str, METRICS_PREFIX_BYTES_READ_LOCAL) {
77+
if strings.HasPrefix(str, MetricsPrefixBytesReadLocal) {
7878
cacheHitStates.bytesReadLocal, _ = utils.FromHumanSize(counterPattern.FindStringSubmatch(str)[1])
7979
continue
8080
}
8181

82-
if strings.HasPrefix(str, METRICS_PREFIX_BYTES_READ_REMOTE) {
82+
if strings.HasPrefix(str, MetricsPrefixBytesReadRemote) {
8383
cacheHitStates.bytesReadRemote, _ = utils.FromHumanSize(counterPattern.FindStringSubmatch(str)[1])
8484
continue
8585
}
8686

87-
if strings.HasPrefix(str, METRICS_PREFIX_BYTES_READ_UFS_ALL) {
87+
if strings.HasPrefix(str, MetricsPrefixBytesReadUfsAll) {
8888
cacheHitStates.bytesReadUfsAll, _ = utils.FromHumanSize(counterPattern.FindStringSubmatch(str)[1])
8989
continue
9090
}
9191

92-
if strings.HasPrefix(str, METRICS_PREFIX_BYTES_READ_LOCAL_THROUGHPUT) {
92+
if strings.HasPrefix(str, MetricsPrefixBytesReadLocalThroughput) {
9393
localThroughput, _ = utils.FromHumanSize(gaugePattern.FindStringSubmatch(str)[1])
9494
continue
9595
}
9696

97-
if strings.HasPrefix(str, METRICS_PREFIX_BYTES_READ_REMOTE_THROUGHPUT) {
97+
if strings.HasPrefix(str, MetricsPrefixBytesReadRemoteThroughput) {
9898
remoteThroughput, _ = utils.FromHumanSize(gaugePattern.FindStringSubmatch(str)[1])
9999
continue
100100
}
101101

102-
if strings.HasPrefix(str, METRICS_PREFIX_BYTES_READ_UFS_THROUGHPUT) {
102+
if strings.HasPrefix(str, MetricsPrefixBytesReadUfsThroughput) {
103103
ufsThroughput, _ = utils.FromHumanSize(gaugePattern.FindStringSubmatch(str)[1])
104104
}
105105
}

pkg/ddc/goosefs/transform.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (e *GooseFSEngine) transformCommonPart(runtime *datav1alpha1.GooseFSRuntime
220220
}
221221

222222
if !runtime.Spec.DisablePrometheus {
223-
value.Monitoring = GOOSEFS_RUNTIME_METRICS_LABEL
223+
value.Monitoring = GooseFSRuntimeMetricsLabel
224224
}
225225

226226
// transform Tolerations
@@ -359,7 +359,7 @@ func (e *GooseFSEngine) transformWorkers(runtime *datav1alpha1.GooseFSRuntime, v
359359

360360
// 8.allocate port for fluid engine
361361
func (e *GooseFSEngine) allocatePorts(value *GooseFS) error {
362-
expectedPortNum := PORT_NUM
362+
expectedPortNum := PortNum
363363

364364
if e.runtime.Spec.APIGateway.Enabled {
365365
expectedPortNum += 1

pkg/ddc/goosefs/transform_hadoop_config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ func (e *GooseFSEngine) transformHadoopConfig(runtime *datav1alpha1.GooseFSRunti
5050
var confFiles []string
5151
for k := range hadoopConfigMap.Data {
5252
switch k {
53-
case HADOOP_CONF_HDFS_SITE_FILENAME:
53+
case HadoopConfHdfsSiteFilename:
5454
value.HadoopConfig.IncludeHdfsSite = true
55-
confFiles = append(confFiles, HADOOP_CONF_MOUNT_PATH+"/"+HADOOP_CONF_HDFS_SITE_FILENAME)
56-
case HADOOP_CONF_CORE_SITE_FILENAME:
55+
confFiles = append(confFiles, HadoopConfMountPath+"/"+HadoopConfHdfsSiteFilename)
56+
case HadoopConfCoreSiteFilename:
5757
value.HadoopConfig.IncludeCoreSite = true
58-
confFiles = append(confFiles, HADOOP_CONF_MOUNT_PATH+"/"+HADOOP_CONF_CORE_SITE_FILENAME)
58+
confFiles = append(confFiles, HadoopConfMountPath+"/"+HadoopConfCoreSiteFilename)
5959
}
6060
}
6161

6262
// Neither hdfs-site.xml nor core-site.xml is found in the configMap
6363
if !value.HadoopConfig.IncludeCoreSite && !value.HadoopConfig.IncludeHdfsSite {
64-
err = fmt.Errorf("neither \"%v\" nor \"%v\" is found in the specified configMap \"%v\" ", HADOOP_CONF_HDFS_SITE_FILENAME, HADOOP_CONF_CORE_SITE_FILENAME, runtime.Spec.HadoopConfig)
64+
err = fmt.Errorf("neither \"%v\" nor \"%v\" is found in the specified configMap \"%v\" ", HadoopConfHdfsSiteFilename, HadoopConfCoreSiteFilename, runtime.Spec.HadoopConfig)
6565
return err
6666
}
6767

pkg/ddc/goosefs/ufs_internal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (e *GooseFSEngine) processUpdatingUFS(ufsToUpdate *utils.UFSToUpdate) (err
236236
}
237237
// need to reset ufsTotal to Calculating so that SyncMetadata will work
238238
datasetToUpdate := dataset.DeepCopy()
239-
datasetToUpdate.Status.UfsTotal = METADATA_SYNC_NOT_DONE_MSG
239+
datasetToUpdate.Status.UfsTotal = MetadataSyncNotDoneMsg
240240
if !reflect.DeepEqual(dataset.Status, datasetToUpdate.Status) {
241241
err = e.Client.Status().Update(context.TODO(), datasetToUpdate)
242242
if err != nil {

pkg/ddc/goosefs/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (e *GooseFSEngine) CheckWorkersReady() (ready bool, err error) {
109109
func (e *GooseFSEngine) getWorkerSelectors() string {
110110
labels := map[string]string{
111111
"release": e.name,
112-
common.PodRoleType: WOKRER_POD_ROLE,
112+
common.PodRoleType: WokrerPodRole,
113113
"app": common.GooseFSRuntime,
114114
}
115115
labelSelector := &metav1.LabelSelector{

0 commit comments

Comments
 (0)