Merge branch 'develop' into feature/liaohj

This commit is contained in:
Hongze Cheng 2020-01-17 14:04:44 +08:00
commit 87861caf3d
59 changed files with 1683 additions and 569 deletions

View File

@ -280,6 +280,11 @@ IF (NOT DEFINED TD_CLUSTER)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll.a DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll.a DESTINATION driver)
ENDIF () ENDIF ()
ELSEIF (TD_DARWIN_64)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR} Darwin)")
ENDIF () ENDIF ()
ENDIF () ENDIF ()

View File

@ -337,6 +337,7 @@ TDengine也支持在shell对已存在的表从CSV文件中进行数据导入。
insert into tb1 file a.csv b.csv tb2 c.csv … insert into tb1 file a.csv b.csv tb2 c.csv …
import into tb1 file a.csv b.csv tb2 c.csv … import into tb1 file a.csv b.csv tb2 c.csv …
``` ```
> 注意导入的CSV文件不能够带表头, 且表的列与CSV文件的列需要严格对应
## 数据导出 ## 数据导出

View File

@ -1125,8 +1125,6 @@ TDengine在Window系统上提供的API与Linux系统是相同的 应用程序
[TDengine GO windows驱动的编译和使用](https://www.taosdata.com/blog/2020/01/06/tdengine-go-windows%E9%A9%B1%E5%8A%A8%E7%9A%84%E7%BC%96%E8%AF%91/) [TDengine GO windows驱动的编译和使用](https://www.taosdata.com/blog/2020/01/06/tdengine-go-windows%E9%A9%B1%E5%8A%A8%E7%9A%84%E7%BC%96%E8%AF%91/)
#### JDBC接口注意事项 #### JDBC接口注意事项
在Windows系统上应用程序可以使用JDBC接口来操纵数据库使用JDBC接口的注意事项如下 在Windows系统上应用程序可以使用JDBC接口来操纵数据库使用JDBC接口的注意事项如下
@ -1142,6 +1140,49 @@ TDengine在Window系统上提供的API与Linux系统是相同的 应用程序
+ 将Windows开发包(taos.dll)放置到system32目录下。 + 将Windows开发包(taos.dll)放置到system32目录下。
## Mac客户端及程序接口
### 客户端安装
在Mac操作系统下TDengine提供64位的Mac客户端([2月10日起提供下载](https://www.taosdata.com/cn/all-downloads/#tdengine_mac-list)),客户端安装程序为.tar.gz文件解压并运行其中的install_client.sh后即可完成安装安装路径为/usr/loca/taos。客户端目录结构如下
```
├── cfg
├───└── taos.cfg
├── connector
├───├── go
├───├── grafana
├───├── jdbc
├───└── python
├── driver
├───├── libtaos.1.6.5.1.dylib
├── examples
├───├── bash
├───├── c
├───├── C#
├───├── go
├───├── JDBC
├───├── lua
├───├── matlab
├───├── nodejs
├───├── python
├───├── R
├───└── rust
├── include
├───└── taos.h
└── bin
├───└── taos
```
其中,最常用的文件列出如下:
+ Client可执行文件: /usr/local/taos/bin/taos 软连接到 /usr/local/bin/taos
+ 配置文件: /usr/local/taos/cfg/taos.cfg 软连接到 /etc/taos/taos.cfg
+ 驱动程序目录: /usr/local/taos/driver/libtaos.1.6.5.1.dylib 软连接到 /usr/local/lib/libtaos.dylib
+ 驱动程序头文件: /usr/local/taos/include/taos.h 软连接到 /usr/local/include/taos.h
+ 日志目录(第一次运行程序时生成):~/TDengineLog
[1]: https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver [1]: https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver
[2]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver [2]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver

View File

@ -2,7 +2,7 @@
# #
# Generate deb package for ubuntu # Generate deb package for ubuntu
set -e set -e
#set -x # set -x
#curr_dir=$(pwd) #curr_dir=$(pwd)
compile_dir=$1 compile_dir=$1

View File

@ -0,0 +1,18 @@
FROM centos:7
WORKDIR /root
COPY tdengine.tar.gz /root/
RUN tar -zxf tdengine.tar.gz
WORKDIR /root/tdengine/
RUN sh install.sh
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib"
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
EXPOSE 6020 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042
EXPOSE 6043 6044 6045 6046 6047 6048 6049 6050
CMD ["taosd"]
VOLUME [ "/var/lib/taos", "/var/log/taos","/etc/taos/" ]

12
packaging/docker/dockerbuild.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -x
$1
tar -zxf $1
DIR=`echo $1|awk -F . '{print($1"."$2"."$3"."$4)}'`
mv $DIR tdengine
tar -czf tdengine.tar.gz tdengine
TMP=`echo $1|awk -F . '{print($2"."$3"."$4)}'`
TAG="1."$TMP
docker build --rm -f "Dockerfile" -t tdengine/tdengine:$TAG "."
docker login -u tdengine -p ******** #replace the docker registry username and password
docker push tdengine/tdengine:$TAG

View File

@ -3,7 +3,7 @@
# Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os # Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os
set -e set -e
# set -x #set -x
# releash.sh -v [cluster | lite] -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | ...] -V [stable | beta] # releash.sh -v [cluster | lite] -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | ...] -V [stable | beta]
@ -46,8 +46,17 @@ done
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType}" echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType}"
curr_dir=$(pwd) curr_dir=$(pwd)
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/..)" if [ "$osType" != "Darwin" ]; then
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/..)"
else
script_dir=`dirname $0`
cd ${script_dir}
script_dir="$(pwd)"
top_dir=${script_dir}/..
fi
versioninfo="${top_dir}/src/util/src/version.c" versioninfo="${top_dir}/src/util/src/version.c"
csudo="" csudo=""
@ -147,7 +156,14 @@ build_time=$(date +"%F %R")
echo "char version[64] = \"${version}\";" > ${versioninfo} echo "char version[64] = \"${version}\";" > ${versioninfo}
echo "char compatible_version[64] = \"${compatible_version}\";" >> ${versioninfo} echo "char compatible_version[64] = \"${compatible_version}\";" >> ${versioninfo}
echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo} echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo}
echo "char gitinfoOfInternal[128] = \"\";" >> ${versioninfo} if [ "$verMode" != "cluster" ]; then
echo "char gitinfoOfInternal[128] = \"\";" >> ${versioninfo}
else
enterprise_dir="${top_dir}/../enterprise"
cd ${enterprise_dir}
echo "char gitinfoOfInternal[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo}
cd ${curr_dir}
fi
echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo} echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo}
echo "" >> ${versioninfo} echo "" >> ${versioninfo}
tmp_version=$(echo $version | tr -s "." "_") tmp_version=$(echo $version | tr -s "." "_")
@ -167,15 +183,23 @@ if [ -d ${compile_dir} ]; then
${csudo} rm -rf ${compile_dir} ${csudo} rm -rf ${compile_dir}
fi fi
${csudo} mkdir -p ${compile_dir} if [ "$osType" != "Darwin" ]; then
${csudo} mkdir -p ${compile_dir}
else
mkdir -p ${compile_dir}
fi
cd ${compile_dir} cd ${compile_dir}
# check support cpu type # check support cpu type
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
cmake ../ -DCPUTYPE=${cpuType} if [ "$verMode" != "cluster" ]; then
cmake ../ -DCPUTYPE=${cpuType}
else
cmake ../../ -DCPUTYPE=${cpuType}
fi
else else
echo "input cpuType=${cpuType} error!!!" echo "input cpuType=${cpuType} error!!!"
exit 1 exit 1
fi fi
make make
@ -187,28 +211,36 @@ cd ${curr_dir}
#osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) #osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
#echo "osinfo: ${osinfo}" #echo "osinfo: ${osinfo}"
echo "====do deb package for the ubuntu system====" if [ "$osType" != "Darwin" ]; then
output_dir="${top_dir}/debs" if [ "$verMode" != "cluster" ]; then
if [ -d ${output_dir} ]; then echo "====do deb package for the ubuntu system===="
${csudo} rm -rf ${output_dir} output_dir="${top_dir}/debs"
fi if [ -d ${output_dir} ]; then
${csudo} mkdir -p ${output_dir} ${csudo} rm -rf ${output_dir}
cd ${script_dir}/deb fi
${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${version} ${cpuType} ${osType} ${verMode} ${verType} ${csudo} mkdir -p ${output_dir}
cd ${script_dir}/deb
echo "====do rpm package for the centos system====" ${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${version} ${cpuType} ${osType} ${verMode} ${verType}
output_dir="${top_dir}/rpms"
if [ -d ${output_dir} ]; then
${csudo} rm -rf ${output_dir}
fi
${csudo} mkdir -p ${output_dir}
cd ${script_dir}/rpm
${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version} ${cpuType} ${osType} ${verMode} ${verType}
echo "====do tar.gz package for all systems====" echo "====do rpm package for the centos system===="
cd ${script_dir}/tools output_dir="${top_dir}/rpms"
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} if [ -d ${output_dir} ]; then
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${csudo} rm -rf ${output_dir}
fi
${csudo} mkdir -p ${output_dir}
cd ${script_dir}/rpm
${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version} ${cpuType} ${osType} ${verMode} ${verType}
fi
echo "====do tar.gz package for all systems===="
cd ${script_dir}/tools
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType}
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType}
else
cd ${script_dir}/tools
./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType}
fi
# 4. Clean up temporary compile directories # 4. Clean up temporary compile directories
#${csudo} rm -rf ${compile_dir} #${csudo} rm -rf ${compile_dir}

View File

@ -2,8 +2,8 @@
# #
# Generate rpm package for centos # Generate rpm package for centos
#set -e set -e
#set -x # set -x
#curr_dir=$(pwd) #curr_dir=$(pwd)
compile_dir=$1 compile_dir=$1

View File

@ -26,7 +26,7 @@ MAX_OPEN_FILES=65535
# Default program options # Default program options
NAME=taosd NAME=taosd
PROG=/usr/local/bin/taos/taosd PROG=/usr/local/taos/bin/taosd
USER=root USER=root
GROUP=root GROUP=root

179
packaging/tools/install.sh Executable file → Normal file
View File

@ -6,6 +6,8 @@
set -e set -e
#set -x #set -x
verMode=lite
# -----------------------Variables definition--------------------- # -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -f "$0")) script_dir=$(dirname $(readlink -f "$0"))
# Dynamic directory # Dynamic directory
@ -27,7 +29,12 @@ install_main_dir="/usr/local/taos"
# old bin dir # old bin dir
bin_dir="/usr/local/taos/bin" bin_dir="/usr/local/taos/bin"
# v1.5 jar dir
v15_java_app_dir="/usr/local/lib/taos"
service_config_dir="/etc/systemd/system" service_config_dir="/etc/systemd/system"
nginx_port=6060
nginx_dir="/usr/local/nginxd"
# Color setting # Color setting
RED='\033[0;31m' RED='\033[0;31m'
@ -41,6 +48,8 @@ if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
fi fi
update_flag=0
initd_mod=0 initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
@ -106,6 +115,9 @@ function install_main_path() {
${csudo} mkdir -p ${install_main_dir}/examples ${csudo} mkdir -p ${install_main_dir}/examples
${csudo} mkdir -p ${install_main_dir}/include ${csudo} mkdir -p ${install_main_dir}/include
${csudo} mkdir -p ${install_main_dir}/init.d ${csudo} mkdir -p ${install_main_dir}/init.d
if [ "$verMode" == "cluster" ]; then
${csudo} mkdir -p ${nginx_dir}
fi
} }
function install_bin() { function install_bin() {
@ -124,16 +136,30 @@ function install_bin() {
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -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/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 || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
if [ "$verMode" == "cluster" ]; then
${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/*
${csudo} mkdir -p ${nginx_dir}/logs
${csudo} chmod 777 ${nginx_dir}/sbin/nginx
fi
} }
function install_lib() { function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -rf ${v15_java_app_dir} || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${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 ${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 ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
if [ "$verMode" == "cluster" ]; then
# Compatible with version 1.5
${csudo} mkdir -p ${v15_java_app_dir}
${csudo} ln -s ${install_main_dir}/connector/taos-jdbcdriver-1.0.2-dist.jar ${v15_java_app_dir}/JDBCDriver-1.0.2-dist.jar
${csudo} chmod 777 ${v15_java_app_dir} || :
fi
} }
function install_header() { function install_header() {
@ -154,6 +180,57 @@ function install_config() {
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org ${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
if [ "$verMode" == "cluster" ]; then
[ ! -z $1 ] && return 0 || : # only install client
if ((${update_flag}==1)); then
return 0
fi
IP_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
IP_PATTERN="\b$IP_FORMAT\.$IP_FORMAT\.$IP_FORMAT\.$IP_FORMAT\b"
echo
echo -e -n "${GREEN}Enter the IP address of an existing TDengine cluster node to join${NC} OR ${GREEN}leave it blank to build one${NC} :"
read masterIp
while true; do
if [ ! -z "$masterIp" ]; then
# check the format of the masterIp
if [[ $masterIp =~ $IP_PATTERN ]]; then
# Write the first IP to configuration file
sudo sed -i -r "s/#*\s*(masterIp\s*).*/\1$masterIp/" ${cfg_dir}/taos.cfg
# Get the second IP address
echo
echo -e -n "${GREEN}Enter the IP address of another node in cluster${NC} OR ${GREEN}leave it blank to skip${NC}: "
read secondIp
while true; do
if [ ! -z "$secondIp" ]; then
if [[ $secondIp =~ $IP_PATTERN ]]; then
# Write the second IP to configuration file
sudo sed -i -r "s/#*\s*(secondIp\s*).*/\1$secondIp/" ${cfg_dir}/taos.cfg
break
else
read -p "Please enter the correct IP address: " secondIp
fi
else
break
fi
done
break
else
read -p "Please enter the correct IP address: " masterIp
fi
else
break
fi
done
fi
} }
@ -175,7 +252,9 @@ function install_connector() {
} }
function install_examples() { function install_examples() {
${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples if [ -d ${script_dir}/examples ]; then
${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples
fi
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
@ -240,7 +319,19 @@ function clean_service_on_systemd() {
${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null ${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null
${csudo} rm -f ${taosd_service_config} ${csudo} rm -f ${taosd_service_config}
}
if [ "$verMode" == "cluster" ]; then
nginx_service_config="${service_config_dir}/nginxd.service"
if systemctl is-active --quiet nginxd; then
echo "Nginx for TDengine is running, stopping it..."
${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null
fi
${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null
${csudo} rm -f ${nginx_service_config}
fi
}
# taos:2345:respawn:/etc/init.d/taosd start # taos:2345:respawn:/etc/init.d/taosd start
@ -269,6 +360,36 @@ function install_service_on_systemd() {
${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}" ${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}"
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
${csudo} systemctl enable taosd ${csudo} systemctl enable taosd
if [ "$verMode" == "cluster" ]; then
nginx_service_config="${service_config_dir}/nginxd.service"
${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}"
${csudo} bash -c "echo 'Description=Nginx For TDengine Service' >> ${nginx_service_config}"
${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}"
${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}"
${csudo} bash -c "echo >> ${nginx_service_config}"
${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}"
${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}"
${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}"
${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}"
${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}"
${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}"
${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}"
${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}"
${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}"
${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}"
${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}"
${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}"
${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}"
${csudo} bash -c "echo >> ${nginx_service_config}"
${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}"
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}"
if ! ${csudo} systemctl enable nginxd &> /dev/null; then
${csudo} systemctl daemon-reexec
${csudo} systemctl enable nginxd
fi
${csudo} systemctl start nginxd
fi
} }
function install_service() { function install_service() {
@ -363,6 +484,21 @@ function update_TDengine() {
install_bin install_bin
install_service install_service
install_config install_config
if [ "$verMode" == "cluster" ]; then
# Check if openresty is installed
openresty_work=false
# Check if nginx is installed successfully
if type curl &> /dev/null; then
if curl -sSf http://127.0.0.1:${nginx_port} &> /dev/null; then
echo -e "\033[44;32;1mNginx for TDengine is updated successfully!${NC}"
openresty_work=true
else
echo -e "\033[44;31;5mNginx for TDengine does not work! Please try again!\033[0m"
fi
fi
fi
echo echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
@ -376,7 +512,15 @@ function update_TDengine() {
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
fi fi
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}" if [ "$verMode" == "cluster" ]; then
if [ ${openresty_work} = 'true' ]; then
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${nginx_port}${NC}"
else
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
fi
else
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
fi
echo echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
else else
@ -416,6 +560,20 @@ function install_TDengine() {
# For installing new # For installing new
install_bin install_bin
install_service install_service
if [ "$verMode" == "cluster" ]; then
openresty_work=false
# Check if nginx is installed successfully
if type curl &> /dev/null; then
if curl -sSf http://127.0.0.1:${nginx_port} &> /dev/null; then
echo -e "\033[44;32;1mNginx for TDengine is installed successfully!${NC}"
openresty_work=true
else
echo -e "\033[44;31;5mNginx for TDengine does not work! Please try again!\033[0m"
fi
fi
fi
install_config install_config
# Ask if to start the service # Ask if to start the service
@ -430,8 +588,17 @@ function install_TDengine() {
else else
echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}"
fi fi
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}" if [ "$verMode" == "cluster" ]; then
if [ ${openresty_work} = 'true' ]; then
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${nginx_port}${NC}"
else
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
fi
else
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
fi
echo echo
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
else # Only install client else # Only install client
@ -450,6 +617,7 @@ function install_TDengine() {
if [ -z $1 ]; then if [ -z $1 ]; then
# Install server and client # Install server and client
if [ -x ${bin_dir}/taosd ]; then if [ -x ${bin_dir}/taosd ]; then
update_flag=1
update_TDengine update_TDengine
else else
install_TDengine install_TDengine
@ -457,6 +625,7 @@ if [ -z $1 ]; then
else else
# Only install client # Only install client
if [ -x ${bin_dir}/taos ]; then if [ -x ${bin_dir}/taos ]; then
update_flag=1
update_TDengine client update_TDengine client
else else
install_TDengine client install_TDengine client

View File

@ -7,18 +7,35 @@ set -e
#set -x #set -x
# -----------------------Variables definition--------------------- # -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -f "$0"))
# Dynamic directory osType=Linux
data_dir="/var/lib/taos"
log_dir="/var/log/taos" if [ "$osType" != "Darwin" ]; then
script_dir=$(dirname $(readlink -f "$0"))
# Dynamic directory
data_dir="/var/lib/taos"
log_dir="/var/log/taos"
else
script_dir=`dirname $0`
cd ${script_dir}
script_dir="$(pwd)"
data_dir="/var/lib/taos"
log_dir="~/TDengineLog"
fi
log_link_dir="/usr/local/taos/log" log_link_dir="/usr/local/taos/log"
cfg_install_dir="/etc/taos" cfg_install_dir="/etc/taos"
bin_link_dir="/usr/bin" if [ "$osType" != "Darwin" ]; then
lib_link_dir="/usr/lib" bin_link_dir="/usr/bin"
inc_link_dir="/usr/include" lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
else
bin_link_dir="/usr/local/bin"
lib_link_dir="/usr/local/lib"
inc_link_dir="/usr/local/include"
fi
#install main path #install main path
install_main_dir="/usr/local/taos" install_main_dir="/usr/local/taos"
@ -26,6 +43,8 @@ install_main_dir="/usr/local/taos"
# old bin dir # old bin dir
bin_dir="/usr/local/taos/bin" bin_dir="/usr/local/taos/bin"
# v1.5 jar dir
v15_java_app_dir="/usr/local/lib/taos"
# Color setting # Color setting
RED='\033[0;31m' RED='\033[0;31m'
@ -51,9 +70,9 @@ function kill_client() {
function install_main_path() { function install_main_path() {
#create install main dir and all sub dir #create install main dir and all sub dir
${csudo} rm -rf ${install_main_dir} || : ${csudo} rm -rf ${install_main_dir} || :
${csudo} mkdir -p ${install_main_dir} ${csudo} mkdir -p ${install_main_dir}
${csudo} mkdir -p ${install_main_dir}/cfg ${csudo} mkdir -p ${install_main_dir}/cfg
${csudo} mkdir -p ${install_main_dir}/bin ${csudo} mkdir -p ${install_main_dir}/bin
${csudo} mkdir -p ${install_main_dir}/connector ${csudo} mkdir -p ${install_main_dir}/connector
${csudo} mkdir -p ${install_main_dir}/driver ${csudo} mkdir -p ${install_main_dir}/driver
${csudo} mkdir -p ${install_main_dir}/examples ${csudo} mkdir -p ${install_main_dir}/examples
@ -61,51 +80,60 @@ function install_main_path() {
} }
function install_bin() { function install_bin() {
# Remove links # Remove links
${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosdump || : if [ "$osType" == "Darwin" ]; then
${csudo} rm -f ${bin_link_dir}/rmtaos || : ${csudo} rm -f ${bin_link_dir}/taosdump || :
fi
${csudo} rm -f ${bin_link_dir}/rmtaos || :
${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/*
#Make link #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/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 || : if [ "$osType" == "Darwin" ]; then
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
fi
[ -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() { function clean_lib() {
sudo rm -f /usr/lib/libtaos.so || : sudo rm -f /usr/lib/libtaos.* || :
sudo rm -rf ${lib_dir} || : sudo rm -rf ${lib_dir} || :
} }
function install_lib() { function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -rf ${v15_java_app_dir} || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${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 if [ "$osType" != "Darwin" ]; then
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${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
else
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib
${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
fi
} }
function install_header() { 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} 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/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
} }
function install_config() { function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : #${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} ${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${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}/* ${csudo} chmod 644 ${cfg_install_dir}/*
fi fi
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org ${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
} }
@ -113,8 +141,12 @@ function install_config() {
function install_log() { function install_log() {
${csudo} rm -rf ${log_dir} || : ${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
if [ "$osType" != "Darwin" ]; then
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
else
mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
fi
${csudo} ln -s ${log_dir} ${install_main_dir}/log ${csudo} ln -s ${log_dir} ${install_main_dir}/log
} }
@ -142,7 +174,7 @@ function update_TDengine() {
kill_client kill_client
sleep 1 sleep 1
fi fi
install_main_path install_main_path
install_log install_log
@ -152,7 +184,7 @@ function update_TDengine() {
install_examples install_examples
install_bin install_bin
install_config install_config
echo echo
echo -e "\033[44;32;1mTDengine client is updated successfully!${NC}" echo -e "\033[44;32;1mTDengine client is updated successfully!${NC}"
@ -168,16 +200,16 @@ function install_TDengine() {
tar -zxf taos.tar.gz tar -zxf taos.tar.gz
echo -e "${GREEN}Start to install TDengine client...${NC}" echo -e "${GREEN}Start to install TDengine client...${NC}"
install_main_path install_main_path
install_log install_log
install_header install_header
install_lib install_lib
install_connector install_connector
install_examples install_examples
install_bin install_bin
install_config install_config
echo echo
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}" echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
@ -191,8 +223,8 @@ function install_TDengine() {
if [ -e ${bin_dir}/taosd ]; then if [ -e ${bin_dir}/taosd ]; then
echo -e "\033[44;32;1mThere are already installed TDengine server, so don't need install client!${NC}" echo -e "\033[44;32;1mThere are already installed TDengine server, so don't need install client!${NC}"
exit 0 exit 0
fi fi
if [ -x ${bin_dir}/taos ]; then if [ -x ${bin_dir}/taos ]; then
update_flag=1 update_flag=1
update_TDengine update_TDengine

View File

@ -9,19 +9,37 @@ set -e
# -----------------------Variables definition--------------------- # -----------------------Variables definition---------------------
source_dir=$1 source_dir=$1
binary_dir=$2 binary_dir=$2
script_dir=$(dirname $(readlink -f "$0")) osType=$3
if [ "$osType" != "Darwin" ]; then
script_dir=$(dirname $(readlink -f "$0"))
else
script_dir=${source_dir}/packaging/tools
fi
# Dynamic directory # Dynamic directory
data_dir="/var/lib/taos" data_dir="/var/lib/taos"
log_dir="/var/log/taos"
if [ "$osType" != "Darwin" ]; then
log_dir="/var/log/taos"
else
log_dir="~/TDengineLog"
fi
data_link_dir="/usr/local/taos/data" data_link_dir="/usr/local/taos/data"
log_link_dir="/usr/local/taos/log" log_link_dir="/usr/local/taos/log"
cfg_install_dir="/etc/taos" cfg_install_dir="/etc/taos"
bin_link_dir="/usr/bin" if [ "$osType" != "Darwin" ]; then
lib_link_dir="/usr/lib" bin_link_dir="/usr/bin"
inc_link_dir="/usr/include" lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
else
bin_link_dir="/usr/local/bin"
lib_link_dir="/usr/local/lib"
inc_link_dir="/usr/local/include"
fi
#install main path #install main path
install_main_dir="/usr/local/taos" install_main_dir="/usr/local/taos"
@ -43,58 +61,61 @@ if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
fi fi
initd_mod=0 if [ "$osType" != "Darwin" ]; then
service_mod=2
if pidof systemd &> /dev/null; then initd_mod=0
service_mod=0 service_mod=2
elif $(which service &> /dev/null); then if pidof systemd &> /dev/null; then
service_mod=1 service_mod=0
service_config_dir="/etc/init.d" elif $(which service &> /dev/null); then
if $(which chkconfig &> /dev/null); then service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
elif $(which insserv &> /dev/null); then if $(which chkconfig &> /dev/null); then
initd_mod=2 initd_mod=1
elif $(which update-rc.d &> /dev/null); then elif $(which insserv &> /dev/null); then
initd_mod=3 initd_mod=2
elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi 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
# 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 fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then if [ -n "$pid" ]; then
${csudo} kill -9 $pid || : ${csudo} kill -9 $pid || :
fi fi
} }
function install_main_path() { function install_main_path() {
@ -107,37 +128,62 @@ function install_main_path() {
${csudo} mkdir -p ${install_main_dir}/driver ${csudo} mkdir -p ${install_main_dir}/driver
${csudo} mkdir -p ${install_main_dir}/examples ${csudo} mkdir -p ${install_main_dir}/examples
${csudo} mkdir -p ${install_main_dir}/include ${csudo} mkdir -p ${install_main_dir}/include
${csudo} mkdir -p ${install_main_dir}/init.d if [ "$osType" != "Darwin" ]; then
${csudo} mkdir -p ${install_main_dir}/init.d
fi
} }
function install_bin() { function install_bin() {
# Remove links # Remove links
${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosd || :
${csudo} rm -f ${bin_link_dir}/taosdemo || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${bin_link_dir}/rmtaos || :
${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin if [ "$osType" != "Darwin" ]; then
${csudo} cp -r ${script_dir}/remove.sh ${install_main_dir}/bin ${csudo} rm -f ${bin_link_dir}/taosd || :
${csudo} rm -f ${bin_link_dir}/taosdemo || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
fi
${csudo} rm -f ${bin_link_dir}/rmtaos || :
${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin
if [ "$osType" != "Darwin" ]; then
${csudo} cp -r ${script_dir}/remove.sh ${install_main_dir}/bin
else
${csudo} cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin
fi
${csudo} chmod 0555 ${install_main_dir}/bin/* ${csudo} chmod 0555 ${install_main_dir}/bin/*
#Make link #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/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/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : if [ "$osType" != "Darwin" ]; then
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : [ -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 || :
fi
if [ "$osType" != "Darwin" ]; then
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
else
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || :
fi
} }
function install_lib() { function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
versioninfo=$(${script_dir}/get_version.sh ${source_dir}/src/util/src/version.c) versioninfo=$(${script_dir}/get_version.sh ${source_dir}/src/util/src/version.c)
${csudo} cp ${binary_dir}/build/lib/libtaos.so.${versioninfo} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then
${csudo} ln -sf ${install_main_dir}/driver/libtaos.so.${versioninfo} ${lib_link_dir}/libtaos.so.1 ${csudo} cp ${binary_dir}/build/lib/libtaos.so.${versioninfo} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo} ln -sf ${install_main_dir}/driver/libtaos.so.${versioninfo} ${lib_link_dir}/libtaos.so.1
${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
else
${csudo} cp ${binary_dir}/build/lib/libtaos.${versioninfo}.dylib ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.${versioninfo}.dylib ${lib_link_dir}/libtaos.1.dylib
${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
fi
} }
function install_header() { function install_header() {
@ -163,8 +209,13 @@ function install_config() {
function install_log() { function install_log() {
${csudo} rm -rf ${log_dir} || : ${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
if [ "$osType" != "Darwin" ]; then
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
else
mkdir -p ${log_dir} && chmod 777 ${log_dir}
fi
${csudo} ln -s ${log_dir} ${install_main_dir}/log ${csudo} ln -s ${log_dir} ${install_main_dir}/log
} }
@ -291,7 +342,9 @@ function install_service() {
function update_TDengine() { function update_TDengine() {
echo -e "${GREEN}Start to update TDEngine...${NC}" echo -e "${GREEN}Start to update TDEngine...${NC}"
# Stop the service if running # Stop the service if running
if pidof taosd &> /dev/null; then
if [ "$osType" != "Darwin" ]; then
if pidof taosd &> /dev/null; then
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
${csudo} systemctl stop taosd || : ${csudo} systemctl stop taosd || :
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
@ -300,6 +353,7 @@ function update_TDengine() {
kill_taosd kill_taosd
fi fi
sleep 1 sleep 1
fi
fi fi
install_main_path install_main_path
@ -310,32 +364,54 @@ function update_TDengine() {
install_connector install_connector
install_examples install_examples
install_bin install_bin
install_service
if [ "$osType" != "Darwin" ]; then
install_service
fi
install_config install_config
echo if [ "$osType" != "Darwin" ]; then
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo
echo echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" echo
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} service taosd start${NC}"
else
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}" echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
echo if ((${service_mod}==0)); then
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" 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} service taosd start${NC}"
else
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}"
echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
else
echo
echo -e "\033[44;32;1mTDengine Client is updated successfully!${NC}"
echo
echo -e "${GREEN_DARK}To access TDengine Client ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
echo
echo -e "\033[44;32;1mTDengine Client is updated successfully!${NC}"
fi
} }
function install_TDengine() { function install_TDengine() {
# Start to install # Start to install
echo -e "${GREEN}Start to install TDEngine...${NC}" if [ "$osType" != "Darwin" ]; then
echo -e "${GREEN}Start to install TDEngine...${NC}"
else
echo -e "${GREEN}Start to install TDEngine Client ...${NC}"
fi
install_main_path install_main_path
install_data
if [ "$osType" != "Darwin" ]; then
install_data
fi
install_log install_log
install_header install_header
install_lib install_lib
@ -343,30 +419,41 @@ function install_TDengine() {
install_examples install_examples
install_bin install_bin
install_service
install_config if [ "$osType" != "Darwin" ]; then
# Ask if to start the service install_service
echo
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
echo
echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
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} service taosd start${NC}"
else
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
fi fi
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}" install_config
echo
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" if [ "$osType" != "Darwin" ]; then
# Ask if to start the service
echo
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
echo
echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
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} service taosd start${NC}"
else
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}"
echo
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
else
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
echo
echo -e "\033[44;32;1mTDengine Client is installed successfully!${NC}"
fi
} }
## ==============================Main program starts from here============================ ## ==============================Main program starts from here============================
echo source directory: $1 echo source directory: $1
echo binary directory: $2 echo binary directory: $2
if [ -x ${bin_dir}/taosd ]; then if [ -x ${bin_dir}/taos ]; then
update_TDengine update_TDengine
else else
install_TDengine install_TDengine

View File

@ -13,8 +13,15 @@ osType=$5
verMode=$6 verMode=$6
verType=$7 verType=$7
script_dir="$(dirname $(readlink -f $0))" if [ "$osType" != "Darwin" ]; then
top_dir="$(readlink -f ${script_dir}/../..)" script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/../..)"
else
script_dir=`dirname $0`
cd ${script_dir}
script_dir="$(pwd)"
top_dir=${script_dir}/../..
fi
# create compressed install file. # create compressed install file.
build_dir="${compile_dir}/build" build_dir="${compile_dir}/build"
@ -22,13 +29,26 @@ code_dir="${top_dir}/src"
release_dir="${top_dir}/release" release_dir="${top_dir}/release"
#package_name='linux' #package_name='linux'
install_dir="${release_dir}/TDengine-client"
if [ "$verMode" == "cluster" ]; then
install_dir="${release_dir}/TDengine-enterprise-client"
else
install_dir="${release_dir}/TDengine-client"
fi
# Directories and files. # 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}" if [ "$osType" != "Darwin" ]; then
bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdump ${script_dir}/remove_client.sh"
lib_files="${build_dir}/lib/libtaos.so.${version}"
else
bin_files="${build_dir}/bin/taos ${script_dir}/remove_client.sh"
lib_files="${build_dir}/lib/libtaos.${version}.dylib"
fi
header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h" header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
cfg_dir="${top_dir}/packaging/cfg" cfg_dir="${top_dir}/packaging/cfg"
install_files="${script_dir}/install_client.sh" install_files="${script_dir}/install_client.sh"
# make directories. # make directories.
@ -38,10 +58,23 @@ mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cf
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
cd ${install_dir} cd ${install_dir}
tar -zcv -f taos.tar.gz * --remove-files || :
if [ "$osType" != "Darwin" ]; then
tar -zcv -f taos.tar.gz * --remove-files || :
else
tar -zcv -f taos.tar.gz * || :
mv taos.tar.gz ..
rm -rf ./*
mv ../taos.tar.gz .
fi
cd ${curr_dir} cd ${curr_dir}
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install* cp ${install_files} ${install_dir}
if [ "$osType" == "Darwin" ]; then
sed 's/osType=Linux/osType=Darwin/g' ${install_dir}/install_client.sh >> install_client_temp.sh
mv install_client_temp.sh ${install_dir}/install_client.sh
fi
chmod a+x ${install_dir}/install_client.sh
# Copy example code # Copy example code
mkdir -p ${install_dir}/examples mkdir -p ${install_dir}/examples
@ -60,7 +93,10 @@ cp ${lib_files} ${install_dir}/driver
# Copy connector # Copy connector
connector_dir="${code_dir}/connector" connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector mkdir -p ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
if [ "$osType" != "Darwin" ]; then
cp ${build_dir}/lib/*.jar ${install_dir}/connector
fi
cp -r ${connector_dir}/grafana ${install_dir}/connector/ cp -r ${connector_dir}/grafana ${install_dir}/connector/
cp -r ${connector_dir}/python ${install_dir}/connector/ cp -r ${connector_dir}/python ${install_dir}/connector/
cp -r ${connector_dir}/go ${install_dir}/connector cp -r ${connector_dir}/go ${install_dir}/connector
@ -90,6 +126,13 @@ else
exit 1 exit 1
fi fi
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files if [ "$osType" != "Darwin" ]; then
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
else
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) || :
mv "$(basename ${pkg_name}).tar.gz" ..
rm -rf ./*
mv ../"$(basename ${pkg_name}).tar.gz" .
fi
cd ${curr_dir} cd ${curr_dir}

View File

@ -23,7 +23,11 @@ code_dir="${top_dir}/src"
release_dir="${top_dir}/release" release_dir="${top_dir}/release"
#package_name='linux' #package_name='linux'
install_dir="${release_dir}/TDengine-server" if [ "$verMode" == "cluster" ]; then
install_dir="${release_dir}/TDengine-enterprise-server"
else
install_dir="${release_dir}/TDengine-server"
fi
# Directories and files. # 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" bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh"
@ -31,6 +35,7 @@ lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h" header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
cfg_dir="${top_dir}/packaging/cfg" cfg_dir="${top_dir}/packaging/cfg"
install_files="${script_dir}/install.sh" install_files="${script_dir}/install.sh"
nginx_dir="${code_dir}/../../enterprise/src/modules/web"
# Init file # Init file
#init_dir=${script_dir}/deb #init_dir=${script_dir}/deb
@ -50,11 +55,29 @@ mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x $
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_deb} ${install_dir}/init.d/taosd.deb
mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm
if [ "$verMode" == "cluster" ]; then
mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd
cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png
rm -rf ${install_dir}/nginxd/png
if [ "$cpuType" == "aarch64" ]; then
cp -f ${install_dir}/nginxd/sbin/arm/64bit/nginx ${install_dir}/nginxd/sbin/
elif [ "$cpuType" == "aarch32" ]; then
cp -f ${install_dir}/nginxd/sbin/arm/32bit/nginx ${install_dir}/nginxd/sbin/
fi
rm -rf ${install_dir}/nginxd/sbin/arm
fi
cd ${install_dir} cd ${install_dir}
tar -zcv -f taos.tar.gz * --remove-files || : tar -zcv -f taos.tar.gz * --remove-files || :
cd ${curr_dir} cd ${curr_dir}
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install* cp ${install_files} ${install_dir}
if [ "$verMode" == "cluster" ]; then
sed 's/verMode=lite/verMode=cluster/g' ${install_dir}/install.sh >> install_temp.sh
mv install_temp.sh ${install_dir}/install.sh
fi
chmod a+x ${install_dir}/install.sh
# Copy example code # Copy example code
mkdir -p ${install_dir}/examples mkdir -p ${install_dir}/examples
@ -103,6 +126,6 @@ else
exit 1 exit 1
fi fi
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
cd ${curr_dir} cd ${curr_dir}

View File

@ -2,6 +2,11 @@
# #
# 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.
set -e
#set -x
verMode=lite
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[1;32m' GREEN='\033[1;32m'
NC='\033[0m' NC='\033[0m'
@ -14,10 +19,14 @@ cfg_link_dir="/usr/local/taos/cfg"
bin_link_dir="/usr/bin" bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib" lib_link_dir="/usr/lib"
inc_link_dir="/usr/include" inc_link_dir="/usr/include"
install_nginxd_dir="/usr/local/nginxd"
# v1.5 jar dir
v15_java_app_dir="/usr/local/lib/taos"
service_config_dir="/etc/systemd/system" service_config_dir="/etc/systemd/system"
taos_service_name="taosd" taos_service_name="taosd"
nginx_service_name="nginxd"
csudo="" csudo=""
if command -v sudo > /dev/null; then if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
@ -62,6 +71,7 @@ function clean_bin() {
function clean_lib() { function clean_lib() {
# Remove link # Remove link
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -rf ${v15_java_app_dir} || :
} }
function clean_header() { function clean_header() {
@ -90,6 +100,20 @@ function clean_service_on_systemd() {
${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null
${csudo} rm -f ${taosd_service_config} ${csudo} rm -f ${taosd_service_config}
if [ "$verMode" == "cluster" ]; then
nginx_service_config="${service_config_dir}/${nginx_service_name}.service"
if [ -d ${bin_dir}/web ]; then
if systemctl is-active --quiet ${nginx_service_name}; then
echo "Nginx for TDengine is running, stopping it..."
${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null
fi
${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null
${csudo} rm -f ${nginx_service_config}
fi
fi
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
@ -143,6 +167,7 @@ clean_config
${csudo} rm -rf ${data_link_dir} || : ${csudo} rm -rf ${data_link_dir} || :
${csudo} rm -rf ${install_main_dir} ${csudo} rm -rf ${install_main_dir}
${csudo} rm -rf ${install_nginxd_dir}
osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
if echo $osinfo | grep -qwi "ubuntu" ; then if echo $osinfo | grep -qwi "ubuntu" ; then

View File

@ -17,6 +17,10 @@ bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib" lib_link_dir="/usr/lib"
inc_link_dir="/usr/include" inc_link_dir="/usr/include"
# v1.5 jar dir
v15_java_app_dir="/usr/local/lib/taos"
csudo="" csudo=""
if command -v sudo > /dev/null; then if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
@ -39,6 +43,7 @@ function clean_bin() {
function clean_lib() { function clean_lib() {
# Remove link # Remove link
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -rf ${v15_java_app_dir} || :
} }
function clean_header() { function clean_header() {

View File

@ -24,20 +24,10 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
#set version of .so #set version of .so
#VERSION so version #VERSION so version
#SOVERSION api version #SOVERSION api version
IF (TD_LITE) execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh) execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c
execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c OUTPUT_VARIABLE
OUTPUT_VARIABLE VERSION_INFO)
VERSION_INFO)
MESSAGE(STATUS "build lite version ${VERSION_INFO}")
ELSE ()
execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO)
MESSAGE(STATUS "build cluster version ${VERSION_INFO}")
ENDIF ()
MESSAGE(STATUS "build version ${VERSION_INFO}") MESSAGE(STATUS "build version ${VERSION_INFO}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1) SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)
@ -57,6 +47,7 @@ ELSEIF (TD_WINDOWS_64)
TARGET_LINK_LIBRARIES(taos trpc) TARGET_LINK_LIBRARIES(taos trpc)
ELSEIF (TD_DARWIN_64) ELSEIF (TD_DARWIN_64)
SET(CMAKE_MACOSX_RPATH 1)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
@ -66,6 +57,17 @@ ELSEIF (TD_DARWIN_64)
# generate dynamic library (*.dylib) # generate dynamic library (*.dylib)
ADD_LIBRARY(taos SHARED ${SRC}) ADD_LIBRARY(taos SHARED ${SRC})
TARGET_LINK_LIBRARIES(taos trpc tutil pthread m) TARGET_LINK_LIBRARIES(taos trpc tutil pthread m)
SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1)
#set version of .so
#VERSION so version
#SOVERSION api version
execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO)
MESSAGE(STATUS "build version ${VERSION_INFO}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)
ENDIF () ENDIF ()

View File

@ -495,12 +495,12 @@ static void setInitialValueForRangeQueryCondition(tSKipListQueryCond *q, int8_t
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_BINARY: { case TSDB_DATA_TYPE_BINARY: {
q->upperBnd.nType = type; q->upperBnd.nType = type;
q->upperBnd.pz = "\0"; q->upperBnd.pz = NULL;
q->upperBnd.nLen = -1; q->upperBnd.nLen = -1;
q->lowerBnd.nType = type; q->lowerBnd.nType = type;
q->lowerBnd.pz = "\0"; q->lowerBnd.pz = NULL;
q->lowerBnd.nLen = 0; q->lowerBnd.nLen = -1;
} }
} }
} }

View File

@ -96,11 +96,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port,
pObj = (SConnCache *)handle; pObj = (SConnCache *)handle;
if (pObj == NULL || pObj->maxSessions == 0) return NULL; if (pObj == NULL || pObj->maxSessions == 0) return NULL;
#ifdef CLUSTER
if (data == NULL || ip == 0) {
#else
if (data == NULL) { if (data == NULL) {
#endif
tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port); tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port);
return NULL; return NULL;
} }

View File

@ -4651,6 +4651,13 @@ void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClau
} }
} }
// limit the output to be 1 for each state value
static void doLimitOutputNormalColOfGroupby(SSqlExpr* pExpr) {
int32_t outputRow = 1;
tVariantCreateFromBinary(&pExpr->param[0], (char*) &outputRow, sizeof(int32_t), TSDB_DATA_TYPE_INT);
pExpr->numOfParams = 1;
}
void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) { void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
int32_t index = pQueryInfo->groupbyExpr.columnInfo[tagIndex].colIdx; int32_t index = pQueryInfo->groupbyExpr.columnInfo[tagIndex].colIdx;
@ -4663,9 +4670,8 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
pSchema->type, pSchema->bytes, pSchema->bytes); pSchema->type, pSchema->bytes, pSchema->bytes);
pExpr->colInfo.flag = TSDB_COL_NORMAL; pExpr->colInfo.flag = TSDB_COL_NORMAL;
pExpr->param[0].i64Key = 1; doLimitOutputNormalColOfGroupby(pExpr);
pExpr->numOfParams = 1;
// NOTE: tag column does not add to source column list // NOTE: tag column does not add to source column list
SColumnList list = {0}; SColumnList list = {0};
list.num = 1; list.num = 1;
@ -4710,8 +4716,7 @@ static void doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) {
for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) { for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) {
if (pExpr->colInfo.colId == pQueryInfo->groupbyExpr.columnInfo[j].colId) { if (pExpr->colInfo.colId == pQueryInfo->groupbyExpr.columnInfo[j].colId) {
qualifiedCol = true; qualifiedCol = true;
doLimitOutputNormalColOfGroupby(pExpr);
pExpr->param[0].i64Key = 1; // limit the output to be 1 for each state value
pExpr->numOfParams = 1; pExpr->numOfParams = 1;
break; break;
} }

View File

@ -446,8 +446,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
tscTrace("%p waiting for delete procedure, status: %d", pSql, status); tscTrace("%p waiting for delete procedure, status: %d", pSql, status);
} }
tfree(pLocalReducer->interpolationInfo.prevValues); taosDestoryInterpoInfo(&pLocalReducer->interpolationInfo);
tfree(pLocalReducer->interpolationInfo.pTags);
if (pLocalReducer->pCtx != NULL) { if (pLocalReducer->pCtx != NULL) {
for(int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) { for(int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) {

View File

@ -31,15 +31,9 @@
#define TSC_MGMT_VNODE 999 #define TSC_MGMT_VNODE 999
#ifdef CLUSTER SIpStrList tscMgmtIpList;
SIpStrList tscMgmtIpList; int tsMasterIndex = 0;
int tsMasterIndex = 0; int tsSlaveIndex = 1;
int tsSlaveIndex = 1;
#else
int tsMasterIndex = 0;
int tsSlaveIndex = 0; // slave == master for single node edition
uint32_t tsServerIp;
#endif
int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0}; int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0};
@ -50,17 +44,51 @@ int tscKeepConn[TSDB_SQL_MAX] = {0};
static int32_t minMsgSize() { return tsRpcHeadSize + sizeof(STaosDigest); } static int32_t minMsgSize() { return tsRpcHeadSize + sizeof(STaosDigest); }
static char *doBuildMsgHeader(SSqlObj *pSql, char **pStart);
#ifdef CLUSTER
void tscPrintMgmtIp() { void tscPrintMgmtIp() {
if (tscMgmtIpList.numOfIps <= 0) { if (tscMgmtIpList.numOfIps <= 0) {
tscError("invalid IP list:%d", tscMgmtIpList.numOfIps); tscError("invalid mgmt IP list:%d", tscMgmtIpList.numOfIps);
} else { } else {
for (int i = 0; i < tscMgmtIpList.numOfIps; ++i) tscTrace("mgmt index:%d ip:%s", i, tscMgmtIpList.ipstr[i]); for (int i = 0; i < tscMgmtIpList.numOfIps; ++i) {
tscTrace("mgmt index:%d ip:%s", i, tscMgmtIpList.ipstr[i]);
}
}
}
void tscSetMgmtIpListFromCluster(SIpList *pIpList) {
tscMgmtIpList.numOfIps = pIpList->numOfIps;
if (memcmp(tscMgmtIpList.ip, pIpList->ip, pIpList->numOfIps * 4) != 0) {
for (int i = 0; i < pIpList->numOfIps; ++i) {
tinet_ntoa(tscMgmtIpList.ipstr[i], pIpList->ip[i]);
tscMgmtIpList.ip[i] = pIpList->ip[i];
}
tscTrace("cluster mgmt IP list:");
tscPrintMgmtIp();
}
}
void tscSetMgmtIpListFromEdge() {
if (tscMgmtIpList.numOfIps != 2) {
tscMgmtIpList.numOfIps = 2;
strcpy(tscMgmtIpList.ipstr[0], tsMasterIp);
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
strcpy(tscMgmtIpList.ipstr[1], tsMasterIp);
tscMgmtIpList.ip[1] = inet_addr(tsMasterIp);
tscTrace("edge mgmt IP list:");
tscPrintMgmtIp();
}
}
void tscSetMgmtIpList(SIpList *pIpList) {
/*
* The iplist returned by the cluster edition is the current management nodes
* and the iplist returned by the edge edition is empty
*/
if (pIpList->numOfIps != 0) {
tscSetMgmtIpListFromCluster(pIpList);
} else {
tscSetMgmtIpListFromEdge();
} }
} }
#endif
/* /*
* For each management node, try twice at least in case of poor network situation. * For each management node, try twice at least in case of poor network situation.
@ -71,11 +99,7 @@ void tscPrintMgmtIp() {
*/ */
static int32_t tscGetMgmtConnMaxRetryTimes() { static int32_t tscGetMgmtConnMaxRetryTimes() {
int32_t factor = 2; int32_t factor = 2;
#ifdef CLUSTER
return tscMgmtIpList.numOfIps * factor; return tscMgmtIpList.numOfIps * factor;
#else
return 1 * factor;
#endif
} }
void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
@ -91,18 +115,9 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
if (code == 0) { if (code == 0) {
SHeartBeatRsp *pRsp = (SHeartBeatRsp *)pRes->pRsp; SHeartBeatRsp *pRsp = (SHeartBeatRsp *)pRes->pRsp;
#ifdef CLUSTER SIpList * pIpList = &pRsp->ipList;
SIpList *pIpList = &pRsp->ipList; tscSetMgmtIpList(pIpList);
tscMgmtIpList.numOfIps = pIpList->numOfIps;
if (memcmp(tscMgmtIpList.ip, pIpList->ip, pIpList->numOfIps * 4) != 0) {
for (int i = 0; i < pIpList->numOfIps; ++i) {
tinet_ntoa(tscMgmtIpList.ipstr[i], pIpList->ip[i]);
tscMgmtIpList.ip[i] = pIpList->ip[i];
}
tscTrace("new mgmt IP list:");
tscPrintMgmtIp();
}
#endif
if (pRsp->killConnection) { if (pRsp->killConnection) {
tscKillConnection(pObj); tscKillConnection(pObj);
} else { } else {
@ -161,19 +176,12 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) { void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) {
STscObj *pTscObj = pSql->pTscObj; STscObj *pTscObj = pSql->pTscObj;
#ifdef CLUSTER
if (pSql->retry < tscGetMgmtConnMaxRetryTimes()) { if (pSql->retry < tscGetMgmtConnMaxRetryTimes()) {
*pCode = 0; *pCode = 0;
pSql->retry++; pSql->retry++;
pSql->index = pSql->index % tscMgmtIpList.numOfIps; pSql->index = pSql->index % tscMgmtIpList.numOfIps;
if (pSql->cmd.command > TSDB_SQL_READ && pSql->index == 0) pSql->index = 1; if (pSql->cmd.command > TSDB_SQL_READ && pSql->index == 0) pSql->index = 1;
void *thandle = taosGetConnFromCache(tscConnCache, tscMgmtIpList.ip[pSql->index], TSC_MGMT_VNODE, pTscObj->user); void *thandle = taosGetConnFromCache(tscConnCache, tscMgmtIpList.ip[pSql->index], TSC_MGMT_VNODE, pTscObj->user);
#else
if (pSql->retry < tscGetMgmtConnMaxRetryTimes()) {
*pCode = 0;
pSql->retry++;
void *thandle = taosGetConnFromCache(tscConnCache, tsServerIp, TSC_MGMT_VNODE, pTscObj->user);
#endif
if (thandle == NULL) { if (thandle == NULL) {
SRpcConnInit connInit; SRpcConnInit connInit;
@ -188,25 +196,16 @@ void tscGetConnToMgmt(SSqlObj *pSql, uint8_t *pCode) {
connInit.spi = 1; connInit.spi = 1;
connInit.encrypt = 0; connInit.encrypt = 0;
connInit.secret = pSql->pTscObj->pass; connInit.secret = pSql->pTscObj->pass;
#ifdef CLUSTER
connInit.peerIp = tscMgmtIpList.ipstr[pSql->index]; connInit.peerIp = tscMgmtIpList.ipstr[pSql->index];
#else
connInit.peerIp = tsMasterIp;
#endif
thandle = taosOpenRpcConn(&connInit, pCode); thandle = taosOpenRpcConn(&connInit, pCode);
} }
pSql->thandle = thandle; pSql->thandle = thandle;
#ifdef CLUSTER
pSql->ip = tscMgmtIpList.ip[pSql->index]; pSql->ip = tscMgmtIpList.ip[pSql->index];
pSql->vnode = TSC_MGMT_VNODE; pSql->vnode = TSC_MGMT_VNODE;
tscTrace("%p mgmt index:%d ip:0x%x is picked up, pConn:%p", pSql, pSql->index, tscMgmtIpList.ip[pSql->index], tscTrace("%p mgmt index:%d ip:0x%x is picked up, pConn:%p", pSql, pSql->index, tscMgmtIpList.ip[pSql->index],
pSql->thandle); pSql->thandle);
#else
pSql->ip = tsServerIp;
pSql->vnode = TSC_MGMT_VNODE;
#endif
} }
// the pSql->res.code is the previous error(status) code. // the pSql->res.code is the previous error(status) code.
@ -251,11 +250,16 @@ void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) {
while (pSql->retry < pSql->maxRetry) { while (pSql->retry < pSql->maxRetry) {
(pSql->retry)++; (pSql->retry)++;
#ifdef CLUSTER
char ipstr[40] = {0}; char ipstr[40] = {0};
if (pVPeersDesc[pSql->index].ip == 0) { if (pVPeersDesc[pSql->index].ip == 0) {
(pSql->index) = (pSql->index + 1) % TSDB_VNODES_SUPPORT; /*
continue; * in the edge edition, ip is 0, and at this time we use masterIp instead
* in the cluster edition, ip is vnode ip
*/
//(pSql->index) = (pSql->index + 1) % TSDB_VNODES_SUPPORT;
//continue;
pVPeersDesc[pSql->index].ip = tscMgmtIpList.ip[0];
} }
*pCode = TSDB_CODE_SUCCESS; *pCode = TSDB_CODE_SUCCESS;
@ -285,31 +289,6 @@ void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) {
pSql->vnode = pVPeersDesc[pSql->index].vnode; pSql->vnode = pVPeersDesc[pSql->index].vnode;
tscTrace("%p vnode:%d ip:%p index:%d is picked up, pConn:%p", pSql, pVPeersDesc[pSql->index].vnode, tscTrace("%p vnode:%d ip:%p index:%d is picked up, pConn:%p", pSql, pVPeersDesc[pSql->index].vnode,
pVPeersDesc[pSql->index].ip, pSql->index, pSql->thandle); pVPeersDesc[pSql->index].ip, pSql->index, pSql->thandle);
#else
*pCode = 0;
void *thandle = taosGetConnFromCache(tscConnCache, tsServerIp, pVPeersDesc[0].vnode, pTscObj->user);
if (thandle == NULL) {
SRpcConnInit connInit;
memset(&connInit, 0, sizeof(connInit));
connInit.cid = vidIndex;
connInit.sid = 0;
connInit.spi = 0;
connInit.encrypt = 0;
connInit.meterId = pSql->pTscObj->user;
connInit.peerId = htonl((pVPeersDesc[0].vnode << TSDB_SHELL_VNODE_BITS));
connInit.shandle = pVnodeConn;
connInit.ahandle = pSql;
connInit.peerIp = tsMasterIp;
connInit.peerPort = tsVnodeShellPort;
thandle = taosOpenRpcConn(&connInit, pCode);
vidIndex = (vidIndex + 1) % tscNumOfThreads;
}
pSql->thandle = thandle;
pSql->ip = tsServerIp;
pSql->vnode = pVPeersDesc[0].vnode;
#endif
break; break;
} }
@ -376,15 +355,9 @@ int tscSendMsgToServer(SSqlObj *pSql) {
return code; return code;
} }
#ifdef CLUSTER
void tscProcessMgmtRedirect(SSqlObj *pSql, uint8_t *cont) { void tscProcessMgmtRedirect(SSqlObj *pSql, uint8_t *cont) {
SIpList *pIpList = (SIpList *)(cont); SIpList *pIpList = (SIpList *)(cont);
tscMgmtIpList.numOfIps = pIpList->numOfIps; tscSetMgmtIpList(pIpList);
for (int i = 0; i < pIpList->numOfIps; ++i) {
tinet_ntoa(tscMgmtIpList.ipstr[i], pIpList->ip[i]);
tscMgmtIpList.ip[i] = pIpList->ip[i];
tscTrace("Update mgmt Ip, index:%d ip:%s", i, tscMgmtIpList.ipstr[i]);
}
if (pSql->cmd.command < TSDB_SQL_READ) { if (pSql->cmd.command < TSDB_SQL_READ) {
tsMasterIndex = 0; tsMasterIndex = 0;
@ -395,7 +368,6 @@ void tscProcessMgmtRedirect(SSqlObj *pSql, uint8_t *cont) {
tscPrintMgmtIp(); tscPrintMgmtIp();
} }
#endif
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) { void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
if (ahandle == NULL) return NULL; if (ahandle == NULL) return NULL;
@ -431,11 +403,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
if (msg == NULL) { if (msg == NULL) {
tscTrace("%p no response from ip:0x%x", pSql, pSql->ip); tscTrace("%p no response from ip:0x%x", pSql, pSql->ip);
#ifdef CLUSTER
pSql->index++; pSql->index++;
#else
// for single node situation, do NOT try next index
#endif
pSql->thandle = NULL; pSql->thandle = NULL;
// todo taos_stop_query() in async model // todo taos_stop_query() in async model
/* /*
@ -451,12 +419,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
// renew meter meta in case it is changed // renew meter meta in case it is changed
if (pCmd->command < TSDB_SQL_FETCH && pRes->code != TSDB_CODE_QUERY_CANCELLED) { if (pCmd->command < TSDB_SQL_FETCH && pRes->code != TSDB_CODE_QUERY_CANCELLED) {
#ifdef CLUSTER
pSql->maxRetry = TSDB_VNODES_SUPPORT * 2; pSql->maxRetry = TSDB_VNODES_SUPPORT * 2;
#else
// for fetch, it shall not renew meter meta
pSql->maxRetry = 2;
#endif
code = tscRenewMeterMeta(pSql, pMeterMetaInfo->name); code = tscRenewMeterMeta(pSql, pMeterMetaInfo->name);
pRes->code = code; pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return pSql; if (code == TSDB_CODE_ACTION_IN_PROGRESS) return pSql;
@ -468,9 +431,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
} }
} else { } else {
uint16_t rspCode = pMsg->content[0]; uint16_t rspCode = pMsg->content[0];
#ifdef CLUSTER
if (rspCode == TSDB_CODE_REDIRECT) { if (rspCode == TSDB_CODE_REDIRECT) {
tscTrace("%p it shall be redirected!", pSql); tscTrace("%p it shall be redirected!", pSql);
taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user); taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user);
@ -502,12 +463,7 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
* removed. So, renew metermeta and try again. * removed. So, renew metermeta and try again.
* not_active_session: db has been move to other node, the vnode does not exist on this dnode anymore. * not_active_session: db has been move to other node, the vnode does not exist on this dnode anymore.
*/ */
#else pSql->thandle = NULL;
if (rspCode == TSDB_CODE_NOT_ACTIVE_TABLE || rspCode == TSDB_CODE_INVALID_TABLE_ID ||
rspCode == TSDB_CODE_NOT_ACTIVE_VNODE || rspCode == TSDB_CODE_INVALID_VNODE_ID ||
rspCode == TSDB_CODE_TABLE_ID_MISMATCH || rspCode == TSDB_CODE_NETWORK_UNAVAIL) {
#endif
pSql->thandle = NULL;
taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user); taosAddConnIntoCache(tscConnCache, thandle, pSql->ip, pSql->vnode, pObj->user);
if (pCmd->command == TSDB_SQL_CONNECT) { if (pCmd->command == TSDB_SQL_CONNECT) {
@ -809,13 +765,10 @@ int tscProcessSql(SSqlObj *pSql) {
tscTrace("%p SQL cmd:%d will be processed, name:%s, type:%d", pSql, pCmd->command, name, type); tscTrace("%p SQL cmd:%d will be processed, name:%s, type:%d", pSql, pCmd->command, name, type);
pSql->retry = 0; pSql->retry = 0;
if (pSql->cmd.command < TSDB_SQL_MGMT) { if (pSql->cmd.command < TSDB_SQL_MGMT) {
#ifdef CLUSTER
pSql->maxRetry = TSDB_VNODES_SUPPORT; pSql->maxRetry = TSDB_VNODES_SUPPORT;
#else
pSql->maxRetry = 2;
#endif
if (pMeterMetaInfo == NULL) { // the pMeterMetaInfo cannot be NULL // the pMeterMetaInfo cannot be NULL
if (pMeterMetaInfo == NULL) {
pSql->res.code = TSDB_CODE_OTHERS; pSql->res.code = TSDB_CODE_OTHERS;
return pSql->res.code; return pSql->res.code;
} }
@ -863,10 +816,10 @@ int tscProcessSql(SSqlObj *pSql) {
} }
} }
sem_post(&pSql->emptyRspSem); tsem_post(&pSql->emptyRspSem);
sem_wait(&pSql->rspSem); tsem_wait(&pSql->rspSem);
sem_post(&pSql->emptyRspSem); tsem_post(&pSql->emptyRspSem);
if (pSql->numOfSubs <= 0) { if (pSql->numOfSubs <= 0) {
pSql->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT; pSql->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
@ -899,9 +852,9 @@ int tscProcessSql(SSqlObj *pSql) {
} }
if (fp == NULL) { if (fp == NULL) {
sem_post(&pSql->emptyRspSem); tsem_post(&pSql->emptyRspSem);
sem_wait(&pSql->rspSem); tsem_wait(&pSql->rspSem);
sem_post(&pSql->emptyRspSem); tsem_post(&pSql->emptyRspSem);
// set the command flag must be after the semaphore been correctly set. // set the command flag must be after the semaphore been correctly set.
pSql->cmd.command = TSDB_SQL_RETRIEVE_METRIC; pSql->cmd.command = TSDB_SQL_RETRIEVE_METRIC;
@ -3352,21 +3305,12 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
assert(len <= tListLen(pObj->db)); assert(len <= tListLen(pObj->db));
strncpy(pObj->db, temp, tListLen(pObj->db)); strncpy(pObj->db, temp, tListLen(pObj->db));
#ifdef CLUSTER SIpList * pIpList;
SIpList *pIpList; char *rsp = pRes->pRsp + sizeof(SConnectRsp);
char * rsp = pRes->pRsp + sizeof(SConnectRsp);
pIpList = (SIpList *)rsp; pIpList = (SIpList *)rsp;
tscMgmtIpList.numOfIps = pIpList->numOfIps; tscSetMgmtIpList(pIpList);
for (int i = 0; i < pIpList->numOfIps; ++i) {
tinet_ntoa(tscMgmtIpList.ipstr[i], pIpList->ip[i]);
tscMgmtIpList.ip[i] = pIpList->ip[i];
}
rsp += sizeof(SIpList) + sizeof(int32_t) * pIpList->numOfIps;
tscPrintMgmtIp();
#endif
strcpy(pObj->sversion, pConnect->version); strcpy(pObj->sversion, pConnect->version);
pObj->writeAuth = pConnect->writeAuth; pObj->writeAuth = pConnect->writeAuth;
pObj->superAuth = pConnect->superAuth; pObj->superAuth = pConnect->superAuth;

View File

@ -63,19 +63,10 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
} }
} }
#ifdef CLUSTER
if (ip && ip[0]) { if (ip && ip[0]) {
strcpy(tscMgmtIpList.ipstr[1], ip); strcpy(tscMgmtIpList.ipstr[0], ip);
tscMgmtIpList.ip[1] = inet_addr(ip); tscMgmtIpList.ip[0] = inet_addr(ip);
} }
#else
if (ip && ip[0]) {
if (ip != tsMasterIp) {
strcpy(tsMasterIp, ip);
}
tsServerIp = inet_addr(ip);
}
#endif
pObj = (STscObj *)malloc(sizeof(STscObj)); pObj = (STscObj *)malloc(sizeof(STscObj));
if (NULL == pObj) { if (NULL == pObj) {
@ -174,11 +165,6 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t 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 *param, void **taos) {
#ifndef CLUSTER
if (ip == NULL) {
ip = tsMasterIp;
}
#endif
return taos_connect_imp(ip, user, pass, db, port, fp, param, taos); return taos_connect_imp(ip, user, pass, db, port, fp, param, taos);
} }

View File

@ -95,7 +95,6 @@ void taos_init_imp() {
taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note"); taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note");
} }
#ifdef CLUSTER
tscMgmtIpList.numOfIps = 2; tscMgmtIpList.numOfIps = 2;
strcpy(tscMgmtIpList.ipstr[0], tsMasterIp); strcpy(tscMgmtIpList.ipstr[0], tsMasterIp);
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp); tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
@ -108,7 +107,6 @@ void taos_init_imp() {
strcpy(tscMgmtIpList.ipstr[2], tsSecondIp); strcpy(tscMgmtIpList.ipstr[2], tsSecondIp);
tscMgmtIpList.ip[2] = inet_addr(tsSecondIp); tscMgmtIpList.ip[2] = inet_addr(tsSecondIp);
} }
#endif
tscInitMsgs(); tscInitMsgs();
slaveIndex = rand(); slaveIndex = rand();

View File

@ -91,7 +91,7 @@ extern "C" {
#define TSDB_CODE_INVALID_QHANDLE 70 #define TSDB_CODE_INVALID_QHANDLE 70
#define TSDB_CODE_RELATED_TABLES_EXIST 71 #define TSDB_CODE_RELATED_TABLES_EXIST 71
#define TSDB_CODE_MONITOR_DB_FORBEIDDEN 72 #define TSDB_CODE_MONITOR_DB_FORBEIDDEN 72
#define TSDB_CODE_VG_COMMITLOG_INIT_FAILED 73 #define TSDB_CODE_NO_DISK_PERMISSIONS 73
#define TSDB_CODE_VG_INIT_FAILED 74 #define TSDB_CODE_VG_INIT_FAILED 74
#define TSDB_CODE_DATA_ALREADY_IMPORTED 75 #define TSDB_CODE_DATA_ALREADY_IMPORTED 75
#define TSDB_CODE_OPS_NOT_SUPPORT 76 #define TSDB_CODE_OPS_NOT_SUPPORT 76

View File

@ -54,6 +54,7 @@ extern char tsDirectory[];
extern char dataDir[]; extern char dataDir[];
extern char logDir[]; extern char logDir[];
extern char scriptDir[]; extern char scriptDir[];
extern char osName[];
extern char tsMasterIp[]; extern char tsMasterIp[];
extern char tsSecondIp[]; extern char tsSecondIp[];
@ -78,7 +79,6 @@ extern char tsPrivateIp[];
extern short tsNumOfVnodesPerCore; extern short tsNumOfVnodesPerCore;
extern short tsNumOfTotalVnodes; extern short tsNumOfTotalVnodes;
extern short tsCheckHeaderFile; extern short tsCheckHeaderFile;
extern uint32_t tsServerIp;
extern uint32_t tsPublicIpInt; extern uint32_t tsPublicIpInt;
extern int tsSessionsPerVnode; extern int tsSessionsPerVnode;

View File

@ -38,13 +38,13 @@ typedef struct SPoint {
void * val; void * val;
} SPoint; } SPoint;
typedef void (*__interpo_callback_fn_t)(void *param);
int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char intervalTimeUnit, int16_t precision); int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char intervalTimeUnit, int16_t precision);
void taosInitInterpoInfo(SInterpolationInfo *pInterpoInfo, int32_t order, int64_t startTimeStamp, int32_t numOfTags, void taosInitInterpoInfo(SInterpolationInfo *pInterpoInfo, int32_t order, int64_t startTimeStamp, int32_t numOfTags,
int32_t rowSize); int32_t rowSize);
void taosDestoryInterpoInfo(SInterpolationInfo *pInterpoInfo);
void taosInterpoSetStartInfo(SInterpolationInfo *pInterpoInfo, int32_t numOfRawDataInRows, int32_t type); void taosInterpoSetStartInfo(SInterpolationInfo *pInterpoInfo, int32_t numOfRawDataInRows, int32_t type);
TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int32_t timeInterval, int8_t intervalTimeUnit, int8_t precision); TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int32_t timeInterval, int8_t intervalTimeUnit, int8_t precision);
@ -78,8 +78,8 @@ int32_t taosNumOfRemainPoints(SInterpolationInfo *pInterpoInfo);
*/ */
int32_t taosDoInterpoResult(SInterpolationInfo *pInterpoInfo, int16_t interpoType, tFilePage **data, int32_t taosDoInterpoResult(SInterpolationInfo *pInterpoInfo, int16_t interpoType, tFilePage **data,
int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval, int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval,
int64_t *pPrimaryKeyArray, tColModel *pModel, char **srcData, int64_t *defaultVal, const int64_t *pPrimaryKeyArray, tColModel *pModel, char **srcData, int64_t *defaultVal,
int32_t *functionIDs, int32_t bufSize); const int32_t *functionIDs, int32_t bufSize);
int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point); int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point);

View File

@ -9,6 +9,7 @@ INCLUDE_DIRECTORIES(inc)
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
AUX_SOURCE_DIRECTORY(./src SRC) AUX_SOURCE_DIRECTORY(./src SRC)
LIST(REMOVE_ITEM SRC ./src/shellWindows.c) LIST(REMOVE_ITEM SRC ./src/shellWindows.c)
LIST(REMOVE_ITEM SRC ./src/shellDarwin.c)
ADD_EXECUTABLE(shell ${SRC}) ADD_EXECUTABLE(shell ${SRC})
TARGET_LINK_LIBRARIES(shell taos_static) TARGET_LINK_LIBRARIES(shell taos_static)
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)
@ -24,7 +25,9 @@ ELSEIF (TD_WINDOWS_64)
ELSEIF (TD_DARWIN_64) ELSEIF (TD_DARWIN_64)
LIST(APPEND SRC ./src/shellEngine.c) LIST(APPEND SRC ./src/shellEngine.c)
LIST(APPEND SRC ./src/shellMain.c) LIST(APPEND SRC ./src/shellMain.c)
LIST(APPEND SRC ./src/shellWindows.c) LIST(APPEND SRC ./src/shellDarwin.c)
LIST(APPEND SRC ./src/shellCommand.c)
LIST(APPEND SRC ./src/shellImport.c)
ADD_EXECUTABLE(shell ${SRC}) ADD_EXECUTABLE(shell ${SRC})
TARGET_LINK_LIBRARIES(shell taos_static) TARGET_LINK_LIBRARIES(shell taos_static)
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)

View File

@ -0,0 +1,532 @@
/*
* 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/>.
*/
#define __USE_XOPEN
#include "os.h"
#include "shell.h"
#include "shellCommand.h"
#include "tkey.h"
#define OPT_ABORT 1 /* <20>Cabort */
int indicator = 1;
struct termios oldtio;
extern int wcwidth(wchar_t c);
void insertChar(Command *cmd, char *c, int size);
void printHelp() {
char indent[10] = " ";
printf("taos shell is used to test the TDEngine database\n");
printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "TDEngine server IP address to connect. The default host is localhost.");
printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server.");
printf("%s%s\n", indent, "-P");
printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection");
printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "The TDEngine user name to use when connecting to the server.");
printf("%s%s\n", indent, "-c");
printf("%s%s%s\n", indent, indent, "Configuration directory.");
printf("%s%s\n", indent, "-s");
printf("%s%s%s\n", indent, indent, "Commands to run without enter the shell.");
printf("%s%s\n", indent, "-r");
printf("%s%s%s\n", indent, indent, "Output time as unsigned long..");
printf("%s%s\n", indent, "-f");
printf("%s%s%s\n", indent, indent, "Script to run without enter the shell.");
printf("%s%s\n", indent, "-d");
printf("%s%s%s\n", indent, indent, "Database to use when connecting to the server.");
printf("%s%s\n", indent, "-t");
printf("%s%s%s\n", indent, indent, "Time zone of the shell, default is local.");
printf("%s%s\n", indent, "-D");
printf("%s%s%s\n", indent, indent, "Use multi-thread to import all SQL files in the directory separately.");
printf("%s%s\n", indent, "-T");
printf("%s%s%s\n", indent, indent, "Number of threads when using multi-thread to import data.");
exit(EXIT_SUCCESS);
}
void shellParseArgument(int argc, char *argv[], struct arguments *arguments) {
wordexp_t full_path;
for (int i = 1; i < argc; i++) {
// for host
if (strcmp(argv[i], "-h") == 0) {
if (i < argc - 1) {
arguments->host = argv[++i];
} else {
fprintf(stderr, "option -h requires an argument\n");
exit(EXIT_FAILURE);
}
}
// for password
else if (strcmp(argv[i], "-p") == 0) {
arguments->is_use_passwd = true;
}
// for management port
else if (strcmp(argv[i], "-P") == 0) {
if (i < argc - 1) {
tsMgmtShellPort = atoi(argv[++i]);
} else {
fprintf(stderr, "option -P requires an argument\n");
exit(EXIT_FAILURE);
}
}
// for user
else if (strcmp(argv[i], "-u") == 0) {
if (i < argc - 1) {
arguments->user = argv[++i];
} else {
fprintf(stderr, "option -u requires an argument\n");
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) {
strcpy(configDir, argv[++i]);
} else {
fprintf(stderr, "Option -c requires an argument\n");
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-s") == 0) {
if (i < argc - 1) {
arguments->commands = argv[++i];
} else {
fprintf(stderr, "option -s requires an argument\n");
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-r") == 0) {
arguments->is_raw_time = true;
}
// For temperory batch commands to run TODO
else if (strcmp(argv[i], "-f") == 0) {
if (i < argc - 1) {
strcpy(arguments->file, argv[++i]);
} else {
fprintf(stderr, "option -f requires an argument\n");
exit(EXIT_FAILURE);
}
}
// for default database
else if (strcmp(argv[i], "-d") == 0) {
if (i < argc - 1) {
arguments->database = argv[++i];
} else {
fprintf(stderr, "option -d requires an argument\n");
exit(EXIT_FAILURE);
}
}
// For time zone
else if (strcmp(argv[i], "-t") == 0) {
if (i < argc - 1) {
arguments->timezone = argv[++i];
} else {
fprintf(stderr, "option -t requires an argument\n");
exit(EXIT_FAILURE);
}
}
// For import directory
else if (strcmp(argv[i], "-D") == 0) {
if (i < argc - 1) {
if (wordexp(argv[++i], &full_path, 0) != 0) {
fprintf(stderr, "Invalid path %s\n", argv[i]);
exit(EXIT_FAILURE);
}
strcpy(arguments->dir, full_path.we_wordv[0]);
wordfree(&full_path);
} else {
fprintf(stderr, "option -D requires an argument\n");
exit(EXIT_FAILURE);
}
}
// For time zone
else if (strcmp(argv[i], "-T") == 0) {
if (i < argc - 1) {
arguments->threadNum = atoi(argv[++i]);
} else {
fprintf(stderr, "option -T requires an argument\n");
exit(EXIT_FAILURE);
}
}
// For temperory command TODO
else if (strcmp(argv[i], "--help") == 0) {
printHelp();
exit(EXIT_FAILURE);
} else {
fprintf(stderr, "wrong options\n");
printHelp();
exit(EXIT_FAILURE);
}
}
}
void shellReadCommand(TAOS *con, char *command) {
unsigned hist_counter = history.hend;
char utf8_array[10] = "\0";
Command cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.buffer = (char *)calloc(1, MAX_COMMAND_SIZE);
cmd.command = (char *)calloc(1, MAX_COMMAND_SIZE);
showOnScreen(&cmd);
// Read input.
char c;
while (1) {
c = getchar();
if (c < 0) { // For UTF-8
int count = countPrefixOnes(c);
utf8_array[0] = c;
for (int k = 1; k < count; k++) {
c = getchar();
utf8_array[k] = c;
}
insertChar(&cmd, utf8_array, count);
} else if (c < '\033') {
// Ctrl keys. TODO: Implement ctrl combinations
switch (c) {
case 1: // ctrl A
positionCursorHome(&cmd);
break;
case 3:
printf("\n");
resetCommand(&cmd, "");
kill(0, SIGINT);
break;
case 4: // EOF or Ctrl+D
printf("\n");
taos_close(con);
// write the history
write_history();
exitShell();
break;
case 5: // ctrl E
positionCursorEnd(&cmd);
break;
case 8:
backspaceChar(&cmd);
break;
case '\n':
case '\r':
printf("\n");
if (isReadyGo(&cmd)) {
sprintf(command, "%s%s", cmd.buffer, cmd.command);
tfree(cmd.buffer);
tfree(cmd.command);
return;
} else {
updateBuffer(&cmd);
}
break;
case 12: // Ctrl + L;
system("clear");
showOnScreen(&cmd);
break;
}
} else if (c == '\033') {
c = getchar();
switch (c) {
case '[':
c = getchar();
switch (c) {
case 'A': // Up arrow
if (hist_counter != history.hstart) {
hist_counter = (hist_counter + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE;
resetCommand(&cmd, (history.hist[hist_counter] == NULL) ? "" : history.hist[hist_counter]);
}
break;
case 'B': // Down arrow
if (hist_counter != history.hend) {
int next_hist = (hist_counter + 1) % MAX_HISTORY_SIZE;
if (next_hist != history.hend) {
resetCommand(&cmd, (history.hist[next_hist] == NULL) ? "" : history.hist[next_hist]);
} else {
resetCommand(&cmd, "");
}
hist_counter = next_hist;
}
break;
case 'C': // Right arrow
moveCursorRight(&cmd);
break;
case 'D': // Left arrow
moveCursorLeft(&cmd);
break;
case '1':
if ((c = getchar()) == '~') {
// Home key
positionCursorHome(&cmd);
}
break;
case '2':
if ((c = getchar()) == '~') {
// Insert key
}
break;
case '3':
if ((c = getchar()) == '~') {
// Delete key
deleteChar(&cmd);
}
break;
case '4':
if ((c = getchar()) == '~') {
// End key
positionCursorEnd(&cmd);
}
break;
case '5':
if ((c = getchar()) == '~') {
// Page up key
}
break;
case '6':
if ((c = getchar()) == '~') {
// Page down key
}
break;
case 72:
// Home key
positionCursorHome(&cmd);
break;
case 70:
// End key
positionCursorEnd(&cmd);
break;
}
break;
}
} else if (c == 0x7f) {
// press delete key
backspaceChar(&cmd);
} else {
insertChar(&cmd, &c, 1);
}
}
}
void *shellLoopQuery(void *arg) {
if (indicator) {
get_old_terminal_mode(&oldtio);
indicator = 0;
}
TAOS *con = (TAOS *)arg;
pthread_cleanup_push(cleanup_handler, NULL);
char *command = malloc(MAX_COMMAND_SIZE);
if (command == NULL){
tscError("failed to malloc command");
return NULL;
}
while (1) {
// Read command from shell.
memset(command, 0, MAX_COMMAND_SIZE);
set_terminal_mode();
shellReadCommand(con, command);
reset_terminal_mode();
// Run the command
shellRunCommand(con, command);
}
pthread_cleanup_pop(1);
return NULL;
}
void shellPrintNChar(char *str, int width, bool printMode) {
int col_left = width;
wchar_t wc;
while (col_left > 0) {
if (*str == '\0') break;
char *tstr = str;
int byte_width = mbtowc(&wc, tstr, MB_CUR_MAX);
if (byte_width <= 0) break;
int col_width = wcwidth(wc);
if (col_width <= 0) {
str += byte_width;
continue;
}
if (col_left < col_width) break;
printf("%lc", wc);
str += byte_width;
col_left -= col_width;
}
while (col_left > 0) {
printf(" ");
col_left--;
}
if (!printMode) {
printf("|");
} else {
printf("\n");
}
}
int get_old_terminal_mode(struct termios *tio) {
/* Make sure stdin is a terminal. */
if (!isatty(STDIN_FILENO)) {
return -1;
}
// Get the parameter of current terminal
if (tcgetattr(0, &oldtio) != 0) {
return -1;
}
return 1;
}
void reset_terminal_mode() {
if (tcsetattr(0, TCSANOW, &oldtio) != 0) {
fprintf(stderr, "Fail to reset the terminal properties!\n");
exit(EXIT_FAILURE);
}
}
void set_terminal_mode() {
struct termios newtio;
/* if (atexit(reset_terminal_mode) != 0) { */
/* fprintf(stderr, "Error register exit function!\n"); */
/* exit(EXIT_FAILURE); */
/* } */
memcpy(&newtio, &oldtio, sizeof(oldtio));
// Set new terminal attributes.
newtio.c_iflag &= ~(IXON | IXOFF | ICRNL | INLCR | IGNCR | IMAXBEL | ISTRIP);
newtio.c_iflag |= IGNBRK;
// newtio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET);
newtio.c_oflag |= OPOST;
newtio.c_oflag |= ONLCR;
newtio.c_oflag &= ~(OCRNL | ONLRET);
newtio.c_lflag &= ~(IEXTEN | ICANON | ECHO | ECHOE | ECHONL | ECHOCTL | ECHOPRT | ECHOKE | ISIG);
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSANOW, &newtio) != 0) {
fprintf(stderr, "Fail to set terminal properties!\n");
exit(EXIT_FAILURE);
}
}
void get_history_path(char *history) { sprintf(history, "%s/%s", getpwuid(getuid())->pw_dir, HISTORY_FILE); }
void clearScreen(int ecmd_pos, int cursor_pos) {
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
int cursor_x = cursor_pos / w.ws_col;
int cursor_y = cursor_pos % w.ws_col;
int command_x = ecmd_pos / w.ws_col;
positionCursor(cursor_y, LEFT);
positionCursor(command_x - cursor_x, DOWN);
fprintf(stdout, "\033[2K");
for (int i = 0; i < command_x; i++) {
positionCursor(1, UP);
fprintf(stdout, "\033[2K");
}
fflush(stdout);
}
void showOnScreen(Command *cmd) {
struct winsize w;
if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) {
fprintf(stderr, "No stream device\n");
exit(EXIT_FAILURE);
}
wchar_t wc;
int size = 0;
// Print out the command.
char *total_string = malloc(MAX_COMMAND_SIZE);
memset(total_string, '\0', MAX_COMMAND_SIZE);
if (strcmp(cmd->buffer, "") == 0) {
sprintf(total_string, "%s%s", PROMPT_HEADER, cmd->command);
} else {
sprintf(total_string, "%s%s", CONTINUE_PROMPT, cmd->command);
}
int remain_column = w.ws_col;
/* size = cmd->commandSize + prompt_size; */
for (char *str = total_string; size < cmd->commandSize + prompt_size;) {
int ret = mbtowc(&wc, str, MB_CUR_MAX);
if (ret < 0) break;
size += ret;
/* assert(size >= 0); */
int width = wcwidth(wc);
if (remain_column > width) {
printf("%lc", wc);
remain_column -= width;
} else {
if (remain_column == width) {
printf("%lc\n\r", wc);
remain_column = w.ws_col;
} else {
printf("\n\r%lc", wc);
remain_column = w.ws_col - width;
}
}
str = total_string + size;
}
free(total_string);
/* for (int i = 0; i < size; i++){ */
/* char c = total_string[i]; */
/* if (k % w.ws_col == 0) { */
/* printf("%c\n\r", c); */
/* } */
/* else { */
/* printf("%c", c); */
/* } */
/* k += 1; */
/* } */
// Position the cursor
int cursor_pos = cmd->screenOffset + prompt_size;
int ecmd_pos = cmd->endOffset + prompt_size;
int cursor_x = cursor_pos / w.ws_col;
int cursor_y = cursor_pos % w.ws_col;
// int cursor_y = cursor % w.ws_col;
int command_x = ecmd_pos / w.ws_col;
int command_y = ecmd_pos % w.ws_col;
// int command_y = (command.size() + prompt_size) % w.ws_col;
positionCursor(command_y, LEFT);
positionCursor(command_x, UP);
positionCursor(cursor_x, DOWN);
positionCursor(cursor_y, RIGHT);
fflush(stdout);
}
void cleanup_handler(void *arg) { tcsetattr(0, TCSANOW, &oldtio); }
void exitShell() {
tcsetattr(0, TCSANOW, &oldtio);
exit(EXIT_SUCCESS);
}

View File

@ -21,28 +21,13 @@
#include "shellCommand.h" #include "shellCommand.h"
#include "ttime.h" #include "ttime.h"
#include "tutil.h" #include "tutil.h"
#include "taoserror.h"
#include <regex.h> #include <regex.h>
/**************** Global variables ****************/ /**************** Global variables ****************/
#ifdef WINDOWS char CLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n"
char CLIENT_VERSION[] = "Welcome to the TDengine shell from windows, client version:%s "; "Copyright (c) 2017 by TAOS Data, Inc. All rights reserved.\n\n";
#elif defined(DARWIN)
char CLIENT_VERSION[] = "Welcome to the TDengine shell from mac, client version:%s ";
#else
#ifdef CLUSTER
char CLIENT_VERSION[] = "Welcome to the TDengine shell from linux, enterprise client version:%s ";
#else
char CLIENT_VERSION[] = "Welcome to the TDengine shell from linux, community client version:%s ";
#endif
#endif
#ifdef CLUSTER
char SERVER_VERSION[] = "enterprise server version:%s\nCopyright (c) 2017 by TAOS Data, Inc. All rights reserved.\n\n";
#else
char SERVER_VERSION[] = "community server version:%s\nCopyright (c) 2017 by TAOS Data, Inc. All rights reserved.\n\n";
#endif
char PROMPT_HEADER[] = "taos> "; char PROMPT_HEADER[] = "taos> ";
char CONTINUE_PROMPT[] = " -> "; char CONTINUE_PROMPT[] = " -> ";
int prompt_size = 6; int prompt_size = 6;
@ -54,7 +39,7 @@ History history;
*/ */
TAOS *shellInit(struct arguments *args) { TAOS *shellInit(struct arguments *args) {
printf("\n"); printf("\n");
printf(CLIENT_VERSION, taos_get_client_info()); printf(CLIENT_VERSION, osName, taos_get_client_info());
fflush(stdout); fflush(stdout);
// set options before initializing // set options before initializing
@ -111,7 +96,7 @@ TAOS *shellInit(struct arguments *args) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
#ifdef LINUX #ifndef WINDOWS
if (args->dir[0] != 0) { if (args->dir[0] != 0) {
source_dir(con, args); source_dir(con, args);
taos_close(con); taos_close(con);
@ -119,8 +104,6 @@ TAOS *shellInit(struct arguments *args) {
} }
#endif #endif
printf(SERVER_VERSION, taos_get_server_info(con));
return con; return con;
} }
@ -817,11 +800,16 @@ void source_file(TAOS *con, char *fptr) {
} }
void shellGetGrantInfo(void *con) { void shellGetGrantInfo(void *con) {
#ifdef CLUSTER
char sql[] = "show grants"; char sql[] = "show grants";
if (taos_query(con, sql)) { int code = taos_query(con, sql);
fprintf(stdout, "\n");
if (code != TSDB_CODE_SUCCESS) {
if (code == TSDB_CODE_OPS_NOT_SUPPORT) {
fprintf(stdout, "Server is Community Edition, version is %s\n\n", taos_get_server_info(con));
} else {
fprintf(stderr, "Failed to check Server Edition, Reason:%d:%s\n\n", taos_errno(con), taos_errstr(con));
}
return; return;
} }
@ -843,18 +831,18 @@ void shellGetGrantInfo(void *con) {
exit(0); exit(0);
} }
char version[32] = {0}; char serverVersion[32] = {0};
char expiretime[32] = {0}; char expiretime[32] = {0};
char expired[32] = {0}; char expired[32] = {0};
memcpy(version, row[0], fields[0].bytes); memcpy(serverVersion, row[0], fields[0].bytes);
memcpy(expiretime, row[1], fields[1].bytes); memcpy(expiretime, row[1], fields[1].bytes);
memcpy(expired, row[2], fields[2].bytes); memcpy(expired, row[2], fields[2].bytes);
if (strcmp(expiretime, "unlimited") == 0) { if (strcmp(expiretime, "unlimited") == 0) {
fprintf(stdout, "This is the %s version and will never expire.\n", version); fprintf(stdout, "Server is Enterprise %s Edition, version is %s and will never expire.\n", serverVersion, taos_get_server_info(con));
} else { } else {
fprintf(stdout, "This is the %s version and will expire at %s.\n", version, expiretime); fprintf(stdout, "Server is Enterprise %s Edition, version is %s and will expire at %s.\n", serverVersion, taos_get_server_info(con), expiretime);
} }
taos_free_result(result); taos_free_result(result);
@ -862,5 +850,4 @@ void shellGetGrantInfo(void *con) {
} }
fprintf(stdout, "\n"); fprintf(stdout, "\n");
#endif
} }

View File

@ -90,20 +90,12 @@ static void shellParseDirectory(const char *directoryName, const char *prefix, c
static void shellCheckTablesSQLFile(const char *directoryName) static void shellCheckTablesSQLFile(const char *directoryName)
{ {
char cmd[1024] = { 0 }; sprintf(shellTablesSQLFile, "%s/tables.sql", directoryName);
sprintf(cmd, "ls %s/tables.sql", directoryName);
FILE *fp = popen(cmd, "r"); struct stat fstat;
if (fp == NULL) { if (stat(shellTablesSQLFile, &fstat) < 0) {
fprintf(stderr, "ERROR: failed to execute:%s, error:%s\n", cmd, strerror(errno)); shellTablesSQLFile[0] = 0;
exit(0);
} }
while (fscanf(fp, "%s", shellTablesSQLFile)) {
break;
}
pclose(fp);
} }
static void shellMallocSQLFiles() static void shellMallocSQLFiles()

View File

@ -119,13 +119,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
static struct argp argp = {options, parse_opt, args_doc, doc}; static struct argp argp = {options, parse_opt, args_doc, doc};
void shellParseArgument(int argc, char *argv[], struct arguments *arguments) { void shellParseArgument(int argc, char *argv[], struct arguments *arguments) {
char verType[32] = {0}; static char verType[32] = {0};
#ifdef CLUSTER sprintf(verType, "version: %s\n", version);
sprintf(verType, "enterprise version: %s\n", version);
#else
sprintf(verType, "community version: %s\n", version);
#endif
argp_program_version = verType; argp_program_version = verType;
argp_parse(&argp, argc, argv, 0, 0, arguments); argp_parse(&argp, argc, argv, 0, 0, arguments);

View File

@ -79,7 +79,9 @@ void gcStopQueryJson(HttpContext *pContext, HttpSqlCmd *cmd) {
if (jsonBuf == NULL) return; if (jsonBuf == NULL) return;
// write end of target // write end of target
gcWriteTargetEndJson(jsonBuf); if (cmd->numOfRows != 0) {
gcWriteTargetEndJson(jsonBuf);
}
} }
bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int numOfRows) { bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int numOfRows) {
@ -116,8 +118,8 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
if (groupFields == -1 && cmd->numOfRows == 0) { if (groupFields == -1 && cmd->numOfRows == 0) {
gcWriteTargetStartJson(jsonBuf, refIdBuffer, aliasBuffer); gcWriteTargetStartJson(jsonBuf, refIdBuffer, aliasBuffer);
cmd->numOfRows += numOfRows;
} }
cmd->numOfRows += numOfRows;
for (int k = 0; k < numOfRows; ++k) { for (int k = 0; k < numOfRows; ++k) {
TAOS_ROW row = taos_fetch_row(result); TAOS_ROW row = taos_fetch_row(result);
@ -158,7 +160,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
} }
break; break;
default: default:
snprintf(target, HTTP_GC_TARGET_SIZE, "%s%s", aliasBuffer, "invalidcol"); snprintf(target, HTTP_GC_TARGET_SIZE, "%s%s", aliasBuffer, "-");
break; break;
} }
@ -217,7 +219,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
} }
break; break;
default: default:
httpJsonString(jsonBuf, "invalidcol", 10); httpJsonString(jsonBuf, "-", 1);
break; break;
} }
} }

View File

@ -310,7 +310,9 @@ void httpJsonInt(JsonBuf* buf, int num) {
void httpJsonFloat(JsonBuf* buf, float num) { void httpJsonFloat(JsonBuf* buf, float num) {
httpJsonItemToken(buf); httpJsonItemToken(buf);
httpJsonTestBuf(buf, MAX_NUM_STR_SZ); httpJsonTestBuf(buf, MAX_NUM_STR_SZ);
if (num > 1E10 || num < -1E10) { if (isinf(num) || isnan(num)) {
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "null");
} else if (num > 1E10 || num < -1E10) {
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.5e", num); buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.5e", num);
} else { } else {
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.5f", num); buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.5f", num);
@ -320,7 +322,9 @@ void httpJsonFloat(JsonBuf* buf, float num) {
void httpJsonDouble(JsonBuf* buf, double num) { void httpJsonDouble(JsonBuf* buf, double num) {
httpJsonItemToken(buf); httpJsonItemToken(buf);
httpJsonTestBuf(buf, MAX_NUM_STR_SZ); httpJsonTestBuf(buf, MAX_NUM_STR_SZ);
if (num > 1E10 || num < -1E10) { if (isinf(num) || isnan(num)) {
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "null");
} else if (num > 1E10 || num < -1E10) {
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.9e", num); buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.9e", num);
} else { } else {
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.9f", num); buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%.9f", num);

View File

@ -67,10 +67,16 @@ bool restProcessSqlRequest(HttpContext* pContext, int timestampFmt) {
return false; return false;
} }
/*
* for async test
* /
/*
if (httpCheckUsedbSql(sql)) { if (httpCheckUsedbSql(sql)) {
httpSendErrorResp(pContext, HTTP_NO_EXEC_USEDB); httpSendErrorResp(pContext, HTTP_NO_EXEC_USEDB);
return false; return false;
} }
*/
HttpSqlCmd* cmd = &(pContext->singleCmd); HttpSqlCmd* cmd = &(pContext->singleCmd);
cmd->nativSql = sql; cmd->nativSql = sql;

View File

@ -217,9 +217,7 @@ void monitorInitDatabaseCb(void *param, TAOS_RES *result, int code) {
if (monitor->cmdIndex == MONITOR_CMD_CREATE_TB_LOG) { if (monitor->cmdIndex == MONITOR_CMD_CREATE_TB_LOG) {
taosLogFp = monitorSaveLog; taosLogFp = monitorSaveLog;
taosLogSqlFp = monitorExecuteSQL; taosLogSqlFp = monitorExecuteSQL;
#ifdef CLUSTER
taosLogAcctFp = monitorSaveAcctLog; taosLogAcctFp = monitorSaveAcctLog;
#endif
monitorLPrint("dnode:%s is started", tsPrivateIp); monitorLPrint("dnode:%s is started", tsPrivateIp);
} }
monitor->cmdIndex++; monitor->cmdIndex++;

View File

@ -1,57 +1,85 @@
/* /*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com> * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* *
* This program is free software: you can use, redistribute, and/or modify * 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 * it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation. * or later ("AGPL"), as published by the Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. * FITNESS FOR A PARTICULAR PURPOSE.
* *
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_PLATFORM_LINUX_H
#define TDENGINE_PLATFORM_LINUX_H
#ifndef TDENGINE_PLATFORM_DARWIN_H #ifdef __cplusplus
#define TDENGINE_PLATFORM_DARWIN_H extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <pwd.h>
#include <syslog.h>
#include <termios.h>
#include <wordexp.h>
#include <unistd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <float.h>
#include <ifaddrs.h>
#include <libgen.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netinet/udp.h> #include <netinet/udp.h>
#include <pthread.h>
#include <pwd.h>
#include <regex.h>
#include <semaphore.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/statvfs.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/un.h> #include <sys/un.h>
#include <stdint.h> #include <syslog.h>
#include <pthread.h> #include <termios.h>
#include <stdbool.h> #include <unistd.h>
#include <limits.h> #include <wchar.h>
#include <locale.h> #include <wordexp.h>
#include <wctype.h>
#include <inttypes.h>
#include <dispatch/dispatch.h> #include <dispatch/dispatch.h>
#define htobe64 htonll #define htobe64 htonll
#define taosCloseSocket(x) \ #define taosCloseSocket(x) \
{ \ { \
if (FD_VALID(x)) { \ if (FD_VALID(x)) { \
close(x); \ close(x); \
x = -1; \ x = FD_INITIALIZER; \
} \ } \
} }
#define taosWriteSocket(fd, buf, len) write(fd, buf, len) #define taosWriteSocket(fd, buf, len) write(fd, buf, len)
#define taosReadSocket(fd, buf, len) read(fd, buf, len) #define taosReadSocket(fd, buf, len) read(fd, buf, len)
@ -160,7 +188,7 @@
(__a < __b) ? __a : __b; \ (__a < __b) ? __a : __b; \
}) })
#define MILLISECOND_PER_SECOND (1000L) #define MILLISECOND_PER_SECOND ((int64_t)1000L)
#define tsem_t dispatch_semaphore_t #define tsem_t dispatch_semaphore_t
@ -197,6 +225,10 @@ bool taosSkipSocketCheck();
bool taosGetDisk(); bool taosGetDisk();
int fsendfile(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count);
void taosSetCoreDump();
typedef int(*__compar_fn_t)(const void *, const void *); typedef int(*__compar_fn_t)(const void *, const void *);
// for send function in tsocket.c // for send function in tsocket.c
@ -219,4 +251,8 @@ typedef int(*__compar_fn_t)(const void *, const void *);
#define BUILDIN_CLZ(val) __builtin_clz(val) #define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val) #define BUILDIN_CTZ(val) __builtin_ctz(val)
#endif #ifdef __cplusplus
}
#endif
#endif

View File

@ -33,11 +33,12 @@
#include "tsdb.h" #include "tsdb.h"
#include "tutil.h" #include "tutil.h"
char configDir[TSDB_FILENAME_LEN] = "~/TDengine/cfg"; char configDir[TSDB_FILENAME_LEN] = "/etc/taos";
char tsDirectory[TSDB_FILENAME_LEN] = "~/TDengine/data"; char tsDirectory[TSDB_FILENAME_LEN] = "/var/lib/taos";
char dataDir[TSDB_FILENAME_LEN] = "~/TDengine/data"; char dataDir[TSDB_FILENAME_LEN] = "/var/lib/taos";
char logDir[TSDB_FILENAME_LEN] = "~/TDengine/log"; char logDir[TSDB_FILENAME_LEN] = "~/TDengineLog";
char scriptDir[TSDB_FILENAME_LEN] = "~/TDengine/script"; char scriptDir[TSDB_FILENAME_LEN] = "/etc/taos";
char osName[] = "Darwin";
int64_t str2int64(char *str) { int64_t str2int64(char *str) {
char *endptr = NULL; char *endptr = NULL;
@ -418,4 +419,43 @@ int32_t __sync_val_load_32(int32_t *ptr) {
void __sync_val_restore_32(int32_t *ptr, int32_t newval) { void __sync_val_restore_32(int32_t *ptr, int32_t newval) {
__atomic_store_n(ptr, newval, __ATOMIC_RELEASE); __atomic_store_n(ptr, newval, __ATOMIC_RELEASE);
} }
#define _SEND_FILE_STEP_ 1000
int fsendfile(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count) {
fseek(in_file, (int32_t)(*offset), 0);
int writeLen = 0;
uint8_t buffer[_SEND_FILE_STEP_] = { 0 };
for (int len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
size_t rlen = fread(buffer, 1, _SEND_FILE_STEP_, in_file);
if (rlen <= 0) {
return writeLen;
}
else if (rlen < _SEND_FILE_STEP_) {
fwrite(buffer, 1, rlen, out_file);
return (int)(writeLen + rlen);
}
else {
fwrite(buffer, 1, _SEND_FILE_STEP_, in_file);
writeLen += _SEND_FILE_STEP_;
}
}
int remain = count - writeLen;
if (remain > 0) {
size_t rlen = fread(buffer, 1, remain, in_file);
if (rlen <= 0) {
return writeLen;
}
else {
fwrite(buffer, 1, remain, out_file);
writeLen += remain;
}
}
return writeLen;
}
void taosSetCoreDump() {}

View File

@ -39,6 +39,7 @@ char tsDirectory[TSDB_FILENAME_LEN] = "/var/lib/taos";
char dataDir[TSDB_FILENAME_LEN] = "/var/lib/taos"; char dataDir[TSDB_FILENAME_LEN] = "/var/lib/taos";
char logDir[TSDB_FILENAME_LEN] = "/var/log/taos"; char logDir[TSDB_FILENAME_LEN] = "/var/log/taos";
char scriptDir[TSDB_FILENAME_LEN] = "/etc/taos"; char scriptDir[TSDB_FILENAME_LEN] = "/etc/taos";
char osName[] = "Linux";
int64_t str2int64(char *str) { int64_t str2int64(char *str) {
char *endptr = NULL; char *endptr = NULL;

View File

@ -37,6 +37,7 @@ char tsDirectory[TSDB_FILENAME_LEN] = "C:/TDengine/data";
char logDir[TSDB_FILENAME_LEN] = "C:/TDengine/log"; char logDir[TSDB_FILENAME_LEN] = "C:/TDengine/log";
char dataDir[TSDB_FILENAME_LEN] = "C:/TDengine/data"; char dataDir[TSDB_FILENAME_LEN] = "C:/TDengine/data";
char scriptDir[TSDB_FILENAME_LEN] = "C:/TDengine/script"; char scriptDir[TSDB_FILENAME_LEN] = "C:/TDengine/script";
char osName[] = "Windows";
bool taosCheckPthreadValid(pthread_t thread) { bool taosCheckPthreadValid(pthread_t thread) {
return thread.p != NULL; return thread.p != NULL;

View File

@ -197,7 +197,7 @@ char *tsError[] = {"success",
"invalid query handle", // 70 "invalid query handle", // 70
"tables related to metric exist", "tables related to metric exist",
"can't drop monitor database or tables", "can't drop monitor database or tables",
"commit log init failed", "no disk permissions",
"vgroup init failed", "vgroup init failed",
"data is already imported", // 75 "data is already imported", // 75
"not supported operation", "not supported operation",
@ -234,7 +234,7 @@ char *tsError[] = {"success",
"timestamp disordered in cache block", "timestamp disordered in cache block",
"timestamp disordered in file block", "timestamp disordered in file block",
"invalid commit log", "invalid commit log",
"server no disk space", //110 "no disk space on server", //110
"only super table has metric meta info", "only super table has metric meta info",
"tags value not unique for join", "tags value not unique for join",
"invalid submit message", "invalid submit message",

View File

@ -698,7 +698,12 @@ int taosSendPacketViaTcp(uint32_t ip, uint16_t port, char *data, int dataLen, vo
// send a UDP header first to set up the connection // send a UDP header first to set up the connection
pHead = (STaosHeader *)buffer; pHead = (STaosHeader *)buffer;
memcpy(pHead, data, sizeof(STaosHeader)); memcpy(pHead, data, sizeof(STaosHeader));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wbitfield-constant-conversion"
pHead->tcp = 2; pHead->tcp = 2;
#pragma GCC diagnostic pop
msgLen = sizeof(STaosHeader); msgLen = sizeof(STaosHeader);
pHead->msgLen = (int32_t)htonl(msgLen); pHead->msgLen = (int32_t)htonl(msgLen);
code = taosSendUdpData(ip, port, buffer, msgLen, chandle); code = taosSendUdpData(ip, port, buffer, msgLen, chandle);

View File

@ -24,6 +24,8 @@
extern char version[]; extern char version[];
const int16_t sdbFileVersion = 0; const int16_t sdbFileVersion = 0;
int sdbExtConns = 0; int sdbExtConns = 0;
SIpList *pSdbIpList = NULL;
SIpList *pSdbPublicIpList = NULL;
#ifdef CLUSTER #ifdef CLUSTER
int sdbMaster = 0; int sdbMaster = 0;

View File

@ -16,16 +16,20 @@
#ifndef TDENGINE_TSTATUS_H #ifndef TDENGINE_TSTATUS_H
#define TDENGINE_TSTATUS_H #define TDENGINE_TSTATUS_H
#include "taoserror.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
enum _TSDB_VG_STATUS { enum _TSDB_VG_STATUS {
TSDB_VG_STATUS_READY, TSDB_VG_STATUS_READY = TSDB_CODE_SUCCESS,
TSDB_VG_STATUS_IN_PROGRESS, TSDB_VG_STATUS_IN_PROGRESS = TSDB_CODE_ACTION_IN_PROGRESS,
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED, TSDB_VG_STATUS_NO_DISK_PERMISSIONS = TSDB_CODE_NO_DISK_PERMISSIONS,
TSDB_VG_STATUS_INIT_FAILED, TSDB_VG_STATUS_SERVER_NO_PACE = TSDB_CODE_SERV_NO_DISKSPACE,
TSDB_VG_STATUS_FULL TSDB_VG_STATUS_SERV_OUT_OF_MEMORY = TSDB_CODE_SERV_OUT_OF_MEMORY,
TSDB_VG_STATUS_INIT_FAILED = TSDB_CODE_VG_INIT_FAILED,
TSDB_VG_STATUS_FULL = TSDB_CODE_NO_ENOUGH_DNODES,
}; };
enum _TSDB_DB_STATUS { enum _TSDB_DB_STATUS {

View File

@ -415,10 +415,10 @@ int vnodeProcessVPeerCfgRsp(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
int32_t *pint = (int32_t *)pRsp->more; int32_t *pint = (int32_t *)pRsp->more;
int vnode = htonl(*pint); int vnode = htonl(*pint);
if (vnode < TSDB_MAX_VNODES && vnodeList[vnode].lastKey != 0) { if (vnode < TSDB_MAX_VNODES && vnodeList[vnode].lastKey != 0) {
dError("vnode:%d not configured, it shall be empty"); dError("vnode:%d not configured, it shall be empty, code:%d", vnode, pRsp->code);
vnodeRemoveVnode(vnode); vnodeRemoveVnode(vnode);
} else { } else {
dTrace("vnode:%d is invalid", vnode); dError("vnode:%d is invalid, code:%d", vnode, pRsp->code);
} }
} }

View File

@ -152,19 +152,15 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
return 0; return 0;
} }
if (pRsp->code == 0) { if (pRsp->code == TSDB_CODE_SUCCESS) {
pDb->vgStatus = TSDB_VG_STATUS_READY; pDb->vgStatus = TSDB_VG_STATUS_READY;
mTrace("dnode:%s, db:%s vgroup is created in dnode", taosIpStr(pObj->privateIp), pRsp->more); mTrace("dnode:%s, db:%s vgroup is created in dnode", taosIpStr(pObj->privateIp), pRsp->more);
return 0; return 0;
} }
if (pRsp->code == TSDB_CODE_VG_COMMITLOG_INIT_FAILED) { pDb->vgStatus = pRsp->code;
pDb->vgStatus = TSDB_VG_STATUS_COMMITLOG_INIT_FAILED; mError("dnode:%s, db:%s vgroup init failed, code:%d %s",
mError("dnode:%s, db:%s vgroup commit log init failed, code:%d", taosIpStr(pObj->privateIp), pRsp->more, pRsp->code); taosIpStr(pObj->privateIp), pRsp->more, pRsp->code, taosGetVgroupStatusStr(pDb->vgStatus));
} else {
pDb->vgStatus = TSDB_VG_STATUS_INIT_FAILED;
mError("dnode:%s, db:%s vgroup init failed, code:%d", taosIpStr(pObj->privateIp), pRsp->more, pRsp->code);
}
return 0; return 0;
} }

View File

@ -657,16 +657,13 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
return TSDB_CODE_NO_ENOUGH_DNODES; return TSDB_CODE_NO_ENOUGH_DNODES;
} }
if (pDb->vgStatus == TSDB_VG_STATUS_COMMITLOG_INIT_FAILED) { if (pDb->vgStatus == TSDB_VG_STATUS_NO_DISK_PERMISSIONS ||
pDb->vgStatus == TSDB_VG_STATUS_SERVER_NO_PACE ||
pDb->vgStatus == TSDB_VG_STATUS_SERV_OUT_OF_MEMORY ||
pDb->vgStatus == TSDB_VG_STATUS_INIT_FAILED ) {
mgmtDestroyMeter(pMeter); mgmtDestroyMeter(pMeter);
mError("table:%s, commit log init failed", pCreate->meterId); mError("table:%s, vgroup init failed, reason:%d %s", pCreate->meterId, pDb->vgStatus, taosGetVgroupStatusStr(pDb->vgStatus));
return TSDB_CODE_VG_COMMITLOG_INIT_FAILED; return pDb->vgStatus;
}
if (pDb->vgStatus == TSDB_VG_STATUS_INIT_FAILED) {
mgmtDestroyMeter(pMeter);
mError("table:%s, vgroup init failed", pCreate->meterId);
return TSDB_CODE_VG_INIT_FAILED;
} }
if (pVgroup == NULL) { if (pVgroup == NULL) {

View File

@ -1202,21 +1202,28 @@ int mgmtProcessHeartBeatMsg(char *cont, int contLen, SConnObj *pConn) {
pConn->streamId = 0; pConn->streamId = 0;
pHBRsp->killConnection = pConn->killConnection; pHBRsp->killConnection = pConn->killConnection;
#ifdef CLUSTER
if (pConn->usePublicIp) { if (pConn->usePublicIp) {
int size = pSdbPublicIpList->numOfIps * 4; if (pSdbPublicIpList != NULL) {
pHBRsp->ipList.numOfIps = pSdbPublicIpList->numOfIps; int size = pSdbPublicIpList->numOfIps * 4;
memcpy(pHBRsp->ipList.ip, pSdbPublicIpList->ip, size); pHBRsp->ipList.numOfIps = pSdbPublicIpList->numOfIps;
pMsg += sizeof(SHeartBeatRsp) + size; memcpy(pHBRsp->ipList.ip, pSdbPublicIpList->ip, size);
pMsg += sizeof(SHeartBeatRsp) + size;
} else {
pHBRsp->ipList.numOfIps = 0;
pMsg += sizeof(SHeartBeatRsp);
}
} else { } else {
int size = pSdbIpList->numOfIps * 4; if (pSdbIpList != NULL) {
pHBRsp->ipList.numOfIps = pSdbIpList->numOfIps; int size = pSdbIpList->numOfIps * 4;
memcpy(pHBRsp->ipList.ip, pSdbIpList->ip, size); pHBRsp->ipList.numOfIps = pSdbIpList->numOfIps;
pMsg += sizeof(SHeartBeatRsp) + size; memcpy(pHBRsp->ipList.ip, pSdbIpList->ip, size);
pMsg += sizeof(SHeartBeatRsp) + size;
} else {
pHBRsp->ipList.numOfIps = 0;
pMsg += sizeof(SHeartBeatRsp);
}
} }
#else
pMsg += sizeof(SHeartBeatRsp);
#endif
msgLen = pMsg - pStart; msgLen = pMsg - pStart;
taosSendMsgToPeer(pConn->thandle, pStart, msgLen); taosSendMsgToPeer(pConn->thandle, pStart, msgLen);
@ -1334,15 +1341,22 @@ _rsp:
pConnectRsp->superAuth = pConn->superAuth; pConnectRsp->superAuth = pConn->superAuth;
pMsg += sizeof(SConnectRsp); pMsg += sizeof(SConnectRsp);
#ifdef CLUSTER int size;
int size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList); if (pSdbPublicIpList != NULL && pSdbIpList != NULL) {
if (pConn->usePublicIp) { size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList);
memcpy(pMsg, pSdbPublicIpList, size); if (pConn->usePublicIp) {
memcpy(pMsg, pSdbPublicIpList, size);
} else {
memcpy(pMsg, pSdbIpList, size);
}
} else { } else {
memcpy(pMsg, pSdbIpList, size); SIpList tmpIpList;
tmpIpList.numOfIps = 0;
size = tmpIpList.numOfIps * 4 + sizeof(SIpList);
memcpy(pMsg, &tmpIpList, size);
} }
pMsg += size; pMsg += size;
#endif
// set the time resolution: millisecond or microsecond // set the time resolution: millisecond or microsecond
*((uint32_t *)pMsg) = tsTimePrecision; *((uint32_t *)pMsg) = tsTimePrecision;

View File

@ -966,6 +966,7 @@ void vnodeSetCommitQuery(SMeterObj *pObj, SQuery *pQuery) {
pObj->vnode, pObj->sid, pObj->meterId, firstKey, pQuery->skey); pObj->vnode, pObj->sid, pObj->meterId, firstKey, pQuery->skey);
pthread_mutex_lock(&(pVnode->vmutex)); pthread_mutex_lock(&(pVnode->vmutex));
if (firstKey < pVnode->firstKey) pVnode->firstKey = firstKey; if (firstKey < pVnode->firstKey) pVnode->firstKey = firstKey;
assert(pVnode->firstKey > 0);
pthread_mutex_unlock(&(pVnode->vmutex)); pthread_mutex_unlock(&(pVnode->vmutex));
} }
} }

View File

@ -1823,7 +1823,7 @@ int vnodeUpdateFileMagic(int vnode, int fileId) {
} }
int vnodeInitFile(int vnode) { int vnodeInitFile(int vnode) {
int code = 0; int code = TSDB_CODE_SUCCESS;
SVnodeObj *pVnode = vnodeList + vnode; SVnodeObj *pVnode = vnodeList + vnode;
pVnode->maxFiles = pVnode->cfg.daysToKeep / pVnode->cfg.daysPerFile + 1; pVnode->maxFiles = pVnode->cfg.daysToKeep / pVnode->cfg.daysPerFile + 1;

View File

@ -77,8 +77,14 @@ int vnodeCreateMeterObjFile(int vnode) {
sprintf(fileName, "%s/vnode%d/meterObj.v%d", tsDirectory, vnode, vnode); sprintf(fileName, "%s/vnode%d/meterObj.v%d", tsDirectory, vnode, vnode);
fp = fopen(fileName, "w+"); fp = fopen(fileName, "w+");
if (fp == NULL) { if (fp == NULL) {
dError("failed to create vnode:%d file:%s", vnode, fileName); dError("failed to create vnode:%d file:%s, errno:%d, reason:%s", vnode, fileName, errno, strerror(errno));
return -1; if (errno == EACCES) {
return TSDB_CODE_NO_DISK_PERMISSIONS;
} else if (errno == ENOSPC) {
return TSDB_CODE_SERV_NO_DISKSPACE;
} else {
return TSDB_CODE_VG_INIT_FAILED;
}
} else { } else {
vnodeCreateFileHeader(fp); vnodeCreateFileHeader(fp);
vnodeUpdateVnodeFileHeader(fp, vnodeList + vnode); vnodeUpdateVnodeFileHeader(fp, vnodeList + vnode);
@ -93,7 +99,7 @@ int vnodeCreateMeterObjFile(int vnode) {
fclose(fp); fclose(fp);
} }
return 0; return TSDB_CODE_SUCCESS;
} }
FILE *vnodeOpenMeterObjFile(int vnode) { FILE *vnodeOpenMeterObjFile(int vnode) {
@ -271,7 +277,7 @@ int vnodeSaveVnodeCfg(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
/* vnodeUpdateFileCheckSum(fp); */ /* vnodeUpdateFileCheckSum(fp); */
fclose(fp); fclose(fp);
return 0; return TSDB_CODE_SUCCESS;
} }
int vnodeSaveVnodeInfo(int vnode) { int vnodeSaveVnodeInfo(int vnode) {
@ -568,6 +574,14 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
return code; return code;
} }
/*
* please refer to TBASE-926, data may be lost when the cache is full
*/
if (source == TSDB_DATA_SOURCE_SHELL && pVnode->cfg.replications > 1) {
code = vnodeForwardToPeer(pObj, cont, contLen, TSDB_ACTION_INSERT, sversion);
if (code != TSDB_CODE_SUCCESS) return code;
}
SCachePool *pPool = (SCachePool *)pVnode->pCachePool; SCachePool *pPool = (SCachePool *)pVnode->pCachePool;
if (pObj->freePoints < numOfPoints || pObj->freePoints < (pObj->pointsPerBlock << 1) || if (pObj->freePoints < numOfPoints || pObj->freePoints < (pObj->pointsPerBlock << 1) ||
pPool->notFreeSlots > pVnode->cfg.cacheNumOfBlocks.totalBlocks - 2) { pPool->notFreeSlots > pVnode->cfg.cacheNumOfBlocks.totalBlocks - 2) {
@ -585,11 +599,6 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
if (code != TSDB_CODE_SUCCESS) return code; if (code != TSDB_CODE_SUCCESS) return code;
} }
if (source == TSDB_DATA_SOURCE_SHELL && pVnode->cfg.replications > 1) {
code = vnodeForwardToPeer(pObj, cont, contLen, TSDB_ACTION_INSERT, sversion);
if (code != TSDB_CODE_SUCCESS) return code;
}
if (pObj->sversion < sversion) { if (pObj->sversion < sversion) {
dTrace("vid:%d sid:%d id:%s, schema is changed, new:%d old:%d", pObj->vnode, pObj->sid, pObj->meterId, sversion, dTrace("vid:%d sid:%d id:%s, schema is changed, new:%d old:%d", pObj->vnode, pObj->sid, pObj->meterId, sversion,
pObj->sversion); pObj->sversion);
@ -660,6 +669,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
if (pObj->lastKey > pVnode->lastKey) pVnode->lastKey = pObj->lastKey; if (pObj->lastKey > pVnode->lastKey) pVnode->lastKey = pObj->lastKey;
if (firstKey < pVnode->firstKey) pVnode->firstKey = firstKey; if (firstKey < pVnode->firstKey) pVnode->firstKey = firstKey;
assert(pVnode->firstKey > 0);
pVnode->version++; pVnode->version++;

View File

@ -2180,16 +2180,15 @@ static int32_t setupQueryRuntimeEnv(SMeterObj *pMeterObj, SQuery *pQuery, SQuery
pCtx->order = pQuery->order.order; pCtx->order = pQuery->order.order;
pCtx->functionId = pSqlFuncMsg->functionId; pCtx->functionId = pSqlFuncMsg->functionId;
pCtx->numOfParams = pSqlFuncMsg->numOfParams; pCtx->numOfParams = pSqlFuncMsg->numOfParams;
for (int32_t j = 0; j < pCtx->numOfParams; ++j) { for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
if (pSqlFuncMsg->arg[j].argType == TSDB_DATA_TYPE_BINARY || int16_t type = pSqlFuncMsg->arg[j].argType;
pSqlFuncMsg->arg[j].argType == TSDB_DATA_TYPE_NCHAR) { int16_t bytes = pSqlFuncMsg->arg[j].argBytes;
tVariantCreateFromBinary(&pCtx->param[j], pSqlFuncMsg->arg[j].argValue.pz, if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
pSqlFuncMsg->arg[j].argBytes, pSqlFuncMsg->arg[j].argType); tVariantCreateFromBinary(&pCtx->param[j], pSqlFuncMsg->arg->argValue.pz, bytes, type);
} else { } else {
tVariantCreateFromBinary(&pCtx->param[j], (char*) &pSqlFuncMsg->arg[j].argValue.d, tVariantCreateFromBinary(&pCtx->param[j], (char*) &pSqlFuncMsg->arg[j].argValue.i64, bytes, type);
pSqlFuncMsg->arg[j].argBytes, pSqlFuncMsg->arg[j].argType);
} }
} }
@ -2278,7 +2277,9 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
pRuntimeEnv->vnodeFileInfo.numOfFiles = 0; pRuntimeEnv->vnodeFileInfo.numOfFiles = 0;
free(pRuntimeEnv->vnodeFileInfo.pFileInfo); free(pRuntimeEnv->vnodeFileInfo.pFileInfo);
} }
taosDestoryInterpoInfo(&pRuntimeEnv->interpoInfo);
if (pRuntimeEnv->pInterpoBuf != NULL) { if (pRuntimeEnv->pInterpoBuf != NULL) {
for (int32_t i = 0; i < pRuntimeEnv->pQuery->numOfOutputCols; ++i) { for (int32_t i = 0; i < pRuntimeEnv->pQuery->numOfOutputCols; ++i) {
tfree(pRuntimeEnv->pInterpoBuf[i]); tfree(pRuntimeEnv->pInterpoBuf[i]);
@ -7186,7 +7187,6 @@ bool vnodeHasRemainResults(void *handle) {
SQuery * pQuery = pRuntimeEnv->pQuery; SQuery * pQuery = pRuntimeEnv->pQuery;
SInterpolationInfo *pInterpoInfo = &pRuntimeEnv->interpoInfo; SInterpolationInfo *pInterpoInfo = &pRuntimeEnv->interpoInfo;
if (pQuery->limit.limit > 0 && pQInfo->pointsRead >= pQuery->limit.limit) { if (pQuery->limit.limit > 0 && pQInfo->pointsRead >= pQuery->limit.limit) {
return false; return false;
} }

View File

@ -19,11 +19,13 @@
const char* taosGetVgroupStatusStr(int32_t vgroupStatus) { const char* taosGetVgroupStatusStr(int32_t vgroupStatus) {
switch (vgroupStatus) { switch (vgroupStatus) {
case TSDB_VG_STATUS_READY: return "ready"; case TSDB_VG_STATUS_READY: return tsError[vgroupStatus];
case TSDB_VG_STATUS_IN_PROGRESS: return "inprogress"; case TSDB_VG_STATUS_IN_PROGRESS: return tsError[vgroupStatus];
case TSDB_VG_STATUS_COMMITLOG_INIT_FAILED: return "commitlog_init_failed"; case TSDB_VG_STATUS_NO_DISK_PERMISSIONS: return tsError[vgroupStatus];
case TSDB_VG_STATUS_INIT_FAILED: return "init_failed"; case TSDB_VG_STATUS_SERVER_NO_PACE: return tsError[vgroupStatus];
case TSDB_VG_STATUS_FULL: return "full"; case TSDB_VG_STATUS_SERV_OUT_OF_MEMORY: return tsError[vgroupStatus];
case TSDB_VG_STATUS_INIT_FAILED: return tsError[vgroupStatus];
case TSDB_VG_STATUS_FULL: return tsError[vgroupStatus];
default: return "undefined"; default: return "undefined";
} }
} }

View File

@ -42,24 +42,24 @@ static int vnodeInitStoreVnode(int vnode) {
pVnode->pCachePool = vnodeOpenCachePool(vnode); pVnode->pCachePool = vnodeOpenCachePool(vnode);
if (pVnode->pCachePool == NULL) { if (pVnode->pCachePool == NULL) {
dError("vid:%d, cache pool init failed.", pVnode->vnode); dError("vid:%d, cache pool init failed.", pVnode->vnode);
return -1; return TSDB_CODE_SERV_OUT_OF_MEMORY;
} }
if (vnodeInitFile(vnode) < 0) { if (vnodeInitFile(vnode) != TSDB_CODE_SUCCESS) {
dError("vid:%d, files init failed.", pVnode->vnode); dError("vid:%d, files init failed.", pVnode->vnode);
return -1; return TSDB_CODE_VG_INIT_FAILED;
} }
if (vnodeInitCommit(vnode) < 0) { if (vnodeInitCommit(vnode) != TSDB_CODE_SUCCESS) {
dError("vid:%d, commit init failed.", pVnode->vnode); dError("vid:%d, commit init failed.", pVnode->vnode);
return -1; return TSDB_CODE_VG_INIT_FAILED;
} }
pthread_mutex_init(&(pVnode->vmutex), NULL); pthread_mutex_init(&(pVnode->vmutex), NULL);
dPrint("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId, dPrint("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId,
pVnode->numOfFiles); pVnode->numOfFiles);
return 0; return TSDB_CODE_SUCCESS;
} }
int vnodeOpenVnode(int vnode) { int vnodeOpenVnode(int vnode) {
@ -183,22 +183,45 @@ int vnodeCreateVnode(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
vnodeList[vnode].vnodeStatus = TSDB_VN_STATUS_CREATING; vnodeList[vnode].vnodeStatus = TSDB_VN_STATUS_CREATING;
sprintf(fileName, "%s/vnode%d", tsDirectory, vnode); sprintf(fileName, "%s/vnode%d", tsDirectory, vnode);
mkdir(fileName, 0755); if (mkdir(fileName, 0755) != 0) {
dError("failed to create vnode:%d directory:%s, errno:%d, reason:%s", vnode, fileName, errno, strerror(errno));
if (errno == EACCES) {
return TSDB_CODE_NO_DISK_PERMISSIONS;
} else if (errno == ENOSPC) {
return TSDB_CODE_SERV_NO_DISKSPACE;
} else if (errno == EEXIST) {
} else {
return TSDB_CODE_VG_INIT_FAILED;
}
}
sprintf(fileName, "%s/vnode%d/db", tsDirectory, vnode); sprintf(fileName, "%s/vnode%d/db", tsDirectory, vnode);
mkdir(fileName, 0755); if (mkdir(fileName, 0755) != 0) {
dError("failed to create vnode:%d directory:%s, errno:%d, reason:%s", vnode, fileName, errno, strerror(errno));
if (errno == EACCES) {
return TSDB_CODE_NO_DISK_PERMISSIONS;
} else if (errno == ENOSPC) {
return TSDB_CODE_SERV_NO_DISKSPACE;
} else if (errno == EEXIST) {
} else {
return TSDB_CODE_VG_INIT_FAILED;
}
}
vnodeList[vnode].cfg = *pCfg; vnodeList[vnode].cfg = *pCfg;
if (vnodeCreateMeterObjFile(vnode) != 0) { int code = vnodeCreateMeterObjFile(vnode);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
code = vnodeSaveVnodeCfg(vnode, pCfg, pDesc);
if (code != TSDB_CODE_SUCCESS) {
return TSDB_CODE_VG_INIT_FAILED; return TSDB_CODE_VG_INIT_FAILED;
} }
if (vnodeSaveVnodeCfg(vnode, pCfg, pDesc) != 0) { code = vnodeInitStoreVnode(vnode);
return TSDB_CODE_VG_INIT_FAILED; if (code != TSDB_CODE_SUCCESS) {
} return code;
if (vnodeInitStoreVnode(vnode) < 0) {
return TSDB_CODE_VG_COMMITLOG_INIT_FAILED;
} }
return vnodeOpenVnode(vnode); return vnodeOpenVnode(vnode);
@ -291,7 +314,8 @@ int vnodeInitStore() {
if (vnodeInitInfo() < 0) return -1; if (vnodeInitInfo() < 0) return -1;
for (vnode = 0; vnode < TSDB_MAX_VNODES; ++vnode) { for (vnode = 0; vnode < TSDB_MAX_VNODES; ++vnode) {
if (vnodeInitStoreVnode(vnode) < 0) { int code = vnodeInitStoreVnode(vnode);
if (code != TSDB_CODE_SUCCESS) {
// one vnode is failed to recover from commit log, continue for remain // one vnode is failed to recover from commit log, continue for remain
return -1; return -1;
} }

View File

@ -68,9 +68,36 @@ ELSEIF (TD_WINDOWS_64)
TARGET_LINK_LIBRARIES(tutil iconv regex pthread os winmm IPHLPAPI ws2_32) TARGET_LINK_LIBRARIES(tutil iconv regex pthread os winmm IPHLPAPI ws2_32)
ELSEIF(TD_DARWIN_64) ELSEIF(TD_DARWIN_64)
ADD_DEFINITIONS(-DUSE_LIBICONV) ADD_DEFINITIONS(-DUSE_LIBICONV)
AUX_SOURCE_DIRECTORY(src SRC) LIST(APPEND SRC ./src/ihash.c)
LIST(REMOVE_ITEM SRC ./src/tcrc32c.c) LIST(APPEND SRC ./src/lz4.c)
LIST(REMOVE_ITEM SRC ./src/tdes.c) LIST(APPEND SRC ./src/shash.c)
LIST(APPEND SRC ./src/tbase64.c)
LIST(APPEND SRC ./src/tcache.c)
LIST(APPEND SRC ./src/tcompression.c)
LIST(APPEND SRC ./src/textbuffer.c)
LIST(APPEND SRC ./src/tglobalcfg.c)
LIST(APPEND SRC ./src/thash.c)
LIST(APPEND SRC ./src/thashutil.c)
LIST(APPEND SRC ./src/thistogram.c)
LIST(APPEND SRC ./src/tidpool.c)
LIST(APPEND SRC ./src/tinterpolation.c)
LIST(APPEND SRC ./src/tlog.c)
LIST(APPEND SRC ./src/tlosertree.c)
LIST(APPEND SRC ./src/tmd5.c)
LIST(APPEND SRC ./src/tmem.c)
LIST(APPEND SRC ./src/tmempool.c)
LIST(APPEND SRC ./src/tmodule.c)
LIST(APPEND SRC ./src/tnote.c)
LIST(APPEND SRC ./src/tsched.c)
LIST(APPEND SRC ./src/tskiplist.c)
LIST(APPEND SRC ./src/tsocket.c)
LIST(APPEND SRC ./src/tstrbuild.c)
LIST(APPEND SRC ./src/ttime.c)
LIST(APPEND SRC ./src/ttimer.c)
LIST(APPEND SRC ./src/ttokenizer.c)
LIST(APPEND SRC ./src/ttypes.c)
LIST(APPEND SRC ./src/tutil.c)
LIST(APPEND SRC ./src/version.c)
ADD_LIBRARY(tutil ${SRC}) ADD_LIBRARY(tutil ${SRC})
TARGET_LINK_LIBRARIES(tutil iconv pthread os) TARGET_LINK_LIBRARIES(tutil iconv pthread os)
ENDIF() ENDIF()

View File

@ -56,11 +56,7 @@ int tscEmbedded = 0;
*/ */
int64_t tsMsPerDay[] = {86400000L, 86400000000L}; int64_t tsMsPerDay[] = {86400000L, 86400000000L};
#ifdef CLUSTER
char tsMasterIp[TSDB_IPv4ADDR_LEN] = {0}; char tsMasterIp[TSDB_IPv4ADDR_LEN] = {0};
#else
char tsMasterIp[TSDB_IPv4ADDR_LEN] = "127.0.0.1";
#endif
char tsSecondIp[TSDB_IPv4ADDR_LEN] = {0}; char tsSecondIp[TSDB_IPv4ADDR_LEN] = {0};
uint16_t tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030] uint16_t tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030]
uint16_t tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035] uint16_t tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035]
@ -455,7 +451,7 @@ static void doInitGlobalConfig() {
// ip address // ip address
tsInitConfigOption(cfg++, "masterIp", tsMasterIp, TSDB_CFG_VTYPE_IPSTR, tsInitConfigOption(cfg++, "masterIp", tsMasterIp, TSDB_CFG_VTYPE_IPSTR,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_CLUSTER, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT,
0, 0, TSDB_IPv4ADDR_LEN, TSDB_CFG_UTYPE_NONE); 0, 0, TSDB_IPv4ADDR_LEN, TSDB_CFG_UTYPE_NONE);
tsInitConfigOption(cfg++, "secondIp", tsSecondIp, TSDB_CFG_VTYPE_IPSTR, tsInitConfigOption(cfg++, "secondIp", tsSecondIp, TSDB_CFG_VTYPE_IPSTR,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_CLUSTER, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_CLUSTER,
@ -801,11 +797,9 @@ static void doInitGlobalConfig() {
TSDB_CFG_CTYPE_B_CONFIG, TSDB_CFG_CTYPE_B_CONFIG,
0, 1, 0, TSDB_CFG_UTYPE_NONE); 0, 1, 0, TSDB_CFG_UTYPE_NONE);
#ifdef CLUSTER
tsInitConfigOption(cfg++, "anyIp", &tsAnyIp, TSDB_CFG_VTYPE_INT, tsInitConfigOption(cfg++, "anyIp", &tsAnyIp, TSDB_CFG_VTYPE_INT,
TSDB_CFG_CTYPE_B_CONFIG, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLUSTER,
0, 1, 0, TSDB_CFG_UTYPE_NONE); 0, 1, 0, TSDB_CFG_UTYPE_NONE);
#endif
// version info // version info
tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING, tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING,

View File

@ -77,6 +77,18 @@ void taosInitInterpoInfo(SInterpolationInfo* pInterpoInfo, int32_t order, int64_
tfree(pInterpoInfo->prevValues); tfree(pInterpoInfo->prevValues);
} }
// the SInterpolationInfo itself will not be released
void taosDestoryInterpoInfo(SInterpolationInfo *pInterpoInfo) {
if (pInterpoInfo == NULL) {
return;
}
tfree(pInterpoInfo->prevValues);
tfree(pInterpoInfo->nextValues);
tfree(pInterpoInfo->pTags);
}
void taosInterpoSetStartInfo(SInterpolationInfo* pInterpoInfo, int32_t numOfRawDataInRows, int32_t type) { void taosInterpoSetStartInfo(SInterpolationInfo* pInterpoInfo, int32_t numOfRawDataInRows, int32_t type) {
if (type == TSDB_INTERPO_NONE) { if (type == TSDB_INTERPO_NONE) {
return; return;
@ -283,8 +295,8 @@ static void doInterpoResultImpl(SInterpolationInfo* pInterpoInfo, int16_t interp
int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoType, tFilePage** data, int32_t taosDoInterpoResult(SInterpolationInfo* pInterpoInfo, int16_t interpoType, tFilePage** data,
int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval, int32_t numOfRawDataInRows, int32_t outputRows, int64_t nInterval,
int64_t* pPrimaryKeyArray, tColModel* pModel, char** srcData, int64_t* defaultVal, const int64_t* pPrimaryKeyArray, tColModel* pModel, char** srcData, int64_t* defaultVal,
int32_t* functionIDs, int32_t bufSize) { const int32_t* functionIDs, int32_t bufSize) {
int32_t num = 0; int32_t num = 0;
pInterpoInfo->numOfCurrentInterpo = 0; pInterpoInfo->numOfCurrentInterpo = 0;

View File

@ -231,8 +231,13 @@ void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...)
gettimeofday(&timeSecs, NULL); gettimeofday(&timeSecs, NULL);
curTime = timeSecs.tv_sec; curTime = timeSecs.tv_sec;
ptm = localtime_r(&curTime, &Tm); ptm = localtime_r(&curTime, &Tm);
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()); #ifndef LINUX
len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d 0x%lld ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
ptm->tm_min, ptm->tm_sec, (int)timeSecs.tv_usec, taosGetPthreadId());
#else
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());
#endif
va_start(argpointer, format); va_start(argpointer, format);
len += vsnprintf(buffer + len, MAX_NOTE_LINE_SIZE - len, format, argpointer); len += vsnprintf(buffer + len, MAX_NOTE_LINE_SIZE - len, format, argpointer);
va_end(argpointer); va_end(argpointer);

View File

@ -1,6 +1,6 @@
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/pthread) INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/pthread)
ENDIF () ENDIF ()