Skip to content

Commit

Permalink
refactor: uniform jindo const naming (#4407)
Browse files Browse the repository at this point in the history
Signed-off-by: XuJin <xujin_job@163.com>
  • Loading branch information
xujin-wk authored Nov 29, 2024
1 parent 8815a96 commit d6dc9bf
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pkg/ddc/jindo/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (e *JindoEngine) queryCacheStatus() (states cacheStates, err error) {
}

// `dataset.Status.UfsTotal` probably haven't summed, in which case we won't compute cache percentage
if dataset.Status.UfsTotal != "" && dataset.Status.UfsTotal != METADATA_SYNC_NOT_DONE_MSG {
if dataset.Status.UfsTotal != "" && dataset.Status.UfsTotal != MetadataSyncNotDoneMsg {
usedInBytes, _ := utils.FromHumanSize(states.cached)
ufsTotalInBytes, _ := utils.FromHumanSize(dataset.Status.UfsTotal)
// jindofs calculate cached storage bytesize with block sum, so percentage will be over 100% if totally cached
Expand Down
26 changes: 13 additions & 13 deletions pkg/ddc/jindo/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ limitations under the License.
package jindo

const (
METADATA_SYNC_NOT_DONE_MSG = "[Calculating]"
MetadataSyncNotDoneMsg = "[Calculating]"

CHECK_METADATA_SYNC_DONE_TIMEOUT_MILLISEC = 500
CheckMetadataSyncDoneTimeoutMillisec = 500

HADOOP_CONF_HDFS_SITE_FILENAME = "hdfs-site.xml"
HadoopConfHdfsSiteFilename = "hdfs-site.xml"

HADOOP_CONF_CORE_SITE_FILENAME = "core-site.xml"
HadoopConfCoreSiteFilename = "core-site.xml"

JINDO_MASTERNUM_DEFAULT = 1
JINDO_HA_MASTERNUM = 3
JindoMasterNumDefault = 1
JindoHAMasterNum = 3

defaultMasterRpcPort = 8101
DEFAULT_WORKER_RPC_PORT = 6101
DEFAULT_RAFT_RPC_PORT = 8103
DefaultMasterRpcPort = 8101
DefaultWorkerRpcPort = 6101
DefaultRaftRpcPort = 8103

workerPodRole = "jindo-worker"
WorkerPodRole = "jindo-worker"

runtimeFSType = "jindofs"
RuntimeFSType = "jindofs"

jindoFuseMountpath = "/jfs/jindofs-fuse"
JindoFuseMountPath = "/jfs/jindofs-fuse"

DEFAULT_JINDO_RUNTIME_IMAGE = "registry.cn-shanghai.aliyuncs.com/jindofs/smartdata:3.8.0"
DefaultJindoRuntimeImage = "registry.cn-shanghai.aliyuncs.com/jindofs/smartdata:3.8.0"
)
8 changes: 4 additions & 4 deletions pkg/ddc/jindo/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (e *JindoEngine) shouldSyncMetadata() (should bool, err error) {
return should, err
}

if dataset.Status.UfsTotal != "" && dataset.Status.UfsTotal != METADATA_SYNC_NOT_DONE_MSG {
if dataset.Status.UfsTotal != "" && dataset.Status.UfsTotal != MetadataSyncNotDoneMsg {
e.Log.V(1).Info("dataset ufs is ready",
"dataset name", dataset.Name,
"dataset namespace", dataset.Namespace,
Expand Down Expand Up @@ -102,7 +102,7 @@ func (e *JindoEngine) syncMetadataInternal() (err error) {
e.Log.Error(result.Err, "Metadata sync failed")
return result.Err
}
case <-time.After(CHECK_METADATA_SYNC_DONE_TIMEOUT_MILLISEC * time.Millisecond):
case <-time.After(CheckMetadataSyncDoneTimeoutMillisec * time.Millisecond):
e.Log.V(1).Info("Metadata sync still in progress")
}
} else {
Expand All @@ -113,8 +113,8 @@ func (e *JindoEngine) syncMetadataInternal() (err error) {
return
}
datasetToUpdate := dataset.DeepCopy()
datasetToUpdate.Status.UfsTotal = METADATA_SYNC_NOT_DONE_MSG
datasetToUpdate.Status.FileNum = METADATA_SYNC_NOT_DONE_MSG
datasetToUpdate.Status.UfsTotal = MetadataSyncNotDoneMsg
datasetToUpdate.Status.FileNum = MetadataSyncNotDoneMsg
if !reflect.DeepEqual(dataset, datasetToUpdate) {
err = e.Client.Status().Update(context.TODO(), datasetToUpdate)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddc/jindo/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (e *JindoEngine) cleanAll() (err error) {
func (e *JindoEngine) cleanConfigMap() (err error) {
var (
valueConfigmapName = e.getHelmValuesConfigmapName()
configmapName = e.name + "-" + runtimeFSType + "-config"
clientConfigmapName = e.name + "-" + runtimeFSType + "-client-config"
configmapName = e.name + "-" + RuntimeFSType + "-config"
clientConfigmapName = e.name + "-" + RuntimeFSType + "-client-config"
namespace = e.namespace
)

Expand Down
22 changes: 11 additions & 11 deletions pkg/ddc/jindo/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (e *JindoEngine) transform(runtime *datav1alpha1.JindoRuntime) (value *Jind
e.transformLogConfig(runtime, value)
value.Master.DnsServer = dnsServer
value.Master.NameSpace = e.namespace
value.Fuse.MountPath = jindoFuseMountpath
value.Fuse.MountPath = JindoFuseMountPath
return value, err
}

Expand Down Expand Up @@ -479,10 +479,10 @@ func (e *JindoEngine) transformNodeSelector(runtime *datav1alpha1.JindoRuntime)
}

func (e *JindoEngine) transformReplicasCount(runtime *datav1alpha1.JindoRuntime) int {
if runtime.Spec.Master.Replicas == JINDO_HA_MASTERNUM {
return JINDO_HA_MASTERNUM
if runtime.Spec.Master.Replicas == JindoHAMasterNum {
return JindoHAMasterNum
}
return JINDO_MASTERNUM_DEFAULT
return JindoMasterNumDefault
}

func (e *JindoEngine) transformMasterSelector(runtime *datav1alpha1.JindoRuntime) map[string]string {
Expand Down Expand Up @@ -605,15 +605,15 @@ func (e *JindoEngine) allocatePorts(value *Jindo) error {
// usehostnetwork to choose port from port allocator
expectedPortNum := 2
if !value.UseHostNetwork {
value.Master.Port.Rpc = defaultMasterRpcPort
value.Worker.Port.Rpc = DEFAULT_WORKER_RPC_PORT
if value.Master.ReplicaCount == JINDO_HA_MASTERNUM {
value.Master.Port.Raft = DEFAULT_RAFT_RPC_PORT
value.Master.Port.Rpc = DefaultMasterRpcPort
value.Worker.Port.Rpc = DefaultWorkerRpcPort
if value.Master.ReplicaCount == JindoHAMasterNum {
value.Master.Port.Raft = DefaultRaftRpcPort
}
return nil
}

if value.Master.ReplicaCount == JINDO_HA_MASTERNUM {
if value.Master.ReplicaCount == JindoHAMasterNum {
expectedPortNum = 3
}

Expand All @@ -633,7 +633,7 @@ func (e *JindoEngine) allocatePorts(value *Jindo) error {
value.Master.Port.Rpc = allocatedPorts[index]
index++
value.Worker.Port.Rpc = allocatedPorts[index]
if value.Master.ReplicaCount == JINDO_HA_MASTERNUM {
if value.Master.ReplicaCount == JindoHAMasterNum {
index++
value.Master.Port.Raft = allocatedPorts[index]
}
Expand All @@ -658,7 +658,7 @@ func (e *JindoEngine) transformInitPortCheck(value *Jindo) error {
var ports []string

ports = append(ports, strconv.Itoa(value.Master.Port.Rpc))
if value.Master.ReplicaCount == JINDO_HA_MASTERNUM {
if value.Master.ReplicaCount == JindoHAMasterNum {
ports = append(ports, strconv.Itoa(value.Master.Port.Raft))
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/ddc/jindo/transform_hadoop_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ func (e *JindoEngine) transformHadoopConfig(runtime *datav1alpha1.JindoRuntime,

for k := range hadoopConfigMap.Data {
switch k {
case HADOOP_CONF_HDFS_SITE_FILENAME:
case HadoopConfHdfsSiteFilename:
value.HadoopConfig.IncludeHdfsSite = true
case HADOOP_CONF_CORE_SITE_FILENAME:
case HadoopConfCoreSiteFilename:
value.HadoopConfig.IncludeCoreSite = true
}
}

// Neither hdfs-site.xml nor core-site.xml is found in the configMap
if !value.HadoopConfig.IncludeCoreSite && !value.HadoopConfig.IncludeHdfsSite {
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)
err = fmt.Errorf("neither \"%v\" nor \"%v\" is found in the specified configMap \"%v\" ", HadoopConfHdfsSiteFilename, HadoopConfCoreSiteFilename, runtime.Spec.HadoopConfig)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/jindo/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (e *JindoEngine) CheckWorkersReady() (ready bool, err error) {
func (e *JindoEngine) getWorkerSelectors() string {
labels := map[string]string{
"release": e.name,
common.PodRoleType: workerPodRole,
common.PodRoleType: WorkerPodRole,
"app": common.JindoRuntime,
}
labelSelector := &metav1.LabelSelector{
Expand Down

0 comments on commit d6dc9bf

Please sign in to comment.