Skip to content

Commit

Permalink
format code and change time
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeOnePlus authored and yiguolei committed Dec 24, 2024
1 parent 6d6473e commit 5c54392
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 178 deletions.
214 changes: 107 additions & 107 deletions docker/runtime/be/resource/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,95 +61,95 @@ docker_setup_env() {

# Check the variables required for startup
docker_required_variables_env() {
declare -g RUN_TYPE
if [[ -n "$FE_SERVERS" && -n "$BE_ADDR" ]]; then
RUN_TYPE="ELECTION"
if [[ $FE_SERVERS =~ ^.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}(,.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4})*$ || $FE_SERVERS =~ ^.+:([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
doris_warn "FE_SERVERS" $FE_SERVERS
else
doris_error "FE_SERVERS rule error!example: \$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT[,\$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT]..."
fi
if [[ $BE_ADDR =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}$ || $BE_ADDR =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:):[1-6]{0,1}[0-9]{1,4}$ ]]; then
doris_warn "BE_ADDR" $BE_ADDR
else
doris_error "BE_ADDR rule error!example: \$BE_IP:\$HEARTBEAT_SERVICE_PORT"
fi
export RUN_TYPE=${RUN_TYPE}
return
fi
declare -g RUN_TYPE
if [[ -n "$FE_SERVERS" && -n "$BE_ADDR" ]]; then
RUN_TYPE="ELECTION"
if [[ $FE_SERVERS =~ ^.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}(,.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4})*$ || $FE_SERVERS =~ ^.+:([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
doris_warn "FE_SERVERS" $FE_SERVERS
else
doris_error "FE_SERVERS rule error!example: \$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT[,\$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT]..."
fi
if [[ $BE_ADDR =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}$ || $BE_ADDR =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:):[1-6]{0,1}[0-9]{1,4}$ ]]; then
doris_warn "BE_ADDR" $BE_ADDR
else
doris_error "BE_ADDR rule error!example: \$BE_IP:\$HEARTBEAT_SERVICE_PORT"
fi
export RUN_TYPE=${RUN_TYPE}
return
fi
if [[ -n "$FE_MASTER_IP" && -n "$BE_IP" && -n "$BE_PORT" ]]; then
RUN_TYPE="ASSIGN"
if [[ $FE_MASTER_IP =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}$ || $FE_MASTER_IP =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
doris_warn "FE_MASTER_IP" $FE_MASTER_IP
else
doris_error "FE_MASTER_IP rule error!example: \$FE_MASTER_IP"
fi
if [[ $BE_IP =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}$ || $BE_IP =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
doris_warn "BE_IP" $BE_IP
else
doris_error "BE_IP rule error!example: \$BE_IP"
fi
if [[ $BE_PORT =~ ^[1-6]{0,1}[0-9]{1,4}$ ]]; then
doris_warn "BE_PORT" $BE_PORT
else
doris_error "BE_PORT rule error!example: \$BE_PORT."
fi
export RUN_TYPE=${RUN_TYPE}
return
fi
if [[ -n "$FE_MASTER_IP" && -n "$BE_IP" && -n "$BE_PORT" ]]; then
RUN_TYPE="ASSIGN"
if [[ $FE_MASTER_IP =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}$ || $FE_MASTER_IP =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
doris_warn "FE_MASTER_IP" $FE_MASTER_IP
else
doris_error "FE_MASTER_IP rule error!example: \$FE_MASTER_IP"
fi
if [[ $BE_IP =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}$ || $BE_IP =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
doris_warn "BE_IP" $BE_IP
else
doris_error "BE_IP rule error!example: \$BE_IP"
fi
if [[ $BE_PORT =~ ^[1-6]{0,1}[0-9]{1,4}$ ]]; then
doris_warn "BE_PORT" $BE_PORT
else
doris_error "BE_PORT rule error!example: \$BE_PORT."
fi
export RUN_TYPE=${RUN_TYPE}
return
fi
doris_error EOF "
Note that you did not configure the required parameters!
plan 1:
FE_SERVERS & BE_ADDR
plan 2:
FE_MASTER_IP & FE_MASTER_PORT & BE_IP & BE_PORT"
EOF
doris_error EOF "
Note that you did not configure the required parameters!
plan 1:
FE_SERVERS & BE_ADDR
plan 2:
FE_MASTER_IP & FE_MASTER_PORT & BE_IP & BE_PORT"
EOF
}
get_doris_args() {
declare -g MASTER_FE_IP CURRENT_BE_IP CURRENT_BE_PORT PRIORITY_NETWORKS
if [ $RUN_TYPE == "ELECTION" ]; then
local feServerArray=($(echo "${FE_SERVERS}" | awk '{gsub (/,/," "); print $0}'))
for i in "${feServerArray[@]}"; do
val=${i}
val=${val// /}
tmpFeName=$(echo "${val}" | awk -F ':' '{ sub(/fe/, ""); sub(/ /, ""); print$1}')
tmpFeIp=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$2}')
tmpFeEditLogPort=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$3}')
check_arg "TMP_FE_NAME" $tmpFeName
feIpArray[$tmpFeName]=${tmpFeIp}
done
declare -g MASTER_FE_IP CURRENT_BE_IP CURRENT_BE_PORT PRIORITY_NETWORKS
if [ $RUN_TYPE == "ELECTION" ]; then
local feServerArray=($(echo "${FE_SERVERS}" | awk '{gsub (/,/," "); print $0}'))
for i in "${feServerArray[@]}"; do
val=${i}
val=${val// /}
tmpFeName=$(echo "${val}" | awk -F ':' '{ sub(/fe/, ""); sub(/ /, ""); print$1}')
tmpFeIp=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$2}')
tmpFeEditLogPort=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$3}')
check_arg "TMP_FE_NAME" $tmpFeName
feIpArray[$tmpFeName]=${tmpFeIp}
done

FE_MASTER_IP=${feIpArray[1]}
check_arg "FE_MASTER_IP" $FE_MASTER_IP
BE_IP=$(echo "${BE_ADDR}" | awk -F ':' '{ sub(/ /, ""); print$1}')
check_arg "BE_IP" $BE_IP
BE_PORT=$(echo "${BE_ADDR}" | awk -F ':' '{ sub(/ /, ""); print$2}')
check_arg "BE_PORT" $BE_PORT
FE_MASTER_IP=${feIpArray[1]}
check_arg "FE_MASTER_IP" $FE_MASTER_IP
BE_IP=$(echo "${BE_ADDR}" | awk -F ':' '{ sub(/ /, ""); print$1}')
check_arg "BE_IP" $BE_IP
BE_PORT=$(echo "${BE_ADDR}" | awk -F ':' '{ sub(/ /, ""); print$2}')
check_arg "BE_PORT" $BE_PORT

elif [ $RUN_TYPE == "ASSIGN" ]; then
check_arg "FE_MASTER_IP" $FE_MASTER_IP
check_arg "BE_IP" $BE_IP
check_arg "BE_PORT" $BE_PORT
fi
elif [ $RUN_TYPE == "ASSIGN" ]; then
check_arg "FE_MASTER_IP" $FE_MASTER_IP
check_arg "BE_IP" $BE_IP
check_arg "BE_PORT" $BE_PORT
fi

PRIORITY_NETWORKS=$(echo "${BE_IP}" | awk -F '.' '{print$1"."$2"."$3".0/24"}')
check_arg "PRIORITY_NETWORKS" $PRIORITY_NETWORKS
PRIORITY_NETWORKS=$(echo "${BE_IP}" | awk -F '.' '{print$1"."$2"."$3".0/24"}')
check_arg "PRIORITY_NETWORKS" $PRIORITY_NETWORKS

# export be args
export MASTER_FE_IP=${FE_MASTER_IP}
export CURRENT_BE_IP=${BE_IP}
export CURRENT_BE_PORT=${BE_PORT}
export PRIORITY_NETWORKS=${PRIORITY_NETWORKS}
# export be args
export MASTER_FE_IP=${FE_MASTER_IP}
export CURRENT_BE_IP=${BE_IP}
export CURRENT_BE_PORT=${BE_PORT}
export PRIORITY_NETWORKS=${PRIORITY_NETWORKS}

doris_note "MASTER_FE_IP ${MASTER_FE_IP}"
doris_note "CURRENT_BE_IP ${CURRENT_BE_IP}"
doris_note "CURRENT_BE_PORT ${CURRENT_BE_PORT}"
doris_note "PRIORITY_NETWORKS ${PRIORITY_NETWORKS}"
doris_note "MASTER_FE_IP ${MASTER_FE_IP}"
doris_note "CURRENT_BE_IP ${CURRENT_BE_IP}"
doris_note "CURRENT_BE_PORT ${CURRENT_BE_PORT}"
doris_note "PRIORITY_NETWORKS ${PRIORITY_NETWORKS}"

check_be_status true
check_be_status true
}

# Execute sql script, passed via stdin
Expand All @@ -162,32 +162,32 @@ docker_process_sql() {
}

check_be_status() {
set +e
for i in {1..300}; do
if [[ $1 == true ]]; then
docker_process_sql <<<"show frontends" | grep "[[:space:]]${MASTER_FE_IP}[[:space:]]"
else
docker_process_sql <<<"show backends" | grep "[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" | grep "[[:space:]]true[[:space:]]"
fi
be_join_status=$?
if [[ "${be_join_status}" == 0 ]]; then
if [[ $1 == true ]]; then
doris_note "MASTER FE is started!"
else
doris_note "EntryPoint Check - Verify that BE is registered to FE successfully"
BE_ALREADY_EXISTS=true
fi
return
fi
if [[ $(( $i % 20 )) == 1 ]]; then
if [[ $1 == true ]]; then
doris_note "MASTER FE is not started. retry."
else
doris_note "BE is not register. retry."
fi
fi
sleep 1
done
set +e
for i in {1..30}; do
if [[ $1 == true ]]; then
docker_process_sql <<<"show frontends" | grep "[[:space:]]${MASTER_FE_IP}[[:space:]]"
else
docker_process_sql <<<"show backends" | grep "[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" | grep "[[:space:]]true[[:space:]]"
fi
be_join_status=$?
if [[ "${be_join_status}" == 0 ]]; then
if [[ $1 == true ]]; then
doris_note "MASTER FE is started!"
else
doris_note "EntryPoint Check - Verify that BE is registered to FE successfully"
BE_ALREADY_EXISTS=true
fi
return
fi
if [[ $(( $i % 15 )) == 1 ]]; then
if [[ $1 == true ]]; then
doris_note "MASTER FE is not started. retry."
else
doris_note "BE is not register. retry."
fi
fi
sleep 1
done
}

# usage: docker_process_init_files [file [file [...]]]
Expand Down Expand Up @@ -240,9 +240,9 @@ docker_process_init_files() {
# Check whether the passed parameters are empty to avoid subsequent task execution failures. At the same time,
# enumeration checks can be added, such as checking whether a certain parameter appears repeatedly, etc.
check_arg() {
if [ -z $2 ]; then
doris_error "$1 is null!"
fi
if [ -z $2 ]; then
doris_error "$1 is null!"
fi
}

_main() {
Expand Down
Loading

0 comments on commit 5c54392

Please sign in to comment.