-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #829 from WeBankFinTech/dev-1.0.0
[release] Prepare for release Linkis-1.0.0
- Loading branch information
Showing
2,595 changed files
with
120,294 additions
and
19,592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
assembly-combined-package/assembly-combined/bin/linkis-cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2019 WeBank | ||
# | ||
# 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. | ||
# | ||
|
||
#set -x | ||
export LANG=en_US.utf-8 | ||
LINKIS_CLIENT='com.webank.wedatasphere.linkis.cli.application.LinkisClientApplication' | ||
|
||
i=0 | ||
for arg in "$@" | ||
do | ||
args[i]=${arg} | ||
input_args[i]=${arg} | ||
((i++)) | ||
done | ||
|
||
|
||
#=============================================== | ||
# finf java_home | ||
#=============================================== | ||
locate_java_home() { | ||
local JAVA8_HOME_CANDIDATES='\ | ||
/usr/java/jdk1.8* \ | ||
/nemo/jdk1.8*' | ||
|
||
JAVA_HOME_CANDIDATES="$JAVA8_HOME_CANDIDATES" | ||
|
||
# attempt to find java 8 | ||
flag="" | ||
for candidate_regex in $JAVA_HOME_CANDIDATES ; do | ||
for candidate in `ls -rd $candidate_regex 2>/dev/null`; do | ||
if [ -e $candidate/bin/java ]; then | ||
export JAVA_HOME=$candidate | ||
flag="true" | ||
break 2 | ||
fi | ||
done | ||
done | ||
|
||
if [ -z "$flag" ]; then | ||
echo -e "\033[0;31;40mNo JDK 8 found. linkis-client requires Java 1.8\033[0m" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
verify_java_home | ||
} | ||
|
||
# Verify that JAVA_HOME set - does not verify that it's set to a meaningful | ||
# value. | ||
verify_java_home() { | ||
if [ -z "$JAVA_HOME" ]; then | ||
cat 1>&2 <<EOF | ||
+======================================================================+ | ||
| Error: JAVA_HOME is not set and Java could not be found | | ||
+----------------------------------------------------------------------+ | ||
EOF | ||
exit 1 | ||
fi | ||
} | ||
|
||
|
||
function call_linkis_client() { | ||
current_dir=`pwd` | ||
workdir=`dirname "$0"`/../ | ||
workdir=`cd ${workdir};pwd` | ||
cd ${current_dir} | ||
|
||
LINKIS_DEPLOY_LIB_DIR='lib/linkis-computation-governance/linkis-client/linkis-cli/' | ||
LINKIS_DEPLOY_CONF_DIR='conf/linkis-cli' | ||
LINKIS_DEPLOY_LOG_DIR='logs/linkis-cli' | ||
LINKIS_CLIENT_CLASSPATH=${workdir}/${LINKIS_DEPLOY_CONF_DIR}:${workdir}/${LINKIS_DEPLOY_LIB_DIR}*:${CLASSPATH} | ||
LINKIS_CLIENT_LOG_DIR=${LINKIS_CLIENT_LOG_DIR:-"${workdir}/${LINKIS_DEPLOY_LOG_DIR}"} | ||
LINKIS_CLIENT_CONF_DIR=${LINKIS_CLIENT_CONF_DIR:-"${workdir}/${LINKIS_DEPLOY_CONF_DIR}"} | ||
LINKIS_CLIENT_CONF_FILE=${LINKIS_CLIENT_CONF_FILE:-"linkis-cli.properties"} | ||
|
||
LINKIS_CLIENT_HEAP_OPTS="-server -Xms32m -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LINKIS_CLIENT_LOG_DIR} -XX:ErrorFile=${LINKIS_CLIENT_LOG_DIR}/ps_err_pid%p.log" | ||
LINKIS_CLIENT_GC_OPTS="-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=80 -XX:+DisableExplicitGC" | ||
LINKIS_CLIENT_LOG_OPTS="-Dlog.path=${LINKIS_CLIENT_LOG_DIR} -Dlog.file=linkis-client.${USER}.log.`date '+%Y%m%d%H%M%S%N'`" | ||
#DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" | ||
LINKIS_CLIENT_OPTS=${LINKIS_CLIENT_OPTS:-" ${DEBUG_OPTS} "} | ||
|
||
|
||
|
||
exec ${JAVA} ${LINKIS_CLIENT_HEAP_OPTS} ${LINKIS_CLIENT_GC_OPTS} ${LINKIS_CLIENT_OPTS} -classpath ${LINKIS_CLIENT_CLASSPATH} -Dconf.root=${LINKIS_CLIENT_CONF_DIR} -Dconf.file=${LINKIS_CLIENT_CONF_FILE} ${LINKIS_CLIENT_LOG_OPTS} ${LINKIS_CLIENT} "${input_args[@]}" | ||
} | ||
|
||
|
||
locate_java_home | ||
JAVA=${JAVA_HOME}/bin/java | ||
|
||
call_linkis_client |
187 changes: 187 additions & 0 deletions
187
assembly-combined-package/assembly-combined/bin/linkis-cli-hive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2019 WeBank | ||
# | ||
# 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. | ||
# | ||
|
||
# set -x | ||
export LANG=en_US.utf-8 | ||
declare -A ord_opts=(\ | ||
#cli options | ||
['-e']='-code' \ | ||
['-f']='-codePath' \ | ||
# ['-i']=true \ #not supported | ||
# ['-S']=true \ #not supported | ||
# ['--silent']=true \ #not supported | ||
# ['-v']=true \ #not supported | ||
# ['--verbose']=true \ #not supported | ||
['--hiveconf']='-confMap' \ | ||
['-d']='-varMap' \ | ||
['--hivevar']='-varMap' \ | ||
#linkis opts | ||
['--kill']='--kill' \ | ||
['--status']='--status' \ | ||
) | ||
|
||
#options that should be put in confMap(startupMap) | ||
declare -A confMap_opts=(\ | ||
#cli options | ||
# ['--database']='k_db' \ | ||
) | ||
|
||
#options that should be put in varMap(for variable substitution) | ||
declare -A kv_var_opts=(\ | ||
['-d']=true \ | ||
['--hivevar']=true \ | ||
) | ||
|
||
#k-v pairs style options | ||
declare -A kv_conf_opts=(\ | ||
['--hiveconf']=true \ | ||
) | ||
|
||
# for help | ||
declare -A help_opts=(\ | ||
['-H']='--help' \ | ||
['--help']='--help' \ | ||
) | ||
|
||
declare -A help_msg=(\ | ||
['-d']="Variable subsitution to apply to hive commands. e.g. -d A=B or --define A=B" | ||
#['--database']="Specify the database to use" \ | ||
['-e']="SQL from command line" \ | ||
['-f']="SQL from files" \ | ||
['-H,--help']="Print help information" \ | ||
['--hiveconf']="Use value for given property" \ | ||
['--hivevar']="Variable subsitution to apply to hive commands. e.g. --hivevar A=B" \ | ||
['--kill']="--kill" \ | ||
['--status']="--status" \ | ||
) | ||
|
||
function print_help() { | ||
printf "Usage:\n" | ||
for key in $(echo ${!help_msg[*]}) | ||
do | ||
if [ -n "${help_msg[${key}]}" ]; then | ||
msg=${help_msg[${key}]} | ||
len=${#msg} | ||
printf " %-30s%-30s\n" "$key" "${msg: 0:50}" | ||
for ((i=50;i<len;i+=50)) | ||
do | ||
if (( i+50<len )); then | ||
printf " %-30s%-30s\n" "" "${msg: i:50}" | ||
else | ||
printf " %-30s%-30s\n" "" "${msg: i}" | ||
fi | ||
|
||
done | ||
|
||
fi | ||
done | ||
} | ||
|
||
|
||
|
||
i=0 | ||
for arg in "$@" | ||
do | ||
ARGS[i]=${arg} | ||
((i++)) | ||
done | ||
NUM_ARGS=$i | ||
|
||
CONFMAP_OPTS="" | ||
VARMAP_OPTS="" | ||
LABELMAP_OPTS="" | ||
REMAINS_STR="" | ||
declare -a PARSED_CMD | ||
j=0 | ||
|
||
function parse() { | ||
for((i=0;i<NUM_ARGS;i++)); | ||
do | ||
arg=${ARGS[${i}]} | ||
if [ -n "${help_opts[${arg}]}" ]; then | ||
print_help | ||
PARSED_CMD[$j]=${help_opts[${arg}]} | ||
break | ||
fi | ||
if [ $((${i}+1)) -lt ${NUM_ARGS} ]; then | ||
val=${ARGS[${i}+1]} | ||
if [ -n "${ord_opts[${arg}]}" ]; then | ||
lks_opt=${ord_opts[${arg}]} | ||
PARSED_CMD[$j]=$lks_opt | ||
PARSED_CMD[$j+1]=$val | ||
((j=j+2)) | ||
elif [ -n "${kv_conf_opts[${arg}]}" ]; then | ||
kv_str=$val | ||
if [ -n "${CONFMAP_OPT}" ]; then | ||
CONFMAP_OPT=$CONFMAP_OPT","$kv_str | ||
else | ||
CONFMAP_OPT=$kv_str | ||
fi | ||
elif [ -n "${kv_var_opts[${arg}]}" ]; then | ||
kv_str=$val | ||
if [ -n "${VARMAP_OPTS}" ]; then | ||
VARMAP_OPTS=$VARMAP_OPTS","$kv_str | ||
else | ||
VARMAP_OPTS=$kv_str | ||
fi | ||
elif [ -n "${confMap_opts[${arg}]}" ]; then | ||
key=${confMap_opts[${arg}]} | ||
kv_str=$key"="$val | ||
if [ -n "${CONFMAP_OPT}" ]; then | ||
CONFMAP_OPT=$CONFMAP_OPT","$kv_str | ||
else | ||
CONFMAP_OPT=$kv_str | ||
fi | ||
else | ||
PARSED_CMD[$j]=$arg | ||
PARSED_CMD[$j+1]=$val | ||
((j=j+2)) | ||
fi | ||
((i++)) | ||
else | ||
PARSED_CMD[$j]=$arg | ||
((j++)) | ||
fi | ||
done | ||
if [ -n "${CONFMAP_OPT}" ]; then | ||
PARSED_CMD[$j]="-confMap" | ||
PARSED_CMD[$j+1]=$CONFMAP_OPT | ||
((j=j+2)) | ||
fi | ||
if [ -n "${VARMAP_OPTS}" ]; then | ||
PARSED_CMD[$j]="-varMap" | ||
PARSED_CMD[$j+1]=$VARMAP_OPTS | ||
((j=j+2)) | ||
fi | ||
} | ||
|
||
|
||
current_dir=`pwd` | ||
if [ -n $WORK_DIR ]; then | ||
work_dir=`dirname "$0"`/../ | ||
export WORK_DIR=`cd ${work_dir};pwd` | ||
fi | ||
cd ${current_dir}/ | ||
if (( NUM_ARGS == 0 )); then | ||
PARSED_CMD[$j]='--help' | ||
print_help | ||
else | ||
parse | ||
fi | ||
exec ${WORK_DIR}/bin/linkis-cli-start -engineType hive-1.2.1 -codeType hql "${PARSED_CMD[@]}" | ||
|
||
|
Oops, something went wrong.