diff --git a/.gitmodules b/.gitmodules index 8179b9caa5701f7a94ed6c1dbda3ad75db1b866e..9ae88e6381ebba52f20d13984e4194a980af645a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "src/connector/php-tdengine-restful-connector"] path = src/connector/php-tdengine-restful-connector url = https://github.com/Yurunsoft/tdengine-restful-connector.git +[submodule "src/plugins/taosws-rs"] + path = src/plugins/taosws-rs + url = https://github.com/taosdata/taosws-rs diff --git a/README-CN.md b/README-CN.md index f9e6db6c473886a1c8b632490f1feedc9f4fce42..2ba2c38e7f37fbbd8255007db1788d362f6d2bd9 100644 --- a/README-CN.md +++ b/README-CN.md @@ -53,7 +53,7 @@ TDengine 目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后 ### Ubuntu 16.04 及以上版本 & Debian: ```bash -sudo apt-get install -y gcc cmake build-essential git +sudo apt-get install -y gcc cmake build-essential git libssl-dev ``` ### Ubuntu 14.04: @@ -86,13 +86,13 @@ taosTools 是用于 TDengine 的辅助工具软件集合。目前它包含 taosB 为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件: ```bash -sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config +sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config libssl-dev ``` -### CentOS 7: +### CentOS 7/RHEL ```bash -sudo yum install -y gcc gcc-c++ make cmake git +sudo yum install -y gcc gcc-c++ make cmake git openssl-devel ``` 安装 OpenJDK 8: @@ -107,10 +107,10 @@ sudo yum install -y java-1.8.0-openjdk sudo yum install -y maven ``` -### CentOS 8 & Fedora +### CentOS 8/Fedora/Rocky Linux ```bash -sudo dnf install -y gcc gcc-c++ make cmake epel-release git +sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel ``` 安装 OpenJDK 8: @@ -130,13 +130,28 @@ sudo dnf install -y maven 为了在 CentOS 上构建 [taosTools](https://github.com/taosdata/taos-tools) 需要安装如下依赖软件 ```bash -sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static +sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel ``` 注意:由于 snappy 缺乏 pkg-config 支持 (参考 [链接](https://github.com/google/snappy/pull/86)),会导致 cmake 提示无法发现 libsnappy,实际上工作正常。 +### 设置 golang 开发环境 + +TDengine 包含数个使用 Go 语言开发的组件,请参考 golang.org 官方文档设置 go 开发环境。 + +请使用 1.14 及以上版本。对于中国用户,我们建议使用代理来加速软件包下载。 + +``` +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct +``` + +### 设置 rust 开发环境 + +TDengine 包含数个使用 Rust 语言开发的组件. 请参考 rust-lang.org 官方文档设置 rust 开发环境。 + ## 获取源码 首先,你需要从 GitHub 克隆源码: diff --git a/README.md b/README.md index 99916710d31a2401dfd08dfb9a4e5bf097c536ab..434a49186ca8e72bcfa7ddf1f97f4865662112f4 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ To build TDengine, use [CMake](https://cmake.org/) 3.0.2 or higher versions in t ### Ubuntu 16.04 and above or Debian ```bash -sudo apt-get install -y gcc cmake build-essential git +sudo apt-get install -y gcc cmake build-essential git libssl-dev ``` ### Ubuntu 14.04 @@ -88,15 +88,15 @@ By default, TDengine compiling does not include taosTools. You can use 'cmake .. To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed. ```bash -sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config +sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config libssl-dev ``` -### CentOS 7 +### CentOS 7/RHEL ```bash sudo yum install epel-release sudo yum update -sudo yum install -y gcc gcc-c++ make cmake3 git +sudo yum install -y gcc gcc-c++ make cmake3 git openssl-devel sudo ln -sf /usr/bin/cmake3 /usr/bin/cmake ``` @@ -112,10 +112,10 @@ To install Apache Maven: sudo yum install -y maven ``` -### CentOS 8 & Fedora +### CentOS 8/Fedora/Rocky Linux ```bash -sudo dnf install -y gcc gcc-c++ make cmake epel-release git +sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel ``` To install openjdk-8: @@ -135,7 +135,7 @@ sudo dnf install -y maven To build the [taosTools](https://github.com/taosdata/taos-tools) on CentOS, the following packages need to be installed. ```bash -sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static +sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel ``` Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it lead a cmake prompt libsnappy not found. But snappy will works well. @@ -151,6 +151,10 @@ go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.cn,direct ``` +### Setup rust environment + +TDengine includees few compoments developed by Rust language. Please refer to rust-lang.org official documentation for rust environment setup. + ## Get the source codes First of all, you may clone the source codes from github: diff --git a/cmake/define.inc b/cmake/define.inc index 5947472e2d04651a53421bfebacf5f7e23d8b268..9a5c331aa851dfb8df1f620f72e7b73ab141293c 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -112,6 +112,10 @@ IF (TD_ALPINE) MESSAGE(STATUS "alpine is defined") ENDIF () +IF ("${WEBSOCKET}" MATCHES "true") + SET(TD_WEBSOCKET TRUE) +ENDIF () + IF ("${BUILD_HTTP}" STREQUAL "") IF (TD_LINUX) IF (TD_ARM_32) @@ -169,6 +173,11 @@ IF (${BUILD_LUA} MATCHES "false") SET(TD_BUILD_LUA FALSE) ENDIF () +IF (TD_WEBSOCKET) + MESSAGE("Enable websocket") + ADD_DEFINITIONS(-DWEBSOCKET) +ENDIF() + IF (TD_BUILD_LUA) MESSAGE("Enable lua") ADD_DEFINITIONS(-DLUA_EMBEDDED) diff --git a/cmake/input.inc b/cmake/input.inc index 6eb7e44e0af007240c803dd5cf50c69de47f4fc8..b5ae4f9aeb85803583c873470ccaf85b9537927a 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -76,6 +76,8 @@ ENDIF () SET(TD_BUILD_HTTP TRUE) +SET(TD_WEBSOCKET FALSE) + SET(TD_TAOS_TOOLS TRUE) SET(TD_BUILD_LUA TRUE) diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 5217a8229571bf993c6c3df8f82beb1ed67c3e96..c9957fc89c9570f9195e7ab0859db4583cbce0cf 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -37,4 +37,5 @@ if [ -f "${install_main_dir}/taosadapter.service" ]; then fi # there can not libtaos.so*, otherwise ln -s error -${csudo}rm -f ${install_main_dir}/driver/libtaos* || : +${csudo}rm -f ${install_main_dir}/driver/libtaos.* || : +${csudo}rm -f ${install_main_dir}/driver/libtaosws.* || : diff --git a/packaging/deb/DEBIAN/prerm b/packaging/deb/DEBIAN/prerm index c01db74701f99e52cc45b589d8fe7b07c4c8afe1..bda2c01db6b05e22e35b1cf47d42c5454e84e166 100644 --- a/packaging/deb/DEBIAN/prerm +++ b/packaging/deb/DEBIAN/prerm @@ -29,7 +29,11 @@ else ${csudo}rm -f ${bin_link_dir}/taosdemo || : ${csudo}rm -f ${cfg_link_dir}/* || : ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taosws.h || : ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : ${csudo}rm -f ${log_link_dir} || : ${csudo}rm -f ${data_link_dir} || : diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index 42110657a6d9c32d37637c034a84ae34cbedba8e..2b8356b3b84587bc37875839af6b5f71d51b82d0 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -30,6 +30,7 @@ mkdir -p ${pkg_dir} cd ${pkg_dir} libfile="libtaos.so.${tdengine_ver}" +wslibfile="libtaosws.so" # create install dir install_home_path="/usr/local/taos" @@ -67,9 +68,11 @@ fi cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver +cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||: cp ${compile_dir}/../src/inc/taos.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../src/inc/taosdef.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../src/inc/taoserror.h ${pkg_dir}${install_home_path}/include +cp ${compile_dir}/../src/inc/taosws.h ${pkg_dir}${install_home_path}/include ||: cp -r ${top_dir}/examples/* ${pkg_dir}${install_home_path}/examples #cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector #cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index dcc615132896e25c7f18398643576608b344f58e..cd5ac490be81eece155b16d17c8f95342c044e55 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -42,6 +42,7 @@ echo version: %{_version} echo buildroot: %{buildroot} libfile="libtaos.so.%{_version}" +wslibfile="libtaosws.so" # create install path, and cp file mkdir -p %{buildroot}%{homepath}/bin @@ -74,9 +75,11 @@ if [ -f %{_compiledir}/build/bin/taosadapter ]; then cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||: fi cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver +cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||: cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include cp %{_compiledir}/../src/inc/taosdef.h %{buildroot}%{homepath}/include cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include +cp %{_compiledir}/../src/inc/taosws.h %{buildroot}%{homepath}/include ||: #cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector #cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector #cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index d730cc0d8af8e3db0c16e4609138c0f63ac5329b..522608e853970715baa11a87c1032e34c5f01b45 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -229,9 +229,13 @@ function install_lib() { ${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}/libtaosws.so ${lib_link_dir}/libtaosws.so || : + if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + + ${csudo}ln -s ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : fi ${csudo}ldconfig @@ -315,10 +319,15 @@ function install_jemalloc() { function install_header() { ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + + ${csudo}rm -f ${inc_link_dir}/taosws.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + + [ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || : } function add_newHostname_to_hosts() { diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index eded9e4b956af4620f531d41987565d3e4a9a657..628ced29a6c5b86c92c304e72e00e545fce813ef 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -291,14 +291,16 @@ function install_avro() { function install_lib() { # Remove links ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || : fi if [ "$osType" != "Darwin" ]; then ${csudo}cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \ ${install_main_dir}/driver && - ${csudo}chmod 777 ${install_main_dir}/driver/* + ${csudo}chmod 777 ${install_main_dir}/driver/libtaos.so.${verNumber} ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so @@ -307,6 +309,16 @@ function install_lib() { ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 ${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so fi + + if [ -f ${binary_dir}/build/lib/libtaosws.so ]; then + ${csudo}cp ${binary_dir}/build/lib/libtaosws.so \ + ${install_main_dir}/driver && + ${csudo}chmod 777 ${install_main_dir}/driver/libtaosws.so + ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || : + if [ -d "${lib64_link_dir}" ]; then + ${csudo}ln -sf ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : + fi + fi else ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ ${install_main_dir}/driver || @@ -334,8 +346,8 @@ function install_lib() { fi install_jemalloc - install_avro lib - install_avro lib64 + #install_avro lib + #install_avro lib64 if [ "$osType" != "Darwin" ]; then ${csudo}ldconfig @@ -346,11 +358,20 @@ function install_header() { if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taosws.h || : + ${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + + if [ -f ${binary_dir}/build/include/taosws.h ]; then + ${csudo}cp -f ${binary_dir}/build/include/taosws.h ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/taosws.h + ${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||: + fi + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + else ${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ ${install_main_dir}/include || diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 89865ae54f7b42b56c4ad4e85f51e4f84e0a720d..33c69fcb0e2f3c8c95b43be060daba53609e2130 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -161,13 +161,11 @@ if [[ $productName == "TDengine" ]]; then mkdir -p ${install_dir}/connector if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then if [ "$osType" != "Darwin" ]; then - cp ${build_dir}/lib/*.jar ${install_dir}/connector || : - fi - if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then - cp -r ${connector_dir}/go ${install_dir}/connector - else - echo "WARNING: go connector not found, please check if want to use it!" + [ -f ${build_dir}/lib/*.jar ] && cp ${build_dir}/lib/*.jar ${install_dir}/connector || : fi + + git clone --depth 1 https://github.com/taosdata/driver-go ${install_dir}/connector/go + rm -rf ${install_dir}/connector/go/.git ||: git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python rm -rf ${install_dir}/connector/python/.git ||: # cp -r ${connector_dir}/python ${install_dir}/connector diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 8c45b0a7d12485d3e95554f7d2223790366f3401..ca061a50c6d9abd3d295cbd4e920c1faf26a1a71 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -96,7 +96,10 @@ else fi lib_files="${build_dir}/lib/libtaos.so.${version}" +wslib_files="${build_dir}/lib/libtaosws.so." + header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taosdef.h ${code_dir}/inc/taoserror.h" +wsheader_files="${code_dir}/inc/taosws.h" if [ "$dbName" != "taos" ]; then cfg_dir="${top_dir}/../enterprise/packaging/cfg" @@ -115,6 +118,9 @@ init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord # make directories. mkdir -p ${install_dir} mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc + +[ -f ${wsheader_files} ] && cp ${wsheader_files} ${install_dir}/inc || : + mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile} # !!! do not change the taosadapter here!!! @@ -298,18 +304,17 @@ fi # Copy driver mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt +[ -f ${wslib_files} ] && cp ${wslib_files} ${install_dir}/driver || : # Copy connector if [ "$verMode" == "cluster" ]; then connector_dir="${code_dir}/connector" mkdir -p ${install_dir}/connector if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then - cp ${build_dir}/lib/*.jar ${install_dir}/connector || : - if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then - cp -r ${connector_dir}/go ${install_dir}/connector - else - echo "WARNING: go connector not found, please check if want to use it!" - fi + [ -f ${build_dir}/lib/*.jar ] && cp ${build_dir}/lib/*.jar ${install_dir}/connector || : + + git clone --depth 1 https://github.com/taosdata/driver-go ${install_dir}/connector/go + rm -rf ${install_dir}/connector/go/.git ||: git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python rm -rf ${install_dir}/connector/python/.git ||: diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index d34c81a4f59186ead2dd4ba58c4c14ebba52276d..ec836f2eac297751f969470e89fbffac7cdf3d47 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -102,7 +102,10 @@ function clean_local_bin() { function clean_lib() { # Remove link ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || : #${csudo}rm -rf ${v15_java_app_dir} || : } @@ -111,6 +114,8 @@ function clean_header() { ${csudo}rm -f ${inc_link_dir}/taos.h || : ${csudo}rm -f ${inc_link_dir}/taosdef.h || : ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + + ${csudo}rm -f ${inc_link_dir}/taosws.h || : } function clean_config() { diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index b311361c438d033ad3f7582d30df7d1c33357c1d..b766ed8b6ab23a7a5c3e60bd4c0464b0cebd96e2 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -11,17 +11,26 @@ IF (TD_LINUX) LIST(REMOVE_ITEM SRC ./src/shellDarwin.c) ADD_EXECUTABLE(shell ${SRC}) -IF (TD_LINUX_64 AND JEMALLOC_ENABLED) - ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc) - SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc") -ELSE () - SET(LINK_JEMALLOC "") -ENDIF () + IF (TD_LINUX AND TD_WEBSOCKET) + ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws) + SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws") + ADD_DEPENDENCIES(shell taosws-rs) + ELSE () + SET(LINK_WEBSOCKET "") + ENDIF () + + IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc) + SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc") + ADD_DEPENDENCIES(shell jemalloc) + ELSE () + SET(LINK_JEMALLOC "") + ENDIF () IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(shell taos_static cJson ${LINK_LUA} ${LINK_JEMALLOC}) + TARGET_LINK_LIBRARIES(shell taos_static cJson ${LINK_LUA} ${LINK_JEMALLOC} ${LINK_WEBSOCKET}) ELSE () - TARGET_LINK_LIBRARIES(shell taos cJson ${LINK_LUA} ${LINK_JEMALLOC}) + TARGET_LINK_LIBRARIES(shell taos cJson ${LINK_LUA} ${LINK_JEMALLOC} ${LINK_WEBSOCKET}) ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) @@ -32,7 +41,7 @@ ELSEIF (TD_WINDOWS) LIST(APPEND SRC ./src/shellMain.c) LIST(APPEND SRC ./src/shellWindows.c) ADD_EXECUTABLE(shell ${SRC}) - IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + IF (JEMALLOC_ENABLED) ADD_DEPENDENCIES(shell jemalloc) ENDIF () diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 9cb71e3c4c0474553aa961cbe19795541c29b5c7..3f42d428eb6b90dea2651f4ccea66e44705c831b 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 9cb71e3c4c0474553aa961cbe19795541c29b5c7 +Subproject commit 3f42d428eb6b90dea2651f4ccea66e44705c831b diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index aeb7f538ce3c81dc619a124fe31bebd2902ea357..821ea49dc9eaae070aaf1c62330003af1a178e4f 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -3,6 +3,53 @@ PROJECT(TDengine) ADD_SUBDIRECTORY(monitor) +IF (TD_WEBSOCKET) + MESSAGE("${Green} use libtaos-ws${ColourReset}") + IF (TD_LINUX) + IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" OR + "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/src/plugins/taosws-rs/FETCH_HEAD") + MESSAGE("target is newer than fetch head") + include(ExternalProject) + ExternalProject_Add(taosws-rs + PREFIX "taosws-rs" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs + BUILD_ALWAYS off + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" + PATCH_COMMAND + COMMAND git clean -f -d + BUILD_COMMAND + COMMAND cargo build --release -p taos-ws-sys + COMMAND ./taos-ws-sys/ci/package.sh + INSTALL_COMMAND + COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include + COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include + ) + ELSE () + include(ExternalProject) + ExternalProject_Add(taosws-rs + PREFIX "taosws-rs" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs + BUILD_ALWAYS on + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" + PATCH_COMMAND + COMMAND git clean -f -d + BUILD_COMMAND + COMMAND cargo build --release -p taos-ws-sys + COMMAND ./taos-ws-sys/ci/package.sh + INSTALL_COMMAND + COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include + COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include + ) + ENDIF() + ENDIF() +ENDIF () + IF (TD_BUILD_HTTP) MESSAGE("") MESSAGE("${Yellow} use original embedded httpd ${ColourReset}") diff --git a/src/plugins/taosws-rs b/src/plugins/taosws-rs new file mode 160000 index 0000000000000000000000000000000000000000..7a94ffab45f08e16f09b3f430fe75d717054adb6 --- /dev/null +++ b/src/plugins/taosws-rs @@ -0,0 +1 @@ +Subproject commit 7a94ffab45f08e16f09b3f430fe75d717054adb6 diff --git a/tests/pytest/tools/taosdumpTestBenchmark.py b/tests/pytest/tools/taosdumpTestBenchmark.py deleted file mode 100644 index d3ac7347b3ad237e29ca5c30a918d4b0f7d649c3..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdumpTestBenchmark.py +++ /dev/null @@ -1,442 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - self.ts = 1538548685000 - self.numberOfTables = 10000 - self.numberOfRecords = 100 - - def checkCommunity(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - return False - else: - return True - - def getPath(self, tool="taosdump"): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - paths = [] - for root, dirs, files in os.walk(projPath): - if ((tool) in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - paths.append(os.path.join(root, tool)) - break - if (len(paths) == 0): - return "" - return paths[0] - - def insert_data(self, tbname, ts_start, count): - pre_insert = "insert into %s values" % tbname - sql = pre_insert - tdLog.debug("doing insert table %s rows=%d ..." % (tbname, count)) - for i in range(count): - sql += " (%d,%d)" % (ts_start + i * 1000, i) - if i > 0 and i % 30000 == 0: - tdSql.execute(sql) - sql = pre_insert - # end sql - if sql != pre_insert: - tdSql.execute(sql) - - tdLog.debug("INSERT TABLE DATA ............ [OK]") - return - - def run(self): - if not os.path.exists("./taosdumptest"): - os.makedirs("./taosdumptest") - else: - os.system("rm -rf ./taosdumptest") - os.makedirs("./taosdumptest") - - for i in range(2): - if not os.path.exists("./taosdumptest/tmp%d" % i): - os.makedirs("./taosdumptest/tmp%d" % i) - else: - os.system("rm -rf ./taosdumptest/tmp%d" % i) - os.makedirs("./taosdumptest/tmp%d" % i) - - binPath = self.getPath("taosdump") - if (binPath == ""): - tdLog.exit("taosdump not found!") - else: - tdLog.info("taosdump found: %s" % binPath) - - # create db1 , one stables and one table ; create general tables - tdSql.execute("drop database if exists dp1") - tdSql.execute("drop database if exists dp2") - tdSql.execute("create database if not exists dp1") - tdSql.execute("use dp1") - tdSql.execute( - '''create table st0(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, - c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) - tags(t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 bool, t8 binary(20), t9 nchar(20), t11 tinyint unsigned, - t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned, t15 timestamp)''') - tdSql.execute( - '''create table st1(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, - c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) tags(jtag json)''') - - intData = [] - floatData = [] - rowNum = 10 - tabNum = 10 - ts = 1537146000000 - for j in range(tabNum): - tdSql.execute( - "create table st0_%d using st0 tags( %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d);" % - (j, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - j + - 0.1, - j + - 0.1, - j % - 2, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - ts)) - for i in range(rowNum): - tdSql.execute( - "insert into st0_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" % - (j, ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % - 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, ts)) - intData.append(i + 1) - floatData.append(i + 0.1) - rowNum = 20 - tabNum = 20 - for j in range(tabNum): - tdSql.execute( - "create table st1_%d using st1 tags('{\"nv\":null,\"tea\":true,\"\":false,\" \":123%d,\"tea\":false}');" % - (j, j + 1)) - for i in range(rowNum): - tdSql.execute( - "insert into st1_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" % - (j, self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % - 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, self.ts)) - intData.append(i + 1) - floatData.append(i + 0.1) - # os.system("%staosBenchmark -f tools/taosdump-insert-dp1.json -y " % benchBinPath) - - # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 - # \stb3,include ctables stb3_0 and stb3_1 - # create general three tables gt0 gt1 gt2 - tdSql.execute("create database if not exists dp2") - tdSql.execute("use dp2") - tdSql.execute( - "create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") - tdSql.execute( - "create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") - tdSql.execute( - "insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')") - tdSql.execute( - "insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')") - tdSql.execute( - "create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)") - tdSql.execute( - "create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ") - tdSql.execute( - "insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')") - tdSql.execute( - "insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')") - tdSql.execute( - "create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)") - tdSql.execute( - "create table st20 using st2 tags(0) st21 using st2 tags(1) ") - tdSql.execute( - "insert into st20 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')") - tdSql.execute( - "insert into st21 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')") - tdSql.execute( - "create table if not exists gt0 (ts timestamp, c00 int, c01 float) ") - tdSql.execute( - "create table if not exists gt1 (ts timestamp, c10 int, c11 double) ") - tdSql.execute( - "create table if not exists gt2 (ts timestamp, c20 int, c21 float) ") - tdSql.execute("insert into gt0 values(1614218412700,8637,78.86155)") - tdSql.execute( - "insert into gt1 values(1614218413800,8638,78.862020199)") - tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)") - # self.insert_data("t", self.ts, 300*10000); - # os.system("%staosBenchmark -f tools/taosdump-insert-dp2.json -y " % benchBinPath) - - # # taosdump data - # os.system("%s -o ./taosdumptest/tmp1 taosdump -h -ptaosdata -P 6030 -u root -o taosdumptest \ - # -D dp1,dp3 -N -c /home/chr/TDinternal/community/sim/dnode1/cfg/taos.cfg -s -d deflate" % binPath) - os.system( - "%s -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8" % - binPath) - os.system( - "%s -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8" % - binPath) - - # check taosdumptest/tmp0 - tdSql.execute("drop database dp1") - tdSql.execute("drop database dp2") - os.system("%s -i ./taosdumptest/tmp0 -T 8 " % binPath) - tdSql.execute("reset query cache") - - tdSql.execute("use dp1") - tdSql.query("show stables") - tdSql.checkRows(3) - for i in range(3): - for j in range(3): - if j < 2: - if tdSql.queryResult[i][0] == 'st%d' % j: - tdSql.checkData(i, 4, (j + 1) * 10) - else: - if tdSql.queryResult[i][0] == 'st%d' % j: - tdSql.checkData(i, 4, 100002) - - tdSql.query("select count(*) from st0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from st1") - tdSql.checkData(0, 0, 400) - tdSql.query("select count(*) from st2") - tdSql.checkData(0, 0, 1000020) - - tdSql.execute("use dp2") - tdSql.query("show stables") - tdSql.checkRows(3) - for i in range(3): - for j in range(3): - if j < 2: - if tdSql.queryResult[i][0] == 'st%d' % j: - # print(i,"stb%d"%j) - tdSql.checkData(i, 4, 2) - else: - if tdSql.queryResult[i][0] == 'st%d' % j: - tdSql.checkData(i, 4, 100002) - tdSql.query("select count(*) from st0") - tdSql.checkData(0, 0, 4) - tdSql.query("select count(*) from st1") - tdSql.checkData(0, 0, 4) - tdSql.query("select count(*) from st2") - tdSql.checkData(0, 0, 1000024) - tdSql.query("select ts from gt0") - tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') - tdSql.query("select c10 from gt1") - tdSql.checkData(0, 0, 8638) - tdSql.query("select c20 from gt2") - tdSql.checkData(0, 0, 8639) - - # check taosdumptest/tmp1 - tdSql.execute("drop database dp1") - tdSql.execute("drop database dp2") - os.system("%s -i ./taosdumptest/tmp1 -T 8 " % binPath) - tdSql.execute("reset query cache") - tdSql.execute("use dp2") - tdSql.query("show stables") - tdSql.checkRows(2) - tdSql.query("show tables") - tdSql.checkRows(4) - tdSql.query("select count(*) from st1_0") - tdSql.checkData(0, 0, 2) - tdSql.query("select ts from gt0") - tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') - tdSql.error("use dp1") - tdSql.error("select count(*) from st2_0") - tdSql.error("select count(*) from gt2") - - # #check taosdumptest/tmp2 - # tdSql.execute("drop database dp1") - # tdSql.execute("drop database dp2") - # os.system("%s -i ./taosdumptest/tmp2 -T 8 " % binPath) - # tdSql.execute("use dp1") - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(3) - # tdSql.query("select c1 from st0_0 order by ts") - # tdSql.checkData(0,0,8537) - # tdSql.query("select c2 from st0_1 order by ts") - # tdSql.checkData(1,0,"D") - # tdSql.query("select * from gt0") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - # tdSql.checkData(0,1,637) - # tdSql.error("select count(*) from gt1") - # tdSql.error("use dp2") - - # #check taosdumptest/tmp3 - # tdSql.execute("drop database dp1") - # os.system("%s -i ./taosdumptest/tmp3 -T 8 " % binPath) - # tdSql.execute("use dp2") - # tdSql.query("show stables") - # tdSql.checkRows(2) - # tdSql.query("show tables") - # tdSql.checkRows(4) - # tdSql.query("select count(*) from st1_0") - # tdSql.checkData(0,0,2) - # tdSql.query("select ts from gt0") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.700') - # tdSql.error("use dp1") - # tdSql.error("select count(*) from st2_0") - # tdSql.error("select count(*) from gt2") - - # #check taosdumptest/tmp4 - # tdSql.execute("drop database dp2") - # os.system("%s -i ./taosdumptest/tmp4 -T 8 " % binPath) - # tdSql.execute("use dp2") - # tdSql.query("show stables") - # tdSql.checkRows(2) - # tdSql.query("show tables") - # tdSql.checkRows(6) - # tdSql.query("select c20 from gt2") - # tdSql.checkData(0, 0, 8639) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st0_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_0") - # tdSql.checkData(0, 0, 2) - # tdSql.error("use dp1") - # tdSql.error("select count(*) from st1_0") - # tdSql.error("select count(*) from st1_1") - # tdSql.error("select count(*) from gt3") - - # #check taosdumptest/tmp5 - # tdSql.execute("drop database dp2") - # os.system("%s -i ./taosdumptest/tmp5 -T 8 " % binPath) - # tdSql.execute("use dp2") - # tdSql.query("show stables") - # tdSql.checkRows(3) - # tdSql.query("show tables") - # tdSql.checkRows(9) - # tdSql.query("select c20 from gt2") - # tdSql.checkData(0, 0, 8639) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st0_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st1_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st1_0") - # tdSql.checkData(0, 0, 2) - # tdSql.execute("use dp1") - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(4) - # tdSql.query("select c1 from st0_0 order by ts") - # tdSql.checkData(0,0,8537) - # tdSql.query("select c2 from st0_1 order by ts") - # tdSql.checkData(1,0,"D") - # tdSql.query("select * from gt0") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - # tdSql.checkData(0,1,637) - - # # check taosdumptest/tmp6 - # tdSql.execute("drop database dp1") - # tdSql.execute("drop database dp2") - # tdSql.execute("drop database dp3") - # os.system("%s -i ./taosdumptest/tmp6 -T 8 " % binPath) - # tdSql.execute("use dp3") - # tdSql.query("show databases") - # tdSql.checkRows(1) - # tdSql.checkData(0,16,'ns') - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(1) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select * from st0 order by ts") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - # tdSql.checkData(0,1,8600) - - # # check taosdumptest/tmp7 - # tdSql.execute("drop database dp3") - # os.system("%s -i ./taosdumptest/tmp7 -T 8 " % binPath) - # tdSql.execute("use dp3") - # tdSql.query("show databases") - # tdSql.checkRows(1) - # tdSql.checkData(0,16,'ms') - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(1) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkRows(0) - # # tdSql.query("select * from st0 order by ts") - # # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - # # tdSql.checkData(0,1,8600) - - # # check taosdumptest/tmp8 - # tdSql.execute("drop database dp3") - # os.system("%s -i ./taosdumptest/tmp8 -T 8 " % binPath) - # tdSql.execute("use dp3") - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(1) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkRows(0) - # # tdSql.query("select * from st0 order by ts") - # # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - # # tdSql.checkData(0,1,8600) - - # os.system("rm -rf ./taosdumptest/tmp1") - # os.system("rm -rf ./taosdumptest/tmp2") - # os.system("rm -rf ./taosdumptest/tmp3") - # os.system("rm -rf ./taosdumptest/tmp4") - # os.system("rm -rf ./taosdumptest/tmp5") - # os.system("rm -rf ./dump_result.txt") - # os.system("rm -rf ./db.csv") - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase())