Merge remote-tracking branch 'origin/develop' into feature/slguan
This commit is contained in:
commit
104455dc8c
|
@ -359,9 +359,9 @@ SELECT function_list FROM tb_name
|
|||
|
||||
SELECT function_list FROM stb_name
|
||||
[WHERE where_condition]
|
||||
[GROUP BY tags]
|
||||
[FILL ({ VALUE | PREV | NULL | LINEAR})]
|
||||
INTERVAL (interval)
|
||||
[FILL ({ VALUE | PREV | NULL | LINEAR})]</code></pre>
|
||||
[GROUP BY tags]</code></pre>
|
||||
<ul>
|
||||
<li>聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。</li>
|
||||
<li>WHERE语句可以指定查询的起止时间和其他过滤条件 </li>
|
||||
|
|
|
@ -54,7 +54,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一
|
|||
说明:
|
||||
|
||||
1. TAGS列总长度不能超过512 bytes;
|
||||
2. TAGS列的数据类型不能是timestamp和nchar类型;
|
||||
2. TAGS列的数据类型不能是timestamp;
|
||||
3. TAGS列名不能与其他列名相同;
|
||||
4. TAGS列名不能为预留关键字.
|
||||
|
||||
|
@ -218,7 +218,7 @@ GROUP BY location, type
|
|||
```mysql
|
||||
SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
|
||||
FROM thermometer
|
||||
WHERE name<>'beijing' and ts>=now-1d
|
||||
WHERE location<>'beijing' and ts>=now-1d
|
||||
INTERVAL(10M)
|
||||
GROUP BY location, type
|
||||
```
|
||||
|
|
|
@ -23,7 +23,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i
|
|||
Note:
|
||||
|
||||
1. The bytes of all tags together shall be less than 512
|
||||
2. Tag's data type can not be time stamp or nchar
|
||||
2. Tag's data type can not be time stamp
|
||||
3. Tag name shall be different from the field name
|
||||
4. Tag name shall not be the same as system keywords
|
||||
5. Maximum number of tags is 6
|
||||
|
@ -102,7 +102,7 @@ List the number of records, average, maximum, and minimum temperature every 10 m
|
|||
```mysql
|
||||
SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
|
||||
FROM thermometer
|
||||
WHERE name='beijing' and type=10 and ts>=now-1d
|
||||
WHERE location='beijing' and type=10 and ts>=now-1d
|
||||
INTERVAL(10M)
|
||||
```
|
||||
|
||||
|
|
|
@ -424,9 +424,9 @@ SELECT function_list FROM tb_name
|
|||
|
||||
SELECT function_list FROM stb_name
|
||||
[WHERE where_condition]
|
||||
[GROUP BY tags]
|
||||
INTERVAL (interval)
|
||||
[FILL ({ VALUE | PREV | NULL | LINEAR})]
|
||||
[GROUP BY tags]
|
||||
```
|
||||
|
||||
- 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。
|
||||
|
|
|
@ -474,9 +474,9 @@ SELECT function_list FROM tb_name
|
|||
|
||||
SELECT function_list FROM stb_name
|
||||
[WHERE where_condition]
|
||||
[GROUP BY tags]
|
||||
INTERVAL (interval)
|
||||
[FILL ({ VALUE | PREV | NULL | LINEAR})]
|
||||
[GROUP BY tags]
|
||||
```
|
||||
|
||||
The downsampling time window is defined by `interval`, which is at least 10 milliseconds. The query returns a new series of downsampled data that has a series of fixed timestamps with an increment of `interval`.
|
||||
|
|
|
@ -9,13 +9,13 @@ fi
|
|||
if pidof taosd &> /dev/null; then
|
||||
if pidof systemd &> /dev/null; then
|
||||
${csudo} systemctl stop taosd || :
|
||||
elif $(which insserv &> /dev/null); then
|
||||
${csudo} service taosd stop || :
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
elif $(which service &> /dev/null); then
|
||||
${csudo} service taosd stop || :
|
||||
else
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
fi
|
||||
echo "Stop taosd service success!"
|
||||
sleep 1
|
||||
|
|
|
@ -35,6 +35,8 @@ else
|
|||
${csudo} rm -f ${data_link_dir} || :
|
||||
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ fi
|
|||
mkdir -p ${pkg_dir}
|
||||
cd ${pkg_dir}
|
||||
|
||||
versioninfo=$(${script_dir}/../tools/get_version.sh ${script_dir}/../../src/util/src/version.c)
|
||||
libfile="libtaos.so.${versioninfo}"
|
||||
libfile="libtaos.so.${tdengine_ver}"
|
||||
|
||||
# create install dir
|
||||
install_home_path="/usr/local/taos"
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
# Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
# set -x
|
||||
|
||||
armver=$1
|
||||
|
||||
curr_dir=$(pwd)
|
||||
script_dir="$(dirname $(readlink -f $0))"
|
||||
|
@ -110,21 +112,28 @@ echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo
|
|||
echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo}
|
||||
|
||||
# 2. cmake executable file
|
||||
#default use debug mode
|
||||
compile_mode="debug"
|
||||
if [[ $1 == "Release" ]] || [[ $1 == "release" ]]; then
|
||||
compile_mode="Release"
|
||||
fi
|
||||
|
||||
compile_dir="${top_dir}/${compile_mode}"
|
||||
compile_dir="${top_dir}/debug"
|
||||
if [ -d ${compile_dir} ]; then
|
||||
${csudo} rm -rf ${compile_dir}
|
||||
${csudo} rm -rf ${compile_dir}
|
||||
fi
|
||||
|
||||
${csudo} mkdir -p ${compile_dir}
|
||||
cd ${compile_dir}
|
||||
${csudo} cmake -DCMAKE_BUILD_TYPE=${compile_mode} ${top_dir}
|
||||
${csudo} make
|
||||
|
||||
# arm only support lite ver
|
||||
if [ -z "$armver" ]; then
|
||||
cmake ${top_dir}/../
|
||||
elif [ "$armver" == "arm64" ]; then
|
||||
cmake ${top_dir}/../ -DVERSION=lite -DARMVER=arm64
|
||||
elif [ "$armver" == "arm32" ]; then
|
||||
cmake ${top_dir}/../ -DVERSION=lite -DARMVER=arm32
|
||||
else
|
||||
echo "input parameter error!!!"
|
||||
return
|
||||
fi
|
||||
|
||||
make
|
||||
|
||||
cd ${curr_dir}
|
||||
|
||||
|
@ -153,7 +162,8 @@ ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version}
|
|||
|
||||
echo "do tar.gz package for all systems"
|
||||
cd ${script_dir}/tools
|
||||
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}"
|
||||
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${armver}
|
||||
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${armver}
|
||||
|
||||
# 4. Clean up temporary compile directories
|
||||
#${csudo} rm -rf ${compile_dir}
|
||||
|
|
|
@ -39,8 +39,7 @@ echo topdir: %{_topdir}
|
|||
echo version: %{_version}
|
||||
echo buildroot: %{buildroot}
|
||||
|
||||
versioninfo=$(%{_compiledir}/../packaging/tools/get_version.sh ../../src/util/src/version.c)
|
||||
libfile="libtaos.so.${versioninfo}"
|
||||
libfile="libtaos.so.%{_version}"
|
||||
|
||||
# create install path, and cp file
|
||||
mkdir -p %{buildroot}%{homepath}/bin
|
||||
|
@ -80,18 +79,17 @@ fi
|
|||
if pidof taosd &> /dev/null; then
|
||||
if pidof systemd &> /dev/null; then
|
||||
${csudo} systemctl stop taosd || :
|
||||
elif $(which insserv &> /dev/null); then
|
||||
${csudo} service taosd stop || :
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
elif $(which service &> /dev/null); then
|
||||
${csudo} service taosd stop || :
|
||||
else
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
fi
|
||||
echo "Stop taosd service success!"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# if taos.cfg already softlink, remove it
|
||||
if [ -f %{cfg_install_dir}/taos.cfg ]; then
|
||||
${csudo} rm -f %{homepath}/cfg/taos.cfg || :
|
||||
|
@ -146,7 +144,9 @@ if [ $1 -eq 0 ];then
|
|||
${csudo} rm -f ${data_link_dir} || :
|
||||
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# This file is used to install TAOS time-series database on linux systems. The operating system
|
||||
# This file is used to install database on linux systems. The operating system
|
||||
# is required to use systemd to manage services at boot
|
||||
|
||||
set -e
|
||||
|
@ -41,19 +41,58 @@ if command -v sudo > /dev/null; then
|
|||
csudo="sudo"
|
||||
fi
|
||||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
service_config_dir="/etc/init.d"
|
||||
service_config_dir="/etc/init.d"
|
||||
if $(which chkconfig &> /dev/null); then
|
||||
initd_mod=1
|
||||
elif $(which insserv &> /dev/null); then
|
||||
initd_mod=2
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
initd_mod=3
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
|
||||
|
||||
# get the operating system type for using the corresponding init file
|
||||
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
|
||||
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
|
||||
#echo "osinfo: ${osinfo}"
|
||||
os_type=0
|
||||
if echo $osinfo | grep -qwi "ubuntu" ; then
|
||||
echo "this is ubuntu system"
|
||||
os_type=1
|
||||
elif echo $osinfo | grep -qwi "debian" ; then
|
||||
echo "this is debian system"
|
||||
os_type=1
|
||||
elif echo $osinfo | grep -qwi "Kylin" ; then
|
||||
echo "this is Kylin system"
|
||||
os_type=1
|
||||
elif echo $osinfo | grep -qwi "centos" ; then
|
||||
echo "this is centos system"
|
||||
os_type=2
|
||||
elif echo $osinfo | grep -qwi "fedora" ; then
|
||||
echo "this is fedora system"
|
||||
os_type=2
|
||||
else
|
||||
echo "this is other linux system"
|
||||
os_type=0
|
||||
fi
|
||||
|
||||
function kill_taosd() {
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 pid || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_main_path() {
|
||||
|
@ -81,7 +120,7 @@ function install_bin() {
|
|||
|
||||
#Make link
|
||||
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
|
||||
[ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
|
||||
[ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
|
||||
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
|
||||
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
|
||||
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
|
||||
|
@ -89,7 +128,7 @@ function install_bin() {
|
|||
|
||||
function install_lib() {
|
||||
# Remove links
|
||||
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
|
||||
|
||||
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
|
||||
|
||||
|
@ -98,7 +137,7 @@ function install_lib() {
|
|||
}
|
||||
|
||||
function install_header() {
|
||||
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
|
||||
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
|
||||
${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
|
||||
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||
|
@ -107,16 +146,17 @@ function install_header() {
|
|||
function install_config() {
|
||||
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
|
||||
|
||||
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
|
||||
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
|
||||
${csudo} mkdir -p ${cfg_install_dir}
|
||||
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
|
||||
${csudo} chmod 644 ${cfg_install_dir}/*
|
||||
fi
|
||||
|
||||
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
|
||||
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
|
||||
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
|
||||
}
|
||||
|
||||
|
||||
function install_log() {
|
||||
${csudo} rm -rf ${log_dir} || :
|
||||
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
|
||||
|
@ -139,14 +179,26 @@ function install_examples() {
|
|||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof taosd &> /dev/null; then
|
||||
${csudo} service taosd stop || :
|
||||
fi
|
||||
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} chkconfig --del taosd || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} insserv -r taosd || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d -f taosd remove || :
|
||||
fi
|
||||
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} init q || :
|
||||
|
||||
if $(which init &> /dev/null); then
|
||||
${csudo} init q || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_service_on_sysvinit() {
|
||||
|
@ -155,14 +207,27 @@ function install_service_on_sysvinit() {
|
|||
sleep 1
|
||||
|
||||
# Install taosd service
|
||||
${csudo} cp -f ${script_dir}/init.d/taosd ${install_main_dir}/init.d
|
||||
${csudo} cp ${script_dir}/init.d/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd
|
||||
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
|
||||
${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
|
||||
# TODO: for centos, change here
|
||||
${csudo} update-rc.d taosd defaults
|
||||
# chkconfig mysqld on
|
||||
if ((${os_type}==1)); then
|
||||
${csudo} cp -f ${script_dir}/init.d/taosd.deb ${install_main_dir}/init.d/taosd
|
||||
${csudo} cp ${script_dir}/init.d/taosd.deb ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd
|
||||
elif ((${os_type}==2)); then
|
||||
${csudo} cp -f ${script_dir}/init.d/taosd.rpm ${install_main_dir}/init.d/taosd
|
||||
${csudo} cp ${script_dir}/init.d/taosd.rpm ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd
|
||||
fi
|
||||
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} chkconfig --add taosd || :
|
||||
${csudo} chkconfig --level 2345 taosd on || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} insserv taosd || :
|
||||
${csudo} insserv -d taosd || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d taosd defaults || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
|
@ -212,7 +277,7 @@ function install_service() {
|
|||
elif ((${service_mod}==1)); then
|
||||
install_service_on_sysvinit
|
||||
else
|
||||
# must manual start taosd
|
||||
# must manual stop taosd
|
||||
kill_taosd
|
||||
fi
|
||||
}
|
||||
|
@ -266,7 +331,7 @@ function update_TDengine() {
|
|||
echo "File taos.tar.gz does not exist"
|
||||
exit 1
|
||||
fi
|
||||
tar -zxf taos.tar.gz
|
||||
tar -zxf taos.tar.gz
|
||||
|
||||
# Check if version compatible
|
||||
if ! is_version_compatible; then
|
||||
|
@ -274,7 +339,7 @@ function update_TDengine() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Start to update TDEngine...${NC}"
|
||||
echo -e "${GREEN}Start to update TDengine...${NC}"
|
||||
# Stop the service if running
|
||||
if pidof taosd &> /dev/null; then
|
||||
if ((${service_mod}==0)); then
|
||||
|
@ -306,8 +371,7 @@ function update_TDengine() {
|
|||
if ((${service_mod}==0)); then
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
|
||||
elif ((${service_mod}==1)); then
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}"
|
||||
echo -e " : ${csudo} service taosd start ${RED} after${NC}"
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
|
||||
fi
|
||||
|
@ -316,7 +380,7 @@ function update_TDengine() {
|
|||
echo
|
||||
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
|
||||
else
|
||||
install_bin $1
|
||||
install_bin
|
||||
install_config
|
||||
|
||||
echo
|
||||
|
@ -332,9 +396,9 @@ function install_TDengine() {
|
|||
echo "File taos.tar.gz does not exist"
|
||||
exit 1
|
||||
fi
|
||||
tar -zxf taos.tar.gz
|
||||
tar -zxf taos.tar.gz
|
||||
|
||||
echo -e "${GREEN}Start to install TDEngine...${NC}"
|
||||
echo -e "${GREEN}Start to install TDengine...${NC}"
|
||||
|
||||
install_main_path
|
||||
|
||||
|
@ -362,10 +426,9 @@ function install_TDengine() {
|
|||
if ((${service_mod}==0)); then
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
|
||||
elif ((${service_mod}==1)); then
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}"
|
||||
echo -e " : ${csudo} service taosd start ${RED} after${NC}"
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
|
||||
|
|
|
@ -1,4 +1,201 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# This file is used to install TDengine client on linux systems. The operating system
|
||||
# is required to use systemd to manage services at boot
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
# -----------------------Variables definition---------------------
|
||||
script_dir=$(dirname $(readlink -m "$0"))
|
||||
${script_dir}/install.sh client
|
||||
# Dynamic directory
|
||||
data_dir="/var/lib/taos"
|
||||
log_dir="/var/log/taos"
|
||||
|
||||
log_link_dir="/usr/local/taos/log"
|
||||
|
||||
cfg_install_dir="/etc/taos"
|
||||
|
||||
bin_link_dir="/usr/bin"
|
||||
lib_link_dir="/usr/lib"
|
||||
inc_link_dir="/usr/include"
|
||||
|
||||
#install main path
|
||||
install_main_dir="/usr/local/taos"
|
||||
|
||||
# old bin dir
|
||||
bin_dir="/usr/local/taos/bin"
|
||||
|
||||
|
||||
# Color setting
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[1;32m'
|
||||
GREEN_DARK='\033[0;32m'
|
||||
GREEN_UNDERLINE='\033[4;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo"
|
||||
fi
|
||||
|
||||
update_flag=0
|
||||
|
||||
function kill_client() {
|
||||
pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_main_path() {
|
||||
#create install main dir and all sub dir
|
||||
${csudo} rm -rf ${install_main_dir} || :
|
||||
${csudo} mkdir -p ${install_main_dir}
|
||||
${csudo} mkdir -p ${install_main_dir}/cfg
|
||||
${csudo} mkdir -p ${install_main_dir}/bin
|
||||
${csudo} mkdir -p ${install_main_dir}/connector
|
||||
${csudo} mkdir -p ${install_main_dir}/driver
|
||||
${csudo} mkdir -p ${install_main_dir}/examples
|
||||
${csudo} mkdir -p ${install_main_dir}/include
|
||||
}
|
||||
|
||||
function install_bin() {
|
||||
# Remove links
|
||||
${csudo} rm -f ${bin_link_dir}/taos || :
|
||||
${csudo} rm -f ${bin_link_dir}/taosdump || :
|
||||
${csudo} rm -f ${bin_link_dir}/rmtaos || :
|
||||
|
||||
${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/*
|
||||
|
||||
#Make link
|
||||
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
|
||||
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
|
||||
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || :
|
||||
}
|
||||
|
||||
function clean_lib() {
|
||||
sudo rm -f /usr/lib/libtaos.so || :
|
||||
sudo rm -rf ${lib_dir} || :
|
||||
}
|
||||
|
||||
function install_lib() {
|
||||
# Remove links
|
||||
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
|
||||
|
||||
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
|
||||
|
||||
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||
|
||||
}
|
||||
|
||||
function install_header() {
|
||||
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
|
||||
${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
|
||||
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||
}
|
||||
|
||||
function install_config() {
|
||||
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
|
||||
|
||||
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
|
||||
${csudo} mkdir -p ${cfg_install_dir}
|
||||
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
|
||||
${csudo} chmod 644 ${cfg_install_dir}/*
|
||||
fi
|
||||
|
||||
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
|
||||
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
|
||||
}
|
||||
|
||||
|
||||
function install_log() {
|
||||
${csudo} rm -rf ${log_dir} || :
|
||||
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
|
||||
|
||||
${csudo} ln -s ${log_dir} ${install_main_dir}/log
|
||||
}
|
||||
|
||||
function install_connector() {
|
||||
${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector
|
||||
}
|
||||
|
||||
function install_examples() {
|
||||
if [ -d ${script_dir}/examples ]; then
|
||||
${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples
|
||||
fi
|
||||
}
|
||||
|
||||
function update_TDengine() {
|
||||
# Start to update
|
||||
if [ ! -e taos.tar.gz ]; then
|
||||
echo "File taos.tar.gz does not exist"
|
||||
exit 1
|
||||
fi
|
||||
tar -zxf taos.tar.gz
|
||||
|
||||
echo -e "${GREEN}Start to update TDengine client...${NC}"
|
||||
# Stop the client shell if running
|
||||
if pidof taos &> /dev/null; then
|
||||
kill_client
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
install_main_path
|
||||
|
||||
install_log
|
||||
install_header
|
||||
install_lib
|
||||
install_connector
|
||||
install_examples
|
||||
install_bin
|
||||
install_config
|
||||
|
||||
echo
|
||||
echo -e "\033[44;32;1mTDengine client is updated successfully!${NC}"
|
||||
|
||||
rm -rf $(tar -tf taos.tar.gz)
|
||||
}
|
||||
|
||||
function install_TDengine() {
|
||||
# Start to install
|
||||
if [ ! -e taos.tar.gz ]; then
|
||||
echo "File taos.tar.gz does not exist"
|
||||
exit 1
|
||||
fi
|
||||
tar -zxf taos.tar.gz
|
||||
|
||||
echo -e "${GREEN}Start to install TDengine client...${NC}"
|
||||
|
||||
install_main_path
|
||||
install_log
|
||||
install_header
|
||||
install_lib
|
||||
install_connector
|
||||
install_examples
|
||||
install_bin
|
||||
install_config
|
||||
|
||||
echo
|
||||
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
|
||||
|
||||
rm -rf $(tar -tf taos.tar.gz)
|
||||
}
|
||||
|
||||
|
||||
## ==============================Main program starts from here============================
|
||||
# Install or updata client and client
|
||||
# if server is already install, don't install client
|
||||
if [ -e ${bin_dir}/taosd ]; then
|
||||
echo -e "\033[44;32;1mThere are already installed TDengine server, so don't need install client!${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -x ${bin_dir}/taos ]; then
|
||||
update_flag=1
|
||||
update_TDengine
|
||||
else
|
||||
install_TDengine
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Generate tar.gz package for linux client
|
||||
set -e
|
||||
set -x
|
||||
|
||||
curr_dir=$(pwd)
|
||||
compile_dir=$1
|
||||
version=$2
|
||||
build_time=$3
|
||||
armver=$4
|
||||
|
||||
script_dir="$(dirname $(readlink -f $0))"
|
||||
top_dir="$(readlink -m ${script_dir}/../..)"
|
||||
|
||||
# create compressed install file.
|
||||
build_dir="${compile_dir}/build"
|
||||
code_dir="${top_dir}/src"
|
||||
release_dir="${top_dir}/release"
|
||||
community_dir="${script_dir}/../../../community/src"
|
||||
|
||||
package_name='linux'
|
||||
install_dir="${release_dir}/TDengine-client-enterprise-${version}-${package_name}-$(echo ${build_time}| tr ': ' -)"
|
||||
|
||||
# Directories and files.
|
||||
bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdump ${script_dir}/remove_client.sh"
|
||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
||||
header_files="${community_dir}/inc/taos.h ${community_dir}/inc/taoserror.h"
|
||||
cfg_dir="${top_dir}/packaging/cfg"
|
||||
install_files="${script_dir}/install_client.sh"
|
||||
|
||||
# make directories.
|
||||
mkdir -p ${install_dir}
|
||||
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
|
||||
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
|
||||
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
|
||||
|
||||
cd ${install_dir}
|
||||
tar -zcv -f taos.tar.gz * --remove-files || :
|
||||
|
||||
cd ${curr_dir}
|
||||
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install*
|
||||
|
||||
# Copy example code
|
||||
mkdir -p ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/c ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/JDBC ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/matlab ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/python ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/R ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/go ${install_dir}/examples
|
||||
|
||||
# Copy driver
|
||||
mkdir -p ${install_dir}/driver
|
||||
cp ${lib_files} ${install_dir}/driver
|
||||
|
||||
# Copy connector
|
||||
connector_dir="${community_dir}/connector"
|
||||
mkdir -p ${install_dir}/connector
|
||||
cp ${build_dir}/lib/*.jar ${install_dir}/connector
|
||||
cp -r ${connector_dir}/grafana ${install_dir}/connector/
|
||||
cp -r ${connector_dir}/python ${install_dir}/connector/
|
||||
cp -r ${connector_dir}/go ${install_dir}/connector
|
||||
|
||||
# Copy release note
|
||||
# cp ${script_dir}/release_note ${install_dir}
|
||||
|
||||
# exit 1
|
||||
|
||||
cd ${release_dir}
|
||||
if [ -z "$armver" ]; then
|
||||
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
|
||||
elif [ "$armver" == "arm64" ]; then
|
||||
tar -zcv -f "$(basename ${install_dir})-arm64.tar.gz" $(basename ${install_dir}) --remove-files
|
||||
elif [ "$armver" == "arm32" ]; then
|
||||
tar -zcv -f "$(basename ${install_dir})-arm32.tar.gz" $(basename ${install_dir}) --remove-files
|
||||
fi
|
||||
|
||||
cd ${curr_dir}
|
|
@ -6,6 +6,7 @@ curr_dir=$(pwd)
|
|||
compile_dir=$1
|
||||
version=$2
|
||||
build_time=$3
|
||||
armver=$4
|
||||
|
||||
script_dir="$(dirname $(readlink -f $0))"
|
||||
top_dir="$(readlink -m ${script_dir}/../..)"
|
||||
|
@ -20,11 +21,10 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time}
|
|||
|
||||
# Directories and files.
|
||||
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh"
|
||||
versioninfo=$(${script_dir}/get_version.sh ${code_dir}/util/src/version.c)
|
||||
lib_files="${build_dir}/lib/libtaos.so.${versioninfo}"
|
||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
||||
header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
|
||||
cfg_files="${top_dir}/packaging/cfg/*.cfg"
|
||||
install_files="${script_dir}/install.sh ${script_dir}/install_client.sh"
|
||||
cfg_dir="${top_dir}/packaging/cfg"
|
||||
install_files="${script_dir}/install.sh"
|
||||
|
||||
# Init file
|
||||
#init_dir=${script_dir}/deb
|
||||
|
@ -33,29 +33,32 @@ install_files="${script_dir}/install.sh ${script_dir}/install_client.sh"
|
|||
#fi
|
||||
#init_files=${init_dir}/taosd
|
||||
# temp use rpm's taosd. TODO: later modify according to os type
|
||||
init_files=${script_dir}/../rpm/taosd
|
||||
init_file_deb=${script_dir}/../deb/taosd
|
||||
init_file_rpm=${script_dir}/../rpm/taosd
|
||||
|
||||
# make directories.
|
||||
mkdir -p ${install_dir}
|
||||
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
|
||||
mkdir -p ${install_dir}/cfg && cp ${cfg_files} ${install_dir}/cfg
|
||||
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
|
||||
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
|
||||
mkdir -p ${install_dir}/init.d && cp ${init_files} ${install_dir}/init.d
|
||||
mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/taosd.deb
|
||||
mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm
|
||||
|
||||
cd ${install_dir}
|
||||
tar -zcv -f taos.tar.gz * --remove-files || :
|
||||
tar -zcv -f taos.tar.gz * --remove-files || :
|
||||
|
||||
cd ${curr_dir}
|
||||
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install*
|
||||
|
||||
# Copy example code
|
||||
mkdir -p ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/c ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/JDBC ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/matlab ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/python ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/R ${install_dir}/examples
|
||||
cp -r ${top_dir}/tests/examples/go ${install_dir}/examples
|
||||
examples_dir="${top_dir}/tests/examples"
|
||||
cp -r ${examples_dir}/c ${install_dir}/examples
|
||||
cp -r ${examples_dir}/JDBC ${install_dir}/examples
|
||||
cp -r ${examples_dir}/matlab ${install_dir}/examples
|
||||
cp -r ${examples_dir}/python ${install_dir}/examples
|
||||
cp -r ${examples_dir}/R ${install_dir}/examples
|
||||
cp -r ${examples_dir}/go ${install_dir}/examples
|
||||
|
||||
# Copy driver
|
||||
mkdir -p ${install_dir}/driver
|
||||
|
@ -64,18 +67,23 @@ cp ${lib_files} ${install_dir}/driver
|
|||
# Copy connector
|
||||
connector_dir="${code_dir}/connector"
|
||||
mkdir -p ${install_dir}/connector
|
||||
cp ${build_dir}/lib/*.jar ${install_dir}/connector
|
||||
cp -r ${connector_dir}/grafana ${install_dir}/connector/
|
||||
cp -r ${connector_dir}/python ${install_dir}/connector/
|
||||
cp -r ${connector_dir}/go ${install_dir}/connector
|
||||
cp ${build_dir}/lib/*.jar ${install_dir}/connector
|
||||
|
||||
|
||||
# Copy release note
|
||||
cp ${script_dir}/release_note ${install_dir}
|
||||
# cp ${script_dir}/release_note ${install_dir}
|
||||
|
||||
# exit 1
|
||||
|
||||
cd ${release_dir}
|
||||
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
|
||||
if [ -z "$armver" ]; then
|
||||
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
|
||||
elif [ "$armver" == "arm64" ]; then
|
||||
tar -zcv -f "$(basename ${install_dir})-arm64.tar.gz" $(basename ${install_dir}) --remove-files
|
||||
elif [ "$armver" == "arm32" ]; then
|
||||
tar -zcv -f "$(basename ${install_dir})-arm32.tar.gz" $(basename ${install_dir}) --remove-files
|
||||
fi
|
||||
|
||||
cd ${curr_dir}
|
||||
|
|
|
@ -42,14 +42,18 @@ initd_mod=0
|
|||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which insserv &> /dev/null); then
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
initd_mod=1
|
||||
service_config_dir="/etc/init.d"
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
service_mod=1
|
||||
initd_mod=2
|
||||
service_config_dir="/etc/init.d"
|
||||
service_config_dir="/etc/init.d"
|
||||
if $(which chkconfig &> /dev/null); then
|
||||
initd_mod=1
|
||||
elif $(which insserv &> /dev/null); then
|
||||
initd_mod=2
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
initd_mod=3
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
|
@ -57,7 +61,9 @@ fi
|
|||
function kill_taosd() {
|
||||
# ${csudo} pkill -f taosd || :
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_include() {
|
||||
|
@ -103,20 +109,26 @@ function install_config() {
|
|||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof taosd &> /dev/null; then
|
||||
${csudo} service taosd stop || :
|
||||
fi
|
||||
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || :
|
||||
${csudo} chkconfig --del taosd || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} insserv -r taosd || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d -f taosd remove || :
|
||||
fi
|
||||
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
|
||||
if $(which init &> /dev/null); then
|
||||
${csudo} init q || :
|
||||
fi
|
||||
# ${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} init q || :
|
||||
}
|
||||
|
||||
function install_service_on_sysvinit() {
|
||||
|
@ -127,18 +139,24 @@ function install_service_on_sysvinit() {
|
|||
# Install taosd service
|
||||
${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd
|
||||
|
||||
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
|
||||
${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
|
||||
# TODO: for centos, change here
|
||||
${csudo} update-rc.d taosd defaults
|
||||
# chkconfig mysqld on
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} chkconfig --add taosd || :
|
||||
${csudo} chkconfig --level 2345 taosd on || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} insserv taosd || :
|
||||
${csudo} insserv -d taosd || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d taosd defaults || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
taosd_service_config="${service_config_dir}/taosd.service"
|
||||
|
||||
# taosd service already is stoped before install
|
||||
# taosd service already is stoped before install in preinst script
|
||||
#if systemctl is-active --quiet taosd; then
|
||||
# echo "TDengine is running, stopping it..."
|
||||
# ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null
|
||||
|
|
|
@ -26,22 +26,27 @@ initd_mod=0
|
|||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which insserv &> /dev/null); then
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
initd_mod=1
|
||||
service_config_dir="/etc/init.d"
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
service_mod=1
|
||||
initd_mod=2
|
||||
service_config_dir="/etc/init.d"
|
||||
service_config_dir="/etc/init.d"
|
||||
if $(which chkconfig &> /dev/null); then
|
||||
initd_mod=1
|
||||
elif $(which insserv &> /dev/null); then
|
||||
initd_mod=2
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
initd_mod=3
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
|
||||
|
||||
function kill_taosd() {
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
|
@ -57,20 +62,27 @@ function clean_service_on_systemd() {
|
|||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof taosd &> /dev/null; then
|
||||
echo "TDengine taosd is running, stopping it..."
|
||||
${csudo} service taosd stop || :
|
||||
fi
|
||||
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || :
|
||||
${csudo} chkconfig --del taosd || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} insserv -r taosd || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d -f taosd remove || :
|
||||
fi
|
||||
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
|
||||
if $(which init &> /dev/null); then
|
||||
${csudo} init q || :
|
||||
fi
|
||||
# ${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} init q || :
|
||||
}
|
||||
|
||||
function clean_service() {
|
||||
|
@ -79,7 +91,7 @@ function clean_service() {
|
|||
elif ((${service_mod}==1)); then
|
||||
clean_service_on_sysvinit
|
||||
else
|
||||
# must manual start taosd
|
||||
# must manual stop taosd
|
||||
kill_taosd
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to stop the service and uninstall tdengine, but retain the config, data and log files.
|
||||
# Script to stop the service and uninstall TDengine, but retain the config, data and log files.
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[1;32m'
|
||||
|
@ -27,21 +27,27 @@ initd_mod=0
|
|||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which insserv &> /dev/null); then
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
initd_mod=1
|
||||
service_config_dir="/etc/init.d"
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
service_mod=1
|
||||
initd_mod=2
|
||||
service_config_dir="/etc/init.d"
|
||||
service_config_dir="/etc/init.d"
|
||||
if $(which chkconfig &> /dev/null); then
|
||||
initd_mod=1
|
||||
elif $(which insserv &> /dev/null); then
|
||||
initd_mod=2
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
initd_mod=3
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
|
||||
function kill_taosd() {
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
${csudo} kill -9 ${pid} || :
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_bin() {
|
||||
|
@ -87,20 +93,27 @@ function clean_service_on_systemd() {
|
|||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof taosd &> /dev/null; then
|
||||
echo "TDengine taosd is running, stopping it..."
|
||||
${csudo} service taosd stop || :
|
||||
fi
|
||||
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || :
|
||||
${csudo} chkconfig --del taosd || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} insserv -r taosd || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d -f taosd remove || :
|
||||
fi
|
||||
|
||||
${csudo} rm -f ${service_config_dir}/taosd || :
|
||||
|
||||
if $(which init &> /dev/null); then
|
||||
${csudo} init q || :
|
||||
fi
|
||||
# ${csudo} update-rc.d -f taosd remove || :
|
||||
${csudo} init q || :
|
||||
}
|
||||
|
||||
function clean_service() {
|
||||
|
@ -109,7 +122,7 @@ function clean_service() {
|
|||
elif ((${service_mod}==1)); then
|
||||
clean_service_on_sysvinit
|
||||
else
|
||||
# must manual start taosd
|
||||
# must manual stop taosd
|
||||
kill_taosd
|
||||
fi
|
||||
}
|
||||
|
@ -140,4 +153,4 @@ elif echo $osinfo | grep -qwi "centos" ; then
|
|||
${csudo} rpm -e --noscripts tdengine || :
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}TDEngine is removed successfully!${NC}"
|
||||
echo -e "${GREEN}TDengine is removed successfully!${NC}"
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to stop the client and uninstall database, but retain the config and log files.
|
||||
set -e
|
||||
# set -x
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[1;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
#install main path
|
||||
install_main_dir="/usr/local/taos"
|
||||
|
||||
log_link_dir="/usr/local/taos/log"
|
||||
cfg_link_dir="/usr/local/taos/cfg"
|
||||
bin_link_dir="/usr/bin"
|
||||
lib_link_dir="/usr/lib"
|
||||
inc_link_dir="/usr/include"
|
||||
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo"
|
||||
fi
|
||||
|
||||
function kill_client() {
|
||||
#pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$(pidof taos)" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_bin() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${bin_link_dir}/taos || :
|
||||
${csudo} rm -f ${bin_link_dir}/taosump || :
|
||||
${csudo} rm -f ${bin_link_dir}/rmtaos || :
|
||||
}
|
||||
|
||||
function clean_lib() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
|
||||
}
|
||||
|
||||
function clean_header() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
|
||||
}
|
||||
|
||||
function clean_config() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${cfg_link_dir}/* || :
|
||||
}
|
||||
|
||||
function clean_log() {
|
||||
# Remove link
|
||||
${csudo} rm -rf ${log_link_dir} || :
|
||||
}
|
||||
|
||||
# Stop client.
|
||||
kill_client
|
||||
# Remove binary file and links
|
||||
clean_bin
|
||||
# Remove header file.
|
||||
clean_header
|
||||
# Remove lib file
|
||||
clean_lib
|
||||
# Remove link log directory
|
||||
clean_log
|
||||
# Remove link configuration file
|
||||
clean_config
|
||||
|
||||
${csudo} rm -rf ${install_main_dir}
|
||||
|
||||
echo -e "${GREEN}TDengine client is removed successfully!${NC}"
|
|
@ -24,9 +24,9 @@ void *taosOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl,
|
|||
|
||||
void taosCloseConnCache(void *handle);
|
||||
|
||||
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user);
|
||||
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user);
|
||||
|
||||
void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user);
|
||||
void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t
|
|||
SSchema* pColSchema, int16_t isTag);
|
||||
|
||||
void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex);
|
||||
|
||||
//TODO refactor, remove
|
||||
void SStringFree(SString* str);
|
||||
void SStringCopy(SString* pDest, const SString* pSrc);
|
||||
SString SStringCreate(const char* str);
|
||||
|
@ -125,7 +127,7 @@ int tscAllocPayload(SSqlCmd* pCmd, int size);
|
|||
|
||||
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema);
|
||||
void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField);
|
||||
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes);
|
||||
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, const char* name, int16_t bytes);
|
||||
void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
|
||||
|
||||
void tscFieldInfoCalOffset(SSqlCmd* pCmd);
|
||||
|
@ -141,7 +143,9 @@ void tscClearFieldInfo(SFieldInfo* pFieldInfo);
|
|||
void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes, int16_t tableIndex);
|
||||
|
||||
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
int16_t size, /*int16_t colId,*/ int16_t interSize);
|
||||
int16_t size, int16_t interSize);
|
||||
SSqlExpr* tscSqlExprInsertEmpty(SSqlCmd* pCmd, int32_t index, int16_t functionId);
|
||||
|
||||
SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
|
||||
int16_t size);
|
||||
|
||||
|
@ -224,7 +228,7 @@ void doAddGroupColumnForSubquery(SSqlCmd* pCmd, int32_t tagIndex);
|
|||
|
||||
int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid);
|
||||
|
||||
TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, int port, void (*fp)(void*, TAOS_RES*, int),
|
||||
TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, uint16_t port, void (*fp)(void*, TAOS_RES*, int),
|
||||
void* param, void** taos);
|
||||
|
||||
void sortRemoveDuplicates(STableDataBlocks* dataBuf);
|
||||
|
|
|
@ -92,7 +92,12 @@ enum _sql_cmd {
|
|||
*/
|
||||
TSDB_SQL_RETRIEVE_EMPTY_RESULT,
|
||||
|
||||
TSDB_SQL_RESET_CACHE,
|
||||
TSDB_SQL_RESET_CACHE, // 40
|
||||
TSDB_SQL_SERV_STATUS,
|
||||
TSDB_SQL_CURRENT_DB,
|
||||
TSDB_SQL_SERV_VERSION,
|
||||
TSDB_SQL_CLI_VERSION,
|
||||
TSDB_SQL_CURRENT_USER,
|
||||
TSDB_SQL_CFG_LOCAL,
|
||||
|
||||
TSDB_SQL_MAX
|
||||
|
@ -342,11 +347,11 @@ typedef struct _tsc_obj {
|
|||
void * signature;
|
||||
void * pTimer;
|
||||
char mgmtIp[TSDB_USER_LEN];
|
||||
short mgmtPort;
|
||||
uint16_t mgmtPort;
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_KEY_LEN];
|
||||
char acctId[TSDB_DB_NAME_LEN];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
char db[TSDB_METER_ID_LEN];
|
||||
char sversion[TSDB_VERSION_LEN];
|
||||
char writeAuth : 1;
|
||||
char superAuth : 1;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "tsocket.h"
|
||||
#include "tsql.h"
|
||||
#include "tutil.h"
|
||||
#include "tnote.h"
|
||||
|
||||
void tscProcessFetchRow(SSchedMsg *pMsg);
|
||||
void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows);
|
||||
|
@ -53,7 +54,9 @@ void taos_query_a(TAOS *taos, const char *sqlstr, void (*fp)(void *, TAOS_RES *,
|
|||
tscError("sql string too long");
|
||||
tscQueueAsyncError(fp, param);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
taosNotePrintTsc(sqlstr);
|
||||
|
||||
SSqlObj *pSql = (SSqlObj *)malloc(sizeof(SSqlObj));
|
||||
if (pSql == NULL) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
typedef struct _c_hash_t {
|
||||
uint32_t ip;
|
||||
short port;
|
||||
uint16_t port;
|
||||
struct _c_hash_t *prev;
|
||||
struct _c_hash_t *next;
|
||||
void * data;
|
||||
|
@ -45,14 +45,14 @@ typedef struct {
|
|||
void *pTimer;
|
||||
} SConnCache;
|
||||
|
||||
int taosHashConn(void *handle, uint32_t ip, short port, char *user) {
|
||||
int taosHashConn(void *handle, uint32_t ip, uint16_t port, char *user) {
|
||||
SConnCache *pObj = (SConnCache *)handle;
|
||||
int hash = 0;
|
||||
// size_t user_len = strlen(user);
|
||||
|
||||
hash = ip >> 16;
|
||||
hash += (unsigned short)(ip & 0xFFFF);
|
||||
hash += (unsigned short)port;
|
||||
hash += port;
|
||||
while (*user != '\0') {
|
||||
hash += *user;
|
||||
user++;
|
||||
|
@ -74,7 +74,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
|
|||
pNext = pNode->next;
|
||||
pObj->total--;
|
||||
pObj->count[hash]--;
|
||||
tscTrace("%p ip:0x%x:%d:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode,
|
||||
tscTrace("%p ip:0x%x:%hu:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode,
|
||||
pObj->count[hash]);
|
||||
taosMemPoolFree(pObj->connHashMemPool, (char *)pNode);
|
||||
pNode = pNext;
|
||||
|
@ -86,7 +86,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
|
|||
pObj->connHashList[hash] = NULL;
|
||||
}
|
||||
|
||||
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user) {
|
||||
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user) {
|
||||
int hash;
|
||||
SConnHash * pNode;
|
||||
SConnCache *pObj;
|
||||
|
@ -125,7 +125,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch
|
|||
|
||||
pthread_mutex_unlock(&pObj->mutex);
|
||||
|
||||
tscTrace("%p ip:0x%x:%d:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]);
|
||||
tscTrace("%p ip:0x%x:%hu:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]);
|
||||
|
||||
return pObj;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ void taosCleanConnCache(void *handle, void *tmrId) {
|
|||
taosTmrReset(taosCleanConnCache, pObj->keepTimer * 2, pObj, pObj->tmrCtrl, &pObj->pTimer);
|
||||
}
|
||||
|
||||
void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) {
|
||||
void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user) {
|
||||
int hash;
|
||||
SConnHash * pNode;
|
||||
SConnCache *pObj;
|
||||
|
@ -201,7 +201,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) {
|
|||
pthread_mutex_unlock(&pObj->mutex);
|
||||
|
||||
if (pData) {
|
||||
tscTrace("%p ip:0x%x:%d:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]);
|
||||
tscTrace("%p ip:0x%x:%hu:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]);
|
||||
}
|
||||
|
||||
return pData;
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
#include "tschemautil.h"
|
||||
#include "tsocket.h"
|
||||
|
||||
static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
|
||||
static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, size_t valueLength);
|
||||
|
||||
static int32_t getToStringLength(const char *pData, int32_t length, int32_t type) {
|
||||
char buf[512] = {0};
|
||||
|
||||
int32_t len = 0;
|
||||
|
@ -39,7 +41,7 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
|
|||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
#ifdef _TD_ARM_32_
|
||||
double dv = 0;
|
||||
*(int64_t*)(&dv) = *(int64_t*)pData;
|
||||
*(int64_t *)(&dv) = *(int64_t *)pData;
|
||||
len = sprintf(buf, "%f", dv);
|
||||
#else
|
||||
len = sprintf(buf, "%lf", *(double *)pData);
|
||||
|
@ -47,12 +49,11 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
|
|||
if (strncasecmp("nan", buf, 3) == 0) {
|
||||
len = 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
#ifdef _TD_ARM_32_
|
||||
float fv = 0;
|
||||
*(int32_t*)(&fv) = *(int32_t*)pData;
|
||||
*(int32_t *)(&fv) = *(int32_t *)pData;
|
||||
len = sprintf(buf, "%f", fv);
|
||||
#else
|
||||
len = sprintf(buf, "%f", *(float *)pData);
|
||||
|
@ -60,8 +61,7 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
|
|||
if (strncasecmp("nan", buf, 3) == 0) {
|
||||
len = 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
len = sprintf(buf, "%lld", *(int64_t *)pData);
|
||||
|
@ -203,23 +203,21 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
|
|||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
#ifdef _TD_ARM_32_
|
||||
float fv = 0;
|
||||
*(int32_t*)(&fv) = *(int32_t*)pTagValue;
|
||||
*(int32_t *)(&fv) = *(int32_t *)pTagValue;
|
||||
sprintf(target, "%f", fv);
|
||||
#else
|
||||
sprintf(target, "%f", *(float *)pTagValue);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
#ifdef _TD_ARM_32_
|
||||
double dv = 0;
|
||||
*(int64_t*)(&dv) = *(int64_t*)pTagValue;
|
||||
*(int64_t *)(&dv) = *(int64_t *)pTagValue;
|
||||
sprintf(target, "%lf", dv);
|
||||
#else
|
||||
sprintf(target, "%lf", *(double *)pTagValue);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
sprintf(target, "%d", *(int8_t *)pTagValue);
|
||||
break;
|
||||
|
@ -391,6 +389,68 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
|
|||
}
|
||||
}
|
||||
|
||||
static void tscProcessCurrentUser(SSqlObj *pSql) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
|
||||
tscSetLocalQueryResult(pSql, pSql->pTscObj->user, pExpr->aliasName, TSDB_USER_LEN);
|
||||
}
|
||||
|
||||
static void tscProcessCurrentDB(SSqlObj *pSql) {
|
||||
char db[TSDB_DB_NAME_LEN + 1] = {0};
|
||||
extractDBName(pSql->pTscObj->db, db);
|
||||
|
||||
// no use db is invoked before.
|
||||
if (strlen(db) == 0) {
|
||||
setNull(db, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||
}
|
||||
|
||||
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
|
||||
tscSetLocalQueryResult(pSql, db, pExpr->aliasName, TSDB_DB_NAME_LEN);
|
||||
}
|
||||
|
||||
static void tscProcessServerVer(SSqlObj *pSql) {
|
||||
const char* v = pSql->pTscObj->sversion;
|
||||
|
||||
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
|
||||
tscSetLocalQueryResult(pSql, v, pExpr->aliasName, tListLen(pSql->pTscObj->sversion));
|
||||
}
|
||||
|
||||
static void tscProcessClientVer(SSqlObj *pSql) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
|
||||
tscSetLocalQueryResult(pSql, version, pExpr->aliasName, strlen(version));
|
||||
}
|
||||
|
||||
static void tscProcessServStatus(SSqlObj *pSql) {
|
||||
STscObj* pObj = pSql->pTscObj;
|
||||
|
||||
if (pObj->pHb != NULL) {
|
||||
if (pObj->pHb->res.code == TSDB_CODE_NETWORK_UNAVAIL) {
|
||||
pSql->res.code = TSDB_CODE_NETWORK_UNAVAIL;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (pSql->res.code == TSDB_CODE_NETWORK_UNAVAIL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SSqlExpr* pExpr = tscSqlExprGet(&pSql->cmd, 0);
|
||||
tscSetLocalQueryResult(pSql, "1", pExpr->aliasName, 2);
|
||||
}
|
||||
|
||||
void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, size_t valueLength) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
pCmd->numOfCols = 1;
|
||||
pCmd->order.order = TSQL_SO_ASC;
|
||||
|
||||
tscFieldInfoSetValue(&pCmd->fieldsInfo, 0, TSDB_DATA_TYPE_BINARY, columnName, valueLength);
|
||||
tscInitResObjForLocalQuery(pSql, 1, valueLength);
|
||||
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, 0);
|
||||
strncpy(pRes->data, val, pField->bytes);
|
||||
}
|
||||
|
||||
int tscProcessLocalCmd(SSqlObj *pSql) {
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
|
@ -402,13 +462,23 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
|
|||
pSql->res.code = (uint8_t)tscProcessQueryTags(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
|
||||
/*
|
||||
* pass the qhandle check, in order to call partial release function to
|
||||
* free allocated resources and remove the SqlObj from linked list
|
||||
* set the qhandle to be 1 in order to pass the qhandle check, and to call partial release function to
|
||||
* free allocated resources and remove the SqlObj from sql query linked list
|
||||
*/
|
||||
pSql->res.qhandle = 0x1; // pass the qhandle check
|
||||
pSql->res.qhandle = 0x1;
|
||||
pSql->res.numOfRows = 0;
|
||||
} else if (pCmd->command == TSDB_SQL_RESET_CACHE) {
|
||||
taosClearDataCache(tscCacheHandle);
|
||||
} else if (pCmd->command == TSDB_SQL_SERV_VERSION) {
|
||||
tscProcessServerVer(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_CLI_VERSION) {
|
||||
tscProcessClientVer(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_CURRENT_USER) {
|
||||
tscProcessCurrentUser(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_CURRENT_DB) {
|
||||
tscProcessCurrentDB(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_SERV_STATUS) {
|
||||
tscProcessServStatus(pSql);
|
||||
} else {
|
||||
pSql->res.code = TSDB_CODE_INVALID_SQL;
|
||||
tscError("%p not support command:%d", pSql, pCmd->command);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
void tscSaveSlowQueryFp(void *handle, void *tmrId);
|
||||
void *tscSlowQueryConn = NULL;
|
||||
bool tscSlowQueryConnInitialized = false;
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *param, void **taos);
|
||||
|
||||
void tscInitConnCb(void *param, TAOS_RES *result, int code) {
|
||||
|
|
|
@ -117,7 +117,8 @@ static int32_t optrToString(tSQLExpr* pExpr, char** exprString);
|
|||
static SColumnList getColumnList(int32_t num, int16_t tableIndex, int32_t columnIndex);
|
||||
static int32_t getMeterIndex(SSQLToken* pTableToken, SSqlCmd* pCmd, SColumnIndex* pIndex);
|
||||
static int32_t doFunctionsCompatibleCheck(SSqlObj* pSql);
|
||||
|
||||
static int32_t doLocalQueryProcess(SQuerySQL* pQuerySql, SSqlCmd* pCmd);
|
||||
|
||||
static int32_t tscQueryOnlyMetricTags(SSqlCmd* pCmd, bool* queryOnMetricTags) {
|
||||
assert(QUERY_IS_STABLE_QUERY(pCmd->type));
|
||||
|
||||
|
@ -877,7 +878,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
|
||||
case TSQL_QUERY_METER: {
|
||||
SQuerySQL* pQuerySql = pInfo->pQueryInfo;
|
||||
assert(pQuerySql != NULL && pQuerySql->from->nExpr > 0);
|
||||
assert(pQuerySql != NULL && (pQuerySql->from == NULL || pQuerySql->from->nExpr > 0));
|
||||
|
||||
const char* msg0 = "invalid table name";
|
||||
const char* msg1 = "table name too long";
|
||||
|
@ -895,6 +896,19 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
setErrMsg(pCmd, msg8);
|
||||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle the sql expression without from subclause
|
||||
* select current_database();
|
||||
* select server_version();
|
||||
* select client_version();
|
||||
* select server_state();
|
||||
*/
|
||||
if (pQuerySql->from == NULL) {
|
||||
assert(pQuerySql->fillType == NULL && pQuerySql->pGroupby == NULL && pQuerySql->pWhere == NULL &&
|
||||
pQuerySql->pSortOrder == NULL);
|
||||
return doLocalQueryProcess(pQuerySql, pCmd);
|
||||
}
|
||||
|
||||
if (pQuerySql->from->nExpr > TSDB_MAX_JOIN_TABLE_NUM) {
|
||||
setErrMsg(pCmd, msg7);
|
||||
|
@ -1120,7 +1134,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
|
|||
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
|
||||
|
||||
if (pQuerySql->interval.type == 0) {
|
||||
if (pQuerySql->interval.type == 0 || pQuerySql->interval.n == 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2669,7 +2683,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
int32_t port = strtol(portStr, NULL, 10);
|
||||
uint16_t port = (uint16_t)strtol(portStr, NULL, 10);
|
||||
if (port <= 0 || port > 65535) {
|
||||
memset(pCmd->payload, 0, tListLen(pCmd->payload));
|
||||
|
||||
|
@ -4971,8 +4985,8 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd) {
|
|||
}
|
||||
|
||||
typedef struct SDNodeDynConfOption {
|
||||
char* name;
|
||||
int32_t len;
|
||||
char* name; // command name
|
||||
int32_t len; // name string length
|
||||
} SDNodeDynConfOption;
|
||||
|
||||
int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
||||
|
@ -4980,7 +4994,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
|||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
SDNodeDynConfOption DNODE_DYNAMIC_CFG_OPTIONS[14] = {
|
||||
const SDNodeDynConfOption DNODE_DYNAMIC_CFG_OPTIONS[14] = {
|
||||
{"resetLog", 8}, {"resetQueryCache", 15}, {"dDebugFlag", 10}, {"rpcDebugFlag", 12},
|
||||
{"tmrDebugFlag", 12}, {"cDebugFlag", 10}, {"uDebugFlag", 10}, {"mDebugFlag", 10},
|
||||
{"sdbDebugFlag", 12}, {"httpDebugFlag", 13}, {"monitorDebugFlag", 16}, {"qDebugflag", 10},
|
||||
|
@ -4991,7 +5005,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
|||
if (pOptions->nTokens == 2) {
|
||||
// reset log and reset query cache does not need value
|
||||
for (int32_t i = 0; i < 2; ++i) {
|
||||
SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i];
|
||||
const SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i];
|
||||
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -5014,7 +5028,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
|||
}
|
||||
|
||||
for (int32_t i = 2; i < tListLen(DNODE_DYNAMIC_CFG_OPTIONS) - 1; ++i) {
|
||||
SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i];
|
||||
const SDNodeDynConfOption* pOption = &DNODE_DYNAMIC_CFG_OPTIONS[i];
|
||||
|
||||
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
|
||||
/* options is valid */
|
||||
|
@ -5031,8 +5045,10 @@ int32_t validateLocalConfig(tDCLSQL* pOptions) {
|
|||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
|
||||
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}};
|
||||
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {
|
||||
{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
|
||||
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}
|
||||
};
|
||||
|
||||
SSQLToken* pOptionToken = &pOptions->a[0];
|
||||
|
||||
|
@ -5686,3 +5702,53 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
|
|||
return checkUpdateTagPrjFunctions(pCmd);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t doLocalQueryProcess(SQuerySQL* pQuerySql, SSqlCmd* pCmd) {
|
||||
const char* msg1 = "only one expression allowed";
|
||||
const char* msg2 = "invalid expression in select clause";
|
||||
const char* msg3 = "invalid function";
|
||||
|
||||
tSQLExprList* pExprList = pQuerySql->pSelection;
|
||||
if (pExprList->nExpr != 1) {
|
||||
setErrMsg(pCmd, msg1);
|
||||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
tSQLExpr* pExpr = pExprList->a[0].pNode;
|
||||
if (pExpr->operand.z == NULL) {
|
||||
setErrMsg(pCmd, msg2);
|
||||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
|
||||
SDNodeDynConfOption functionsInfo[5] = {
|
||||
{"database()", 10}, {"server_version()", 16}, {"server_status()", 15}, {"client_version()", 16}, {"current_user()", 14}
|
||||
};
|
||||
|
||||
int32_t index = -1;
|
||||
for(int32_t i = 0; i < tListLen(functionsInfo); ++i) {
|
||||
if (strncasecmp(functionsInfo[i].name, pExpr->operand.z, functionsInfo[i].len) == 0 &&
|
||||
functionsInfo[i].len == pExpr->operand.n) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SSqlExpr* pExpr1 = tscSqlExprInsertEmpty(pCmd, 0, TSDB_FUNC_TAG_DUMMY);
|
||||
if (pExprList->a[0].aliasName != NULL) {
|
||||
strncpy(pExpr1->aliasName, pExprList->a[0].aliasName, tListLen(pExpr1->aliasName));
|
||||
} else {
|
||||
strncpy(pExpr1->aliasName, functionsInfo[index].name, tListLen(pExpr1->aliasName));
|
||||
}
|
||||
|
||||
switch(index) {
|
||||
case 0: pCmd->command = TSDB_SQL_CURRENT_DB;return TSDB_CODE_SUCCESS;
|
||||
case 1: pCmd->command = TSDB_SQL_SERV_VERSION;return TSDB_CODE_SUCCESS;
|
||||
case 2: pCmd->command = TSDB_SQL_SERV_STATUS;return TSDB_CODE_SUCCESS;
|
||||
case 3: pCmd->command = TSDB_SQL_CLI_VERSION;return TSDB_CODE_SUCCESS;
|
||||
case 4: pCmd->command = TSDB_SQL_CURRENT_USER;return TSDB_CODE_SUCCESS;
|
||||
default: {
|
||||
setErrMsg(pCmd, msg3);
|
||||
return TSDB_CODE_INVALID_SQL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -500,7 +500,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
|
|||
SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
|
||||
tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval,
|
||||
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
|
||||
assert(pSelection != NULL && pFrom != NULL && pInterval != NULL && pLimit != NULL && pGLimit != NULL);
|
||||
assert(pSelection != NULL);
|
||||
|
||||
SQuerySQL *pQuery = calloc(1, sizeof(SQuerySQL));
|
||||
pQuery->selectToken = *pSelectToken;
|
||||
|
@ -512,13 +512,23 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
|
|||
pQuery->pSortOrder = pSortOrder;
|
||||
pQuery->pWhere = pWhere;
|
||||
|
||||
pQuery->limit = *pLimit;
|
||||
pQuery->slimit = *pGLimit;
|
||||
if (pLimit != NULL) {
|
||||
pQuery->limit = *pLimit;
|
||||
}
|
||||
|
||||
if (pGLimit != NULL) {
|
||||
pQuery->slimit = *pGLimit;
|
||||
}
|
||||
|
||||
pQuery->interval = *pInterval;
|
||||
pQuery->sliding = *pSliding;
|
||||
if (pInterval != NULL) {
|
||||
pQuery->interval = *pInterval;
|
||||
}
|
||||
|
||||
if (pSliding != NULL) {
|
||||
pQuery->sliding = *pSliding;
|
||||
}
|
||||
|
||||
pQuery->fillType = pFill;
|
||||
|
||||
return pQuery;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,6 +184,15 @@ void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) {
|
|||
pSql->vnode = TSC_MGMT_VNODE;
|
||||
#endif
|
||||
}
|
||||
|
||||
// the pSql->res.code is the previous error(status) code.
|
||||
if (pSql->thandle == NULL && pSql->retry >= pSql->maxRetry) {
|
||||
if (pSql->res.code != TSDB_CODE_SUCCESS && pSql->res.code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
*pCode = pSql->res.code;
|
||||
}
|
||||
|
||||
tscError("%p reach the max retry:%d, code:%d", pSql, pSql->retry, *pCode);
|
||||
}
|
||||
}
|
||||
|
||||
void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) {
|
||||
|
@ -442,6 +451,9 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
|
|||
tscTrace("%p it shall be redirected!", pSql);
|
||||
taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user);
|
||||
pSql->thandle = NULL;
|
||||
|
||||
// reset the retry times for a new mgmt node
|
||||
pSql->retry = 0;
|
||||
|
||||
if (pCmd->command > TSDB_SQL_MGMT) {
|
||||
tscProcessMgmtRedirect(pSql, pMsg->content + 1);
|
||||
|
@ -1795,7 +1807,7 @@ int tscBuildCreateDbMsg(SSqlObj *pSql) {
|
|||
pMsg += sizeof(SMgmtHead);
|
||||
|
||||
pCreateDbMsg = (SCreateDbMsg *)pMsg;
|
||||
strcpy(pCreateDbMsg->db, pMeterMetaInfo->name);
|
||||
strncpy(pCreateDbMsg->db, pMeterMetaInfo->name, tListLen(pCreateDbMsg->db));
|
||||
pMsg += sizeof(SCreateDbMsg);
|
||||
|
||||
msgLen = pMsg - pStart;
|
||||
|
@ -2017,7 +2029,7 @@ int tscBuildDropDbMsg(SSqlObj *pSql) {
|
|||
pMsg += sizeof(SMgmtHead);
|
||||
|
||||
pDropDbMsg = (SDropDbMsg *)pMsg;
|
||||
strcpy(pDropDbMsg->db, pMeterMetaInfo->name);
|
||||
strncpy(pDropDbMsg->db, pMeterMetaInfo->name, tListLen(pDropDbMsg->db));
|
||||
|
||||
pDropDbMsg->ignoreNotExists = htons(pCmd->existsCheck ? 1 : 0);
|
||||
|
||||
|
@ -3795,7 +3807,14 @@ void tscInitMsgs() {
|
|||
tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE] = tscProcessRetrieveRspFromVnode; // rsp handled by same function.
|
||||
tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_TAGS] = tscProcessTagRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessTagRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_CURRENT_USER] = tscProcessTagRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_SERV_VERSION] = tscProcessTagRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_CLI_VERSION] = tscProcessTagRetrieveRsp;
|
||||
tscProcessMsgRsp[TSDB_SQL_SERV_STATUS] = tscProcessTagRetrieveRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp;
|
||||
|
||||
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_METRIC] = tscProcessRetrieveMetricRsp;
|
||||
|
|
|
@ -27,8 +27,9 @@
|
|||
#include "tsql.h"
|
||||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
#include "tnote.h"
|
||||
|
||||
TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||
TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *param, void **taos) {
|
||||
STscObj *pObj;
|
||||
|
||||
|
@ -149,7 +150,7 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
|
|||
return pObj;
|
||||
}
|
||||
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port) {
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
||||
if (ip == NULL || (ip != NULL && (strcmp("127.0.0.1", ip) == 0 || strcasecmp("localhost", ip) == 0))) {
|
||||
#ifdef CLUSTER
|
||||
ip = tsMasterIp;
|
||||
|
@ -201,7 +202,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
|||
return taos;
|
||||
}
|
||||
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *param, void **taos) {
|
||||
#ifndef CLUSTER
|
||||
if (ip == NULL) {
|
||||
|
@ -241,9 +242,9 @@ int taos_query_imp(STscObj* pObj, SSqlObj* pSql) {
|
|||
pRes->qhandle = 0;
|
||||
pSql->thandle = NULL;
|
||||
|
||||
if (pRes->code != TSDB_CODE_SUCCESS) return pRes->code;
|
||||
|
||||
tscDoQuery(pSql);
|
||||
if (pRes->code == TSDB_CODE_SUCCESS) {
|
||||
tscDoQuery(pSql);
|
||||
}
|
||||
|
||||
tscTrace("%p SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pObj), pObj);
|
||||
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -270,6 +271,8 @@ int taos_query(TAOS *taos, const char *sqlstr) {
|
|||
return pRes->code;
|
||||
}
|
||||
|
||||
taosNotePrintTsc(sqlstr);
|
||||
|
||||
void *sql = realloc(pSql->sqlstr, sqlLen + 1);
|
||||
if (sql == NULL) {
|
||||
pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||
|
|
|
@ -45,6 +45,10 @@ extern int tscEmbedded;
|
|||
int tscNumOfThreads;
|
||||
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
||||
|
||||
extern int tsTscEnableRecordSql;
|
||||
extern int tsNumOfLogLines;
|
||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
||||
|
||||
void tscCheckDiskUsage(void *para, void *unused) {
|
||||
taosGetDisk();
|
||||
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
||||
|
@ -85,6 +89,10 @@ void taos_init_imp() {
|
|||
|
||||
taosSetCoreDump();
|
||||
|
||||
if (tsTscEnableRecordSql != 0) {
|
||||
taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note");
|
||||
}
|
||||
|
||||
#ifdef CLUSTER
|
||||
tscMgmtIpList.numOfIps = 2;
|
||||
strcpy(tscMgmtIpList.ipstr[0], tsMasterIp);
|
||||
|
@ -354,4 +362,4 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
|||
|
||||
atomic_store_32(&lock, 0);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -720,7 +720,7 @@ static void evic(SFieldInfo* pFieldInfo, int32_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
static void setValueImpl(TAOS_FIELD* pField, int8_t type, char* name, int16_t bytes) {
|
||||
static void setValueImpl(TAOS_FIELD* pField, int8_t type, const char* name, int16_t bytes) {
|
||||
pField->type = type;
|
||||
strncpy(pField->name, name, TSDB_COL_NAME_LEN);
|
||||
pField->bytes = bytes;
|
||||
|
@ -764,7 +764,7 @@ void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visib
|
|||
}
|
||||
}
|
||||
|
||||
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes) {
|
||||
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, const char* name, int16_t bytes) {
|
||||
ensureSpace(pFieldInfo, pFieldInfo->numOfOutputCols + 1);
|
||||
evic(pFieldInfo, index);
|
||||
|
||||
|
@ -896,6 +896,19 @@ static void _exprEvic(SSqlExprInfo* pExprInfo, int32_t index) {
|
|||
}
|
||||
}
|
||||
|
||||
SSqlExpr* tscSqlExprInsertEmpty(SSqlCmd* pCmd, int32_t index, int16_t functionId) {
|
||||
SSqlExprInfo* pExprInfo = &pCmd->exprsInfo;
|
||||
|
||||
_exprCheckSpace(pExprInfo, pExprInfo->numOfExprs + 1);
|
||||
_exprEvic(pExprInfo, index);
|
||||
|
||||
SSqlExpr* pExpr = &pExprInfo->pExprs[index];
|
||||
pExpr->functionId = functionId;
|
||||
|
||||
pExprInfo->numOfExprs++;
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
int16_t size, int16_t interSize) {
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pColIndex->tableIndex);
|
||||
|
@ -1643,7 +1656,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
|
|||
}
|
||||
|
||||
// remain space is insufficient, allocate more spaces
|
||||
int32_t inc = (size < MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE;
|
||||
int32_t inc = (size >= MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE;
|
||||
if (inc < (pStr->alloc >> 1)) {
|
||||
inc = (pStr->alloc >> 1);
|
||||
}
|
||||
|
@ -1670,6 +1683,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
|
|||
}
|
||||
|
||||
memset(tmp + pStr->n, 0, inc);
|
||||
pStr->alloc = newsize;
|
||||
pStr->z = tmp;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -273,6 +273,9 @@ public class TSDBDriver implements java.sql.Driver {
|
|||
String user = "";
|
||||
for (String queryStr : queryStrings) {
|
||||
String[] kvPair = queryStr.trim().split("=");
|
||||
if (kvPair.length < 2){
|
||||
continue;
|
||||
}
|
||||
switch (kvPair[0].toLowerCase()) {
|
||||
case PROPERTY_KEY_USER:
|
||||
urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]);
|
||||
|
|
|
@ -23,8 +23,8 @@ extern "C" {
|
|||
#include "taosmsg.h"
|
||||
#include "tsdb.h"
|
||||
|
||||
extern short tsMgmtMgmtPort;
|
||||
extern short tsMgmtSyncPort;
|
||||
extern uint16_t tsMgmtMgmtPort;
|
||||
extern uint16_t tsMgmtSyncPort;
|
||||
extern int sdbMaxNodes;
|
||||
extern int tsMgmtPeerHBTimer; // seconds
|
||||
extern char sdbZone[];
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "tsql.h"
|
||||
#include "tutil.h"
|
||||
}
|
||||
|
@ -113,7 +112,7 @@ cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
|
|||
}
|
||||
|
||||
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDCLSQLElems(pInfo, DROP_DATABASE, 2, &X, &Y); }
|
||||
cmd ::= DROP DNODE IP(X). { setDCLSQLElems(pInfo, DROP_DNODE, 1, &X); }
|
||||
cmd ::= DROP DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, DROP_DNODE, 1, &X); }
|
||||
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, DROP_USER, 1, &X); }
|
||||
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, DROP_ACCOUNT, 1, &X); }
|
||||
|
||||
|
@ -129,8 +128,8 @@ cmd ::= DESCRIBE ids(X) cpxName(Y). {
|
|||
/////////////////////////////////THE ALTER STATEMENT////////////////////////////////////////
|
||||
cmd ::= ALTER USER ids(X) PASS ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PASSWD, 2, &X, &Y); }
|
||||
cmd ::= ALTER USER ids(X) PRIVILEGE ids(Y). { setDCLSQLElems(pInfo, ALTER_USER_PRIVILEGES, 2, &X, &Y);}
|
||||
cmd ::= ALTER DNODE IP(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_DNODE, 2, &X, &Y); }
|
||||
cmd ::= ALTER DNODE IP(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, ALTER_DNODE, 3, &X, &Y, &Z); }
|
||||
cmd ::= ALTER DNODE IPTOKEN(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_DNODE, 2, &X, &Y); }
|
||||
cmd ::= ALTER DNODE IPTOKEN(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, ALTER_DNODE, 3, &X, &Y, &Z); }
|
||||
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, ALTER_LOCAL, 1, &X); }
|
||||
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, ALTER_LOCAL, 2, &X, &Y); }
|
||||
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SSQLToken t = {0}; setCreateDBSQL(pInfo, ALTER_DATABASE, &X, &Y, &t);}
|
||||
|
@ -155,7 +154,7 @@ ifnotexists(X) ::= . {X.n = 0;}
|
|||
|
||||
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
|
||||
//create option for dnode/db/user/account
|
||||
cmd ::= CREATE DNODE IP(X). { setDCLSQLElems(pInfo, CREATE_DNODE, 1, &X);}
|
||||
cmd ::= CREATE DNODE IPTOKEN(X). { setDCLSQLElems(pInfo, CREATE_DNODE, 1, &X);}
|
||||
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
|
||||
{ setCreateAcctSQL(pInfo, CREATE_ACCOUNT, &X, &Y, &Z);}
|
||||
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDBSQL(pInfo, CREATE_DATABASE, &X, &Y, &Z);}
|
||||
|
@ -219,7 +218,7 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; }
|
|||
prec(Y) ::= PRECISION STRING(X). { Y = X; }
|
||||
|
||||
%type db_optr {SCreateDBInfo}
|
||||
db_optr ::= . {}
|
||||
db_optr(Y) ::= . {memset(&Y, 0, sizeof(SCreateDBInfo));}
|
||||
db_optr(Y) ::= db_optr(Z) tables(X). { Y = Z; Y.tablesPerVnode = strtol(X.z, NULL, 10); }
|
||||
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
|
||||
db_optr(Y) ::= db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
||||
|
@ -350,6 +349,14 @@ select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) fill_
|
|||
A = tSetQuerySQLElems(&T, W, X, Y, P, Z, &K, &S, F, &L, &G);
|
||||
}
|
||||
|
||||
// Support for the SQL exprssion without from & where subclauses, e.g.,
|
||||
// select current_database(),
|
||||
// select server_version(), select client_version(),
|
||||
// select server_state();
|
||||
select(A) ::= SELECT(T) selcollist(W). {
|
||||
A = tSetQuerySQLElems(&T, W, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
// selcollist is a list of expressions that are to become the return
|
||||
// values of the SELECT statement. The "*" in statements like
|
||||
// "SELECT * FROM ..." is encoded as a special expression with an opcode of TK_ALL.
|
||||
|
@ -392,7 +399,7 @@ tmvar(A) ::= VARIABLE(X). {A = X;}
|
|||
|
||||
%type interval_opt {SSQLToken}
|
||||
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
|
||||
interval_opt(N) ::= . {N.n = 0; }
|
||||
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
|
||||
|
||||
%type fill_opt {tVariantList*}
|
||||
%destructor fill_opt {tVariantListDestroy($$);}
|
||||
|
@ -413,7 +420,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. {
|
|||
|
||||
%type sliding_opt {SSQLToken}
|
||||
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
|
||||
sliding_opt(K) ::= . {K.n = 0; }
|
||||
sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
|
||||
|
||||
%type orderby_opt {tVariantList*}
|
||||
%destructor orderby_opt {tVariantListDestroy($$);}
|
||||
|
@ -642,12 +649,12 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
|
|||
}
|
||||
|
||||
////////////////////////////////////////kill statement///////////////////////////////////////
|
||||
cmd ::= KILL CONNECTION IP(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &X);}
|
||||
cmd ::= KILL STREAM IP(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &X);}
|
||||
cmd ::= KILL QUERY IP(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &X);}
|
||||
cmd ::= KILL CONNECTION IPTOKEN(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setDCLSQLElems(pInfo, KILL_CONNECTION, 1, &X);}
|
||||
cmd ::= KILL STREAM IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_STREAM, 1, &X);}
|
||||
cmd ::= KILL QUERY IPTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F.n); setDCLSQLElems(pInfo, KILL_QUERY, 1, &X);}
|
||||
|
||||
%fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED
|
||||
DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD
|
||||
LIKE MATCH KEY OF OFFSET RAISE REPLACE RESTRICT ROW STATEMENT TRIGGER VIEW ALL
|
||||
COUNT SUM AVG MIN MAX FIRST LAST TOP BOTTOM STDDEV PERCENTILE APERCENTILE LEASTSQUARES HISTOGRAM DIFF
|
||||
SPREAD TWA INTERP LAST_ROW NOW IP SEMI NONE PREV LINEAR IMPORT METRIC TBNAME JOIN METRICS STABLE.
|
||||
SPREAD TWA INTERP LAST_ROW NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT METRIC TBNAME JOIN METRICS STABLE NULL.
|
|
@ -59,7 +59,7 @@ typedef struct taosField {
|
|||
|
||||
void taos_init();
|
||||
int taos_options(TSDB_OPTION option, const void *arg, ...);
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port);
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
|
||||
void taos_close(TAOS *taos);
|
||||
|
||||
typedef struct TAOS_BIND {
|
||||
|
|
|
@ -222,7 +222,7 @@ typedef struct {
|
|||
// internal part
|
||||
uint32_t destId;
|
||||
char meterId[TSDB_UNI_LEN];
|
||||
short port; // for UDP only
|
||||
uint16_t port; // for UDP only
|
||||
char empty[1];
|
||||
char msgType;
|
||||
int32_t msgLen;
|
||||
|
@ -309,7 +309,7 @@ typedef struct {
|
|||
} SCreateMsg;
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
char db[TSDB_METER_ID_LEN];
|
||||
short ignoreNotExists;
|
||||
} SDropDbMsg, SUseDbMsg;
|
||||
|
||||
|
@ -594,7 +594,7 @@ typedef struct {
|
|||
// NOTE: sizeof(SVnodeCfg) < TSDB_FILE_HEADER_LEN/4
|
||||
typedef struct {
|
||||
char acct[TSDB_USER_LEN];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
char db[TSDB_METER_ID_LEN+2]; // 8bytes align
|
||||
uint32_t vgId;
|
||||
int32_t maxSessions;
|
||||
int32_t cacheBlockSize;
|
||||
|
|
|
@ -57,12 +57,12 @@ extern char scriptDir[];
|
|||
|
||||
extern char tsMasterIp[];
|
||||
extern char tsSecondIp[];
|
||||
extern short tsMgmtVnodePort;
|
||||
extern short tsMgmtShellPort;
|
||||
extern short tsVnodeShellPort;
|
||||
extern short tsVnodeVnodePort;
|
||||
extern short tsMgmtMgmtPort;
|
||||
extern short tsMgmtSyncPort;
|
||||
extern uint16_t tsMgmtVnodePort;
|
||||
extern uint16_t tsMgmtShellPort;
|
||||
extern uint16_t tsVnodeShellPort;
|
||||
extern uint16_t tsVnodeVnodePort;
|
||||
extern uint16_t tsMgmtMgmtPort;
|
||||
extern uint16_t tsMgmtSyncPort;
|
||||
|
||||
extern int tsStatusInterval;
|
||||
extern int tsShellActivityTimer;
|
||||
|
@ -141,7 +141,7 @@ extern int tsProjectExecInterval;
|
|||
extern int64_t tsMaxRetentWindow;
|
||||
|
||||
extern char tsHttpIp[];
|
||||
extern short tsHttpPort;
|
||||
extern uint16_t tsHttpPort;
|
||||
extern int tsHttpCacheSessions;
|
||||
extern int tsHttpSessionExpire;
|
||||
extern int tsHttpMaxThreads;
|
||||
|
@ -150,6 +150,8 @@ extern int tsHttpEnableRecordSql;
|
|||
extern int tsTelegrafUseFieldNum;
|
||||
extern int tsAdminRowLimit;
|
||||
|
||||
extern int tsTscEnableRecordSql;
|
||||
|
||||
extern char tsMonitorDbName[];
|
||||
extern char tsInternalPass[];
|
||||
extern int tsMonitorInterval;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_TNOTE_H
|
||||
#define TDENGINE_TNOTE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "unistd.h"
|
||||
#include "os.h"
|
||||
#include "tutil.h"
|
||||
#include "tglobalcfg.h"
|
||||
|
||||
#define MAX_NOTE_LINE_SIZE 66000
|
||||
#define NOTE_FILE_NAME_LEN 300
|
||||
|
||||
typedef struct _taosNoteInfo {
|
||||
int taosNoteFileNum ;
|
||||
int taosNoteMaxLines;
|
||||
int taosNoteLines;
|
||||
char taosNoteName[NOTE_FILE_NAME_LEN];
|
||||
int taosNoteFlag;
|
||||
int taosNoteFd;
|
||||
int taosNoteOpenInProgress;
|
||||
pthread_mutex_t taosNoteMutex;
|
||||
}taosNoteInfo;
|
||||
|
||||
void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...);
|
||||
|
||||
extern taosNoteInfo m_HttpNote;
|
||||
extern taosNoteInfo m_TscNote;
|
||||
|
||||
extern int tsHttpEnableRecordSql;
|
||||
extern int tsTscEnableRecordSql;
|
||||
|
||||
#define taosNotePrintHttp(...) \
|
||||
if (tsHttpEnableRecordSql) { \
|
||||
taosNotePrint(&m_HttpNote, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define taosNotePrintTsc(...) \
|
||||
if (tsTscEnableRecordSql) { \
|
||||
taosNotePrint(&m_TscNote, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
char *localIp; // local IP used
|
||||
short localPort; // local port
|
||||
uint16_t localPort; // local port
|
||||
char *label; // for debug purpose
|
||||
int numOfThreads; // number of threads to handle connections
|
||||
void *(*fp)(char *, void *, void *); // function to process the incoming msg
|
||||
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
void * shandle; // pointer returned by taosOpenRpc
|
||||
void * ahandle; // handle provided by app
|
||||
char * peerIp; // peer IP string
|
||||
short peerPort; // peer port
|
||||
uint16_t peerPort; // peer port
|
||||
char spi; // security parameter index
|
||||
char encrypt; // encrypt algorithm
|
||||
char * secret; // key for authentication
|
||||
|
@ -107,7 +107,7 @@ int taosSendSimpleRsp(void *thandle, char rsptype, char code);
|
|||
|
||||
int taosSetSecurityInfo(int cid, int sid, char *id, int spi, int encrypt, char *secret, char *ckey);
|
||||
|
||||
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, short *peerPort, int *cid, int *sid);
|
||||
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid);
|
||||
|
||||
int taosGetOutType(void *thandle);
|
||||
|
||||
|
|
|
@ -33,19 +33,19 @@ int taosWriteMsg(int fd, void *ptr, int nbytes);
|
|||
|
||||
int taosReadMsg(int fd, void *ptr, int nbytes);
|
||||
|
||||
int taosOpenUdpSocket(char *ip, short port);
|
||||
int taosOpenUdpSocket(char *ip, uint16_t port);
|
||||
|
||||
int taosOpenTcpClientSocket(char *ip, short port, char *localIp);
|
||||
int taosOpenTcpClientSocket(char *ip, uint16_t port, char *localIp);
|
||||
|
||||
int taosOpenTcpServerSocket(char *ip, short port);
|
||||
int taosOpenTcpServerSocket(char *ip, uint16_t port);
|
||||
|
||||
int taosKeepTcpAlive(int sockFd);
|
||||
|
||||
void taosCloseTcpSocket(int sockFd);
|
||||
|
||||
int taosOpenUDServerSocket(char *ip, short port);
|
||||
int taosOpenUDServerSocket(char *ip, uint16_t port);
|
||||
|
||||
int taosOpenUDClientSocket(char *ip, short port);
|
||||
int taosOpenUDClientSocket(char *ip, uint16_t port);
|
||||
|
||||
int taosOpenRawSocket(char *ip);
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ extern "C" {
|
|||
#define TK_OCT 204 // oct number
|
||||
#define TK_BIN 205 // bin format data 0b111
|
||||
#define TK_FILE 206
|
||||
#define TK_QUESTION 207 // denoting the placeholder of "?",when invoking statement bind query
|
||||
|
||||
#define TSQL_SO_ASC 1
|
||||
#define TSQL_SO_DESC 0
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
#define TK_TABLE 62
|
||||
#define TK_DATABASE 63
|
||||
#define TK_DNODE 64
|
||||
#define TK_IP 65
|
||||
#define TK_IPTOKEN 65
|
||||
#define TK_USER 66
|
||||
#define TK_ACCOUNT 67
|
||||
#define TK_USE 68
|
||||
|
@ -210,7 +210,6 @@
|
|||
#define TK_JOIN 192
|
||||
#define TK_METRICS 193
|
||||
#define TK_STABLE 194
|
||||
#define TK_QUESTION 195
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static struct argp_option options[] = {
|
|||
/* Used by main to communicate with parse_opt. */
|
||||
struct arguments {
|
||||
char *host;
|
||||
int port;
|
||||
uint16_t port;
|
||||
char *user;
|
||||
char *password;
|
||||
char *database;
|
||||
|
@ -310,7 +310,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
enum MODE query_mode = arguments.mode;
|
||||
char *ip_addr = arguments.host;
|
||||
int port = arguments.port;
|
||||
uint16_t port = arguments.port;
|
||||
char *user = arguments.user;
|
||||
char *pass = arguments.password;
|
||||
char *db_name = arguments.database;
|
||||
|
@ -343,7 +343,7 @@ int main(int argc, char *argv[]) {
|
|||
struct tm tm = *localtime(&tTime);
|
||||
|
||||
fprintf(fp, "###################################################################\n");
|
||||
fprintf(fp, "# Server IP: %s:%d\n", ip_addr == NULL ? "localhost" : ip_addr, port);
|
||||
fprintf(fp, "# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port);
|
||||
fprintf(fp, "# User: %s\n", user);
|
||||
fprintf(fp, "# Password: %s\n", pass);
|
||||
fprintf(fp, "# Use metric: %s\n", use_metric ? "true" : "false");
|
||||
|
|
|
@ -172,7 +172,7 @@ struct arguments {
|
|||
char *host;
|
||||
char *user;
|
||||
char *password;
|
||||
int port;
|
||||
uint16_t port;
|
||||
// output file
|
||||
char output[TSDB_FILENAME_LEN + 1];
|
||||
char input[TSDB_FILENAME_LEN + 1];
|
||||
|
|
|
@ -210,7 +210,7 @@ typedef struct HttpThread {
|
|||
typedef struct _http_server_obj_ {
|
||||
char label[HTTP_LABEL_SIZE];
|
||||
char serverIp[16];
|
||||
short serverPort;
|
||||
uint16_t serverPort;
|
||||
int cacheContext;
|
||||
int sessionExpire;
|
||||
int numOfThreads;
|
||||
|
@ -233,7 +233,7 @@ bool httpCheckUsedbSql(char *sql);
|
|||
void httpTimeToString(time_t t, char *buf, int buflen);
|
||||
|
||||
// http init method
|
||||
void *httpInitServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle);
|
||||
void *httpInitServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle);
|
||||
void httpCleanUpServer(HttpServer *pServer);
|
||||
|
||||
// http server connection
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "httpResp.h"
|
||||
#include "taos.h"
|
||||
#include "tsclient.h"
|
||||
#include "tnote.h"
|
||||
|
||||
void *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *param, void **taos);
|
||||
void httpProcessMultiSql(HttpContext *pContext);
|
||||
void taosNotePrint(const char * const format, ...);
|
||||
|
||||
void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows) {
|
||||
HttpContext *pContext = (HttpContext *)param;
|
||||
|
@ -165,7 +165,7 @@ void httpProcessMultiSql(HttpContext *pContext) {
|
|||
char *sql = httpGetCmdsString(pContext, cmd->sql);
|
||||
httpDump("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start query, sql:%s", pContext, pContext->fd,
|
||||
pContext->ipstr, pContext->user, multiCmds->pos, sql);
|
||||
taosNotePrint(sql);
|
||||
taosNotePrintHttp(sql);
|
||||
taos_query_a(pContext->session->taos, sql, httpProcessMultiSqlCallBack, (void *)pContext);
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) {
|
|||
|
||||
httpDump("context:%p, fd:%d, ip:%s, user:%s, start query, sql:%s", pContext, pContext->fd, pContext->ipstr,
|
||||
pContext->user, sql);
|
||||
taosNotePrint(sql);
|
||||
taosNotePrintHttp(sql);
|
||||
taos_query_a(pSession->taos, sql, httpProcessSingleSqlCallBack, (void *)pContext);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#endif
|
||||
|
||||
static HttpServer *httpServer = NULL;
|
||||
void taosInitNote(int numOfNoteLines, int maxNotes);
|
||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
||||
|
||||
int httpInitSystem() {
|
||||
taos_init();
|
||||
|
@ -61,7 +61,7 @@ int httpInitSystem() {
|
|||
pthread_mutex_init(&httpServer->serverMutex, NULL);
|
||||
|
||||
if (tsHttpEnableRecordSql != 0) {
|
||||
taosInitNote(tsNumOfLogLines / 10, 1);
|
||||
taosInitNote(tsNumOfLogLines / 10, 1, (char*)"http_note");
|
||||
}
|
||||
restInitHandle(httpServer);
|
||||
adminInitHandle(httpServer);
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct {
|
|||
|
||||
MonitorConn *monitor = NULL;
|
||||
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int),
|
||||
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
|
||||
void *param, void **taos);
|
||||
void monitorInitConn(void *para, void *unused);
|
||||
void monitorInitConnCb(void *param, TAOS_RES *result, int code);
|
||||
|
|
|
@ -170,12 +170,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle
|
|||
return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen);
|
||||
}
|
||||
|
||||
int taosOpenUDClientSocket(char *ip, short port) {
|
||||
int taosOpenUDClientSocket(char *ip, uint16_t port) {
|
||||
int sockFd = 0;
|
||||
struct sockaddr_un serverAddr;
|
||||
int ret;
|
||||
char name[128];
|
||||
sprintf(name, "%s.%d", ip, port);
|
||||
sprintf(name, "%s.%hu", ip, port);
|
||||
|
||||
sockFd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
|
@ -198,13 +198,13 @@ int taosOpenUDClientSocket(char *ip, short port) {
|
|||
return sockFd;
|
||||
}
|
||||
|
||||
int taosOpenUDServerSocket(char *ip, short port) {
|
||||
int taosOpenUDServerSocket(char *ip, uint16_t port) {
|
||||
struct sockaddr_un serverAdd;
|
||||
int sockFd;
|
||||
char name[128];
|
||||
|
||||
pTrace("open ud socket:%s", name);
|
||||
sprintf(name, "%s.%d", ip, port);
|
||||
sprintf(name, "%s.%hu", ip, port);
|
||||
|
||||
bzero((char *)&serverAdd, sizeof(serverAdd));
|
||||
serverAdd.sun_family = AF_UNIX;
|
||||
|
@ -295,7 +295,7 @@ void taosGetSystemInfo() {
|
|||
taosGetSystemLocale();
|
||||
}
|
||||
|
||||
void *taosInitTcpClient(char *ip, short port, char *flabel, int num, void *fp, void *shandle) {
|
||||
void *taosInitTcpClient(char *ip, uint16_t port, char *flabel, int num, void *fp, void *shandle) {
|
||||
tError("function taosInitTcpClient is not implemented in darwin system, exit!");
|
||||
exit(0);
|
||||
}
|
||||
|
@ -305,12 +305,12 @@ void taosCloseTcpClientConnection(void *chandle) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) {
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
|
||||
tError("function taosOpenTcpClientConnection is not implemented in darwin system, exit!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int taosSendTcpClientData(unsigned int ip, short port, char *data, int len, void *chandle) {
|
||||
int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
|
||||
tError("function taosSendTcpClientData is not implemented in darwin system, exit!");
|
||||
exit(0);
|
||||
}
|
||||
|
@ -330,12 +330,12 @@ void taosCleanUpTcpServer(void *handle) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) {
|
||||
void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
|
||||
tError("function taosInitTcpServer is not implemented in darwin system, exit!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int taosSendTcpServerData(unsigned int ip, short port, char *data, int len, void *chandle) {
|
||||
int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
|
||||
tError("function taosSendTcpServerData is not implemented in darwin system, exit!");
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -163,12 +163,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle
|
|||
return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen);
|
||||
}
|
||||
|
||||
int taosOpenUDClientSocket(char *ip, short port) {
|
||||
int taosOpenUDClientSocket(char *ip, uint16_t port) {
|
||||
int sockFd = 0;
|
||||
struct sockaddr_un serverAddr;
|
||||
int ret;
|
||||
char name[128];
|
||||
sprintf(name, "%s.%d", ip, port);
|
||||
sprintf(name, "%s.%hu", ip, port);
|
||||
|
||||
sockFd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
|
@ -191,13 +191,13 @@ int taosOpenUDClientSocket(char *ip, short port) {
|
|||
return sockFd;
|
||||
}
|
||||
|
||||
int taosOpenUDServerSocket(char *ip, short port) {
|
||||
int taosOpenUDServerSocket(char *ip, uint16_t port) {
|
||||
struct sockaddr_un serverAdd;
|
||||
int sockFd;
|
||||
char name[128];
|
||||
|
||||
pTrace("open ud socket:%s", name);
|
||||
sprintf(name, "%s.%d", ip, port);
|
||||
sprintf(name, "%s.%hu", ip, port);
|
||||
|
||||
bzero((char *)&serverAdd, sizeof(serverAdd));
|
||||
serverAdd.sun_family = AF_UNIX;
|
||||
|
|
|
@ -586,9 +586,13 @@ void taosKillSystem() {
|
|||
kill(tsProcId, 2);
|
||||
}
|
||||
|
||||
|
||||
extern int tsEnableCoreFile;
|
||||
int _sysctl(struct __sysctl_args *args );
|
||||
void taosSetCoreDump() {
|
||||
if (0 == tsEnableCoreFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. set ulimit -c unlimited
|
||||
struct rlimit rlim;
|
||||
struct rlimit rlim_new;
|
||||
|
@ -608,6 +612,7 @@ void taosSetCoreDump() {
|
|||
pPrint("the new unlimited para: rlim_cur=%d, rlim_max=%d", rlim.rlim_cur, rlim.rlim_max);
|
||||
}
|
||||
|
||||
#ifndef _TD_ARM_
|
||||
// 2. set the path for saving core file
|
||||
struct __sysctl_args args;
|
||||
int old_usespid = 0;
|
||||
|
@ -649,9 +654,10 @@ void taosSetCoreDump() {
|
|||
}
|
||||
|
||||
pPrint("The new core_uses_pid[%d]: %d", old_len, old_usespid);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// 3. set the path for saving core file
|
||||
// 3. create the path for saving core file
|
||||
int status;
|
||||
char coredump_dir[32] = "/var/log/taosdump";
|
||||
if (opendir(coredump_dir) == NULL) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "tlog.h"
|
||||
|
||||
void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle) {
|
||||
void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
|
||||
tError("InitTcpClient not support in windows");
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ void taosCloseTcpClientConnection(void *chandle) {
|
|||
tError("CloseTcpClientConnection not support in windows");
|
||||
}
|
||||
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) {
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
|
||||
tError("OpenTcpClientConnection not support in windows");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int taosSendTcpClientData(unsigned int ip, short port, char *data, int len, void *chandle) {
|
||||
int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
|
||||
tError("SendTcpClientData not support in windows");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ void taosCleanUpTcpServer(void *handle) {
|
|||
tError("CleanUpTcpServer not support in windows");
|
||||
}
|
||||
|
||||
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) {
|
||||
void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
|
||||
tError("InitTcpServer not support in windows");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int taosSendTcpServerData(unsigned int ip, short port, char *data, int len, void *chandle) {
|
||||
int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
|
||||
tError("SendTcpServerData not support in windows");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
void *taosOpenIpHash(int maxSessions);
|
||||
void taosCloseIpHash(void *handle);
|
||||
void *taosAddIpHash(void *handle, void *pData, uint32_t ip, short port);
|
||||
void taosDeleteIpHash(void *handle, uint32_t ip, short port);
|
||||
void *taosGetIpHash(void *handle, uint32_t ip, short port);
|
||||
void *taosAddIpHash(void *handle, void *pData, uint32_t ip, uint16_t port);
|
||||
void taosDeleteIpHash(void *handle, uint32_t ip, uint16_t port);
|
||||
void *taosGetIpHash(void *handle, uint32_t ip, uint16_t port);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
#include "tsdb.h"
|
||||
|
||||
void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle);
|
||||
void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle);
|
||||
void taosCleanUpTcpClient(void *chandle);
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port);
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port);
|
||||
void taosCloseTcpClientConnection(void *chandle);
|
||||
int taosSendTcpClientData(uint32_t ip, short port, char *data, int len, void *chandle);
|
||||
int taosSendTcpClientData(uint32_t ip, uint16_t port, char *data, int len, void *chandle);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
#include "tsdb.h"
|
||||
|
||||
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle);
|
||||
void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle);
|
||||
void taosCleanUpTcpServer(void *param);
|
||||
void taosCloseTcpServerConnection(void *param);
|
||||
int taosSendTcpServerData(uint32_t ip, short port, char *data, int len, void *chandle);
|
||||
int taosSendTcpServerData(uint32_t ip, uint16_t port, char *data, int len, void *chandle);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
#include "tsdb.h"
|
||||
|
||||
void *taosInitUdpServer(char *ip, short port, char *label, int, void *fp, void *shandle);
|
||||
void *taosInitUdpClient(char *ip, short port, char *label, int, void *fp, void *shandle);
|
||||
void *taosInitUdpServer(char *ip, uint16_t port, char *label, int, void *fp, void *shandle);
|
||||
void *taosInitUdpClient(char *ip, uint16_t port, char *label, int, void *fp, void *shandle);
|
||||
void taosCleanUpUdpConnection(void *handle);
|
||||
int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chandle);
|
||||
void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port);
|
||||
int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle);
|
||||
void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, uint16_t port);
|
||||
|
||||
void taosFreeMsgHdr(void *hdr);
|
||||
int taosMsgHdrSize(void *hdr);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
typedef struct _ip_hash_t {
|
||||
uint32_t ip;
|
||||
short port;
|
||||
uint16_t port;
|
||||
int hash;
|
||||
struct _ip_hash_t *prev;
|
||||
struct _ip_hash_t *next;
|
||||
|
@ -32,20 +32,20 @@ typedef struct {
|
|||
int maxSessions;
|
||||
} SHashObj;
|
||||
|
||||
int taosHashIp(void *handle, uint32_t ip, short port) {
|
||||
int taosHashIp(void *handle, uint32_t ip, uint16_t port) {
|
||||
SHashObj *pObj = (SHashObj *)handle;
|
||||
int hash = 0;
|
||||
|
||||
hash = (int)(ip >> 16);
|
||||
hash += (unsigned short)(ip & 0xFFFF);
|
||||
hash += (unsigned short)port;
|
||||
hash += port;
|
||||
|
||||
hash = hash % pObj->maxSessions;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) {
|
||||
void *taosAddIpHash(void *handle, void *data, uint32_t ip, uint16_t port) {
|
||||
int hash;
|
||||
SIpHash * pNode;
|
||||
SHashObj *pObj;
|
||||
|
@ -68,7 +68,7 @@ void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) {
|
|||
return pObj;
|
||||
}
|
||||
|
||||
void taosDeleteIpHash(void *handle, uint32_t ip, short port) {
|
||||
void taosDeleteIpHash(void *handle, uint32_t ip, uint16_t port) {
|
||||
int hash;
|
||||
SIpHash * pNode;
|
||||
SHashObj *pObj;
|
||||
|
@ -100,7 +100,7 @@ void taosDeleteIpHash(void *handle, uint32_t ip, short port) {
|
|||
}
|
||||
}
|
||||
|
||||
void *taosGetIpHash(void *handle, uint32_t ip, short port) {
|
||||
void *taosGetIpHash(void *handle, uint32_t ip, uint16_t port) {
|
||||
int hash;
|
||||
SIpHash * pNode;
|
||||
SHashObj *pObj;
|
||||
|
|
|
@ -51,10 +51,10 @@ typedef struct {
|
|||
uint8_t secret[TSDB_KEY_LEN];
|
||||
uint8_t ckey[TSDB_KEY_LEN];
|
||||
|
||||
short localPort; // for UDP only
|
||||
uint16_t localPort; // for UDP only
|
||||
uint32_t peerUid;
|
||||
uint32_t peerIp; // peer IP
|
||||
short peerPort; // peer port
|
||||
uint16_t peerPort; // peer port
|
||||
char peerIpstr[20]; // peer IP string
|
||||
uint16_t tranId; // outgoing transcation ID, for build message
|
||||
uint16_t outTranId; // outgoing transcation ID
|
||||
|
@ -99,7 +99,7 @@ typedef struct rpc_server {
|
|||
int idleTime; // milliseconds;
|
||||
int noFree; // do not free the request msg when rsp is received
|
||||
int index; // for UDP server, next thread for new connection
|
||||
short localPort;
|
||||
uint16_t localPort;
|
||||
char label[12];
|
||||
void *(*fp)(char *, void *ahandle, void *thandle);
|
||||
void (*efp)(int); // FP to report error
|
||||
|
@ -114,16 +114,16 @@ int tsRpcProgressTime = 10; // milliseocnds
|
|||
int tsRpcMaxRetry;
|
||||
int tsRpcHeadSize;
|
||||
|
||||
void *(*taosInitConn[])(char *ip, short port, char *label, int threads, void *fp, void *shandle) = {
|
||||
void *(*taosInitConn[])(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) = {
|
||||
taosInitUdpServer, taosInitUdpClient, taosInitTcpServer, taosInitTcpClient};
|
||||
|
||||
void (*taosCleanUpConn[])(void *thandle) = {taosCleanUpUdpConnection, taosCleanUpUdpConnection, taosCleanUpTcpServer,
|
||||
taosCleanUpTcpClient};
|
||||
|
||||
int (*taosSendData[])(uint32_t ip, short port, char *data, int len, void *chandle) = {
|
||||
int (*taosSendData[])(uint32_t ip, uint16_t port, char *data, int len, void *chandle) = {
|
||||
taosSendUdpData, taosSendUdpData, taosSendTcpServerData, taosSendTcpClientData};
|
||||
|
||||
void *(*taosOpenConn[])(void *shandle, void *thandle, char *ip, short port) = {
|
||||
void *(*taosOpenConn[])(void *shandle, void *thandle, char *ip, uint16_t port) = {
|
||||
taosOpenUdpConnection,
|
||||
taosOpenUdpConnection,
|
||||
NULL,
|
||||
|
@ -134,7 +134,7 @@ void (*taosCloseConn[])(void *chandle) = {NULL, NULL, taosCloseTcpServerConnecti
|
|||
|
||||
int taosReSendRspToPeer(SRpcConn *pConn);
|
||||
void taosProcessTaosTimer(void *, void *);
|
||||
void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle,
|
||||
void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle,
|
||||
void *chandle);
|
||||
int taosSendDataToPeer(SRpcConn *pConn, char *data, int dataLen);
|
||||
void taosProcessSchedMsg(SSchedMsg *pMsg);
|
||||
|
@ -720,7 +720,7 @@ void taosProcessResponse(SRpcConn *pConn) {
|
|||
}
|
||||
|
||||
int taosProcessMsgHeader(STaosHeader *pHeader, SRpcConn **ppConn, STaosRpc *pServer, int dataLen, uint32_t ip,
|
||||
short port, void *chandle) {
|
||||
uint16_t port, void *chandle) {
|
||||
int chann, sid, code = 0;
|
||||
SRpcConn * pConn = NULL;
|
||||
SRpcChann *pChann;
|
||||
|
@ -1009,7 +1009,7 @@ void taosProcessIdleTimer(void *param, void *tmrId) {
|
|||
pthread_mutex_unlock(&pChann->mutex);
|
||||
}
|
||||
|
||||
void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle,
|
||||
void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle,
|
||||
void *chandle) {
|
||||
STaosHeader *pHeader;
|
||||
uint8_t code;
|
||||
|
@ -1075,6 +1075,7 @@ void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port,
|
|||
// parsing error
|
||||
|
||||
if (pHeader->msgType & 1) {
|
||||
memset(pReply, 0, sizeof(pReply));
|
||||
msgLen = taosBuildErrorMsgToPeer(data, code, pReply);
|
||||
(*taosSendData[pServer->type])(ip, port, pReply, msgLen, chandle);
|
||||
tTrace("%s cid:%d sid:%d id:%s, %s is sent with error code:%u pConn:%p", pServer->label, chann, sid,
|
||||
|
@ -1311,7 +1312,7 @@ void taosProcessTaosTimer(void *param, void *tmrId) {
|
|||
|
||||
}
|
||||
|
||||
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, short *peerPort, int *cid, int *sid) {
|
||||
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid) {
|
||||
SRpcConn *pConn = (SRpcConn *)thandle;
|
||||
|
||||
*peerId = pConn->peerId;
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct _tcp_fd {
|
|||
void * thandle;
|
||||
uint32_t ip;
|
||||
char ipstr[20];
|
||||
short port;
|
||||
uint16_t port;
|
||||
struct _tcp_client *pTcp;
|
||||
struct _tcp_fd * prev, *next;
|
||||
} STcpFd;
|
||||
|
@ -45,7 +45,7 @@ typedef struct _tcp_client {
|
|||
char label[12];
|
||||
char ipstr[20];
|
||||
void * shandle; // handle passed by upper layer during server initialization
|
||||
void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle,
|
||||
void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle,
|
||||
void *chandle);
|
||||
// char buffer[128000];
|
||||
} STcpClient;
|
||||
|
@ -194,7 +194,7 @@ static void *taosReadTcpData(void *param) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle) {
|
||||
void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
|
||||
STcpClient * pTcp;
|
||||
pthread_attr_t thattr;
|
||||
|
||||
|
@ -229,7 +229,7 @@ void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, vo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tTrace("%s TCP client is initialized, ip:%s port:%u", label, ip, port);
|
||||
tTrace("%s TCP client is initialized, ip:%s port:%hu", label, ip, port);
|
||||
|
||||
return pTcp;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ void taosCloseTcpClientConnection(void *chandle) {
|
|||
taosCleanUpTcpFdObj(pFdObj);
|
||||
}
|
||||
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) {
|
||||
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
|
||||
STcpClient * pTcp = (STcpClient *)shandle;
|
||||
STcpFd * pFdObj;
|
||||
struct epoll_event event;
|
||||
|
@ -301,12 +301,12 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short
|
|||
|
||||
pthread_mutex_unlock(&(pTcp->mutex));
|
||||
|
||||
tTrace("%s TCP connection to ip:%s port:%u is created, numOfFds:%d", pTcp->label, ip, port, pTcp->numOfFds);
|
||||
tTrace("%s TCP connection to ip:%s port:%hu is created, numOfFds:%d", pTcp->label, ip, port, pTcp->numOfFds);
|
||||
|
||||
return pFdObj;
|
||||
}
|
||||
|
||||
int taosSendTcpClientData(uint32_t ip, short port, char *data, int len, void *chandle) {
|
||||
int taosSendTcpClientData(uint32_t ip, uint16_t port, char *data, int len, void *chandle) {
|
||||
STcpFd *pFdObj = (STcpFd *)chandle;
|
||||
|
||||
if (chandle == NULL) return -1;
|
||||
|
|
|
@ -32,7 +32,7 @@ typedef struct _fd_obj {
|
|||
void * thandle; // handle from upper layer, like TAOS
|
||||
char ipstr[TAOS_IPv4ADDR_LEN];
|
||||
unsigned int ip;
|
||||
unsigned short port;
|
||||
uint16_t port;
|
||||
struct _thread_obj *pThreadObj;
|
||||
struct _fd_obj * prev, *next;
|
||||
} SFdObj;
|
||||
|
@ -48,13 +48,13 @@ typedef struct _thread_obj {
|
|||
char label[12];
|
||||
// char buffer[128000]; // buffer to receive data
|
||||
void *shandle; // handle passed by upper layer during server initialization
|
||||
void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle,
|
||||
void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle,
|
||||
void *chandle);
|
||||
} SThreadObj;
|
||||
|
||||
typedef struct {
|
||||
char ip[40];
|
||||
short port;
|
||||
uint16_t port;
|
||||
char label[12];
|
||||
int numOfThreads;
|
||||
void * shandle;
|
||||
|
@ -209,7 +209,7 @@ static void taosProcessTcpData(void *param) {
|
|||
continue;
|
||||
}
|
||||
|
||||
pFdObj->thandle = (*(pThreadObj->processData))(buffer, dataLen, pFdObj->ip, (int16_t)pFdObj->port,
|
||||
pFdObj->thandle = (*(pThreadObj->processData))(buffer, dataLen, pFdObj->ip, pFdObj->port,
|
||||
pThreadObj->shandle, pFdObj->thandle, pFdObj);
|
||||
|
||||
if (pFdObj->thandle == NULL) taosCleanUpFdObj(pFdObj);
|
||||
|
@ -232,10 +232,10 @@ void taosAcceptTcpConnection(void *arg) {
|
|||
sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port);
|
||||
|
||||
if (sockFd < 0) {
|
||||
tError("%s failed to open TCP socket, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
tError("%s failed to open TCP socket, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
return;
|
||||
} else {
|
||||
tTrace("%s TCP server is ready, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
tTrace("%s TCP server is ready, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -247,7 +247,7 @@ void taosAcceptTcpConnection(void *arg) {
|
|||
continue;
|
||||
}
|
||||
|
||||
tTrace("%s TCP connection from ip:%s port:%u", pServerObj->label, inet_ntoa(clientAddr.sin_addr),
|
||||
tTrace("%s TCP connection from ip:%s port:%hu", pServerObj->label, inet_ntoa(clientAddr.sin_addr),
|
||||
htons(clientAddr.sin_port));
|
||||
taosKeepTcpAlive(connFd);
|
||||
|
||||
|
@ -292,7 +292,7 @@ void taosAcceptTcpConnection(void *arg) {
|
|||
|
||||
pthread_mutex_unlock(&(pThreadObj->threadMutex));
|
||||
|
||||
tTrace("%s TCP thread:%d, a new connection, ip:%s port:%u, numOfFds:%d", pServerObj->label, pThreadObj->threadId,
|
||||
tTrace("%s TCP thread:%d, a new connection, ip:%s port:%hu, numOfFds:%d", pServerObj->label, pThreadObj->threadId,
|
||||
pFdObj->ipstr, pFdObj->port, pThreadObj->numOfFds);
|
||||
|
||||
// pick up next thread for next connection
|
||||
|
@ -314,10 +314,10 @@ void taosAcceptUDConnection(void *arg) {
|
|||
sockFd = taosOpenUDServerSocket(pServerObj->ip, pServerObj->port);
|
||||
|
||||
if (sockFd < 0) {
|
||||
tError("%s failed to open UD socket, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
tError("%s failed to open UD socket, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
return;
|
||||
} else {
|
||||
tTrace("%s UD server is ready, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
tTrace("%s UD server is ready, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -374,7 +374,7 @@ void taosAcceptUDConnection(void *arg) {
|
|||
}
|
||||
}
|
||||
|
||||
void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) {
|
||||
void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
|
||||
int i;
|
||||
SServerObj * pServerObj;
|
||||
pthread_attr_t thattr;
|
||||
|
@ -442,7 +442,7 @@ void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, voi
|
|||
}
|
||||
*/
|
||||
pthread_attr_destroy(&thattr);
|
||||
tTrace("%s TCP server is initialized, ip:%s port:%u numOfThreads:%d", label, ip, port, numOfThreads);
|
||||
tTrace("%s TCP server is initialized, ip:%s port:%hu numOfThreads:%d", label, ip, port, numOfThreads);
|
||||
|
||||
return (void *)pServerObj;
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ void taosListTcpConnection(void *handle, char *buffer) {
|
|||
msg = msg + strlen(msg);
|
||||
pFdObj = pThreadObj->pHead;
|
||||
while (pFdObj) {
|
||||
sprintf(" ip:%s port:%u\n", pFdObj->ipstr, pFdObj->port);
|
||||
sprintf(" ip:%s port:%hu\n", pFdObj->ipstr, pFdObj->port);
|
||||
msg = msg + strlen(msg);
|
||||
numOfFds++;
|
||||
numOfConns++;
|
||||
|
@ -487,7 +487,7 @@ void taosListTcpConnection(void *handle, char *buffer) {
|
|||
return;
|
||||
}
|
||||
|
||||
int taosSendTcpServerData(uint32_t ip, short port, char *data, int len, void *chandle) {
|
||||
int taosSendTcpServerData(uint32_t ip, uint16_t port, char *data, int len, void *chandle) {
|
||||
SFdObj *pFdObj = (SFdObj *)chandle;
|
||||
|
||||
if (chandle == NULL) return -1;
|
||||
|
|
|
@ -35,8 +35,8 @@ typedef struct {
|
|||
void * signature;
|
||||
int index;
|
||||
int fd;
|
||||
short port; // peer port
|
||||
short localPort; // local port
|
||||
uint16_t port; // peer port
|
||||
uint16_t localPort; // local port
|
||||
char label[12]; // copy from udpConnSet;
|
||||
pthread_t thread;
|
||||
pthread_mutex_t mutex;
|
||||
|
@ -44,7 +44,7 @@ typedef struct {
|
|||
void * hash;
|
||||
void * shandle; // handle passed by upper layer during server initialization
|
||||
void * pSet;
|
||||
void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle,
|
||||
void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle,
|
||||
void *chandle);
|
||||
char buffer[RPC_MAX_UDP_SIZE]; // buffer to receive data
|
||||
} SUdpConn;
|
||||
|
@ -53,21 +53,21 @@ typedef struct {
|
|||
int index;
|
||||
int server;
|
||||
char ip[16]; // local IP
|
||||
short port; // local Port
|
||||
uint16_t port; // local Port
|
||||
void * shandle; // handle passed by upper layer during server initialization
|
||||
int threads;
|
||||
char label[12];
|
||||
void * tmrCtrl;
|
||||
pthread_t tcpThread;
|
||||
int tcpFd;
|
||||
void *(*fp)(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, void *chandle);
|
||||
void *(*fp)(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle, void *chandle);
|
||||
SUdpConn udpConn[];
|
||||
} SUdpConnSet;
|
||||
|
||||
typedef struct {
|
||||
void * signature;
|
||||
uint32_t ip; // dest IP
|
||||
short port; // dest Port
|
||||
uint16_t port; // dest Port
|
||||
SUdpConn * pConn;
|
||||
struct sockaddr_in destAdd;
|
||||
void * msgHdr;
|
||||
|
@ -144,12 +144,12 @@ void *taosReadTcpData(void *argv) {
|
|||
pInfo->msgLen = (int32_t)htonl((uint32_t)pInfo->msgLen);
|
||||
|
||||
tinet_ntoa(ipstr, pMonitor->ip);
|
||||
tTrace("%s receive packet via TCP:%s:%d, msgLen:%d, handle:0x%x, source:0x%08x dest:0x%08x tranId:%d", pSet->label,
|
||||
tTrace("%s receive packet via TCP:%s:%hu, msgLen:%d, handle:0x%x, source:0x%08x dest:0x%08x tranId:%d", pSet->label,
|
||||
ipstr, pInfo->port, pInfo->msgLen, pInfo->handle, pHead->sourceId, pHead->destId, pHead->tranId);
|
||||
|
||||
fd = taosOpenTcpClientSocket(ipstr, (int16_t)pInfo->port, tsLocalIp);
|
||||
if (fd < 0) {
|
||||
tError("%s failed to open TCP client socket ip:%s:%d", pSet->label, ipstr, pInfo->port);
|
||||
tError("%s failed to open TCP client socket ip:%s:%hu", pSet->label, ipstr, pInfo->port);
|
||||
pMonitor->pSet = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void *taosReadTcpData(void *argv) {
|
|||
tError("%s failed to read data from server, msgLen:%d retLen:%d", pSet->label, pInfo->msgLen, retLen);
|
||||
tfree(buffer);
|
||||
} else {
|
||||
(*pSet->fp)(buffer, pInfo->msgLen, pMonitor->ip, (int16_t)pInfo->port, pSet->shandle, NULL, pMonitor->pConn);
|
||||
(*pSet->fp)(buffer, pInfo->msgLen, pMonitor->ip, pInfo->port, pSet->shandle, NULL, pMonitor->pConn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ void *taosRecvUdpData(void *param) {
|
|||
struct sockaddr_in sourceAdd;
|
||||
unsigned int addLen, dataLen;
|
||||
SUdpConn * pConn = (SUdpConn *)param;
|
||||
short port;
|
||||
uint16_t port;
|
||||
int minSize = sizeof(STaosHeader);
|
||||
|
||||
memset(&sourceAdd, 0, sizeof(sourceAdd));
|
||||
|
@ -242,7 +242,7 @@ void *taosRecvUdpData(void *param) {
|
|||
continue;
|
||||
}
|
||||
|
||||
port = (int16_t)ntohs(sourceAdd.sin_port);
|
||||
port = ntohs(sourceAdd.sin_port);
|
||||
|
||||
int processedLen = 0, leftLen = 0;
|
||||
int msgLen = 0;
|
||||
|
@ -307,7 +307,7 @@ void *taosTransferDataViaTcp(void *argv) {
|
|||
|
||||
if (handle == 0) {
|
||||
// receive a packet from client
|
||||
tTrace("%s data will be received via TCP from 0x%x:%d", pSet->label, pTransfer->ip, pTransfer->port);
|
||||
tTrace("%s data will be received via TCP from 0x%x:%hu", pSet->label, pTransfer->ip, pTransfer->port);
|
||||
retLen = taosReadMsg(connFd, &head, sizeof(STaosHeader));
|
||||
if (retLen != (int)sizeof(STaosHeader)) {
|
||||
tError("%s failed to read msg header, retLen:%d", pSet->label, retLen);
|
||||
|
@ -345,7 +345,7 @@ void *taosTransferDataViaTcp(void *argv) {
|
|||
tError("%s failed to read data from client, leftLen:%d retLen:%d, error:%s", pSet->label, leftLen, retLen,
|
||||
strerror(errno));
|
||||
} else {
|
||||
tTrace("%s data is received from client via TCP from 0x%x:%d, msgLen:%d", pSet->label, pTransfer->ip,
|
||||
tTrace("%s data is received from client via TCP from 0x%x:%hu, msgLen:%d", pSet->label, pTransfer->ip,
|
||||
pTransfer->port, msgLen);
|
||||
pSet->index = (pSet->index + 1) % pSet->threads;
|
||||
SUdpConn *pConn = pSet->udpConn + pSet->index;
|
||||
|
@ -388,7 +388,7 @@ void *taosTransferDataViaTcp(void *argv) {
|
|||
if (retLen != msgLen) {
|
||||
tError("%s failed to send data to client, msgLen:%d retLen:%d", pSet->label, msgLen, retLen);
|
||||
} else {
|
||||
tTrace("%s data is sent to client successfully via TCP to 0x%x:%d, size:%d", pSet->label, pTransfer->ip,
|
||||
tTrace("%s data is sent to client successfully via TCP to 0x%x:%hu, size:%d", pSet->label, pTransfer->ip,
|
||||
pTransfer->port, msgLen);
|
||||
}
|
||||
}
|
||||
|
@ -413,13 +413,13 @@ void *taosUdpTcpConnection(void *argv) {
|
|||
|
||||
pSet->tcpFd = taosOpenTcpServerSocket(pSet->ip, pSet->port);
|
||||
if (pSet->tcpFd < 0) {
|
||||
tPrint("%s failed to create TCP socket %s:%d for UDP server, reason:%s", pSet->label, pSet->ip, pSet->port,
|
||||
tPrint("%s failed to create TCP socket %s:%hu for UDP server, reason:%s", pSet->label, pSet->ip, pSet->port,
|
||||
strerror(errno));
|
||||
taosKillSystem();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tTrace("%s UDP server is created, ip:%s:%d", pSet->label, pSet->ip, pSet->port);
|
||||
tTrace("%s UDP server is created, ip:%s:%hu", pSet->label, pSet->ip, pSet->port);
|
||||
|
||||
pthread_attr_init(&thattr);
|
||||
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED);
|
||||
|
@ -455,7 +455,7 @@ void *taosUdpTcpConnection(void *argv) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void *fp, void *shandle) {
|
||||
void *taosInitUdpConnection(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) {
|
||||
pthread_attr_t thAttr;
|
||||
SUdpConn * pConn;
|
||||
SUdpConnSet * pSet;
|
||||
|
@ -488,13 +488,13 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void
|
|||
pthread_attr_init(&thAttr);
|
||||
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
short ownPort;
|
||||
uint16_t ownPort;
|
||||
for (int i = 0; i < threads; ++i) {
|
||||
pConn = pSet->udpConn + i;
|
||||
ownPort = (int16_t)(port ? port + i : 0);
|
||||
ownPort = (port ? port + i : 0);
|
||||
pConn->fd = taosOpenUdpSocket(ip, ownPort);
|
||||
if (pConn->fd < 0) {
|
||||
tError("%s failed to open UDP socket %s:%d", label, ip, port);
|
||||
tError("%s failed to open UDP socket %s:%hu", label, ip, port);
|
||||
taosCleanUpUdpConnection(pSet);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -529,12 +529,12 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void
|
|||
}
|
||||
|
||||
pthread_attr_destroy(&thAttr);
|
||||
tTrace("%s UDP connection is initialized, ip:%s port:%u threads:%d", label, ip, port, threads);
|
||||
tTrace("%s UDP connection is initialized, ip:%s port:%hu threads:%d", label, ip, port, threads);
|
||||
|
||||
return pSet;
|
||||
}
|
||||
|
||||
void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp, void *shandle) {
|
||||
void *taosInitUdpServer(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) {
|
||||
SUdpConnSet *pSet;
|
||||
pSet = taosInitUdpConnection(ip, port, label, threads, fp, shandle);
|
||||
if (pSet == NULL) return NULL;
|
||||
|
@ -555,7 +555,7 @@ void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp
|
|||
return pSet;
|
||||
}
|
||||
|
||||
void *taosInitUdpClient(char *ip, short port, char *label, int threads, void *fp, void *shandle) {
|
||||
void *taosInitUdpClient(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) {
|
||||
return taosInitUdpConnection(ip, port, label, threads, fp, shandle);
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ void taosCleanUpUdpConnection(void *handle) {
|
|||
tfree(pSet);
|
||||
}
|
||||
|
||||
void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port) {
|
||||
void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
|
||||
SUdpConnSet *pSet = (SUdpConnSet *)shandle;
|
||||
|
||||
pSet->index = (pSet->index + 1) % pSet->threads;
|
||||
|
@ -599,7 +599,7 @@ void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port)
|
|||
SUdpConn *pConn = pSet->udpConn + pSet->index;
|
||||
pConn->port = port;
|
||||
|
||||
tTrace("%s UDP connection is setup, ip: %s:%d, local: %s:%d", pConn->label, ip, port, pSet->ip,
|
||||
tTrace("%s UDP connection is setup, ip: %s:%hu, local: %s:%d", pConn->label, ip, port, pSet->ip,
|
||||
ntohs((uint16_t)pConn->localPort));
|
||||
|
||||
return pConn;
|
||||
|
@ -643,7 +643,7 @@ void taosProcessUdpBufTimer(void *param, void *tmrId) {
|
|||
if (pBuf) taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer);
|
||||
}
|
||||
|
||||
SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) {
|
||||
SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, uint16_t port) {
|
||||
SUdpBuf *pBuf = (SUdpBuf *)malloc(sizeof(SUdpBuf));
|
||||
memset(pBuf, 0, sizeof(SUdpBuf));
|
||||
|
||||
|
@ -653,7 +653,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) {
|
|||
|
||||
pBuf->destAdd.sin_family = AF_INET;
|
||||
pBuf->destAdd.sin_addr.s_addr = ip;
|
||||
pBuf->destAdd.sin_port = (uint16_t)htons((uint16_t)port);
|
||||
pBuf->destAdd.sin_port = (uint16_t)htons(port);
|
||||
taosInitMsgHdr(&(pBuf->msgHdr), &(pBuf->destAdd), RPC_MAX_UDP_PKTS);
|
||||
pBuf->signature = pBuf;
|
||||
taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer);
|
||||
|
@ -664,7 +664,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) {
|
|||
return pBuf;
|
||||
}
|
||||
|
||||
int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void *chandle) {
|
||||
int taosSendPacketViaTcp(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle) {
|
||||
SUdpConn * pConn = (SUdpConn *)chandle;
|
||||
SUdpConnSet *pSet = (SUdpConnSet *)pConn->pSet;
|
||||
int code = -1, retLen, msgLen;
|
||||
|
@ -681,13 +681,13 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void
|
|||
|
||||
SPacketInfo *pInfo = (SPacketInfo *)pHead->content;
|
||||
pInfo->handle = (uint64_t)data;
|
||||
pInfo->port = (uint16_t)pSet->port;
|
||||
pInfo->port = pSet->port;
|
||||
pInfo->msgLen = pHead->msgLen;
|
||||
|
||||
msgLen = sizeof(STaosHeader) + sizeof(SPacketInfo);
|
||||
pHead->msgLen = (int32_t)htonl((uint32_t)msgLen);
|
||||
code = taosSendUdpData(ip, port, buffer, msgLen, chandle);
|
||||
tTrace("%s data from server will be sent via TCP:%d, msgType:%d, length:%d, handle:0x%x", pSet->label, pInfo->port,
|
||||
tTrace("%s data from server will be sent via TCP:%hu, msgType:%d, length:%d, handle:0x%x", pSet->label, pInfo->port,
|
||||
pHead->msgType, htonl((uint32_t)pInfo->msgLen), pInfo->handle);
|
||||
if (code > 0) code = dataLen;
|
||||
} else {
|
||||
|
@ -707,7 +707,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void
|
|||
tinet_ntoa(ipstr, ip);
|
||||
int fd = taosOpenTcpClientSocket(ipstr, pConn->port, tsLocalIp);
|
||||
if (fd < 0) {
|
||||
tError("%s failed to open TCP socket to:%s:%u to send packet", pSet->label, ipstr, pConn->port);
|
||||
tError("%s failed to open TCP socket to:%s:%hu to send packet", pSet->label, ipstr, pConn->port);
|
||||
} else {
|
||||
SHandleViaTcp handleViaTcp;
|
||||
taosInitHandleViaTcp(&handleViaTcp, 0);
|
||||
|
@ -735,7 +735,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void
|
|||
return code;
|
||||
}
|
||||
|
||||
int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chandle) {
|
||||
int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle) {
|
||||
SUdpConn *pConn = (SUdpConn *)chandle;
|
||||
SUdpBuf * pBuf;
|
||||
|
||||
|
@ -748,7 +748,7 @@ int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chan
|
|||
memset(&destAdd, 0, sizeof(destAdd));
|
||||
destAdd.sin_family = AF_INET;
|
||||
destAdd.sin_addr.s_addr = ip;
|
||||
destAdd.sin_port = htons((uint16_t)port);
|
||||
destAdd.sin_port = htons(port);
|
||||
|
||||
int ret = (int)sendto(pConn->fd, data, (size_t)dataLen, 0, (struct sockaddr *)&destAdd, sizeof(destAdd));
|
||||
tTrace("%s msg is sent to 0x%x:%hu len:%d ret:%d localPort:%hu chandle:0x%x", pConn->label, destAdd.sin_addr.s_addr,
|
||||
|
|
|
@ -146,7 +146,7 @@ typedef struct _vg_obj {
|
|||
} SVgObj;
|
||||
|
||||
typedef struct _db_obj {
|
||||
char name[TSDB_DB_NAME_LEN + 1];
|
||||
char name[TSDB_METER_ID_LEN + 1];
|
||||
int64_t createdTime;
|
||||
SDbCfg cfg;
|
||||
int32_t numOfVgroups;
|
||||
|
@ -222,7 +222,7 @@ typedef struct _connObj {
|
|||
uint32_t queryId; // query ID to be killed
|
||||
uint32_t streamId; // stream ID to be killed
|
||||
uint32_t ip; // shell IP
|
||||
short port; // shell port
|
||||
uint16_t port; // shell port
|
||||
void * thandle;
|
||||
SQList * pQList; // query list
|
||||
SSList * pSList; // stream list
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
|||
int sid;
|
||||
int vnode;
|
||||
uint32_t ip;
|
||||
short port;
|
||||
uint16_t port;
|
||||
int count; // track the number of imports
|
||||
int code; // track the code of imports
|
||||
int numOfTotalPoints; // track the total number of points imported
|
||||
|
|
|
@ -81,6 +81,8 @@ int32_t vnodeSetMeterState(SMeterObj* pMeterObj, int32_t state);
|
|||
void vnodeClearMeterState(SMeterObj* pMeterObj, int32_t state);
|
||||
bool vnodeIsMeterState(SMeterObj* pMeterObj, int32_t state);
|
||||
void vnodeSetMeterDeleting(SMeterObj* pMeterObj);
|
||||
int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st);
|
||||
|
||||
bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid);
|
||||
void vnodeFreeColumnInfo(SColumnInfo* pColumnInfo);
|
||||
bool isGroupbyNormalCol(SSqlGroupbyExpr* pExpr);
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
|||
char user[TSDB_METER_ID_LEN];
|
||||
uint64_t stime;
|
||||
uint32_t ip;
|
||||
short port;
|
||||
uint16_t port;
|
||||
} SConnInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
typedef struct {
|
||||
uint32_t ip;
|
||||
short port;
|
||||
uint16_t port;
|
||||
char user[TSDB_METER_ID_LEN];
|
||||
} SCDesc;
|
||||
|
||||
|
@ -180,7 +180,7 @@ int mgmtKillQuery(char *qidstr, SConnObj *pConn) {
|
|||
chr = strchr(temp, ':');
|
||||
if (chr == NULL) goto _error;
|
||||
*chr = 0;
|
||||
short port = htons(atoi(temp));
|
||||
uint16_t port = htons(atoi(temp));
|
||||
|
||||
temp = chr + 1;
|
||||
uint32_t queryId = atoi(temp);
|
||||
|
@ -448,7 +448,7 @@ int mgmtKillStream(char *qidstr, SConnObj *pConn) {
|
|||
chr = strchr(temp, ':');
|
||||
if (chr == NULL) goto _error;
|
||||
*chr = 0;
|
||||
short port = htons(atoi(temp));
|
||||
uint16_t port = htons(atoi(temp));
|
||||
|
||||
temp = chr + 1;
|
||||
uint32_t streamId = atoi(temp);
|
||||
|
|
|
@ -1280,7 +1280,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
|
|||
if (pConn->pUser) {
|
||||
pConn->pAcct = mgmtGetAcct(pConn->pUser->acct);
|
||||
mgmtEstablishConn(pConn);
|
||||
mTrace("login from:%x:%d", pConn->ip, htons(pConn->port));
|
||||
mTrace("login from:%x:%hu", pConn->ip, htons(pConn->port));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -286,12 +286,9 @@ void vnodeProcessImportTimer(void *param, void *tmrId) {
|
|||
SShellObj *pShell = pImport->pShell;
|
||||
|
||||
pImport->retry++;
|
||||
|
||||
//slow query will block the import operation
|
||||
int32_t state = vnodeSetMeterState(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
if (state >= TSDB_METER_STATE_DELETING) {
|
||||
dError("vid:%d sid:%d id:%s, meter is deleted, failed to import, state:%d",
|
||||
pObj->vnode, pObj->sid, pObj->meterId, state);
|
||||
|
||||
int32_t code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
if (code == TSDB_CODE_NOT_ACTIVE_TABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -303,14 +300,14 @@ void vnodeProcessImportTimer(void *param, void *tmrId) {
|
|||
//if the num == 0, it will never be increased before state is set to TSDB_METER_STATE_READY
|
||||
int32_t commitInProcess = 0;
|
||||
pthread_mutex_lock(&pPool->vmutex);
|
||||
if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0 || state != TSDB_METER_STATE_READY) {
|
||||
if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0 || code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
pthread_mutex_unlock(&pPool->vmutex);
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
|
||||
if (pImport->retry < 1000) {
|
||||
dTrace("vid:%d sid:%d id:%s, import failed, retry later. commit in process or queries on it, or not ready."
|
||||
"commitInProcess:%d, numOfQueries:%d, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
|
||||
commitInProcess, num, state);
|
||||
commitInProcess, num, pObj->state);
|
||||
|
||||
taosTmrStart(vnodeProcessImportTimer, 10, pImport, vnodeTmrCtrl);
|
||||
return;
|
||||
|
@ -320,15 +317,14 @@ void vnodeProcessImportTimer(void *param, void *tmrId) {
|
|||
} else {
|
||||
pPool->commitInProcess = 1;
|
||||
pthread_mutex_unlock(&pPool->vmutex);
|
||||
int code = vnodeImportData(pObj, pImport);
|
||||
int32_t ret = vnodeImportData(pObj, pImport);
|
||||
if (pShell) {
|
||||
pShell->code = code;
|
||||
pShell->code = ret;
|
||||
pShell->numOfTotalPoints += pImport->importedRows;
|
||||
}
|
||||
}
|
||||
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
|
||||
pVnode->version++;
|
||||
|
||||
// send response back to shell
|
||||
|
@ -702,8 +698,8 @@ int vnodeFindKeyInFile(SImportInfo *pImport, int order) {
|
|||
|
||||
if (pImport->key != key && pImport->pos > 0) {
|
||||
if ( pObj->sversion != pBlock->sversion ) {
|
||||
dError("vid:%d sid:%d id:%s, import sversion not matached, expected:%d received:%d", pObj->vnode, pObj->sid,
|
||||
pBlock->sversion, pObj->sversion);
|
||||
dError("vid:%d sid:%d id:%s, import sversion not matched, expected:%d received:%d", pObj->vnode, pObj->sid,
|
||||
pObj->meterId, pBlock->sversion, pObj->sversion);
|
||||
code = TSDB_CODE_OTHERS;
|
||||
} else {
|
||||
pImport->offset = pBlock->offset;
|
||||
|
@ -912,16 +908,12 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
}
|
||||
|
||||
if (*((TSKEY *)(pSubmit->payLoad + (rows - 1) * pObj->bytesPerPoint)) > pObj->lastKey) {
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
vnodeSetMeterState(pObj, TSDB_METER_STATE_INSERT);
|
||||
code = vnodeInsertPoints(pObj, cont, contLen, TSDB_DATA_SOURCE_LOG, NULL, pObj->sversion, &pointsImported, now);
|
||||
|
||||
if (pShell) {
|
||||
pShell->code = code;
|
||||
pShell->numOfTotalPoints += pointsImported;
|
||||
}
|
||||
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
|
||||
} else {
|
||||
SImportInfo *pNew, import;
|
||||
|
||||
|
@ -933,7 +925,11 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
import.pShell = pShell;
|
||||
import.payload = payload;
|
||||
import.rows = rows;
|
||||
|
||||
|
||||
if ((code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_IMPORTING)) != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t num = 0;
|
||||
pthread_mutex_lock(&pVnode->vmutex);
|
||||
num = pObj->numOfQueries;
|
||||
|
@ -944,7 +940,8 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
pthread_mutex_lock(&pPool->vmutex);
|
||||
if (((commitInProcess = pPool->commitInProcess) == 1) || num > 0) {
|
||||
pthread_mutex_unlock(&pPool->vmutex);
|
||||
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
|
||||
pNew = (SImportInfo *)malloc(sizeof(SImportInfo));
|
||||
memcpy(pNew, &import, sizeof(SImportInfo));
|
||||
pNew->signature = pNew;
|
||||
|
@ -956,19 +953,25 @@ int vnodeImportPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
dTrace("vid:%d sid:%d id:%s, import later, commit in process:%d, numOfQueries:%d", pObj->vnode, pObj->sid,
|
||||
pObj->meterId, commitInProcess, pObj->numOfQueries);
|
||||
|
||||
/*
|
||||
* vnodeProcessImportTimer will set the import status for this table, so need to
|
||||
* set the import flag here
|
||||
*/
|
||||
taosTmrStart(vnodeProcessImportTimer, 10, pNew, vnodeTmrCtrl);
|
||||
return 0;
|
||||
} else {
|
||||
pPool->commitInProcess = 1;
|
||||
pthread_mutex_unlock(&pPool->vmutex);
|
||||
int code = vnodeImportData(pObj, &import);
|
||||
|
||||
int ret = vnodeImportData(pObj, &import);
|
||||
if (pShell) {
|
||||
pShell->code = code;
|
||||
pShell->code = ret;
|
||||
pShell->numOfTotalPoints += import.importedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_IMPORTING);
|
||||
pVnode->version++;
|
||||
|
||||
if (pShell) {
|
||||
|
|
|
@ -572,7 +572,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
dTrace("vid:%d sid:%d id:%s, cache is full, freePoints:%d, notFreeSlots:%d", pObj->vnode, pObj->sid, pObj->meterId,
|
||||
pObj->freePoints, pPool->notFreeSlots);
|
||||
vnodeProcessCommitTimer(pVnode, NULL);
|
||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
// FIXME: Here should be after the comparison of sversions.
|
||||
|
@ -596,7 +596,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
}
|
||||
|
||||
pData = pSubmit->payLoad;
|
||||
code = 0;
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
|
||||
TSKEY firstKey = *((TSKEY *)pData);
|
||||
TSKEY lastKey = *((TSKEY *)(pData + pObj->bytesPerPoint * (numOfPoints - 1)));
|
||||
|
@ -608,9 +608,12 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
pObj->vnode, pObj->sid, pObj->meterId, pVnode->lastKeyOnFile, numOfPoints,firstKey, lastKey, minAllowedKey, maxAllowedKey);
|
||||
return TSDB_CODE_TIMESTAMP_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
for (i = 0; i < numOfPoints; ++i) {
|
||||
// meter will be dropped, abort current insertion
|
||||
|
||||
if ((code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_INSERT)) != TSDB_CODE_SUCCESS) {
|
||||
goto _over;
|
||||
}
|
||||
|
||||
for (i = 0; i < numOfPoints; ++i) { // meter will be dropped, abort current insertion
|
||||
if (pObj->state >= TSDB_METER_STATE_DELETING) {
|
||||
dWarn("vid:%d sid:%d id:%s, meter is dropped, abort insert, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
|
||||
pObj->state);
|
||||
|
@ -652,6 +655,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
pVnode->version++;
|
||||
|
||||
pthread_mutex_unlock(&(pVnode->vmutex));
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
|
||||
|
||||
_over:
|
||||
dTrace("vid:%d sid:%d id:%s, %d out of %d points are inserted, lastKey:%ld source:%d, vnode total storage: %ld",
|
||||
|
|
|
@ -48,7 +48,7 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
|
|||
SShellObj *pObj = (SShellObj *)ahandle;
|
||||
SIntMsg * pMsg = (SIntMsg *)msg;
|
||||
uint32_t peerId, peerIp;
|
||||
short peerPort;
|
||||
uint16_t peerPort;
|
||||
char ipstr[20];
|
||||
|
||||
if (msg == NULL) {
|
||||
|
@ -566,40 +566,15 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) {
|
|||
int subMsgLen = sizeof(pBlocks->numOfRows) + htons(pBlocks->numOfRows) * pMeterObj->bytesPerPoint;
|
||||
int sversion = htonl(pBlocks->sversion);
|
||||
|
||||
int32_t state = TSDB_METER_STATE_READY;
|
||||
if (pSubmit->import) {
|
||||
state = vnodeSetMeterState(pMeterObj, TSDB_METER_STATE_IMPORTING);
|
||||
code = vnodeImportPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, pObj,
|
||||
sversion, &numOfPoints, now);
|
||||
} else {
|
||||
state = vnodeSetMeterState(pMeterObj, TSDB_METER_STATE_INSERT);
|
||||
code = vnodeInsertPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, NULL,
|
||||
sversion, &numOfPoints, now);
|
||||
}
|
||||
|
||||
if (state == TSDB_METER_STATE_READY) {
|
||||
// meter status is ready for insert/import
|
||||
if (pSubmit->import) {
|
||||
code = vnodeImportPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, pObj,
|
||||
sversion, &numOfPoints, now);
|
||||
vnodeClearMeterState(pMeterObj, TSDB_METER_STATE_IMPORTING);
|
||||
} else {
|
||||
code = vnodeInsertPoints(pMeterObj, (char *) &(pBlocks->numOfRows), subMsgLen, TSDB_DATA_SOURCE_SHELL, NULL,
|
||||
sversion, &numOfPoints, now);
|
||||
vnodeClearMeterState(pMeterObj, TSDB_METER_STATE_INSERT);
|
||||
}
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {break;}
|
||||
} else {
|
||||
if (vnodeIsMeterState(pMeterObj, TSDB_METER_STATE_DELETING)) {
|
||||
dTrace("vid:%d sid:%d id:%s, it is removed, state:%d", pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId,
|
||||
pMeterObj->state);
|
||||
code = TSDB_CODE_NOT_ACTIVE_TABLE;
|
||||
break;
|
||||
} else {// waiting for 300ms by default and try again
|
||||
dTrace("vid:%d sid:%d id:%s, try submit again since in state:%d", pMeterObj->vnode, pMeterObj->sid,
|
||||
pMeterObj->meterId, pMeterObj->state);
|
||||
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {break;}
|
||||
|
||||
numOfTotalPoints += numOfPoints;
|
||||
pBlocks = (SShellSubmitBlock *)((char *)pBlocks + sizeof(SShellSubmitBlock) +
|
||||
|
|
|
@ -56,14 +56,11 @@ void vnodeProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
|
|||
contLen += sizeof(SSubmitMsg);
|
||||
|
||||
int32_t numOfPoints = 0;
|
||||
int32_t code = vnodeInsertPoints(pObj, (char *)pMsg, contLen, TSDB_DATA_SOURCE_SHELL, NULL, pObj->sversion,
|
||||
&numOfPoints, taosGetTimestamp(vnodeList[pObj->vnode].cfg.precision));
|
||||
|
||||
int32_t state = vnodeSetMeterState(pObj, TSDB_METER_STATE_INSERT);
|
||||
if (state == TSDB_METER_STATE_READY) {
|
||||
vnodeInsertPoints(pObj, (char *)pMsg, contLen, TSDB_DATA_SOURCE_SHELL, NULL, pObj->sversion, &numOfPoints, taosGetTimestamp(vnodeList[pObj->vnode].cfg.precision));
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
|
||||
} else {
|
||||
dError("vid:%d sid:%d id:%s, failed to insert continuous query results, state:%d", pObj->vnode, pObj->sid,
|
||||
pObj->meterId, state);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
dError("vid:%d sid:%d id:%s, failed to insert continuous query results", pObj->vnode, pObj->sid, pObj->meterId);
|
||||
}
|
||||
|
||||
assert(numOfPoints >= 0 && numOfPoints <= 1);
|
||||
|
|
|
@ -668,6 +668,26 @@ void vnodeSetMeterDeleting(SMeterObj* pMeterObj) {
|
|||
pMeterObj->state |= TSDB_METER_STATE_DELETING;
|
||||
}
|
||||
|
||||
int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
int32_t state = vnodeSetMeterState(pObj, st);
|
||||
if (state != TSDB_METER_STATE_READY) {//return to denote import is not performed
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
|
||||
dTrace("vid:%d sid:%d id:%s, meter is deleted, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
|
||||
pObj->state);
|
||||
code = TSDB_CODE_NOT_ACTIVE_TABLE;
|
||||
} else {// waiting for 300ms by default and try again
|
||||
dTrace("vid:%d sid:%d id:%s, try submit again since in state:%d", pObj->vnode, pObj->sid,
|
||||
pObj->meterId, pObj->state);
|
||||
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid) {
|
||||
SMeterObj* pObj = pVnode->meterList[sid];
|
||||
|
||||
|
|
2357
src/util/src/sql.c
2357
src/util/src/sql.c
File diff suppressed because it is too large
Load Diff
|
@ -58,12 +58,12 @@ int64_t tsMsPerDay[] = {86400000L, 86400000000L};
|
|||
|
||||
char tsMasterIp[TSDB_IPv4ADDR_LEN] = {0};
|
||||
char tsSecondIp[TSDB_IPv4ADDR_LEN] = {0};
|
||||
short tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030]
|
||||
short tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035]
|
||||
short tsMgmtVnodePort = 6040; // udp[6040-6044] tcp[6040]
|
||||
short tsVnodeVnodePort = 6045; // tcp[6045]
|
||||
short tsMgmtMgmtPort = 6050; // udp, numOfVnodes fixed to 1, range udp[6050]
|
||||
short tsMgmtSyncPort = 6050; // tcp, range tcp[6050]
|
||||
uint16_t tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030]
|
||||
uint16_t tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035]
|
||||
uint16_t tsMgmtVnodePort = 6040; // udp[6040-6044] tcp[6040]
|
||||
uint16_t tsVnodeVnodePort = 6045; // tcp[6045]
|
||||
uint16_t tsMgmtMgmtPort = 6050; // udp, numOfVnodes fixed to 1, range udp[6050]
|
||||
uint16_t tsMgmtSyncPort = 6050; // tcp, range tcp[6050]
|
||||
|
||||
int tsStatusInterval = 1; // second
|
||||
int tsShellActivityTimer = 3; // second
|
||||
|
@ -152,8 +152,8 @@ int tsProjectExecInterval = 10000; // every 10sec, the projection will be
|
|||
int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance
|
||||
|
||||
char tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0";
|
||||
short tsHttpPort = 6020; // only tcp, range tcp[6020]
|
||||
// short tsNginxPort = 6060; //only tcp, range tcp[6060]
|
||||
uint16_t tsHttpPort = 6020; // only tcp, range tcp[6020]
|
||||
// uint16_t tsNginxPort = 6060; //only tcp, range tcp[6060]
|
||||
int tsHttpCacheSessions = 100;
|
||||
int tsHttpSessionExpire = 36000;
|
||||
int tsHttpMaxThreads = 2;
|
||||
|
@ -162,6 +162,9 @@ int tsHttpEnableRecordSql = 0;
|
|||
int tsTelegrafUseFieldNum = 0;
|
||||
int tsAdminRowLimit = 10240;
|
||||
|
||||
int tsTscEnableRecordSql = 0;
|
||||
int tsEnableCoreFile = 0;
|
||||
|
||||
int tsRpcTimer = 300;
|
||||
int tsRpcMaxTime = 600; // seconds;
|
||||
|
||||
|
@ -767,6 +770,14 @@ static void doInitGlobalConfig() {
|
|||
0, 255, 0,
|
||||
TSDB_CFG_UTYPE_NONE);
|
||||
|
||||
tsInitConfigOption(cfg++, "tscEnableRecordSql", &tsTscEnableRecordSql, TSDB_CFG_VTYPE_INT,
|
||||
TSDB_CFG_CTYPE_B_CONFIG,
|
||||
1, 100000, 0, TSDB_CFG_UTYPE_NONE);
|
||||
|
||||
tsInitConfigOption(cfg++, "enableCoreFile", &tsEnableCoreFile, TSDB_CFG_VTYPE_INT,
|
||||
TSDB_CFG_CTYPE_B_CONFIG,
|
||||
1, 100000, 0, TSDB_CFG_UTYPE_NONE);
|
||||
|
||||
// version info
|
||||
tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING,
|
||||
TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT,
|
||||
|
@ -779,6 +790,7 @@ static void doInitGlobalConfig() {
|
|||
0, 0, 0, TSDB_CFG_UTYPE_NONE);
|
||||
|
||||
tsGlobalConfigNum = (int)(cfg - tsGlobalConfig);
|
||||
assert(tsGlobalConfigNum <= TSDB_CFG_MAX_NUM);
|
||||
}
|
||||
|
||||
static pthread_once_t initGlobalConfig = PTHREAD_ONCE_INIT;
|
||||
|
@ -1156,4 +1168,4 @@ void tsPrintGlobalConfigSpec() {
|
|||
pPrint(" dataDir: %s", dataDir);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -13,58 +13,50 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <semaphore.h>
|
||||
#include "tnote.h"
|
||||
|
||||
#include "os.h"
|
||||
#include "tutil.h"
|
||||
#include "tglobalcfg.h"
|
||||
taosNoteInfo m_HttpNote;
|
||||
taosNoteInfo m_TscNote;
|
||||
|
||||
#define MAX_NOTE_LINE_SIZE 66000
|
||||
#define NOTE_FILE_NAME_LEN 300
|
||||
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote);
|
||||
|
||||
static int taosNoteFileNum = 1;
|
||||
static int taosNoteMaxLines = 0;
|
||||
static int taosNoteLines = 0;
|
||||
static char taosNoteName[NOTE_FILE_NAME_LEN];
|
||||
static int taosNoteFlag = 0;
|
||||
static int taosNoteFd = -1;
|
||||
static int taosNoteOpenInProgress = 0;
|
||||
static pthread_mutex_t taosNoteMutex;
|
||||
void taosNotePrint(const char * const format, ...);
|
||||
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum);
|
||||
|
||||
void taosInitNote(int numOfNoteLines, int maxNotes)
|
||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable)
|
||||
{
|
||||
taosNoteInfo * pNote = NULL;
|
||||
char temp[128] = { 0 };
|
||||
sprintf(temp, "%s/taosnote", logDir);
|
||||
if (taosOpenNoteWithMaxLines(temp, numOfNoteLines, maxNotes) < 0)
|
||||
|
||||
if (strcasecmp(lable, "http_note") == 0) {
|
||||
pNote = &m_HttpNote;
|
||||
sprintf(temp, "%s/httpnote", logDir);
|
||||
} else if (strcasecmp(lable, "tsc_note") == 0) {
|
||||
pNote = &m_TscNote;
|
||||
sprintf(temp, "%s/tscnote-%d", logDir, getpid());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(pNote, 0, sizeof(taosNoteInfo));
|
||||
pNote->taosNoteFileNum = 1;
|
||||
//pNote->taosNoteMaxLines = 0;
|
||||
//pNote->taosNoteLines = 0;
|
||||
//pNote->taosNoteFlag = 0;
|
||||
pNote->taosNoteFd = -1;
|
||||
//pNote->taosNoteOpenInProgress = 0;
|
||||
|
||||
if (taosOpenNoteWithMaxLines(temp, numOfNoteLines, maxNotes, pNote) < 0)
|
||||
fprintf(stderr, "failed to init note file\n");
|
||||
|
||||
taosNotePrint("==================================================");
|
||||
taosNotePrint("=================== new note ===================");
|
||||
taosNotePrint("==================================================");
|
||||
taosNotePrint(pNote, "==================================================");
|
||||
taosNotePrint(pNote, "=================== new note ===================");
|
||||
taosNotePrint(pNote, "==================================================");
|
||||
}
|
||||
|
||||
void taosCloseNoteByFd(int oldFd);
|
||||
bool taosLockNote(int fd)
|
||||
void taosCloseNoteByFd(int oldFd, taosNoteInfo * pNote);
|
||||
bool taosLockNote(int fd, taosNoteInfo * pNote)
|
||||
{
|
||||
if (fd < 0) return false;
|
||||
|
||||
if (taosNoteFileNum > 1) {
|
||||
if (pNote->taosNoteFileNum > 1) {
|
||||
int ret = (int)(flock(fd, LOCK_EX | LOCK_NB));
|
||||
if (ret == 0) {
|
||||
return true;
|
||||
|
@ -74,11 +66,11 @@ bool taosLockNote(int fd)
|
|||
return false;
|
||||
}
|
||||
|
||||
void taosUnLockNote(int fd)
|
||||
void taosUnLockNote(int fd, taosNoteInfo * pNote)
|
||||
{
|
||||
if (fd < 0) return;
|
||||
|
||||
if (taosNoteFileNum > 1) {
|
||||
if (pNote->taosNoteFileNum > 1) {
|
||||
flock(fd, LOCK_UN | LOCK_NB);
|
||||
}
|
||||
}
|
||||
|
@ -86,50 +78,51 @@ void taosUnLockNote(int fd)
|
|||
void *taosThreadToOpenNewNote(void *param)
|
||||
{
|
||||
char name[NOTE_FILE_NAME_LEN];
|
||||
taosNoteInfo * pNote = (taosNoteInfo *)param;
|
||||
|
||||
taosNoteFlag ^= 1;
|
||||
taosNoteLines = 0;
|
||||
sprintf(name, "%s.%d", taosNoteName, taosNoteFlag);
|
||||
pNote->taosNoteFlag ^= 1;
|
||||
pNote->taosNoteLines = 0;
|
||||
sprintf(name, "%s.%d", pNote->taosNoteName, pNote->taosNoteFlag);
|
||||
|
||||
umask(0);
|
||||
|
||||
int fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
taosLockNote(fd);
|
||||
taosLockNote(fd, pNote);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
int oldFd = taosNoteFd;
|
||||
taosNoteFd = fd;
|
||||
taosNoteLines = 0;
|
||||
taosNoteOpenInProgress = 0;
|
||||
taosNotePrint("=============== new note is opened =============");
|
||||
int oldFd = pNote->taosNoteFd;
|
||||
pNote->taosNoteFd = fd;
|
||||
pNote->taosNoteLines = 0;
|
||||
pNote->taosNoteOpenInProgress = 0;
|
||||
taosNotePrint(pNote, "=============== new note is opened =============");
|
||||
|
||||
taosCloseNoteByFd(oldFd);
|
||||
taosCloseNoteByFd(oldFd, pNote);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int taosOpenNewNote()
|
||||
int taosOpenNewNote(taosNoteInfo * pNote)
|
||||
{
|
||||
pthread_mutex_lock(&taosNoteMutex);
|
||||
pthread_mutex_lock(&pNote->taosNoteMutex);
|
||||
|
||||
if (taosNoteLines > taosNoteMaxLines && taosNoteOpenInProgress == 0) {
|
||||
taosNoteOpenInProgress = 1;
|
||||
if (pNote->taosNoteLines > pNote->taosNoteMaxLines && pNote->taosNoteOpenInProgress == 0) {
|
||||
pNote->taosNoteOpenInProgress = 1;
|
||||
|
||||
taosNotePrint("=============== open new note ==================");
|
||||
taosNotePrint(pNote, "=============== open new note ==================");
|
||||
pthread_t pattern;
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
pthread_create(&pattern, &attr, taosThreadToOpenNewNote, NULL);
|
||||
pthread_create(&pattern, &attr, taosThreadToOpenNewNote, (void*)pNote);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&taosNoteMutex);
|
||||
pthread_mutex_unlock(&pNote->taosNoteMutex);
|
||||
|
||||
return taosNoteFd;
|
||||
return pNote->taosNoteFd;
|
||||
}
|
||||
|
||||
bool taosCheckNoteIsOpen(char *noteName)
|
||||
bool taosCheckNoteIsOpen(char *noteName, taosNoteInfo * pNote)
|
||||
{
|
||||
int exist = access(noteName, F_OK);
|
||||
if (exist != 0) {
|
||||
|
@ -142,8 +135,8 @@ bool taosCheckNoteIsOpen(char *noteName)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (taosLockNote(fd)) {
|
||||
taosUnLockNote(fd);
|
||||
if (taosLockNote(fd, pNote)) {
|
||||
taosUnLockNote(fd, pNote);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
@ -153,80 +146,80 @@ bool taosCheckNoteIsOpen(char *noteName)
|
|||
}
|
||||
}
|
||||
|
||||
void taosGetNoteName(char *fn)
|
||||
void taosGetNoteName(char *fn, taosNoteInfo * pNote)
|
||||
{
|
||||
if (taosNoteFileNum > 1) {
|
||||
for (int i = 0; i < taosNoteFileNum; i++) {
|
||||
if (pNote->taosNoteFileNum > 1) {
|
||||
for (int i = 0; i < pNote->taosNoteFileNum; i++) {
|
||||
char fileName[NOTE_FILE_NAME_LEN];
|
||||
|
||||
sprintf(fileName, "%s%d.0", fn, i);
|
||||
bool file1open = taosCheckNoteIsOpen(fileName);
|
||||
bool file1open = taosCheckNoteIsOpen(fileName, pNote);
|
||||
|
||||
sprintf(fileName, "%s%d.1", fn, i);
|
||||
bool file2open = taosCheckNoteIsOpen(fileName);
|
||||
bool file2open = taosCheckNoteIsOpen(fileName, pNote);
|
||||
|
||||
if (!file1open && !file2open) {
|
||||
sprintf(taosNoteName, "%s%d", fn, i);
|
||||
sprintf(pNote->taosNoteName, "%s%d", fn, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(taosNoteName, fn);
|
||||
strcpy(pNote->taosNoteName, fn);
|
||||
}
|
||||
|
||||
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum)
|
||||
int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote)
|
||||
{
|
||||
char name[NOTE_FILE_NAME_LEN] = "\0";
|
||||
struct stat notestat0, notestat1;
|
||||
int size;
|
||||
|
||||
taosNoteMaxLines = maxLines;
|
||||
taosNoteFileNum = maxNoteNum;
|
||||
taosGetNoteName(fn);
|
||||
pNote->taosNoteMaxLines = maxLines;
|
||||
pNote->taosNoteFileNum = maxNoteNum;
|
||||
taosGetNoteName(fn, pNote);
|
||||
|
||||
strcpy(name, fn);
|
||||
strcat(name, ".0");
|
||||
|
||||
// if none of the note files exist, open 0, if both exists, open the old one
|
||||
if (stat(name, ¬estat0) < 0) {
|
||||
taosNoteFlag = 0;
|
||||
pNote->taosNoteFlag = 0;
|
||||
}
|
||||
else {
|
||||
strcpy(name, fn);
|
||||
strcat(name, ".1");
|
||||
if (stat(name, ¬estat1) < 0) {
|
||||
taosNoteFlag = 1;
|
||||
pNote->taosNoteFlag = 1;
|
||||
}
|
||||
else {
|
||||
taosNoteFlag = (notestat0.st_mtime > notestat1.st_mtime) ? 0 : 1;
|
||||
pNote->taosNoteFlag = (notestat0.st_mtime > notestat1.st_mtime) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(name, "%s.%d", taosNoteName, taosNoteFlag);
|
||||
pthread_mutex_init(&taosNoteMutex, NULL);
|
||||
sprintf(name, "%s.%d", pNote->taosNoteName, pNote->taosNoteFlag);
|
||||
pthread_mutex_init(&pNote->taosNoteMutex, NULL);
|
||||
|
||||
umask(0);
|
||||
taosNoteFd = open(name, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
pNote->taosNoteFd = open(name, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
|
||||
if (taosNoteFd < 0) {
|
||||
if (pNote->taosNoteFd < 0) {
|
||||
fprintf(stderr, "failed to open note file:%s reason:%s\n", name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
taosLockNote(taosNoteFd);
|
||||
taosLockNote(pNote->taosNoteFd, pNote);
|
||||
|
||||
// only an estimate for number of lines
|
||||
struct stat filestat;
|
||||
fstat(taosNoteFd, &filestat);
|
||||
fstat(pNote->taosNoteFd, &filestat);
|
||||
size = (int)filestat.st_size;
|
||||
taosNoteLines = size / 60;
|
||||
pNote->taosNoteLines = size / 60;
|
||||
|
||||
lseek(taosNoteFd, 0, SEEK_END);
|
||||
lseek(pNote->taosNoteFd, 0, SEEK_END);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void taosNotePrint(const char * const format, ...)
|
||||
void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...)
|
||||
{
|
||||
va_list argpointer;
|
||||
char buffer[MAX_NOTE_LINE_SIZE];
|
||||
|
@ -238,7 +231,7 @@ void taosNotePrint(const char * const format, ...)
|
|||
gettimeofday(&timeSecs, NULL);
|
||||
curTime = timeSecs.tv_sec;
|
||||
ptm = localtime_r(&curTime, &Tm);
|
||||
len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int)timeSecs.tv_usec);
|
||||
len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %lx ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int)timeSecs.tv_usec, pthread_self());
|
||||
|
||||
va_start(argpointer, format);
|
||||
len += vsnprintf(buffer + len, MAX_NOTE_LINE_SIZE - len, format, argpointer);
|
||||
|
@ -249,26 +242,26 @@ void taosNotePrint(const char * const format, ...)
|
|||
buffer[len++] = '\n';
|
||||
buffer[len] = 0;
|
||||
|
||||
if (taosNoteFd >= 0) {
|
||||
twrite(taosNoteFd, buffer, (unsigned int)len);
|
||||
if (pNote->taosNoteFd >= 0) {
|
||||
twrite(pNote->taosNoteFd, buffer, (unsigned int)len);
|
||||
|
||||
if (taosNoteMaxLines > 0) {
|
||||
taosNoteLines++;
|
||||
if ((taosNoteLines > taosNoteMaxLines) && (taosNoteOpenInProgress == 0))
|
||||
taosOpenNewNote();
|
||||
if (pNote->taosNoteMaxLines > 0) {
|
||||
pNote->taosNoteLines++;
|
||||
if ((pNote->taosNoteLines > pNote->taosNoteMaxLines) && (pNote->taosNoteOpenInProgress == 0))
|
||||
taosOpenNewNote(pNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void taosCloseNote()
|
||||
void taosCloseNote(taosNoteInfo * pNote)
|
||||
{
|
||||
taosCloseNoteByFd(taosNoteFd);
|
||||
taosCloseNoteByFd(pNote->taosNoteFd, pNote);
|
||||
}
|
||||
|
||||
void taosCloseNoteByFd(int fd)
|
||||
void taosCloseNoteByFd(int fd, taosNoteInfo * pNote)
|
||||
{
|
||||
if (fd >= 0) {
|
||||
taosUnLockNote(fd);
|
||||
taosUnLockNote(fd, pNote);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,19 +261,19 @@ int taosReadn(int fd, char *ptr, int nbytes) {
|
|||
return (nbytes - nleft);
|
||||
}
|
||||
|
||||
int taosOpenUdpSocket(char *ip, short port) {
|
||||
int taosOpenUdpSocket(char *ip, uint16_t port) {
|
||||
struct sockaddr_in localAddr;
|
||||
int sockFd;
|
||||
int ttl = 128;
|
||||
int reuse, nocheck;
|
||||
int bufSize = 8192000;
|
||||
|
||||
pTrace("open udp socket:%s:%d", ip, port);
|
||||
pTrace("open udp socket:%s:%hu", ip, port);
|
||||
|
||||
memset((char *)&localAddr, 0, sizeof(localAddr));
|
||||
localAddr.sin_family = AF_INET;
|
||||
localAddr.sin_addr.s_addr = inet_addr(ip);
|
||||
localAddr.sin_port = (uint16_t)htons((uint16_t)port);
|
||||
localAddr.sin_port = (uint16_t)htons(port);
|
||||
|
||||
if ((sockFd = (int)socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
pError("failed to open udp socket: %d (%s)", errno, strerror(errno));
|
||||
|
@ -319,7 +319,7 @@ int taosOpenUdpSocket(char *ip, short port) {
|
|||
|
||||
/* bind socket to local address */
|
||||
if (bind(sockFd, (struct sockaddr *)&localAddr, sizeof(localAddr)) < 0) {
|
||||
pError("failed to bind udp socket: %d (%s), %s:%d", errno, strerror(errno), ip, port);
|
||||
pError("failed to bind udp socket: %d (%s), %s:%hu", errno, strerror(errno), ip, port);
|
||||
taosCloseSocket(sockFd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ int taosOpenUdpSocket(char *ip, short port) {
|
|||
return sockFd;
|
||||
}
|
||||
|
||||
int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) {
|
||||
int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) {
|
||||
int sockFd = 0;
|
||||
struct sockaddr_in serverAddr, clientAddr;
|
||||
int ret;
|
||||
|
@ -364,7 +364,7 @@ int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) {
|
|||
ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
|
||||
|
||||
if (ret != 0) {
|
||||
pError("failed to connect socket, ip:%s, port:%d, reason: %s", destIp, destPort, strerror(errno));
|
||||
pError("failed to connect socket, ip:%s, port:%hu, reason: %s", destIp, destPort, strerror(errno));
|
||||
taosCloseSocket(sockFd);
|
||||
sockFd = -1;
|
||||
}
|
||||
|
@ -422,17 +422,17 @@ int taosKeepTcpAlive(int sockFd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int taosOpenTcpServerSocket(char *ip, short port) {
|
||||
int taosOpenTcpServerSocket(char *ip, uint16_t port) {
|
||||
struct sockaddr_in serverAdd;
|
||||
int sockFd;
|
||||
int reuse;
|
||||
|
||||
pTrace("open tcp server socket:%s:%d", ip, port);
|
||||
pTrace("open tcp server socket:%s:%hu", ip, port);
|
||||
|
||||
bzero((char *)&serverAdd, sizeof(serverAdd));
|
||||
serverAdd.sin_family = AF_INET;
|
||||
serverAdd.sin_addr.s_addr = inet_addr(ip);
|
||||
serverAdd.sin_port = (uint16_t)htons((uint16_t)port);
|
||||
serverAdd.sin_port = (uint16_t)htons(port);
|
||||
|
||||
if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
|
||||
pError("failed to open TCP socket: %d (%s)", errno, strerror(errno));
|
||||
|
@ -449,7 +449,7 @@ int taosOpenTcpServerSocket(char *ip, short port) {
|
|||
|
||||
/* bind socket to server address */
|
||||
if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
|
||||
pError("bind tcp server socket failed, %s:%d, reason:%d(%s)", ip, port, errno, strerror(errno));
|
||||
pError("bind tcp server socket failed, %s:%hu, reason:%d(%s)", ip, port, errno, strerror(errno));
|
||||
close(sockFd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ int taosOpenTcpServerSocket(char *ip, short port) {
|
|||
if (taosKeepTcpAlive(sockFd) < 0) return -1;
|
||||
|
||||
if (listen(sockFd, 10) < 0) {
|
||||
pError("listen tcp server socket failed, %s:%d, reason:%d(%s)", ip, port, errno, strerror(errno));
|
||||
pError("listen tcp server socket failed, %s:%hu, reason:%d(%s)", ip, port, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "os.h"
|
||||
#include <inttypes.h>
|
||||
#include "tlog.h"
|
||||
#include "tsched.h"
|
||||
#include "ttime.h"
|
||||
|
@ -253,13 +254,13 @@ static void processExpiredTimer(void* handle, void* arg) {
|
|||
timer->executedBy = taosGetPthreadId();
|
||||
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
|
||||
if (state == TIMER_STATE_WAITING) {
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] execution start.";
|
||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] execution start.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
|
||||
(*timer->fp)(timer->param, (tmr_h)timer->id);
|
||||
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
|
||||
|
||||
fmt = "%s timer[id=%lld, fp=%p, param=%p] execution end.";
|
||||
fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] execution end.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
}
|
||||
removeTimer(timer->id);
|
||||
|
@ -267,7 +268,7 @@ static void processExpiredTimer(void* handle, void* arg) {
|
|||
}
|
||||
|
||||
static void addToExpired(tmr_obj_t* head) {
|
||||
const char* fmt = "%s adding expired timer[id=%lld, fp=%p, param=%p] to queue.";
|
||||
const char* fmt = "%s adding expired timer[id=" PRIuPTR ", fp=%p, param=%p] to queue.";
|
||||
|
||||
while (head != NULL) {
|
||||
uintptr_t id = head->id;
|
||||
|
@ -281,7 +282,7 @@ static void addToExpired(tmr_obj_t* head) {
|
|||
schedMsg.thandle = NULL;
|
||||
taosScheduleTask(tmrQhandle, &schedMsg);
|
||||
|
||||
tmrTrace("timer[id=%lld] has been added to queue.", id);
|
||||
tmrTrace("timer[id=" PRIuPTR "] has been added to queue.", id);
|
||||
head = next;
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +296,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon
|
|||
timer->ctrl = ctrl;
|
||||
addTimer(timer);
|
||||
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] started";
|
||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] started";
|
||||
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
|
||||
|
||||
if (mseconds == 0) {
|
||||
|
@ -380,40 +381,37 @@ static void taosTimerLoopFunc(int signo) {
|
|||
}
|
||||
|
||||
static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
||||
bool reusable = false;
|
||||
|
||||
if (state == TIMER_STATE_WAITING) {
|
||||
bool reusable = false;
|
||||
if (removeFromWheel(timer)) {
|
||||
removeTimer(timer->id);
|
||||
// only safe to reuse the timer when timer is removed from the wheel.
|
||||
// we cannot guarantee the thread safety of the timr in all other cases.
|
||||
reusable = true;
|
||||
}
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] is cancelled.";
|
||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] is cancelled.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
} else if (state != TIMER_STATE_EXPIRED) {
|
||||
return reusable;
|
||||
}
|
||||
|
||||
if (state != TIMER_STATE_EXPIRED) {
|
||||
// timer already stopped or cancelled, has nothing to do in this case
|
||||
} else if (timer->executedBy == taosGetPthreadId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (timer->executedBy == taosGetPthreadId()) {
|
||||
// taosTmrReset is called in the timer callback, should do nothing in this
|
||||
// case to avoid dead lock. note taosTmrReset must be the last statement
|
||||
// of the callback funtion, will be a bug otherwise.
|
||||
} else {
|
||||
assert(timer->executedBy != taosGetPthreadId());
|
||||
|
||||
const char* fmt = "%s timer[id=%lld, fp=%p, param=%p] fired, waiting...";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
|
||||
for (int i = 1; atomic_load_8(&timer->state) != TIMER_STATE_STOPPED; i++) {
|
||||
if (i % 1000 == 0) {
|
||||
sched_yield();
|
||||
}
|
||||
}
|
||||
|
||||
fmt = "%s timer[id=%lld, fp=%p, param=%p] stopped.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
return false;
|
||||
}
|
||||
|
||||
return reusable;
|
||||
|
||||
// timer callback is executing in another thread, we SHOULD wait it to stop,
|
||||
// BUT this may result in dead lock if current thread are holding a lock which
|
||||
// the timer callback need to acquire. so, we HAVE TO return directly.
|
||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] is executing and cannot be stopped.";
|
||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool taosTmrStop(tmr_h timerId) {
|
||||
|
@ -421,7 +419,7 @@ bool taosTmrStop(tmr_h timerId) {
|
|||
|
||||
tmr_obj_t* timer = findTimer(id);
|
||||
if (timer == NULL) {
|
||||
tmrTrace("timer[id=%lld] does not exist", id);
|
||||
tmrTrace("timer[id=" PRIuPTR "] does not exist", id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -448,7 +446,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
|||
bool stopped = false;
|
||||
tmr_obj_t* timer = findTimer(id);
|
||||
if (timer == NULL) {
|
||||
tmrTrace("%s timer[id=%lld] does not exist", ctrl->label, id);
|
||||
tmrTrace("%s timer[id=" PRIuPTR "] does not exist", ctrl->label, id);
|
||||
} else {
|
||||
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
|
||||
if (!doStopTimer(timer, state)) {
|
||||
|
@ -463,7 +461,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
|||
return stopped;
|
||||
}
|
||||
|
||||
tmrTrace("%s timer[id=%lld] is reused", ctrl->label, timer->id);
|
||||
tmrTrace("%s timer[id=" PRIuPTR "] is reused", ctrl->label, timer->id);
|
||||
|
||||
// wait until there's no other reference to this timer,
|
||||
// so that we can reuse this timer safely.
|
||||
|
|
|
@ -96,7 +96,6 @@ static SKeyword keywordTable[] = {
|
|||
{"TABLE", TK_TABLE},
|
||||
{"DATABASE", TK_DATABASE},
|
||||
{"DNODE", TK_DNODE},
|
||||
{"IP", TK_IP},
|
||||
{"USER", TK_USER},
|
||||
{"ACCOUNT", TK_ACCOUNT},
|
||||
{"USE", TK_USE},
|
||||
|
@ -523,7 +522,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
|
|||
}
|
||||
|
||||
if (seg == 4) { // ip address
|
||||
*tokenType = TK_IP;
|
||||
*tokenType = TK_IPTOKEN;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue