diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000000000000000000000000000000000000..559431e2f9421f4cf1bfe64f1e2e9ee66b7bead5 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,28 @@ +version: 1.0.{build} +os: Visual Studio 2015 +environment: + matrix: + - ARCH: amd64 + +clone_folder: c:\dev\TDengine +clone_depth: 1 + +init: + - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %ARCH% + +before_build: + - cd c:\dev\TDengine + - md build + +build_script: + - cd build + - cmake -G "NMake Makefiles" .. + - nmake install + +notifications: +- provider: Email + to: + - sangshuduo@gmail.com + on_build_success: true + on_build_failure: true + on_build_status_changed: true diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000000000000000000000000000000000000..c3ba81f9e2e9635e06fddd967f8d5bf364b14f0a --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,12 @@ +coverage: + precision: 2 + notify: + email: + default: + to: + - sdsang@taosdata.com + - &author + only_pulls: false + layout: reach, diff, flags, files + flags: null + paths: null diff --git a/.gitignore b/.gitignore index dfc138d13f281ec7a0cba4173f32b8bc7aa13089..e6e327327c2a72bc2262d9b2923314c950c78cf6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,16 +11,15 @@ debs/ rpms/ mac/ *.pyc +.mypy_cache *.tmp +*.swp src/connector/nodejs/node_modules/ src/connector/nodejs/out/ tests/test/ tests/taoshebei/ tests/taoscsv/ tests/taosdalipu/ -tests/sim/ -tests/script/ -tests/pytest/ tests/jenkins/ tests/hdfs/ *.iml @@ -33,4 +32,50 @@ taoshebei/ taosdalipu/ Target/ *.failed -*.sql \ No newline at end of file +*.sql +sim/ +psim/ +pysim/ +*.out +*DS_Store + +# Doxygen Generated files +html/ +/.vs +/CMakeFiles/3.10.2 +/CMakeCache.txt +/Makefile +/*.cmake +/src/cq/test/CMakeFiles/cqtest.dir/*.cmake +*.cmake +/src/cq/test/CMakeFiles/cqtest.dir/*.make +*.make +link.txt +*.internal +*.includecache +*.marks +Makefile +CMakeError.log +*.log +/CMakeFiles/CMakeRuleHashes.txt +/CMakeFiles/Makefile2 +/CMakeFiles/TargetDirectories.txt +/CMakeFiles/cmake.check_cache +/out/isenseconfig/WSL-Clang-Debug +/out/isenseconfig/WSL-GCC-Debug +/test/cfg +/src/.vs +*.o +version.c +taos.rc +src/connector/jdbc/.settings/ +tests/comparisonTest/cassandra/cassandratest/.classpath +tests/comparisonTest/cassandra/cassandratest/.project +tests/comparisonTest/cassandra/cassandratest/.settings/ +tests/comparisonTest/opentsdb/opentsdbtest/.classpath +tests/comparisonTest/opentsdb/opentsdbtest/.factorypath +tests/comparisonTest/opentsdb/opentsdbtest/.project +tests/comparisonTest/opentsdb/opentsdbtest/.settings/ +tests/examples/JDBC/JDBCDemo/.classpath +tests/examples/JDBC/JDBCDemo/.project +tests/examples/JDBC/JDBCDemo/.settings/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..7c84eac8a4ee7529005855bc836387561c49ae2d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "src/connector/go"] + path = src/connector/go + url = https://github.com/taosdata/driver-go +[submodule "src/connector/grafanaplugin"] + path = src/connector/grafanaplugin + url = https://github.com/taosdata/grafanaplugin diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..6e49709c85e9d26d89cd7d7ab8ec8fa78297ef96 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,270 @@ +# +# Configuration +# +# +# Build Matrix +# +branches: + only: + - master + - develop + - coverity_scan + - /^.*ci-.*$/ + +matrix: + - os: linux + dist: focal + language: c + + git: + - depth: 1 + + compiler: gcc + env: DESC="linux/gcc build and test" + + addons: + apt: + packages: + - build-essential + - cmake + - net-tools + - python3-pip + - python3-setuptools + - valgrind + - psmisc + + before_script: + - export TZ=Asia/Harbin + - date + - cd ${TRAVIS_BUILD_DIR} + - mkdir debug + - cd debug + + script: + - cmake .. > /dev/null + - make > /dev/null + + after_success: + - travis_wait 20 + - |- + case $TRAVIS_OS_NAME in + linux) + cd ${TRAVIS_BUILD_DIR}/debug + make install > /dev/null || travis_terminate $? + + py3ver=`python3 --version|awk '{print $2}'|cut -d "." -f 1,2` && apt install python$py3ver-dev + pip3 install psutil + pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/ + + cd ${TRAVIS_BUILD_DIR}/tests + ./test-all.sh smoke || travis_terminate $? + sleep 1 + + cd ${TRAVIS_BUILD_DIR}/tests/pytest + pkill -TERM -x taosd + fuser -k -n tcp 6030 + sleep 1 + ./crash_gen.sh -a -p -t 4 -s 2000|| travis_terminate $? + sleep 1 + + cd ${TRAVIS_BUILD_DIR}/tests/pytest + ./valgrind-test.sh 2>&1 > mem-error-out.log + sleep 1 + + # Color setting + RED='\033[0;31m' + GREEN='\033[1;32m' + GREEN_DARK='\033[0;32m' + GREEN_UNDERLINE='\033[4;32m' + NC='\033[0m' + + grep 'start to execute\|ERROR SUMMARY' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-mem-error-out.log + + for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.log | awk '{print $4}'` + do + if [ -n "$memError" ]; then + if [ "$memError" -gt 12 ]; then + echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ + More than our threshold! ## ${NC}" + travis_terminate $memError + fi + fi + done + + grep 'start to execute\|definitely lost:' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.log + for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.log | awk '{print $7}'` + do + if [ -n "$defiMemError" ]; then + if [ "$defiMemError" -gt 13 ]; then + echo -e "${RED} ## Memory errors number valgrind reports \ + Definitely lost is $defiMemError. More than our threshold! ## ${NC}" + travis_terminate $defiMemError + fi + fi + done + + ;; + esac + + - os: linux + dist: bionic + language: c + compiler: gcc + env: COVERITY_SCAN=true + git: + - depth: 1 + + script: + - echo "this job is for coverity scan" + + addons: + coverity_scan: + # GitHub project metadata + # ** specific to your project ** + project: + name: TDengine + version: 2.x + description: TDengine + + # Where email notification of build analysis results will be sent + notification_email: sdsang@taosdata.com, slguan@taosdata.com + + # Commands to prepare for build_command + # ** likely specific to your build ** + build_command_prepend: cmake . > /dev/null + + # The command that will be added as an argument to "cov-build" to compile your project for analysis, + # ** likely specific to your build ** + build_command: make + + # Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'. + # Take care in resource usage, and consider the build frequency allowances per + # https://scan.coverity.com/faq#frequency + branch_pattern: coverity_scan + + - os: linux + dist: trusty + language: c + git: + - depth: 1 + + addons: + apt: + packages: + - build-essential + - cmake + env: + - DESC="trusty/gcc-4.8 build" + + before_script: + - export TZ=Asia/Harbin + - date + - cd ${TRAVIS_BUILD_DIR} + - mkdir debug + - cd debug + + script: + - cmake .. > /dev/null + - make + + - os: linux + dist: bionic + language: c + compiler: clang + env: DESC="linux/clang build" + git: + - depth: 1 + + addons: + apt: + packages: + - build-essential + - cmake + + before_script: + - export TZ=Asia/Harbin + - date + - cd ${TRAVIS_BUILD_DIR} + - mkdir debug + - cd debug + + script: + - cmake .. > /dev/null + - make > /dev/null + + - os: linux + arch: arm64 + dist: bionic + language: c + compiler: clang + env: DESC="linux/clang build" + git: + - depth: 1 + + addons: + apt: + packages: + - build-essential + - cmake + + before_script: + - export TZ=Asia/Harbin + - date + - cd ${TRAVIS_BUILD_DIR} + - mkdir debug + - cd debug + + script: + - if [ "${TRAVIS_CPU_ARCH}" == "arm64" ]; then + cmake .. -DCPUTYPE=aarch64 > /dev/null; + else + cmake .. > /dev/null; + fi + - make > /dev/null + + - os: linux + arch: arm64 + dist: trusty + language: c + git: + - depth: 1 + + addons: + apt: + packages: + - build-essential + - cmake + env: + - DESC="trusty/gcc-4.8 build" + + before_script: + - export TZ=Asia/Harbin + - date + - cd ${TRAVIS_BUILD_DIR} + - mkdir debug + - cd debug + + script: + - if [ "${TRAVIS_CPU_ARCH}" == "arm64" ]; then + cmake .. -DCPUTYPE=aarch64 > /dev/null; + else + cmake .. > /dev/null; + fi + - make > /dev/null + +# - os: osx +# language: c +# compiler: clang +# env: DESC="mac/clang build" +# git: +# - depth: 1 +# addons: +# homebrew: +# - cmake +# +# script: +# - cd ${TRAVIS_BUILD_DIR} +# - mkdir debug +# - cd debug +# - cmake .. > /dev/null +# - make > /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index b572d7bd16c4fb2725a13324c2fe0b697e9a02a2..588526c28614f753f6ff70e898f13f3fd65318db 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,294 +1,42 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -PROJECT(TDengine) - -SET(CMAKE_C_STANDARD 11) -SET(CMAKE_VERBOSE_MAKEFILE ON) - -# -# If need to set debug options -# 1.Generate debug version: -# mkdir debug; cd debug; -# cmake -DCMAKE_BUILD_TYPE=Debug .. -# 2.Generate release version: -# mkdir release; cd release; -# cmake -DCMAKE_BUILD_TYPE=Release .. -# - -# -# If it is a Windows operating system -# 1.Use command line tool of VS2013 or higher version -# mkdir build; cd build; -# cmake -G "NMake Makefiles" .. -# nmake install -# 2.Use the VS development interface tool -# mkdir build; cd build; -# cmake -A x64 .. -# open the file named TDengine.sln -# - -SET(TD_GODLL FALSE) -IF (${DLLTYPE} MATCHES "go") - ADD_DEFINITIONS(-D_TD_GO_DLL_) - MESSAGE(STATUS "input dll type: " ${DLLTYPE}) - SET(TD_GODLL TRUE) +IF (CMAKE_VERSION VERSION_LESS 3.0) + PROJECT(TDengine CXX) + SET(PROJECT_VERSION_MAJOR "${LIB_MAJOR_VERSION}") + SET(PROJECT_VERSION_MINOR "${LIB_MINOR_VERSION}") + SET(PROJECT_VERSION_PATCH"${LIB_PATCH_VERSION}") + SET(PROJECT_VERSION "${LIB_VERSION_STRING}") +ELSE () + CMAKE_POLICY(SET CMP0048 NEW) + PROJECT(TDengine VERSION "${LIB_VERSION_STRING}" LANGUAGES CXX) ENDIF () -IF (NOT DEFINED TD_CLUSTER) - MESSAGE(STATUS "Build the Lite Version") - SET(TD_CLUSTER FALSE) - SET(TD_LITE TRUE) - - SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR}) - MESSAGE(STATUS "Community directory: " ${TD_COMMUNITY_DIR}) - - - # Set macro definitions according to os platform - SET(TD_LINUX_64 FALSE) - SET(TD_LINUX_32 FALSE) - SET(TD_ARM FALSE) - SET(TD_ARM_64 FALSE) - SET(TD_ARM_32 FALSE) - SET(TD_MIPS FALSE) - SET(TD_MIPS_64 FALSE) - SET(TD_MIPS_32 FALSE) - SET(TD_DARWIN_64 FALSE) - SET(TD_WINDOWS_64 FALSE) - - # if generate ARM version: - # cmake -DCPUTYPE=aarch32 .. or cmake -DCPUTYPE=aarch64 - IF (${CPUTYPE} MATCHES "aarch32") - SET(TD_ARM TRUE) - SET(TD_ARM_32 TRUE) - ADD_DEFINITIONS(-D_TD_ARM_) - ADD_DEFINITIONS(-D_TD_ARM_32_) - ELSEIF (${CPUTYPE} MATCHES "aarch64") - SET(TD_ARM TRUE) - SET(TD_ARM_64 TRUE) - ADD_DEFINITIONS(-D_TD_ARM_) - ADD_DEFINITIONS(-D_TD_ARM_64_) - ELSEIF (${CPUTYPE} MATCHES "mips64") - SET(TD_MIPS TRUE) - SET(TD_MIPS_64 TRUE) - ADD_DEFINITIONS(-D_TD_MIPS_) - ADD_DEFINITIONS(-D_TD_MIPS_64_) - ELSEIF (${CPUTYPE} MATCHES "x64") - MESSAGE(STATUS "input cpuType: " ${CPUTYPE}) - ELSEIF (${CPUTYPE} MATCHES "x86") - MESSAGE(STATUS "input cpuType: " ${CPUTYPE}) - ELSE () - MESSAGE(STATUS "input cpuType: " ${CPUTYPE}) - ENDIF () +SET(TD_ACCOUNT FALSE) +SET(TD_ADMIN FALSE) +SET(TD_GRANT FALSE) +SET(TD_SYNC TRUE) +SET(TD_MQTT TRUE) +SET(TD_TSDB_PLUGINS FALSE) - # - # Get OS information and store in variable TD_OS_INFO. - # - execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh) - execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO) - MESSAGE(STATUS "The current os is " ${TD_OS_INFO}) +SET(TD_COVER FALSE) +SET(TD_MEM_CHECK FALSE) - IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - SET(TD_LINUX_64 TRUE) - SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux) - ADD_DEFINITIONS(-D_M_X64) - MESSAGE(STATUS "The current platform is Linux 64-bit") - ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4) - IF (TD_ARM) - SET(TD_LINUX_32 TRUE) - SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux) - #ADD_DEFINITIONS(-D_M_IX86) - MESSAGE(STATUS "The current platform is Linux 32-bit") - ELSE () - MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, but no ARM not supported yet") - EXIT () - ENDIF () - ELSE () - MESSAGE(FATAL_ERROR "The current platform is Linux neither 32-bit nor 64-bit, not supported yet") - EXIT () - ENDIF () - ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - SET(TD_DARWIN_64 TRUE) - SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/darwin) - MESSAGE(STATUS "The current platform is Darwin 64-bit") - ELSE () - MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet") - EXIT () - ENDIF () - ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - SET(TD_WINDOWS_64 TRUE) - SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/windows) - ADD_DEFINITIONS(-D_M_X64) - MESSAGE(STATUS "The current platform is Windows 64-bit") - ELSE () - MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet") - EXIT () - ENDIF () - ELSE() - MESSAGE(FATAL_ERROR "The current platform is not Linux/Darwin/Windows, stop compile") - EXIT () - ENDIF () - - FIND_PROGRAM(TD_MVN_INSTALLED mvn) - IF (TD_MVN_INSTALLED) - MESSAGE(STATUS "MVN is installed and JDBC will be compiled") - ELSE () - MESSAGE(STATUS "MVN is not installed and JDBC is not compiled") - ENDIF () - - # - # debug flag - # - # ADD_DEFINITIONS(-D_CHECK_HEADER_FILE_) - IF (${MEM_CHECK} MATCHES "true") - ADD_DEFINITIONS(-DTAOS_MEM_CHECK) - ENDIF () - - IF (TD_CLUSTER) - ADD_DEFINITIONS(-DCLUSTER) - ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=3) - ELSE () - ADD_DEFINITIONS(-DLITE) - ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=1) - ENDIF () - IF (TD_LINUX_64) - SET(DEBUG_FLAGS "-O0 -DDEBUG") - SET(RELEASE_FLAGS "-O0") - IF (NOT TD_ARM) - IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - ELSE () - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - ENDIF () - ELSE () - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - ENDIF () - ADD_DEFINITIONS(-DLINUX) - ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) - IF (${TD_OS_INFO} MATCHES "Alpine") - MESSAGE(STATUS "The current OS is Alpine, append extra flags") - SET(COMMON_FLAGS "${COMMON_FLAGS} -largp") - link_libraries(/usr/lib/libargp.a) - ADD_DEFINITIONS(-D_ALPINE) - ENDIF () - ELSEIF (TD_LINUX_32) - IF (NOT TD_ARM) - EXIT () - ENDIF () - SET(DEBUG_FLAGS "-O0 -DDEBUG") - SET(RELEASE_FLAGS "-O0") - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -latomic -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - ADD_DEFINITIONS(-DLINUX) - ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) - ADD_DEFINITIONS(-DUSE_LIBICONV) - IF (${TD_OS_INFO} MATCHES "Alpine") - MESSAGE(STATUS "The current OS is Alpine, add extra flags") - SET(COMMON_FLAGS "${COMMON_FLAGS} -largp") - link_library(/usr/lib/libargp.a) - ADD_DEFINITIONS(-D_ALPINE) - ENDIF () - ELSEIF (TD_WINDOWS_64) - SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE) - IF (NOT TD_GODLL) - SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-") - SET(DEBUG_FLAGS "/Zi /W3 /GL") - SET(RELEASE_FLAGS "/W0 /GL") - ENDIF () - ADD_DEFINITIONS(-DWINDOWS) - ADD_DEFINITIONS(-D__CLEANUP_C) - ADD_DEFINITIONS(-DPTW32_STATIC_LIB) - ADD_DEFINITIONS(-DPTW32_BUILD) - ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - ELSEIF (TD_DARWIN_64) - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") - SET(DEBUG_FLAGS "-O0 -DDEBUG") - SET(RELEASE_FLAGS "-O0") - ADD_DEFINITIONS(-DDARWIN) - ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) - ELSE () - MESSAGE(FATAL_ERROR "The current platform is not support yet, stop compile") - EXIT () - ENDIF () - - # Set compiler options - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}") - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS} ${RELEASE_FLAGS}") - - # Set c++ compiler options - # SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11") - # SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}") - # SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}") - - IF (${CMAKE_BUILD_TYPE} MATCHES "Debug") - MESSAGE(STATUS "Build Debug Version") - ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release") - MESSAGE(STATUS "Build Release Version") - ELSE () - IF (TD_WINDOWS_64) - SET(CMAKE_BUILD_TYPE "Release") - MESSAGE(STATUS "Build Release Version in Windows as default") - ELSE () - SET(CMAKE_BUILD_TYPE "Debug") - MESSAGE(STATUS "Build Debug Version as default") - ENDIF() - ENDIF () - - #set output directory - SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib) - SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin) - SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test) +SET(TD_PAGMODE_LITE FALSE) +SET(TD_SOMODE_STATIC FALSE) +SET(TD_POWER FALSE) +SET(TD_GODLL FALSE) - MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR}) - MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR}) - MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR}) - MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH}) - MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH}) +SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR}) +MESSAGE(STATUS "Community directory: " ${TD_COMMUNITY_DIR}) - IF (TD_LINUX_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})") - ELSEIF (TD_LINUX_32) - IF (NOT TD_ARM) - EXIT () - ENDIF () - 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})") - ELSEIF (TD_WINDOWS_64) - SET(CMAKE_INSTALL_PREFIX C:/TDengine) - IF (NOT TD_GODLL) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/grafana DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .) - INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) - INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) - #INSTALL(TARGETS taos RUNTIME DESTINATION driver) - #INSTALL(TARGETS shell RUNTIME DESTINATION .) - IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc) - ENDIF () - ELSE () - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll.a DESTINATION driver) - 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 () +INCLUDE(cmake/input.inc) +INCLUDE(cmake/platform.inc) +INCLUDE(cmake/define.inc) +INCLUDE(cmake/env.inc) +INCLUDE(cmake/version.inc) +INCLUDE(cmake/install.inc) ADD_SUBDIRECTORY(deps) ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(tests) INCLUDE(CPack) diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000000000000000000000000000000000000..d3f2c27bf6ecb5bb433e468c34577408c7ba6603 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,25 @@ +{ + "configurations": [ + { + "name": "WSL-GCC-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\build\\", + "installRoot": "${projectDir}\\build\\", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "/mnt/d/TDengine/TDengine/build", + "type": "PATH" + } + ] + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 6efa0ff8ef026c51a859123bf37c71d570d3758d..522fc0ebc1277684b77589c5c62d061f7b33ce32 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![Build Status](https://travis-ci.org/taosdata/TDengine.svg?branch=master)](https://travis-ci.org/taosdata/TDengine) +[![Build status](https://ci.appveyor.com/api/projects/status/kf3pwh2or5afsgl9/branch/master?svg=true)](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master) +[![Coverage Status](https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop)](https://coveralls.io/github/taosdata/TDengine?branch=develop) +[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4201/badge)](https://bestpractices.coreinfrastructure.org/projects/4201) +[![tdengine](https://snapcraft.io//tdengine/badge.svg)](https://snapcraft.io/tdengine) + [![TDengine](TDenginelogo.png)](https://www.taosdata.com) # What is TDengine? @@ -17,46 +23,121 @@ TDengine is an open-sourced big data platform under [GNU AGPL v3.0](http://www.g - **Zero Management, No Learning Curve**: It takes only seconds to download, install, and run it successfully; there are no other dependencies. Automatic partitioning on tables or DBs. Standard SQL is used, with C/C++, Python, JDBC, Go and RESTful connectors. # Documentation -For user manual, system design and architecture, engineering blogs, refer to [TDengine Documentation](https://www.taosdata.com/en/documentation/) +For user manual, system design and architecture, engineering blogs, refer to [TDengine Documentation](https://www.taosdata.com/en/documentation/)(中文版请点击[这里](https://www.taosdata.com/cn/documentation20/)) for details. The documentation from our website can also be downloaded locally from *documentation/tdenginedocs-en* or *documentation/tdenginedocs-cn*. # Building At the moment, TDengine only supports building and running on Linux systems. You can choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) or from the source code. This quick guide is for installation from the source only. -To build TDengine, use [CMake](https://cmake.org/) 2.8 or higher versions in the project directory. Install CMake for example on Ubuntu: -``` -sudo apt-get install -y cmake build-essential +To build TDengine, use [CMake](https://cmake.org/) 3.5 or higher versions in the project directory. + +## Install tools + +### Ubuntu & Debian: +```bash +sudo apt-get install -y gcc cmake build-essential git ``` To compile and package the JDBC driver source code, you should have a Java jdk-8 or higher and Apache Maven 2.7 or higher installed. -To install openjdk-8 on Ubuntu: +To install openjdk-8: +```bash +sudo apt-get install -y openjdk-8-jdk +``` + +To install Apache Maven: +```bash +sudo apt-get install -y maven +``` + +### Centos 7: +```bash +sudo yum install -y gcc gcc-c++ make cmake3 epel-release git +sudo yum remove -y cmake +sudo ln -s /usr/bin/cmake3 /usr/bin/cmake +``` + +To install openjdk-8: +```bash +sudo yum install -y java-1.8.0-openjdk ``` -sudo apt-get install openjdk-8-jdk + +To install Apache Maven: +```bash +sudo yum install -y maven ``` -To install Apache Maven on Ubuntu: + +### Centos 8 & Fedora: +```bash +sudo dnf install -y gcc gcc-c++ make cmake epel-release git ``` -sudo apt-get install maven + +To install openjdk-8: +```bash +sudo dnf install -y java-1.8.0-openjdk ``` -Build TDengine: +To install Apache Maven: +```bash +sudo dnf install -y maven +``` +## Get the source codes + +- github: +```bash +git clone https://github.com/taosdata/TDengine.git +cd TDengine ``` -mkdir build && cd build + +## Build TDengine + +### On Linux platform + +```bash +mkdir debug && cd debug cmake .. && cmake --build . ``` To compile on an ARM processor (aarch64 or aarch32), please add option CPUTYPE as below: aarch64: -```cmd +```bash cmake .. -DCPUTYPE=aarch64 && cmake --build . ``` aarch32: -```cmd +```bash cmake .. -DCPUTYPE=aarch32 && cmake --build . ``` +### On Windows platform + +If you use the Visual Studio 2013, please open a command window by executing "cmd.exe". +Please specify "x86_amd64" for 64 bits Windows or specify "x86" is for 32 bits Windows when you execute vcvarsall.bat. +``` +mkdir debug && cd debug +"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" < x86_amd64 | x86 > +cmake .. -G "NMake Makefiles" +nmake +``` + +If you use the Visual Studio 2019, please open a command window by executing "cmd.exe". +Please specify "x64" for 64 bits Windows or specify "x86" is for 32 bits Windows when you execute vcvarsall.bat. +``` +mkdir debug && cd debug +"c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" < x64 | x86 > +cmake .. -G "NMake Makefiles" +nmake +``` + +Or, you can open a command window by clicking Visual Studio 2019 menu "Tools -> Command Line -> Developer Command Prompt" or "Tools -> Command Line -> Developer PowerShell" then execute commands as follows: +``` +mkdir debug && cd debug +cmake .. -G "NMake Makefiles" +nmake +``` + +# Quick Run # Quick Run To quickly start a TDengine server after building, run the command below in terminal: ```cmd @@ -118,6 +199,11 @@ The TDengine community has also kindly built some of their own connectors! Follo - [Rust Connector](https://github.com/taosdata/TDengine/tree/master/tests/examples/rust) - [.Net Core Connector](https://github.com/maikebing/Maikebing.EntityFrameworkCore.Taos) +- [Lua Connector](https://github.com/taosdata/TDengine/tree/develop/tests/examples/lua) + +# How to run the test cases and how to add a new test case? + TDengine's test framework and all test cases are fully open source. + Please refer to [this document](tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md) for how to run test and develop new test case. # TDengine Roadmap - Support event-driven stream computing @@ -130,3 +216,8 @@ The TDengine community has also kindly built some of their own connectors! Follo # Contribute to TDengine Please follow the [contribution guidelines](CONTRIBUTING.md) to contribute to the project. + +# Join TDengine WeChat Group + +Add WeChat “tdengine” to join the group,you can communicate with other users. + diff --git a/alert/.gitignore b/alert/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..332fefb3ae376fb47d21c8e5d44c2d1d61f96e5a --- /dev/null +++ b/alert/.gitignore @@ -0,0 +1,21 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +vendor/ + +# Project specific files +cmd/alert/alert +cmd/alert/alert.log +*.db +*.gz \ No newline at end of file diff --git a/alert/README.md b/alert/README.md new file mode 100644 index 0000000000000000000000000000000000000000..23179669349ebf94f3774c6101c06c2e375ef059 --- /dev/null +++ b/alert/README.md @@ -0,0 +1,184 @@ +# Alert + +The Alert application reads data from [TDEngine](https://www.taosdata.com/), calculating according to predefined rules to generate alerts, and pushes alerts to downstream applications like [AlertManager](https://github.com/prometheus/alertmanager). + +## Install + +### From Binary + +Precompiled binaries is available at [taosdata website](https://www.taosdata.com/en/getting-started/), please download and unpack it by below shell command. + +``` +$ tar -xzf tdengine-alert-$version-$OS-$ARCH.tar.gz +``` + +If you have no TDengine server or client installed, please execute below command to install the required driver library: + +``` +$ ./install_driver.sh +``` + +### From Source Code + +Two prerequisites are required to install from source. + +1. TDEngine server or client must be installed. +2. Latest [Go](https://golang.org) language must be installed. + +When these two prerequisites are ready, please follow steps below to build the application: + +``` +$ mkdir taosdata +$ cd taosdata +$ git clone https://github.com/taosdata/tdengine.git +$ cd tdengine/alert/cmd/alert +$ go build +``` + +If `go build` fails because some of the dependency packages cannot be downloaded, please follow steps in [goproxy.io](https://goproxy.io) to configure `GOPROXY` and try `go build` again. + +## Configure + +The configuration file format of Alert application is standard `json`, below is its default content, please revise according to actual scenario. + +```json +{ + "port": 8100, + "database": "file:alert.db", + "tdengine": "root:taosdata@/tcp(127.0.0.1:0)/", + "log": { + "level": "production", + "path": "alert.log" + }, + "receivers": { + "alertManager": "http://127.0.0.1:9093/api/v1/alerts", + "console": true + } +} +``` + +The use of each configuration item is: + +* **port**: This is the `http` service port which enables other application to manage rules by `restful API`. +* **database**: rules are stored in a `sqlite` database, this is the path of the database file (if the file does not exist, the alert application creates it automatically). +* **tdengine**: connection string of `TDEngine` server, note in most cases the database information should be put in a rule, thus it should NOT be included here. +* **log > level**: log level, could be `production` or `debug`. +* **log > path**: log output file path. +* **receivers > alertManager**: the alert application pushes alerts to `AlertManager` at this URL. +* **receivers > console**: print out alerts to console (stdout) or not. + +When the configruation file is ready, the alert application can be started with below command (`alert.cfg` is the path of the configuration file): + +``` +$ ./alert -cfg alert.cfg +``` + +## Prepare an alert rule + +From technical aspect, an alert could be defined as: query and filter recent data from `TDEngine`, and calculating out a boolean value from these data according to a formula, and trigger an alert if the boolean value last for a certain duration. + +This is a rule example in `json` format: + +```json +{ + "name": "rule1", + "sql": "select sum(col1) as sumCol1 from test.meters where ts > now - 1h group by areaid", + "expr": "sumCol1 > 10", + "for": "10m", + "period": "1m", + "labels": { + "ruleName": "rule1" + }, + "annotations": { + "summary": "sum of rule {{$labels.ruleName}} of area {{$values.areaid}} is {{$values.sumCol1}}" + } +} +``` + +The fields of the rule is explained below: + +* **name**: the name of the rule, must be unique. +* **sql**: this is the `sql` statement used to query data from `TDEngine`, columns of the query result are used in later processing, so please give the column an alias if aggregation functions are used. +* **expr**: an expression whose result is a boolean value, arithmatic and logical calculations can be included in the expression, and builtin functions (see below) are also supported. Alerts are only triggered when the expression evaluates to `true`. +* **for**: this item is a duration which default value is zero second. when `expr` evaluates to `true` and last at least this duration, an alert is triggered. +* **period**: the interval for the alert application to check the rule, default is 1 minute. +* **labels**: a label list, labels are used to generate alert information. note if the `sql` statement includes a `group by` clause, the `group by` columns are inserted into this list automatically. +* **annotations**: the template of alert information which is in [go template](https://golang.org/pkg/text/template) syntax, labels can be referenced by `$labels.