Merge remote-tracking branch 'origin/main' into enh/TD-32190
This commit is contained in:
commit
9f2fba6269
|
@ -121,6 +121,7 @@ TAGS
|
||||||
contrib/*
|
contrib/*
|
||||||
!contrib/CMakeLists.txt
|
!contrib/CMakeLists.txt
|
||||||
!contrib/test
|
!contrib/test
|
||||||
|
!contrib/azure-cmake
|
||||||
sql
|
sql
|
||||||
debug*/
|
debug*/
|
||||||
.env
|
.env
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
project(
|
project(
|
||||||
TDengine
|
TDengine
|
||||||
VERSION 3.0
|
VERSION 3.0
|
||||||
DESCRIPTION "An open-source big data platform designed and optimized for the Internet of Things(IOT)"
|
DESCRIPTION "An open-source big data platform designed and optimized for the Internet of Things(IOT)"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT DEFINED TD_SOURCE_DIR)
|
if(NOT DEFINED TD_SOURCE_DIR)
|
||||||
set( TD_SOURCE_DIR ${PROJECT_SOURCE_DIR} )
|
set(TD_SOURCE_DIR ${PROJECT_SOURCE_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
|
SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
|
||||||
|
@ -15,13 +15,11 @@ SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
|
||||||
set(TD_SUPPORT_DIR "${TD_SOURCE_DIR}/cmake")
|
set(TD_SUPPORT_DIR "${TD_SOURCE_DIR}/cmake")
|
||||||
set(TD_CONTRIB_DIR "${TD_SOURCE_DIR}/contrib")
|
set(TD_CONTRIB_DIR "${TD_SOURCE_DIR}/contrib")
|
||||||
|
|
||||||
|
|
||||||
include(${TD_SUPPORT_DIR}/cmake.platform)
|
include(${TD_SUPPORT_DIR}/cmake.platform)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.define)
|
include(${TD_SUPPORT_DIR}/cmake.define)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.options)
|
include(${TD_SUPPORT_DIR}/cmake.options)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.version)
|
include(${TD_SUPPORT_DIR}/cmake.version)
|
||||||
|
|
||||||
|
|
||||||
# contrib
|
# contrib
|
||||||
add_subdirectory(contrib)
|
add_subdirectory(contrib)
|
||||||
|
|
||||||
|
@ -33,8 +31,8 @@ target_include_directories(api INTERFACE "include/client")
|
||||||
|
|
||||||
# src
|
# src
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
include(CTest)
|
include(CTest)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
|
@ -44,5 +42,5 @@ add_subdirectory(examples/c)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.install)
|
include(${TD_SUPPORT_DIR}/cmake.install)
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
add_subdirectory(docs/doxgen)
|
add_subdirectory(docs/doxgen)
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# azure
|
||||||
|
ExternalProject_Add(azure
|
||||||
|
URL https://github.com/Azure/azure-sdk-for-cpp/archive/refs/tags/azure-storage-blobs_12.13.0-beta.1.tar.gz
|
||||||
|
URL_HASH SHA256=3eca486fd60e3522d0a633025ecd652a71515b1e944799b2e8ee31fd590305a9
|
||||||
|
DOWNLOAD_NO_PROGRESS 1
|
||||||
|
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||||
|
SOURCE_DIR "${TD_CONTRIB_DIR}/azure-sdk-for-cpp-azure-storage-blobs_12.13.0-beta.1"
|
||||||
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
#BUILD_ALWAYS 1
|
||||||
|
#UPDATE_COMMAND ""
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE FALSE)
|
set(CMAKE_VERBOSE_MAKEFILE FALSE)
|
||||||
set(TD_BUILD_TAOSA_INTERNAL FALSE)
|
set(TD_BUILD_TAOSA_INTERNAL FALSE)
|
||||||
|
|
||||||
#set output directory
|
# set output directory
|
||||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
|
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
|
||||||
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
|
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
|
||||||
|
@ -12,170 +12,178 @@ MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
|
||||||
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
|
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
|
||||||
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
|
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
|
||||||
|
|
||||||
if (NOT DEFINED TD_GRANT)
|
IF(NOT DEFINED TD_GRANT)
|
||||||
SET(TD_GRANT FALSE)
|
SET(TD_GRANT FALSE)
|
||||||
endif()
|
ENDIF()
|
||||||
|
|
||||||
IF (NOT DEFINED BUILD_WITH_RAND_ERR)
|
IF(NOT DEFINED BUILD_WITH_RAND_ERR)
|
||||||
SET(BUILD_WITH_RAND_ERR FALSE)
|
SET(BUILD_WITH_RAND_ERR FALSE)
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(BUILD_WITH_RAND_ERR TRUE)
|
SET(BUILD_WITH_RAND_ERR TRUE)
|
||||||
endif()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${WEBSOCKET}" MATCHES "true")
|
IF("${WEBSOCKET}" MATCHES "true")
|
||||||
SET(TD_WEBSOCKET TRUE)
|
SET(TD_WEBSOCKET TRUE)
|
||||||
MESSAGE("Enable websocket")
|
MESSAGE("Enable websocket")
|
||||||
ADD_DEFINITIONS(-DWEBSOCKET)
|
ADD_DEFINITIONS(-DWEBSOCKET)
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(TD_WEBSOCKET FALSE)
|
SET(TD_WEBSOCKET FALSE)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${BUILD_HTTP}" STREQUAL "")
|
IF("${BUILD_HTTP}" STREQUAL "")
|
||||||
IF (TD_LINUX)
|
IF(TD_LINUX)
|
||||||
IF (TD_ARM_32)
|
IF(TD_ARM_32)
|
||||||
SET(TD_BUILD_HTTP TRUE)
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(TD_BUILD_HTTP TRUE)
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
ELSEIF (TD_DARWIN)
|
ELSEIF(TD_DARWIN)
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ELSE()
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ENDIF()
|
||||||
|
ELSEIF(${BUILD_HTTP} MATCHES "false")
|
||||||
|
SET(TD_BUILD_HTTP FALSE)
|
||||||
|
ELSEIF(${BUILD_HTTP} MATCHES "true")
|
||||||
SET(TD_BUILD_HTTP TRUE)
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
ELSE ()
|
ELSEIF(${BUILD_HTTP} MATCHES "internal")
|
||||||
|
SET(TD_BUILD_HTTP FALSE)
|
||||||
|
SET(TD_BUILD_TAOSA_INTERNAL TRUE)
|
||||||
|
ELSE()
|
||||||
SET(TD_BUILD_HTTP TRUE)
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
ELSEIF (${BUILD_HTTP} MATCHES "false")
|
|
||||||
SET(TD_BUILD_HTTP FALSE)
|
|
||||||
ELSEIF (${BUILD_HTTP} MATCHES "true")
|
|
||||||
SET(TD_BUILD_HTTP TRUE)
|
|
||||||
ELSEIF (${BUILD_HTTP} MATCHES "internal")
|
|
||||||
SET(TD_BUILD_HTTP FALSE)
|
|
||||||
SET(TD_BUILD_TAOSA_INTERNAL TRUE)
|
|
||||||
ELSE ()
|
|
||||||
SET(TD_BUILD_HTTP TRUE)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (TD_BUILD_HTTP)
|
IF(TD_BUILD_HTTP)
|
||||||
ADD_DEFINITIONS(-DHTTP_EMBEDDED)
|
ADD_DEFINITIONS(-DHTTP_EMBEDDED)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${BUILD_TOOLS}" STREQUAL "")
|
IF("${BUILD_TOOLS}" STREQUAL "")
|
||||||
IF (TD_LINUX)
|
IF(TD_LINUX)
|
||||||
IF (TD_ARM_32)
|
IF(TD_ARM_32)
|
||||||
SET(BUILD_TOOLS "false")
|
SET(BUILD_TOOLS "false")
|
||||||
ELSEIF (TD_ARM_64)
|
ELSEIF(TD_ARM_64)
|
||||||
SET(BUILD_TOOLS "false")
|
SET(BUILD_TOOLS "false")
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(BUILD_TOOLS "false")
|
SET(BUILD_TOOLS "false")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
ELSEIF (TD_DARWIN)
|
ELSEIF(TD_DARWIN)
|
||||||
SET(BUILD_TOOLS "false")
|
SET(BUILD_TOOLS "false")
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(BUILD_TOOLS "false")
|
SET(BUILD_TOOLS "false")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${BUILD_TOOLS}" MATCHES "false")
|
IF("${BUILD_TOOLS}" MATCHES "false")
|
||||||
MESSAGE("${Yellow} Will _not_ build taos_tools! ${ColourReset}")
|
MESSAGE("${Yellow} Will _not_ build taos_tools! ${ColourReset}")
|
||||||
SET(TD_TAOS_TOOLS FALSE)
|
SET(TD_TAOS_TOOLS FALSE)
|
||||||
ELSE ()
|
ELSE()
|
||||||
MESSAGE("")
|
MESSAGE("")
|
||||||
MESSAGE("${Green} Will build taos_tools! ${ColourReset}")
|
MESSAGE("${Green} Will build taos_tools! ${ColourReset}")
|
||||||
MESSAGE("")
|
MESSAGE("")
|
||||||
SET(TD_TAOS_TOOLS TRUE)
|
SET(TD_TAOS_TOOLS TRUE)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
IF (${TD_WINDOWS})
|
IF(${TD_WINDOWS})
|
||||||
SET(TAOS_LIB taos_static)
|
SET(TAOS_LIB taos_static)
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(TAOS_LIB taos)
|
SET(TAOS_LIB taos)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
# build TSZ by default
|
# build TSZ by default
|
||||||
IF ("${TSZ_ENABLED}" MATCHES "false")
|
IF("${TSZ_ENABLED}" MATCHES "false")
|
||||||
set(VAR_TSZ "" CACHE INTERNAL "global variant empty" )
|
set(VAR_TSZ "" CACHE INTERNAL "global variant empty")
|
||||||
ELSE()
|
ELSE()
|
||||||
# define add
|
# define add
|
||||||
MESSAGE(STATUS "build with TSZ enabled")
|
MESSAGE(STATUS "build with TSZ enabled")
|
||||||
ADD_DEFINITIONS(-DTD_TSZ)
|
ADD_DEFINITIONS(-DTD_TSZ)
|
||||||
set(VAR_TSZ "TSZ" CACHE INTERNAL "global variant tsz" )
|
set(VAR_TSZ "TSZ" CACHE INTERNAL "global variant tsz")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# force set all platform to JEMALLOC_ENABLED = false
|
# force set all platform to JEMALLOC_ENABLED = false
|
||||||
SET(JEMALLOC_ENABLED OFF)
|
SET(JEMALLOC_ENABLED OFF)
|
||||||
IF (TD_WINDOWS)
|
|
||||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
|
||||||
IF (${CMAKE_BUILD_TYPE} MATCHES "Release")
|
|
||||||
MESSAGE("${Green} will build Release version! ${ColourReset}")
|
|
||||||
SET(COMMON_FLAGS "/W3 /D_WIN32 /DWIN32 /Zi- /O2 /GL /MD")
|
|
||||||
|
|
||||||
ELSE ()
|
IF(TD_WINDOWS)
|
||||||
MESSAGE("${Green} will build Debug version! ${ColourReset}")
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
|
|
||||||
|
IF(${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||||
|
MESSAGE("${Green} will build Release version! ${ColourReset}")
|
||||||
|
SET(COMMON_FLAGS "/W3 /D_WIN32 /DWIN32 /Zi- /O2 /GL /MD")
|
||||||
|
|
||||||
|
ELSE()
|
||||||
|
MESSAGE("${Green} will build Debug version! ${ColourReset}")
|
||||||
|
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||||
|
|
||||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||||
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||||
# ENDIF ()
|
# ENDIF ()
|
||||||
IF (CMAKE_DEPFILE_FLAGS_C)
|
IF(CMAKE_DEPFILE_FLAGS_C)
|
||||||
SET(CMAKE_DEPFILE_FLAGS_C "")
|
SET(CMAKE_DEPFILE_FLAGS_C "")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
IF (CMAKE_DEPFILE_FLAGS_CXX)
|
|
||||||
|
IF(CMAKE_DEPFILE_FLAGS_CXX)
|
||||||
SET(CMAKE_DEPFILE_FLAGS_CXX "")
|
SET(CMAKE_DEPFILE_FLAGS_CXX "")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
IF (CMAKE_C_FLAGS_DEBUG)
|
|
||||||
|
IF(CMAKE_C_FLAGS_DEBUG)
|
||||||
SET(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
SET(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
IF (CMAKE_CXX_FLAGS_DEBUG)
|
|
||||||
|
IF(CMAKE_CXX_FLAGS_DEBUG)
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
SET(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
|
||||||
|
|
||||||
ELSE ()
|
ELSE()
|
||||||
IF (${TD_DARWIN})
|
IF(${TD_DARWIN})
|
||||||
set(CMAKE_MACOSX_RPATH 0)
|
set(CMAKE_MACOSX_RPATH 0)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
IF (${COVER} MATCHES "true")
|
|
||||||
|
IF(${COVER} MATCHES "true")
|
||||||
MESSAGE(STATUS "Test coverage mode, add extra flags")
|
MESSAGE(STATUS "Test coverage mode, add extra flags")
|
||||||
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
|
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
|
||||||
SET(GCC_COVERAGE_LINK_FLAGS "-lgcov --coverage")
|
SET(GCC_COVERAGE_LINK_FLAGS "-lgcov --coverage")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
# disable all assert
|
# disable all assert
|
||||||
IF ((${DISABLE_ASSERT} MATCHES "true") OR (${DISABLE_ASSERTS} MATCHES "true"))
|
IF((${DISABLE_ASSERT} MATCHES "true") OR(${DISABLE_ASSERTS} MATCHES "true"))
|
||||||
ADD_DEFINITIONS(-DDISABLE_ASSERT)
|
ADD_DEFINITIONS(-DDISABLE_ASSERT)
|
||||||
MESSAGE(STATUS "Disable all asserts")
|
MESSAGE(STATUS "Disable all asserts")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
INCLUDE(CheckCCompilerFlag)
|
INCLUDE(CheckCCompilerFlag)
|
||||||
IF (TD_ARM_64 OR TD_ARM_32)
|
|
||||||
|
IF(TD_ARM_64 OR TD_ARM_32)
|
||||||
SET(COMPILER_SUPPORT_SSE42 false)
|
SET(COMPILER_SUPPORT_SSE42 false)
|
||||||
ELSEIF (("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") OR ("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang"))
|
ELSEIF(("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") OR("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang"))
|
||||||
SET(COMPILER_SUPPORT_SSE42 true)
|
SET(COMPILER_SUPPORT_SSE42 true)
|
||||||
MESSAGE(STATUS "Always enable sse4.2 for Clang/AppleClang")
|
MESSAGE(STATUS "Always enable sse4.2 for Clang/AppleClang")
|
||||||
ELSE()
|
ELSE()
|
||||||
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF (TD_ARM_64 OR TD_ARM_32)
|
IF(TD_ARM_64 OR TD_ARM_32)
|
||||||
SET(COMPILER_SUPPORT_FMA false)
|
SET(COMPILER_SUPPORT_FMA false)
|
||||||
SET(COMPILER_SUPPORT_AVX false)
|
SET(COMPILER_SUPPORT_AVX false)
|
||||||
SET(COMPILER_SUPPORT_AVX2 false)
|
SET(COMPILER_SUPPORT_AVX2 false)
|
||||||
SET(COMPILER_SUPPORT_AVX512F false)
|
SET(COMPILER_SUPPORT_AVX512F false)
|
||||||
SET(COMPILER_SUPPORT_AVX512BMI false)
|
SET(COMPILER_SUPPORT_AVX512BMI false)
|
||||||
SET(COMPILER_SUPPORT_AVX512VL false)
|
SET(COMPILER_SUPPORT_AVX512VL false)
|
||||||
ELSE()
|
ELSE()
|
||||||
CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA)
|
CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx512f" COMPILER_SUPPORT_AVX512F)
|
CHECK_C_COMPILER_FLAG("-mavx512f" COMPILER_SUPPORT_AVX512F)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx512vbmi" COMPILER_SUPPORT_AVX512BMI)
|
CHECK_C_COMPILER_FLAG("-mavx512vbmi" COMPILER_SUPPORT_AVX512BMI)
|
||||||
CHECK_C_COMPILER_FLAG("-mavx512vl" COMPILER_SUPPORT_AVX512VL)
|
CHECK_C_COMPILER_FLAG("-mavx512vl" COMPILER_SUPPORT_AVX512VL)
|
||||||
|
|
||||||
INCLUDE(CheckCSourceRuns)
|
INCLUDE(CheckCSourceRuns)
|
||||||
SET(CMAKE_REQUIRED_FLAGS "-mavx")
|
SET(CMAKE_REQUIRED_FLAGS "-mavx")
|
||||||
check_c_source_runs("
|
check_c_source_runs("
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
int main() {
|
int main() {
|
||||||
__m256d a, b, c;
|
__m256d a, b, c;
|
||||||
|
@ -185,7 +193,7 @@ ELSE ()
|
||||||
c = _mm256_add_pd(a, b);
|
c = _mm256_add_pd(a, b);
|
||||||
_mm256_storeu_pd(buf, c);
|
_mm256_storeu_pd(buf, c);
|
||||||
for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) {
|
for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) {
|
||||||
if (buf[i] != 0) {
|
IF (buf[i] != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,8 +201,8 @@ ELSE ()
|
||||||
}
|
}
|
||||||
" COMPILER_SUPPORT_AVX)
|
" COMPILER_SUPPORT_AVX)
|
||||||
|
|
||||||
SET(CMAKE_REQUIRED_FLAGS "-mavx2")
|
SET(CMAKE_REQUIRED_FLAGS "-mavx2")
|
||||||
check_c_source_runs("
|
check_c_source_runs("
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
int main() {
|
int main() {
|
||||||
__m256i a, b, c;
|
__m256i a, b, c;
|
||||||
|
@ -204,7 +212,7 @@ ELSE ()
|
||||||
c = _mm256_and_si256(a, b);
|
c = _mm256_and_si256(a, b);
|
||||||
_mm256_storeu_si256((__m256i *)buf, c);
|
_mm256_storeu_si256((__m256i *)buf, c);
|
||||||
for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) {
|
for (int i = 0; i < sizeof(buf) / sizeof(buf[0]); ++i) {
|
||||||
if (buf[i] != 0) {
|
IF (buf[i] != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,40 +221,42 @@ ELSE ()
|
||||||
" COMPILER_SUPPORT_AVX2)
|
" COMPILER_SUPPORT_AVX2)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF (COMPILER_SUPPORT_SSE42)
|
IF(COMPILER_SUPPORT_SSE42)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
IF("${SIMD_SUPPORT}" MATCHES "true")
|
||||||
IF (COMPILER_SUPPORT_FMA)
|
IF(COMPILER_SUPPORT_FMA)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||||
|
MESSAGE(STATUS "FMA instructions is ACTIVATED")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(COMPILER_SUPPORT_AVX)
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||||
|
MESSAGE(STATUS "AVX instructions is ACTIVATED")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(COMPILER_SUPPORT_AVX2)
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
||||||
|
MESSAGE(STATUS "AVX2 instructions is ACTIVATED")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
MESSAGE(STATUS "FMA instructions is ACTIVATED")
|
|
||||||
ENDIF()
|
|
||||||
IF (COMPILER_SUPPORT_AVX)
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
|
||||||
MESSAGE(STATUS "AVX instructions is ACTIVATED")
|
|
||||||
ENDIF()
|
|
||||||
IF (COMPILER_SUPPORT_AVX2)
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
|
||||||
MESSAGE(STATUS "AVX2 instructions is ACTIVATED")
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${SIMD_AVX512_SUPPORT}" MATCHES "true")
|
IF("${SIMD_AVX512_SUPPORT}" MATCHES "true")
|
||||||
IF (COMPILER_SUPPORT_AVX512F AND COMPILER_SUPPORT_AVX512BMI)
|
IF(COMPILER_SUPPORT_AVX512F AND COMPILER_SUPPORT_AVX512BMI)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f -mavx512vbmi")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f -mavx512vbmi")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -mavx512vbmi")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -mavx512vbmi")
|
||||||
MESSAGE(STATUS "avx512f/avx512bmi enabled by compiler")
|
MESSAGE(STATUS "avx512f/avx512bmi enabled by compiler")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF (COMPILER_SUPPORT_AVX512VL)
|
IF(COMPILER_SUPPORT_AVX512VL)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512vl")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512vl")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512vl")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512vl")
|
||||||
MESSAGE(STATUS "avx512vl enabled by compiler")
|
MESSAGE(STATUS "avx512vl enabled by compiler")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
@ -254,16 +264,17 @@ ELSE ()
|
||||||
SET(CMAKE_C_FLAGS_REL "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -O3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
SET(CMAKE_C_FLAGS_REL "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -O3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||||
SET(CMAKE_CXX_FLAGS_REL "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -O3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
SET(CMAKE_CXX_FLAGS_REL "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -O3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||||
|
|
||||||
IF (${BUILD_SANITIZER})
|
IF(${BUILD_SANITIZER})
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
|
|
||||||
MESSAGE(STATUS "Compile with Address Sanitizer!")
|
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
|
||||||
ELSEIF (${BUILD_RELEASE})
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
|
||||||
|
MESSAGE(STATUS "Compile with Address Sanitizer!")
|
||||||
|
ELSEIF(${BUILD_RELEASE})
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REL}")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REL}")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL}")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL}")
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -g3 -gdwarf-2 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -g3 -gdwarf-2 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-user-defined-literal -g3 -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-user-defined-literal -g3 -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
ENDIF ()
|
|
||||||
|
|
|
@ -144,6 +144,12 @@ option(
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
BUILD_WITH_ANALYSIS
|
||||||
|
"If build with analysis"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF(NOT TD_ENTERPRISE)
|
IF(NOT TD_ENTERPRISE)
|
||||||
|
@ -151,8 +157,15 @@ MESSAGE("switch s3 off with community version")
|
||||||
set(BUILD_S3 OFF)
|
set(BUILD_S3 OFF)
|
||||||
set(BUILD_WITH_S3 OFF)
|
set(BUILD_WITH_S3 OFF)
|
||||||
set(BUILD_WITH_COS OFF)
|
set(BUILD_WITH_COS OFF)
|
||||||
|
set(BUILD_WITH_ANALYSIS OFF)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF(${BUILD_WITH_ANALYSIS})
|
||||||
|
message("build with analysis")
|
||||||
|
set(BUILD_S3 ON)
|
||||||
|
set(BUILD_WITH_S3 ON)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(${BUILD_S3})
|
IF(${BUILD_S3})
|
||||||
|
|
||||||
IF(${BUILD_WITH_S3})
|
IF(${BUILD_WITH_S3})
|
||||||
|
|
|
@ -10,39 +10,36 @@ if(${BUILD_WITH_S3})
|
||||||
file(MAKE_DIRECTORY $ENV{HOME}/.cos-local.2/)
|
file(MAKE_DIRECTORY $ENV{HOME}/.cos-local.2/)
|
||||||
|
|
||||||
elseif(${BUILD_WITH_COS})
|
elseif(${BUILD_WITH_COS})
|
||||||
|
set(CONTRIB_TMP_FILE3 "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in3")
|
||||||
|
configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
||||||
|
|
||||||
set(CONTRIB_TMP_FILE3 "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in3")
|
if(${BUILD_WITH_COS})
|
||||||
configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
file(MAKE_DIRECTORY $ENV{HOME}/.cos-local.1/)
|
||||||
|
cat("${TD_SUPPORT_DIR}/mxml_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
||||||
|
cat("${TD_SUPPORT_DIR}/apr_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
||||||
|
cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
||||||
|
endif(${BUILD_WITH_COS})
|
||||||
|
|
||||||
if(${BUILD_WITH_COS})
|
configure_file(${CONTRIB_TMP_FILE3} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
||||||
file(MAKE_DIRECTORY $ENV{HOME}/.cos-local.1/)
|
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||||
cat("${TD_SUPPORT_DIR}/mxml_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
|
||||||
cat("${TD_SUPPORT_DIR}/apr_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
|
||||||
cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE3})
|
|
||||||
endif(${BUILD_WITH_COS})
|
|
||||||
|
|
||||||
configure_file(${CONTRIB_TMP_FILE3} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
|
||||||
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
||||||
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
||||||
|
|
||||||
set(CONTRIB_TMP_FILE2 "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in2")
|
set(CONTRIB_TMP_FILE2 "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in2")
|
||||||
configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE2})
|
configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE2})
|
||||||
|
|
||||||
if(${BUILD_WITH_COS})
|
if(${BUILD_WITH_COS})
|
||||||
cat("${TD_SUPPORT_DIR}/apr-util_CMakeLists.txt.in" ${CONTRIB_TMP_FILE2})
|
cat("${TD_SUPPORT_DIR}/apr-util_CMakeLists.txt.in" ${CONTRIB_TMP_FILE2})
|
||||||
endif(${BUILD_WITH_COS})
|
endif(${BUILD_WITH_COS})
|
||||||
|
|
||||||
configure_file(${CONTRIB_TMP_FILE2} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
configure_file(${CONTRIB_TMP_FILE2} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||||
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
||||||
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(CONTRIB_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in")
|
set(CONTRIB_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in")
|
||||||
configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
|
@ -59,7 +56,7 @@ endif()
|
||||||
# taosadapter
|
# taosadapter
|
||||||
if(${BUILD_HTTP})
|
if(${BUILD_HTTP})
|
||||||
MESSAGE("BUILD_HTTP is on")
|
MESSAGE("BUILD_HTTP is on")
|
||||||
else ()
|
else()
|
||||||
MESSAGE("BUILD_HTTP is off, use taosAdapter")
|
MESSAGE("BUILD_HTTP is off, use taosAdapter")
|
||||||
cat("${TD_SUPPORT_DIR}/taosadapter_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/taosadapter_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
@ -110,19 +107,18 @@ cat("${TD_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
cat("${TD_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
# xz
|
# xz
|
||||||
#cat("${TD_SUPPORT_DIR}/xz_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/xz_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
#lzma2
|
# lzma2
|
||||||
cat("${TD_SUPPORT_DIR}/lzma_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/lzma_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
|
if(${BUILD_CONTRIB})
|
||||||
if (${BUILD_CONTRIB})
|
|
||||||
if(${BUILD_WITH_ROCKSDB})
|
if(${BUILD_WITH_ROCKSDB})
|
||||||
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
add_definitions(-DUSE_ROCKSDB)
|
add_definitions(-DUSE_ROCKSDB)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if (NOT ${TD_LINUX})
|
if(NOT ${TD_LINUX})
|
||||||
if(${BUILD_WITH_ROCKSDB})
|
if(${BUILD_WITH_ROCKSDB})
|
||||||
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
add_definitions(-DUSE_ROCKSDB)
|
add_definitions(-DUSE_ROCKSDB)
|
||||||
|
@ -134,9 +130,9 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#cat("${TD_SUPPORT_DIR}/zstd_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/zstd_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
#libuv
|
# libuv
|
||||||
if(${BUILD_WITH_UV})
|
if(${BUILD_WITH_UV})
|
||||||
cat("${TD_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif(${BUILD_WITH_UV})
|
endif(${BUILD_WITH_UV})
|
||||||
|
@ -152,17 +148,17 @@ if(${BUILD_WITH_S3})
|
||||||
cat("${TD_SUPPORT_DIR}/xml2_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/xml2_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
cat("${TD_SUPPORT_DIR}/libs3_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/libs3_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
cat("${TD_SUPPORT_DIR}/azure_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
add_definitions(-DUSE_S3)
|
add_definitions(-DUSE_S3)
|
||||||
|
|
||||||
# cos
|
# cos
|
||||||
elseif(${BUILD_WITH_COS})
|
elseif(${BUILD_WITH_COS})
|
||||||
#cat("${TD_SUPPORT_DIR}/mxml_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/mxml_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
#cat("${TD_SUPPORT_DIR}/apr_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/apr_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
#cat("${TD_SUPPORT_DIR}/apr-util_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/apr-util_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
#cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
cat("${TD_SUPPORT_DIR}/cos_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/cos_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# crashdump
|
# crashdump
|
||||||
|
@ -191,9 +187,9 @@ endif()
|
||||||
# download dependencies
|
# download dependencies
|
||||||
configure_file(${CONTRIB_TMP_FILE} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
configure_file(${CONTRIB_TMP_FILE} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||||
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
||||||
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
|
||||||
|
|
||||||
# ================================================================================================
|
# ================================================================================================
|
||||||
# Build
|
# Build
|
||||||
|
@ -206,25 +202,27 @@ if(${BUILD_TEST})
|
||||||
gtest
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${TD_WINDOWS})
|
if(${TD_WINDOWS})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
gtest
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_win>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_win>
|
||||||
)
|
)
|
||||||
endif(${TD_WINDOWS})
|
endif(${TD_WINDOWS})
|
||||||
|
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
gtest
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
||||||
)
|
)
|
||||||
endif(${TD_LINUX})
|
endif(${TD_LINUX})
|
||||||
|
|
||||||
if(${TD_DARWIN})
|
if(${TD_DARWIN})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
gtest
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_darwin>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_darwin>
|
||||||
)
|
)
|
||||||
endif(${TD_DARWIN})
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
||||||
# cJson
|
# cJson
|
||||||
|
@ -236,15 +234,16 @@ option(CJSON_BUILD_SHARED_LIBS "Overrides BUILD_SHARED_LIBS if CJSON_OVERRIDE_BU
|
||||||
add_subdirectory(cJson EXCLUDE_FROM_ALL)
|
add_subdirectory(cJson EXCLUDE_FROM_ALL)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
cjson
|
cjson
|
||||||
|
|
||||||
# see https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
|
# see https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cJson>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cJson>
|
||||||
)
|
)
|
||||||
unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
||||||
|
|
||||||
# xml2
|
# xml2
|
||||||
#if(${BUILD_WITH_S3})
|
# if(${BUILD_WITH_S3})
|
||||||
# add_subdirectory(xml2 EXCLUDE_FROM_ALL)
|
# add_subdirectory(xml2 EXCLUDE_FROM_ALL)
|
||||||
#endif()
|
# endif()
|
||||||
|
|
||||||
# lz4
|
# lz4
|
||||||
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
|
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
|
||||||
|
@ -255,10 +254,12 @@ target_include_directories(
|
||||||
|
|
||||||
# zlib
|
# zlib
|
||||||
set(CMAKE_PROJECT_INCLUDE_BEFORE "${TD_SUPPORT_DIR}/EnableCMP0048.txt.in")
|
set(CMAKE_PROJECT_INCLUDE_BEFORE "${TD_SUPPORT_DIR}/EnableCMP0048.txt.in")
|
||||||
|
|
||||||
if(${TD_DARWIN})
|
if(${TD_DARWIN})
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-non-prototype")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-non-prototype")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-non-prototype")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-non-prototype")
|
||||||
endif(${TD_DARWIN})
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
add_subdirectory(zlib EXCLUDE_FROM_ALL)
|
add_subdirectory(zlib EXCLUDE_FROM_ALL)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
zlibstatic
|
zlibstatic
|
||||||
|
@ -274,9 +275,9 @@ unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
||||||
|
|
||||||
# add_subdirectory(xz EXCLUDE_FROM_ALL)
|
# add_subdirectory(xz EXCLUDE_FROM_ALL)
|
||||||
# target_include_directories(
|
# target_include_directories(
|
||||||
# xz
|
# xz
|
||||||
# PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/xz
|
# PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/xz
|
||||||
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/xz
|
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/xz
|
||||||
# )
|
# )
|
||||||
|
|
||||||
# leveldb
|
# leveldb
|
||||||
|
@ -291,24 +292,27 @@ endif(${BUILD_WITH_LEVELDB})
|
||||||
|
|
||||||
# rocksdb
|
# rocksdb
|
||||||
# To support rocksdb build on ubuntu: sudo apt-get install libgflags-dev
|
# To support rocksdb build on ubuntu: sudo apt-get install libgflags-dev
|
||||||
if (${BUILD_WITH_UV})
|
if(${BUILD_WITH_UV})
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REL}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REL}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL}")
|
||||||
IF ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
SET(CMAKE_BUILD_TYPE Release)
|
SET(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
endif(${TD_LINUX})
|
endif(${TD_LINUX})
|
||||||
endif (${BUILD_WITH_UV})
|
endif(${BUILD_WITH_UV})
|
||||||
|
|
||||||
if (${BUILD_WITH_ROCKSDB})
|
if(${BUILD_WITH_ROCKSDB})
|
||||||
if (${BUILD_CONTRIB})
|
if(${BUILD_CONTRIB})
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL} -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=unused-function -Wno-errno=unused-private-field -Wno-error=unused-result")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL} -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=unused-function -Wno-errno=unused-private-field -Wno-error=unused-result")
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
SET(CMAKE_BUILD_TYPE Release)
|
SET(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
endif(${TD_LINUX})
|
endif(${TD_LINUX})
|
||||||
|
|
||||||
MESSAGE(STATUS "ROCKSDB CXXXX STATUS CONFIG: " ${CMAKE_CXX_FLAGS})
|
MESSAGE(STATUS "ROCKSDB CXXXX STATUS CONFIG: " ${CMAKE_CXX_FLAGS})
|
||||||
MESSAGE(STATUS "ROCKSDB C STATUS CONFIG: " ${CMAKE_C_FLAGS})
|
MESSAGE(STATUS "ROCKSDB C STATUS CONFIG: " ${CMAKE_C_FLAGS})
|
||||||
|
|
||||||
|
@ -316,22 +320,23 @@ if (${BUILD_WITH_ROCKSDB})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized")
|
||||||
endif(${TD_DARWIN})
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
if (${TD_DARWIN_ARM64})
|
if(${TD_DARWIN_ARM64})
|
||||||
set(HAS_ARMV8_CRC true)
|
set(HAS_ARMV8_CRC true)
|
||||||
endif(${TD_DARWIN_ARM64})
|
endif(${TD_DARWIN_ARM64})
|
||||||
|
|
||||||
if (${TD_WINDOWS})
|
if(${TD_WINDOWS})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4819 /std:c++17")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4819 /std:c++17")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4819")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4819")
|
||||||
option(WITH_JNI "" OFF)
|
option(WITH_JNI "" OFF)
|
||||||
|
|
||||||
if(CMAKE_C_FLAGS MATCHES "/MT" OR CMAKE_C_FLAGS MATCHES "/MTd")
|
if(CMAKE_C_FLAGS MATCHES "/MT" OR CMAKE_C_FLAGS MATCHES "/MTd")
|
||||||
message("Rocksdb build runtime lib use /MT or /MTd")
|
message("Rocksdb build runtime lib use /MT or /MTd")
|
||||||
option(WITH_MD_LIBRARY "build with MD" OFF)
|
option(WITH_MD_LIBRARY "build with MD" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SYSTEM_LIBS ${SYSTEM_LIBS} shlwapi.lib rpcrt4.lib)
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} shlwapi.lib rpcrt4.lib)
|
||||||
endif(${TD_WINDOWS})
|
endif(${TD_WINDOWS})
|
||||||
|
|
||||||
|
|
||||||
if(${TD_DARWIN})
|
if(${TD_DARWIN})
|
||||||
option(HAVE_THREAD_LOCAL "" OFF)
|
option(HAVE_THREAD_LOCAL "" OFF)
|
||||||
option(WITH_IOSTATS_CONTEXT "" OFF)
|
option(WITH_IOSTATS_CONTEXT "" OFF)
|
||||||
|
@ -357,30 +362,32 @@ if (${BUILD_WITH_ROCKSDB})
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
if (NOT ${TD_LINUX})
|
if(NOT ${TD_LINUX})
|
||||||
MESSAGE(STATUS "ROCKSDB CXX STATUS CONFIG: " ${CMAKE_CXX_FLAGS})
|
MESSAGE(STATUS "ROCKSDB CXX STATUS CONFIG: " ${CMAKE_CXX_FLAGS})
|
||||||
MESSAGE(STATUS "ROCKSDB C STATUS CONFIG: " ${CMAKE_C_FLAGS})
|
MESSAGE(STATUS "ROCKSDB C STATUS CONFIG: " ${CMAKE_C_FLAGS})
|
||||||
|
|
||||||
if(${TD_DARWIN})
|
if(${TD_DARWIN})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=maybe-uninitialized")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=maybe-uninitialized")
|
||||||
endif(${TD_DARWIN})
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
if (${TD_DARWIN_ARM64})
|
if(${TD_DARWIN_ARM64})
|
||||||
set(HAS_ARMV8_CRC true)
|
set(HAS_ARMV8_CRC true)
|
||||||
endif(${TD_DARWIN_ARM64})
|
endif(${TD_DARWIN_ARM64})
|
||||||
|
|
||||||
if (${TD_WINDOWS})
|
if(${TD_WINDOWS})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4819 /std:c++17")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4819 /std:c++17")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4819")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4819")
|
||||||
option(WITH_JNI "" OFF)
|
option(WITH_JNI "" OFF)
|
||||||
|
|
||||||
if(CMAKE_C_FLAGS MATCHES "/MT" OR CMAKE_C_FLAGS MATCHES "/MTd")
|
if(CMAKE_C_FLAGS MATCHES "/MT" OR CMAKE_C_FLAGS MATCHES "/MTd")
|
||||||
message("Rocksdb build runtime lib use /MT or /MTd")
|
message("Rocksdb build runtime lib use /MT or /MTd")
|
||||||
option(WITH_MD_LIBRARY "build with MD" OFF)
|
option(WITH_MD_LIBRARY "build with MD" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SYSTEM_LIBS ${SYSTEM_LIBS} shlwapi.lib rpcrt4.lib)
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} shlwapi.lib rpcrt4.lib)
|
||||||
endif(${TD_WINDOWS})
|
endif(${TD_WINDOWS})
|
||||||
|
|
||||||
|
|
||||||
if(${TD_DARWIN})
|
if(${TD_DARWIN})
|
||||||
option(HAVE_THREAD_LOCAL "" OFF)
|
option(HAVE_THREAD_LOCAL "" OFF)
|
||||||
option(WITH_IOSTATS_CONTEXT "" OFF)
|
option(WITH_IOSTATS_CONTEXT "" OFF)
|
||||||
|
@ -406,44 +413,44 @@ if (${BUILD_WITH_ROCKSDB})
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${BUILD_WITH_S3})
|
if(${BUILD_WITH_S3})
|
||||||
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.2/include)
|
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.2/include)
|
||||||
MESSAGE("build with s3: ${BUILD_WITH_S3}")
|
MESSAGE("build with s3: ${BUILD_WITH_S3}")
|
||||||
|
|
||||||
# cos
|
# cos
|
||||||
elseif(${BUILD_WITH_COS})
|
elseif(${BUILD_WITH_COS})
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
set(CMAKE_PREFIX_PATH $ENV{HOME}/.cos-local.1)
|
set(CMAKE_PREFIX_PATH $ENV{HOME}/.cos-local.1)
|
||||||
#ADD_DEFINITIONS(-DMINIXML_LIBRARY=${CMAKE_BINARY_DIR}/build/lib/libxml.a)
|
|
||||||
option(ENABLE_TEST "Enable the tests" OFF)
|
|
||||||
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.1/include)
|
|
||||||
#MESSAGE("$ENV{HOME}/.cos-local.1/include")
|
|
||||||
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
# ADD_DEFINITIONS(-DMINIXML_LIBRARY=${CMAKE_BINARY_DIR}/build/lib/libxml.a)
|
||||||
set(ORIG_CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME})
|
option(ENABLE_TEST "Enable the tests" OFF)
|
||||||
set(CMAKE_PROJECT_NAME cos_c_sdk)
|
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.1/include)
|
||||||
|
|
||||||
add_subdirectory(cos-c-sdk-v5 EXCLUDE_FROM_ALL)
|
# MESSAGE("$ENV{HOME}/.cos-local.1/include")
|
||||||
target_include_directories(
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
cos_c_sdk
|
set(ORIG_CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME})
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cos-c-sdk-v5/cos_c_sdk>
|
set(CMAKE_PROJECT_NAME cos_c_sdk)
|
||||||
)
|
|
||||||
|
|
||||||
set(CMAKE_PROJECT_NAME ${ORIG_CMAKE_PROJECT_NAME})
|
add_subdirectory(cos-c-sdk-v5 EXCLUDE_FROM_ALL)
|
||||||
else()
|
target_include_directories(
|
||||||
|
cos_c_sdk
|
||||||
endif(${TD_LINUX})
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cos-c-sdk-v5/cos_c_sdk>
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_PROJECT_NAME ${ORIG_CMAKE_PROJECT_NAME})
|
||||||
|
else()
|
||||||
|
endif(${TD_LINUX})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# pthread
|
# pthread
|
||||||
if(${BUILD_PTHREAD})
|
if(${BUILD_PTHREAD})
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
SET(CMAKE_BUILD_TYPE Release)
|
SET(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DPTW32_STATIC_LIB)
|
add_definitions(-DPTW32_STATIC_LIB)
|
||||||
add_subdirectory(pthread EXCLUDE_FROM_ALL)
|
add_subdirectory(pthread EXCLUDE_FROM_ALL)
|
||||||
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
|
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
|
||||||
|
@ -451,16 +458,15 @@ if(${BUILD_PTHREAD})
|
||||||
target_link_libraries(pthread INTERFACE libpthreadVC3)
|
target_link_libraries(pthread INTERFACE libpthreadVC3)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# jemalloc
|
# jemalloc
|
||||||
if(${JEMALLOC_ENABLED})
|
if(${JEMALLOC_ENABLED})
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
ExternalProject_Add(jemalloc
|
ExternalProject_Add(jemalloc
|
||||||
PREFIX "jemalloc"
|
PREFIX "jemalloc"
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc
|
||||||
BUILD_IN_SOURCE 1
|
BUILD_IN_SOURCE 1
|
||||||
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls
|
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls
|
||||||
BUILD_COMMAND ${MAKE}
|
BUILD_COMMAND ${MAKE}
|
||||||
)
|
)
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include)
|
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include)
|
||||||
endif()
|
endif()
|
||||||
|
@ -514,12 +520,13 @@ endif(${BUILD_WCWIDTH})
|
||||||
|
|
||||||
# LIBUV
|
# LIBUV
|
||||||
if(${BUILD_WITH_UV})
|
if(${BUILD_WITH_UV})
|
||||||
if (TD_WINDOWS)
|
if(TD_WINDOWS)
|
||||||
# There is no GetHostNameW function on win7.
|
# There is no GetHostNameW function on win7.
|
||||||
file(READ "libuv/src/win/util.c" LIBUV_WIN_UTIL_CONTENT)
|
file(READ "libuv/src/win/util.c" LIBUV_WIN_UTIL_CONTENT)
|
||||||
string(REPLACE "if (GetHostNameW(buf, UV_MAXHOSTNAMESIZE" "DWORD nSize = UV_MAXHOSTNAMESIZE;\n if (GetComputerNameW(buf, &nSize" LIBUV_WIN_UTIL_CONTENT "${LIBUV_WIN_UTIL_CONTENT}")
|
string(REPLACE "if (GetHostNameW(buf, UV_MAXHOSTNAMESIZE" "DWORD nSize = UV_MAXHOSTNAMESIZE;\n if (GetComputerNameW(buf, &nSize" LIBUV_WIN_UTIL_CONTENT "${LIBUV_WIN_UTIL_CONTENT}")
|
||||||
file(WRITE "libuv/src/win/util.c" "${LIBUV_WIN_UTIL_CONTENT}")
|
file(WRITE "libuv/src/win/util.c" "${LIBUV_WIN_UTIL_CONTENT}")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(libuv EXCLUDE_FROM_ALL)
|
add_subdirectory(libuv EXCLUDE_FROM_ALL)
|
||||||
endif(${BUILD_WITH_UV})
|
endif(${BUILD_WITH_UV})
|
||||||
|
|
||||||
|
@ -535,6 +542,7 @@ if(${BUILD_WITH_SQLITE})
|
||||||
INTERFACE m
|
INTERFACE m
|
||||||
INTERFACE pthread
|
INTERFACE pthread
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT TD_WINDOWS)
|
if(NOT TD_WINDOWS)
|
||||||
target_link_libraries(sqlite
|
target_link_libraries(sqlite
|
||||||
INTERFACE dl
|
INTERFACE dl
|
||||||
|
@ -545,36 +553,38 @@ endif(${BUILD_WITH_SQLITE})
|
||||||
# addr2line
|
# addr2line
|
||||||
if(${BUILD_ADDR2LINE})
|
if(${BUILD_ADDR2LINE})
|
||||||
if(NOT ${TD_WINDOWS})
|
if(NOT ${TD_WINDOWS})
|
||||||
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
|
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
|
||||||
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
|
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
|
||||||
check_include_file( "inttypes.h" HAVE_INTTYPES_H )
|
check_include_file("inttypes.h" HAVE_INTTYPES_H)
|
||||||
check_include_file( "stddef.h" HAVE_STDDEF_H )
|
check_include_file("stddef.h" HAVE_STDDEF_H)
|
||||||
check_include_file( "stdlib.h" HAVE_STDLIB_H )
|
check_include_file("stdlib.h" HAVE_STDLIB_H)
|
||||||
check_include_file( "string.h" HAVE_STRING_H )
|
check_include_file("string.h" HAVE_STRING_H)
|
||||||
check_include_file( "memory.h" HAVE_MEMORY_H )
|
check_include_file("memory.h" HAVE_MEMORY_H)
|
||||||
check_include_file( "strings.h" HAVE_STRINGS_H )
|
check_include_file("strings.h" HAVE_STRINGS_H)
|
||||||
check_include_file( "stdint.h" HAVE_STDINT_H )
|
check_include_file("stdint.h" HAVE_STDINT_H)
|
||||||
check_include_file( "unistd.h" HAVE_UNISTD_H )
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||||
check_include_file( "sgidefs.h" HAVE_SGIDEFS_H )
|
check_include_file("sgidefs.h" HAVE_SGIDEFS_H)
|
||||||
check_include_file( "stdafx.h" HAVE_STDAFX_H )
|
check_include_file("stdafx.h" HAVE_STDAFX_H)
|
||||||
check_include_file( "elf.h" HAVE_ELF_H )
|
check_include_file("elf.h" HAVE_ELF_H)
|
||||||
check_include_file( "libelf.h" HAVE_LIBELF_H )
|
check_include_file("libelf.h" HAVE_LIBELF_H)
|
||||||
check_include_file( "libelf/libelf.h" HAVE_LIBELF_LIBELF_H)
|
check_include_file("libelf/libelf.h" HAVE_LIBELF_LIBELF_H)
|
||||||
check_include_file( "alloca.h" HAVE_ALLOCA_H )
|
check_include_file("alloca.h" HAVE_ALLOCA_H)
|
||||||
check_include_file( "elfaccess.h" HAVE_ELFACCESS_H)
|
check_include_file("elfaccess.h" HAVE_ELFACCESS_H)
|
||||||
check_include_file( "sys/elf_386.h" HAVE_SYS_ELF_386_H )
|
check_include_file("sys/elf_386.h" HAVE_SYS_ELF_386_H)
|
||||||
check_include_file( "sys/elf_amd64.h" HAVE_SYS_ELF_AMD64_H)
|
check_include_file("sys/elf_amd64.h" HAVE_SYS_ELF_AMD64_H)
|
||||||
check_include_file( "sys/elf_sparc.h" HAVE_SYS_ELF_SPARC_H)
|
check_include_file("sys/elf_sparc.h" HAVE_SYS_ELF_SPARC_H)
|
||||||
check_include_file( "sys/ia64/elf.h" HAVE_SYS_IA64_ELF_H )
|
check_include_file("sys/ia64/elf.h" HAVE_SYS_IA64_ELF_H)
|
||||||
set(VERSION 0.3.1)
|
set(VERSION 0.3.1)
|
||||||
set(PACKAGE_VERSION "\"${VERSION}\"")
|
set(PACKAGE_VERSION "\"${VERSION}\"")
|
||||||
configure_file(libdwarf/cmake/config.h.cmake config.h)
|
configure_file(libdwarf/cmake/config.h.cmake config.h)
|
||||||
file(GLOB_RECURSE LIBDWARF_SOURCES "libdwarf/src/lib/libdwarf/*.c")
|
file(GLOB_RECURSE LIBDWARF_SOURCES "libdwarf/src/lib/libdwarf/*.c")
|
||||||
add_library(libdwarf STATIC ${LIBDWARF_SOURCES})
|
add_library(libdwarf STATIC ${LIBDWARF_SOURCES})
|
||||||
set_target_properties(libdwarf PROPERTIES OUTPUT_NAME "libdwarf")
|
set_target_properties(libdwarf PROPERTIES OUTPUT_NAME "libdwarf")
|
||||||
|
|
||||||
if(HAVE_LIBELF_H OR HAVE_LIBELF_LIBELF_H)
|
if(HAVE_LIBELF_H OR HAVE_LIBELF_LIBELF_H)
|
||||||
target_link_libraries(libdwarf PUBLIC libelf)
|
target_link_libraries(libdwarf PUBLIC libelf)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(libdwarf SYSTEM PUBLIC "libdwarf/src/lib/libdwarf" ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(libdwarf SYSTEM PUBLIC "libdwarf/src/lib/libdwarf" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
file(READ "addr2line/addr2line.c" ADDR2LINE_CONTENT)
|
file(READ "addr2line/addr2line.c" ADDR2LINE_CONTENT)
|
||||||
string(REPLACE "static int" "int" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
string(REPLACE "static int" "int" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||||
|
@ -583,7 +593,7 @@ if(${BUILD_ADDR2LINE})
|
||||||
file(WRITE "addr2line/addr2line.c" "${ADDR2LINE_CONTENT}")
|
file(WRITE "addr2line/addr2line.c" "${ADDR2LINE_CONTENT}")
|
||||||
add_library(addr2line STATIC "addr2line/addr2line.c")
|
add_library(addr2line STATIC "addr2line/addr2line.c")
|
||||||
target_link_libraries(addr2line PUBLIC libdwarf dl z)
|
target_link_libraries(addr2line PUBLIC libdwarf dl z)
|
||||||
target_include_directories(addr2line PUBLIC "libdwarf/src/lib/libdwarf" )
|
target_include_directories(addr2line PUBLIC "libdwarf/src/lib/libdwarf")
|
||||||
endif(NOT ${TD_WINDOWS})
|
endif(NOT ${TD_WINDOWS})
|
||||||
endif(${BUILD_ADDR2LINE})
|
endif(${BUILD_ADDR2LINE})
|
||||||
|
|
||||||
|
@ -592,31 +602,41 @@ if(${BUILD_GEOS})
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REL}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REL}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REL}")
|
||||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
SET(CMAKE_BUILD_TYPE Release)
|
SET(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
endif(${TD_LINUX})
|
endif(${TD_LINUX})
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build GEOS with shared libraries" OFF)
|
option(BUILD_SHARED_LIBS "Build GEOS with shared libraries" OFF)
|
||||||
add_subdirectory(geos EXCLUDE_FROM_ALL)
|
add_subdirectory(geos EXCLUDE_FROM_ALL)
|
||||||
if (${TD_WINDOWS})
|
|
||||||
|
if(${TD_WINDOWS})
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
else ()
|
else()
|
||||||
unset(CMAKE_CXX_STANDARD CACHE) # undo libgeos's setting of global CMAKE_CXX_STANDARD
|
unset(CMAKE_CXX_STANDARD CACHE) # undo libgeos's setting of global CMAKE_CXX_STANDARD
|
||||||
endif(${TD_WINDOWS})
|
endif(${TD_WINDOWS})
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
geos_c
|
geos_c
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/geos/include>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/geos/include>
|
||||||
)
|
)
|
||||||
endif(${BUILD_GEOS})
|
endif(${BUILD_GEOS})
|
||||||
|
|
||||||
if (${BUILD_PCRE2})
|
if(${BUILD_PCRE2})
|
||||||
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
|
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
|
||||||
endif(${BUILD_PCRE2})
|
endif(${BUILD_PCRE2})
|
||||||
|
|
||||||
|
if(${TD_LINUX} AND ${BUILD_WITH_S3})
|
||||||
|
add_subdirectory(azure-cmake EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
# ================================================================================================
|
# ================================================================================================
|
||||||
# Build test
|
# Build test
|
||||||
# ================================================================================================
|
# ================================================================================================
|
||||||
|
MESSAGE("build with dependency tests: ${BUILD_DEPENDENCY_TESTS}")
|
||||||
|
|
||||||
if(${BUILD_DEPENDENCY_TESTS})
|
if(${BUILD_DEPENDENCY_TESTS})
|
||||||
add_subdirectory(test EXCLUDE_FROM_ALL)
|
add_subdirectory(test EXCLUDE_FROM_ALL)
|
||||||
endif(${BUILD_DEPENDENCY_TESTS})
|
endif(${BUILD_DEPENDENCY_TESTS})
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
# lib_azure_sdk
|
||||||
|
set(AZURE_DIR "${TD_CONTRIB_DIR}/azure-sdk-for-cpp-azure-storage-blobs_12.13.0-beta.1")
|
||||||
|
set(AZURE_SDK_LIBRARY_DIR "${AZURE_DIR}/sdk")
|
||||||
|
|
||||||
|
file(GLOB AZURE_SDK_SRC
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/credentials/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/cryptography/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/http/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/http/curl/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/io/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/tracing/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/identity/azure-identity/src/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/src/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/src/private/*.cpp"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-common/src/*.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GLOB AZURE_SDK_UNIFIED_SRC
|
||||||
|
${AZURE_SDK_SRC}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(AZURE_SDK_INCLUDES
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/core/azure-core/inc/"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/identity/azure-identity/inc/"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-common/inc/"
|
||||||
|
"${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/inc/"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(_azure_sdk STATIC ${AZURE_SDK_UNIFIED_SRC})
|
||||||
|
target_compile_definitions(_azure_sdk PRIVATE BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
_azure_sdk
|
||||||
|
PUBLIC "$ENV{HOME}/.cos-local.2/include"
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(XML2_LIBRARY xml2 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
# find_library(CURL_LIBRARY curl)
|
||||||
|
# find_library(XML2_LIBRARY xml2)
|
||||||
|
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
# find_library(CoreFoundation_Library CoreFoundation)
|
||||||
|
# find_library(SystemConfiguration_Library SystemConfiguration)
|
||||||
|
target_link_libraries(
|
||||||
|
_azure_sdk
|
||||||
|
PRIVATE ${CURL_LIBRARY}
|
||||||
|
PRIVATE ${SSL_LIBRARY}
|
||||||
|
PRIVATE ${CRYPTO_LIBRARY}
|
||||||
|
PRIVATE ${XML2_LIBRARY}
|
||||||
|
|
||||||
|
# PRIVATE xml2
|
||||||
|
PRIVATE zlib
|
||||||
|
|
||||||
|
# PRIVATE ${CoreFoundation_Library}
|
||||||
|
# PRIVATE ${SystemConfiguration_Library}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Originally, on Windows azure-core is built with bcrypt and crypt32 by default
|
||||||
|
if(TARGET OpenSSL::SSL)
|
||||||
|
target_link_libraries(_azure_sdk PRIVATE OpenSSL::Crypto OpenSSL::SSL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Originally, on Windows azure-core is built with winhttp by default
|
||||||
|
if(TARGET td_contrib::curl)
|
||||||
|
target_link_libraries(_azure_sdk PRIVATE td_contrib::curl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(_azure_sdk SYSTEM BEFORE PUBLIC ${AZURE_SDK_INCLUDES})
|
||||||
|
add_library(td_contrib::azure_sdk ALIAS _azure_sdk)
|
|
@ -28,5 +28,6 @@ if(${BUILD_WITH_TRAFT})
|
||||||
# add_subdirectory(traft)
|
# add_subdirectory(traft)
|
||||||
endif(${BUILD_WITH_TRAFT})
|
endif(${BUILD_WITH_TRAFT})
|
||||||
|
|
||||||
|
add_subdirectory(azure)
|
||||||
add_subdirectory(tdev)
|
add_subdirectory(tdev)
|
||||||
add_subdirectory(lz4)
|
add_subdirectory(lz4)
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
azure-test
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(XML2_LIBRARY xml2 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
# find_library(XML2_LIBRARY xml2)
|
||||||
|
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
# find_library(CoreFoundation_Library CoreFoundation)
|
||||||
|
# find_library(SystemConfiguration_Library SystemConfiguration)
|
||||||
|
target_link_libraries(
|
||||||
|
azure-test
|
||||||
|
PRIVATE _azure_sdk
|
||||||
|
PRIVATE ${CURL_LIBRARY}
|
||||||
|
PRIVATE ${XML2_LIBRARY}
|
||||||
|
PRIVATE ${SSL_LIBRARY}
|
||||||
|
PRIVATE ${CRYPTO_LIBRARY}
|
||||||
|
PRIVATE dl
|
||||||
|
PRIVATE pthread
|
||||||
|
)
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Include the necessary SDK headers
|
||||||
|
#include <azure/core.hpp>
|
||||||
|
#include <azure/storage/blobs.hpp>
|
||||||
|
|
||||||
|
// Add appropriate using namespace directives
|
||||||
|
using namespace Azure::Storage;
|
||||||
|
using namespace Azure::Storage::Blobs;
|
||||||
|
|
||||||
|
// Secrets should be stored & retrieved from secure locations such as Azure::KeyVault. For
|
||||||
|
// convenience and brevity of samples, the secrets are retrieved from environment variables.
|
||||||
|
|
||||||
|
std::string GetEndpointUrl() {
|
||||||
|
// return std::getenv("AZURE_STORAGE_ACCOUNT_URL");
|
||||||
|
std::string accountId = getenv("ablob_account_id");
|
||||||
|
if (accountId.empty()) {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountId + ".blob.core.windows.net";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetAccountName() {
|
||||||
|
// return std::getenv("AZURE_STORAGE_ACCOUNT_NAME");
|
||||||
|
return getenv("ablob_account_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetAccountKey() {
|
||||||
|
// return std::getenv("AZURE_STORAGE_ACCOUNT_KEY");
|
||||||
|
|
||||||
|
return getenv("ablob_account_secret");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::string endpointUrl = GetEndpointUrl();
|
||||||
|
std::string accountName = GetAccountName();
|
||||||
|
std::string accountKey = GetAccountKey();
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto sharedKeyCredential = std::make_shared<StorageSharedKeyCredential>(accountName, accountKey);
|
||||||
|
|
||||||
|
std::string accountURL = "https://fd2d01cd892f844eeaa2273.blob.core.windows.net";
|
||||||
|
BlobServiceClient blobServiceClient(accountURL, sharedKeyCredential);
|
||||||
|
|
||||||
|
std::string containerName = "myblobcontainer";
|
||||||
|
// auto containerClient = blobServiceClient.GetBlobContainerClient("myblobcontainer");
|
||||||
|
auto containerClient = blobServiceClient.GetBlobContainerClient("td-test");
|
||||||
|
|
||||||
|
// Create the container if it does not exist
|
||||||
|
std::cout << "Creating container: " << containerName << std::endl;
|
||||||
|
// containerClient.CreateIfNotExists();
|
||||||
|
|
||||||
|
std::string blobName = "blob.txt";
|
||||||
|
uint8_t blobContent[] = "Hello Azure!";
|
||||||
|
// Create the block blob client
|
||||||
|
BlockBlobClient blobClient = containerClient.GetBlockBlobClient(blobName);
|
||||||
|
|
||||||
|
// Upload the blob
|
||||||
|
std::cout << "Uploading blob: " << blobName << std::endl;
|
||||||
|
blobClient.UploadFrom(blobContent, sizeof(blobContent));
|
||||||
|
/*
|
||||||
|
auto blockBlobClient = BlockBlobClient(endpointUrl, sharedKeyCredential);
|
||||||
|
|
||||||
|
// Create some data to upload into the blob.
|
||||||
|
std::vector<uint8_t> data = {1, 2, 3, 4};
|
||||||
|
Azure::Core::IO::MemoryBodyStream stream(data);
|
||||||
|
|
||||||
|
Azure::Response<Models::UploadBlockBlobResult> response = blockBlobClient.Upload(stream);
|
||||||
|
|
||||||
|
Models::UploadBlockBlobResult model = response.Value;
|
||||||
|
std::cout << "Last modified date of uploaded blob: " << model.LastModified.ToString()
|
||||||
|
<< std::endl;
|
||||||
|
*/
|
||||||
|
} catch (const Azure::Core::RequestFailedException& e) {
|
||||||
|
std::cout << "Status Code: " << static_cast<int>(e.StatusCode) << ", Reason Phrase: " << e.ReasonPhrase
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << e.what() << std::endl;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -80,7 +80,7 @@ These pseudocolumns occur after the aggregation clause.
|
||||||
`FILL` clause is used to specify how to fill when there is data missing in any window, including:
|
`FILL` clause is used to specify how to fill when there is data missing in any window, including:
|
||||||
|
|
||||||
1. NONE: No fill (the default fill mode)
|
1. NONE: No fill (the default fill mode)
|
||||||
2. VALUE: Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` Note: The value filled depends on the data type. For example, if you run FILL(VALUE 1.23) on an integer column, the value 1 is filled. If multiple columns in select list need to be filled, then in the fill clause there must be a fill value for each of these columns, for example, `SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`.
|
2. VALUE: Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` Note: The value filled depends on the data type. For example, if you run FILL(VALUE 1.23) on an integer column, the value 1 is filled. If multiple columns in select list need to be filled, then in the fill clause there must be a fill value for each of these columns, for example, `SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`. Note that only exprs in select list that contains normal cols need to specify fill value, exprs like `_wstart`, `_wend`, `_wduration`, `_wstart + 1a`, `now`, `1+1`, partition keys like tbname(when using partition by) don't need to specify fill value. But exprs like `timediff(last(ts), _wstart)` need to specify fill value.
|
||||||
3. PREV: Fill with the previous non-NULL value, `FILL(PREV)`
|
3. PREV: Fill with the previous non-NULL value, `FILL(PREV)`
|
||||||
4. NULL: Fill with NULL, `FILL(NULL)`
|
4. NULL: Fill with NULL, `FILL(NULL)`
|
||||||
5. LINEAR: Fill with the closest non-NULL value, `FILL(LINEAR)`
|
5. LINEAR: Fill with the closest non-NULL value, `FILL(LINEAR)`
|
||||||
|
|
|
@ -27,11 +27,15 @@ The preceding SQL command shows all dnodes in the cluster with the ID, endpoint,
|
||||||
## Delete a DNODE
|
## Delete a DNODE
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
DROP DNODE dnode_id
|
DROP DNODE dnode_id [force] [unsafe]
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
|
Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
|
||||||
|
|
||||||
|
Only online node is allowed to be deleted. Drop is executed with force option if the offline node need to be deleted.
|
||||||
|
|
||||||
|
Drop is executed with unsafe option if the node with single replica is offline, and the data on it is not able to be restored.
|
||||||
|
|
||||||
## Modify Dnode Configuration
|
## Modify Dnode Configuration
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
import com.taosdata.jdbc.tmq.*;
|
import com.taosdata.jdbc.tmq.*;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -60,7 +61,7 @@ public class ConsumerLoopFull {
|
||||||
// ANCHOR_END: create_consumer
|
// ANCHOR_END: create_consumer
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: poll_data_code_piece
|
// ANCHOR: poll_data_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -73,7 +74,7 @@ public class ConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -91,7 +92,7 @@ public class ConsumerLoopFull {
|
||||||
// ANCHOR_END: poll_data_code_piece
|
// ANCHOR_END: poll_data_code_piece
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: consumer_seek
|
// ANCHOR: consumer_seek
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +100,7 @@ public class ConsumerLoopFull {
|
||||||
consumer.subscribe(topics);
|
consumer.subscribe(topics);
|
||||||
System.out.println("Subscribe topics successfully.");
|
System.out.println("Subscribe topics successfully.");
|
||||||
Set<TopicPartition> assignment = consumer.assignment();
|
Set<TopicPartition> assignment = consumer.assignment();
|
||||||
System.out.println("Now assignment: " + JSON.toJSONString(assignment));
|
System.out.println("Now assignment: " + JsonUtil.getObjectMapper().writeValueAsString(assignment));
|
||||||
|
|
||||||
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
||||||
// make sure we have got some data
|
// make sure we have got some data
|
||||||
|
@ -125,7 +126,7 @@ public class ConsumerLoopFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: commit_code_piece
|
// ANCHOR: commit_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -135,7 +136,7 @@ public class ConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
if (!records.isEmpty()) {
|
if (!records.isEmpty()) {
|
||||||
// after processing the data, commit the offset manually
|
// after processing the data, commit the offset manually
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
@ -31,7 +31,11 @@ public class ConsumerLoopImp {
|
||||||
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
||||||
@Override
|
@Override
|
||||||
public void process(ResultBean result) {
|
public void process(ResultBean result) {
|
||||||
System.out.println("data: " + JSON.toJSONString(result));
|
try{
|
||||||
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(result));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
import com.taosdata.jdbc.tmq.*;
|
import com.taosdata.jdbc.tmq.*;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -60,7 +61,7 @@ public class WsConsumerLoopFull {
|
||||||
// ANCHOR_END: create_consumer
|
// ANCHOR_END: create_consumer
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void pollExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: poll_data_code_piece
|
// ANCHOR: poll_data_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -73,7 +74,7 @@ public class WsConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -91,7 +92,7 @@ public class WsConsumerLoopFull {
|
||||||
// ANCHOR_END: poll_data_code_piece
|
// ANCHOR_END: poll_data_code_piece
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void seekExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: consumer_seek
|
// ANCHOR: consumer_seek
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +100,7 @@ public class WsConsumerLoopFull {
|
||||||
consumer.subscribe(topics);
|
consumer.subscribe(topics);
|
||||||
System.out.println("Subscribe topics successfully.");
|
System.out.println("Subscribe topics successfully.");
|
||||||
Set<TopicPartition> assignment = consumer.assignment();
|
Set<TopicPartition> assignment = consumer.assignment();
|
||||||
System.out.println("Now assignment: " + JSON.toJSONString(assignment));
|
System.out.println("Now assignment: " + JsonUtil.getObjectMapper().writeValueAsString(assignment));
|
||||||
|
|
||||||
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
ConsumerRecords<ResultBean> records = ConsumerRecords.emptyRecord();
|
||||||
// make sure we have got some data
|
// make sure we have got some data
|
||||||
|
@ -125,7 +126,7 @@ public class WsConsumerLoopFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException {
|
public static void commitExample(TaosConsumer<ResultBean> consumer) throws SQLException, JsonProcessingException {
|
||||||
// ANCHOR: commit_code_piece
|
// ANCHOR: commit_code_piece
|
||||||
List<String> topics = Collections.singletonList("topic_meters");
|
List<String> topics = Collections.singletonList("topic_meters");
|
||||||
try {
|
try {
|
||||||
|
@ -135,7 +136,7 @@ public class WsConsumerLoopFull {
|
||||||
for (ConsumerRecord<ResultBean> record : records) {
|
for (ConsumerRecord<ResultBean> record : records) {
|
||||||
ResultBean bean = record.value();
|
ResultBean bean = record.value();
|
||||||
// Add your data processing logic here
|
// Add your data processing logic here
|
||||||
System.out.println("data: " + JSON.toJSONString(bean));
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(bean));
|
||||||
}
|
}
|
||||||
if (!records.isEmpty()) {
|
if (!records.isEmpty()) {
|
||||||
// after processing the data, commit the offset manually
|
// after processing the data, commit the offset manually
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.taos.example;
|
package com.taos.example;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
import com.taosdata.jdbc.TSDBDriver;
|
||||||
|
import com.taosdata.jdbc.utils.JsonUtil;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
@ -28,7 +28,11 @@ public abstract class WsConsumerLoopImp {
|
||||||
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
final AbsConsumerLoop consumerLoop = new AbsConsumerLoop() {
|
||||||
@Override
|
@Override
|
||||||
public void process(ResultBean result) {
|
public void process(ResultBean result) {
|
||||||
System.out.println("data: " + JSON.toJSONString(result));
|
try{
|
||||||
|
System.out.println("data: " + JsonUtil.getObjectMapper().writeValueAsString(result));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ public class DataBaseMonitor {
|
||||||
public DataBaseMonitor init() throws SQLException {
|
public DataBaseMonitor init() throws SQLException {
|
||||||
if (conn == null) {
|
if (conn == null) {
|
||||||
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
||||||
|
if (jdbcURL == null || jdbcURL == ""){
|
||||||
|
jdbcURL = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
}
|
||||||
conn = DriverManager.getConnection(jdbcURL);
|
conn = DriverManager.getConnection(jdbcURL);
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,9 @@ public class SQLWriter {
|
||||||
*/
|
*/
|
||||||
private static Connection getConnection() throws SQLException {
|
private static Connection getConnection() throws SQLException {
|
||||||
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
|
||||||
|
if (jdbcURL == null || jdbcURL == ""){
|
||||||
|
jdbcURL = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
}
|
||||||
return DriverManager.getConnection(jdbcURL);
|
return DriverManager.getConnection(jdbcURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,37 @@ public class TestAll {
|
||||||
stmt.execute("drop database if exists " + dbName);
|
stmt.execute("drop database if exists " + dbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
waitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dropTopic(String topicName) throws SQLException {
|
||||||
|
String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
try (Connection conn = DriverManager.getConnection(jdbcUrl)) {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
stmt.execute("drop topic if exists " + topicName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
waitTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void waitTransaction() throws SQLException {
|
||||||
|
|
||||||
|
String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
|
||||||
|
try (Connection conn = DriverManager.getConnection(jdbcUrl)) {
|
||||||
|
try (Statement stmt = conn.createStatement()) {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
stmt.execute("show transactions");
|
||||||
|
try (ResultSet resultSet = stmt.getResultSet()) {
|
||||||
|
if (resultSet.next()) {
|
||||||
|
int count = resultSet.getInt(1);
|
||||||
|
if (count == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertData() throws SQLException {
|
public void insertData() throws SQLException {
|
||||||
|
@ -104,14 +135,20 @@ public class TestAll {
|
||||||
SubscribeDemo.main(args);
|
SubscribeDemo.main(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void testSubscribeJni() throws SQLException, InterruptedException {
|
public void testSubscribeJni() throws SQLException, InterruptedException {
|
||||||
// dropDB("power");
|
dropTopic("topic_meters");
|
||||||
// ConsumerLoopFull.main(args);
|
dropDB("power");
|
||||||
// }
|
ConsumerLoopFull.main(args);
|
||||||
// @Test
|
dropTopic("topic_meters");
|
||||||
// public void testSubscribeWs() throws SQLException, InterruptedException {
|
dropDB("power");
|
||||||
// dropDB("power");
|
}
|
||||||
// WsConsumerLoopFull.main(args);
|
@Test
|
||||||
// }
|
public void testSubscribeWs() throws SQLException, InterruptedException {
|
||||||
|
dropTopic("topic_meters");
|
||||||
|
dropDB("power");
|
||||||
|
WsConsumerLoopFull.main(args);
|
||||||
|
dropTopic("topic_meters");
|
||||||
|
dropDB("power");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ TDengine 还支持直接向超级表写入数据。需要注意的是,超级
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
insert into meters (tbname, ts, current, voltage, phase, location, group_id)
|
insert into meters (tbname, ts, current, voltage, phase, location, group_id)
|
||||||
values( "d1001v, "2018-10-03 14:38:05", 10.2, 220, 0.23, "California.SanFrancisco", 2)
|
values( "d1001, "2018-10-03 14:38:05", 10.2, 220, 0.23, "California.SanFrancisco", 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 零代码写入
|
### 零代码写入
|
||||||
|
|
|
@ -163,7 +163,7 @@ charset 的有效值是 UTF-8。
|
||||||
|
|
||||||
| 参数名称 | 参数说明 |
|
| 参数名称 | 参数说明 |
|
||||||
| :----------------: | :---------------------------------------------: |
|
| :----------------: | :---------------------------------------------: |
|
||||||
| numOfCommitThreads | 写入线程的最大数量,取值范围 0-1024,缺省值为 4 |
|
| numOfCommitThreads | 落盘线程的最大数量,取值范围 0-1024,缺省值为 4 |
|
||||||
|
|
||||||
### 日志相关
|
### 日志相关
|
||||||
|
|
||||||
|
@ -223,16 +223,16 @@ lossyColumns float|double
|
||||||
|
|
||||||
| 参数名称 | 参数说明 |
|
| 参数名称 | 参数说明 |
|
||||||
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||||
| enableCoreFile | crash 时是否生成 core 文件;0: 不生成,1:生成;默认值 为 1; 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下 <br/> 2、手动启动,就在 taosd 执行目录下。 |
|
| enableCoreFile | crash 时是否生成 core 文件;0: 不生成,1:生成;默认值为 1; 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下 <br/> 2、手动启动,就在 taosd 执行目录下。 |
|
||||||
| udf | 是否启动 UDF 服务;0: 不启动,1:启动;默认值 为 0 |
|
| udf | 是否启动 UDF 服务;0: 不启动,1:启动;默认值为 0 |
|
||||||
| ttlChangeOnWrite | ttl 到期时间是否伴随表的修改操作改变; 0: 不改变,1:改变 ;默认值 为 |
|
| ttlChangeOnWrite | ttl 到期时间是否伴随表的修改操作改变; 0: 不改变,1:改变;默认值为 0 |
|
||||||
| tmqMaxTopicNum | 订阅最多可建立的 topic 数量; 取值范围 1-10000;缺省值 为20 |
|
| tmqMaxTopicNum | 订阅最多可建立的 topic 数量; 取值范围 1-10000;缺省值为20 |
|
||||||
| maxTsmaNum | 集群内可创建的TSMA个数;取值范围:0-3;缺省值: 3 |
|
| maxTsmaNum | 集群内可创建的TSMA个数;取值范围:0-3;缺省值为 3 |
|
||||||
|
|
||||||
|
|
||||||
## taosd 监控指标
|
## taosd 监控指标
|
||||||
|
|
||||||
taosd 会将监控指标上报给 taosKeeper,这些监控指标会被 taosKeeper 写入监控数据库,默认是 `log` 库,可以在 taoskeeper 配置文件中修改。以下是这些监控指标的详细介绍。
|
taosd 会将监控指标上报给 taosKeeper,这些监控指标会被 taosKeeper 写入监控数据库,默认是 `log` 库,可以在 taoskeeper 配置文件中修改。以下是这些监控指标的详细介绍。
|
||||||
|
|
||||||
### taosd\_cluster\_basic 表
|
### taosd\_cluster\_basic 表
|
||||||
|
|
||||||
|
@ -458,4 +458,3 @@ TDengine 的日志文件主要包括普通日志和慢日志两种类型。
|
||||||
3. 多个客户端的日志存储在相应日志路径下的同一个 taosSlowLog.yyyy.mm.dd 文件里。
|
3. 多个客户端的日志存储在相应日志路径下的同一个 taosSlowLog.yyyy.mm.dd 文件里。
|
||||||
4. 慢日志文件不自动删除,不压缩。
|
4. 慢日志文件不自动删除,不压缩。
|
||||||
5. 使用和普通日志文件相同的三个参数 logDir, minimalLogDirGB, asyncLog。另外两个参数 numOfLogLines,logKeepDays 不适用于慢日志。
|
5. 使用和普通日志文件相同的三个参数 logDir, minimalLogDirGB, asyncLog。另外两个参数 numOfLogLines,logKeepDays 不适用于慢日志。
|
||||||
|
|
|
@ -10,7 +10,7 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在
|
||||||
|
|
||||||
| 参数名称 | 参数含义 |
|
| 参数名称 | 参数含义 |
|
||||||
|:-----------:|:----------------------------------------------------------:|
|
|:-----------:|:----------------------------------------------------------:|
|
||||||
|firstEp | taos 启动时,主动连接的集群中首个 dnode 的 endpoint,缺省值:localhost:6030 |
|
|firstEp | taos 启动时,主动连接的集群中首个 dnode 的 endpoint,缺省值:hostname:6030,若无法获取该服务器的 hostname,则赋值为 localhost |
|
||||||
|secondEp | 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint,没有缺省值 |
|
|secondEp | 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint,没有缺省值 |
|
||||||
|numOfRpcSessions | 一个客户端能创建的最大连接数,取值范围:10-50000000(单位为毫秒);缺省值:500000 |
|
|numOfRpcSessions | 一个客户端能创建的最大连接数,取值范围:10-50000000(单位为毫秒);缺省值:500000 |
|
||||||
|telemetryReporting | 是否上传 telemetry,0: 不上传,1: 上传;缺省值:1 |
|
|telemetryReporting | 是否上传 telemetry,0: 不上传,1: 上传;缺省值:1 |
|
||||||
|
|
|
@ -330,7 +330,7 @@ taosAdapter 采集 REST/WebSocket 相关请求的监控指标。将监控指标
|
||||||
| other\_fail | INT UNSIGNED | | 其他失败请求数 |
|
| other\_fail | INT UNSIGNED | | 其他失败请求数 |
|
||||||
| query\_in\_process | INT UNSIGNED | | 正在处理查询请求数 |
|
| query\_in\_process | INT UNSIGNED | | 正在处理查询请求数 |
|
||||||
| write\_in\_process | INT UNSIGNED | | 正在处理写入请求数 |
|
| write\_in\_process | INT UNSIGNED | | 正在处理写入请求数 |
|
||||||
| endpoint | VARCHAR | | 请求端点 |
|
| endpoint | VARCHAR | | 请求端点 |
|
||||||
| req\_type | NCHAR | TAG | 请求类型:0 为 REST,1 为 WebSocket |
|
| req\_type | NCHAR | TAG | 请求类型:0 为 REST,1 为 WebSocket |
|
||||||
|
|
||||||
## 结果返回条数限制
|
## 结果返回条数限制
|
||||||
|
|
|
@ -4,11 +4,11 @@ sidebar_label: taos
|
||||||
toc_max_heading_level: 4
|
toc_max_heading_level: 4
|
||||||
---
|
---
|
||||||
|
|
||||||
TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine 实例并与之交互的最简洁最常用的方式。 使用前需要安装 TDengine Server 安装包或 TDengine Client 安装包。
|
TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine 实例并与之交互的最简洁最常用工具。 使用前需要安装 TDengine Server 安装包或 TDengine Client 安装包。
|
||||||
|
|
||||||
## 启动
|
## 启动
|
||||||
|
|
||||||
要进入 TDengine CLI,您只要在终端执行 `taos` 即可。
|
要进入 TDengine CLI,您在终端执行 `taos` 即可。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
taos
|
taos
|
||||||
|
@ -23,6 +23,11 @@ taos>
|
||||||
```
|
```
|
||||||
|
|
||||||
进入 TDengine CLI 后,你可执行各种 SQL 语句,包括插入、查询以及各种管理命令。
|
进入 TDengine CLI 后,你可执行各种 SQL 语句,包括插入、查询以及各种管理命令。
|
||||||
|
退出 TDengine CLI, 执行 `q` 或 `quit` 或 `exit` 回车即可
|
||||||
|
```shell
|
||||||
|
taos> quit
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## 执行 SQL 脚本
|
## 执行 SQL 脚本
|
||||||
|
|
||||||
|
@ -66,7 +71,7 @@ taos> SET MAX_BINARY_DISPLAY_WIDTH <nn>;
|
||||||
- -l PKTLEN: 网络测试时使用的测试包大小
|
- -l PKTLEN: 网络测试时使用的测试包大小
|
||||||
- -n NETROLE: 网络连接测试时的测试范围,默认为 `client`, 可选值为 `client`、`server`
|
- -n NETROLE: 网络连接测试时的测试范围,默认为 `client`, 可选值为 `client`、`server`
|
||||||
- -N PKTNUM: 网络测试时使用的测试包数量
|
- -N PKTNUM: 网络测试时使用的测试包数量
|
||||||
- -r: 将时间输出出无符号 64 位整数类型(即 C 语音中 uint64_t)
|
- -r: 将时间列转化为无符号 64 位整数类型输出(即 C 语言中 uint64_t)
|
||||||
- -R: 使用 RESTful 模式连接服务端
|
- -R: 使用 RESTful 模式连接服务端
|
||||||
- -s COMMAND: 以非交互模式执行的 SQL 命令
|
- -s COMMAND: 以非交互模式执行的 SQL 命令
|
||||||
- -t: 测试服务端启动状态,状态同-k
|
- -t: 测试服务端启动状态,状态同-k
|
||||||
|
@ -84,6 +89,13 @@ taos -h h1.taos.com -s "use db; show tables;"
|
||||||
|
|
||||||
也可以通过配置文件中的参数设置来控制 TDengine CLI 的行为。可用配置参数请参考[客户端配置](../../components/taosc)
|
也可以通过配置文件中的参数设置来控制 TDengine CLI 的行为。可用配置参数请参考[客户端配置](../../components/taosc)
|
||||||
|
|
||||||
|
## TDengine CLI TAB 键补全
|
||||||
|
|
||||||
|
- TAB 键前为空命令状态下按 TAB 键,会列出 TDengine CLI 支持的所有命令
|
||||||
|
- TAB 键前为空格状态下按 TAB 键,会显示此位置可以出现的所有命令词的第一个,再次按 TAB 键切为下一个
|
||||||
|
- TAB 键前为字符串,会搜索与此字符串前缀匹配的所有可出现命令词,并显示第一个,再次按 TAB 键切为下一个
|
||||||
|
- 输入反斜杠 `\` + TAB 键, 会自动补全为列显示模式命令词 `\G;`
|
||||||
|
|
||||||
## TDengine CLI 小技巧
|
## TDengine CLI 小技巧
|
||||||
|
|
||||||
- 可以使用上下光标键查看历史输入的指令
|
- 可以使用上下光标键查看历史输入的指令
|
||||||
|
@ -91,7 +103,6 @@ taos -h h1.taos.com -s "use db; show tables;"
|
||||||
- Ctrl+C 中止正在进行中的查询
|
- Ctrl+C 中止正在进行中的查询
|
||||||
- 执行 `RESET QUERY CACHE` 可清除本地表 Schema 的缓存
|
- 执行 `RESET QUERY CACHE` 可清除本地表 Schema 的缓存
|
||||||
- 批量执行 SQL 语句。可以将一系列的 TDengine CLI 命令(以英文 ; 结尾,每个 SQL 语句为一行)按行存放在文件里,在 TDengine CLI 里执行命令 `source <file-name>` 自动执行该文件里所有的 SQL 语句
|
- 批量执行 SQL 语句。可以将一系列的 TDengine CLI 命令(以英文 ; 结尾,每个 SQL 语句为一行)按行存放在文件里,在 TDengine CLI 里执行命令 `source <file-name>` 自动执行该文件里所有的 SQL 语句
|
||||||
- 输入 `q` 或 `quit` 或 `exit` 回车,可以退出 TDengine CLI
|
|
||||||
|
|
||||||
## TDengine CLI 导出查询结果到文件中
|
## TDengine CLI 导出查询结果到文件中
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ CREATE DATABASE db_name PRECISION 'ns';
|
||||||
| 14 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 NCHAR 字符占用 4 字节的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\'`。NCHAR 使用时须指定字符串大小,类型为 NCHAR(10) 的列表示此列的字符串最多存储 10 个 NCHAR 字符。如果用户字符串长度超出声明长度,将会报错。 |
|
| 14 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 NCHAR 字符占用 4 字节的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\'`。NCHAR 使用时须指定字符串大小,类型为 NCHAR(10) 的列表示此列的字符串最多存储 10 个 NCHAR 字符。如果用户字符串长度超出声明长度,将会报错。 |
|
||||||
| 15 | JSON | | JSON 数据类型, 只有 Tag 可以是 JSON 格式 |
|
| 15 | JSON | | JSON 数据类型, 只有 Tag 可以是 JSON 格式 |
|
||||||
| 16 | VARCHAR | 自定义 | BINARY 类型的别名 |
|
| 16 | VARCHAR | 自定义 | BINARY 类型的别名 |
|
||||||
| 17 | GEOMETRY | 自定义 | 几何类型
|
| 17 | GEOMETRY | 自定义 | 几何类型,3.1.0.0 版本开始支持
|
||||||
| 18 | VARBINARY | 自定义 | 可变长的二进制数据|
|
| 18 | VARBINARY | 自定义 | 可变长的二进制数据, 3.1.1.0 版本开始支持|
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ window_clause: {
|
||||||
FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种:
|
FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种:
|
||||||
|
|
||||||
1. 不进行填充:NONE(默认填充模式)。
|
1. 不进行填充:NONE(默认填充模式)。
|
||||||
2. VALUE 填充:固定值填充,此时需要指定填充的数值。例如:FILL(VALUE, 1.23)。这里需要注意,最终填充的值受由相应列的类型决定,如 FILL(VALUE, 1.23),相应列为 INT 类型,则填充值为 1, 若查询列表中有多列需要FILL, 则需要给每一个FILL列指定VALUE, 如`SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`。
|
2. VALUE 填充:固定值填充,此时需要指定填充的数值。例如:FILL(VALUE, 1.23)。这里需要注意,最终填充的值受由相应列的类型决定,如 FILL(VALUE, 1.23),相应列为 INT 类型,则填充值为 1, 若查询列表中有多列需要 FILL, 则需要给每一个 FILL 列指定 VALUE, 如 `SELECT _wstart, min(c1), max(c1) FROM ... FILL(VALUE, 0, 0)`, 注意, SELECT 表达式中只有包含普通列时才需要指定 FILL VALUE, 如 `_wstart`, `_wstart+1a`, `now`, `1+1` 以及使用 partition by 时的 partition key (如 tbname)都不需要指定 VALUE, 如 `timediff(last(ts), _wstart)` 则需要指定VALUE。
|
||||||
3. PREV 填充:使用前一个非 NULL 值填充数据。例如:FILL(PREV)。
|
3. PREV 填充:使用前一个非 NULL 值填充数据。例如:FILL(PREV)。
|
||||||
4. NULL 填充:使用 NULL 填充数据。例如:FILL(NULL)。
|
4. NULL 填充:使用 NULL 填充数据。例如:FILL(NULL)。
|
||||||
5. LINEAR 填充:根据前后距离最近的非 NULL 值做线性插值填充。例如:FILL(LINEAR)。
|
5. LINEAR 填充:根据前后距离最近的非 NULL 值做线性插值填充。例如:FILL(LINEAR)。
|
||||||
|
|
|
@ -153,7 +153,7 @@ SELECT * from information_schema.`ins_streams`;
|
||||||
|
|
||||||
由于窗口关闭是由事件时间决定的,如事件流中断、或持续延迟,则事件时间无法更新,可能导致无法得到最新的计算结果。
|
由于窗口关闭是由事件时间决定的,如事件流中断、或持续延迟,则事件时间无法更新,可能导致无法得到最新的计算结果。
|
||||||
|
|
||||||
因此,流式计算提供了以事件时间结合处理时间计算的 MAX_DELAY 触发模式。
|
因此,流式计算提供了以事件时间结合处理时间计算的 MAX_DELAY 触发模式。MAX_DELAY 最小时间是 5s,如果低于 5s,创建流计算时会报错。
|
||||||
|
|
||||||
MAX_DELAY 模式在窗口关闭时会立即触发计算。此外,当数据写入后,计算触发的时间超过 max delay 指定的时间,则立即触发计算
|
MAX_DELAY 模式在窗口关闭时会立即触发计算。此外,当数据写入后,计算触发的时间超过 max delay 指定的时间,则立即触发计算
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ description: 对 JSON 类型如何使用的详细说明
|
||||||
|
|
||||||
## 支持的操作
|
## 支持的操作
|
||||||
|
|
||||||
1. 在 where 条件中时,支持函数 match/nmatch/between and/like/and/or/is null/is no null,不支持 in
|
1. 在 where 条件中时,支持函数 match/nmatch/between and/like/and/or/is null/is not null,不支持 in
|
||||||
|
|
||||||
```
|
```
|
||||||
select * from s1 where info->'k1' match 'v*';
|
select * from s1 where info->'k1' match 'v*';
|
||||||
|
|
|
@ -27,11 +27,15 @@ SHOW DNODES;
|
||||||
## 删除数据节点
|
## 删除数据节点
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
DROP DNODE dnode_id
|
DROP DNODE dnode_id [force] [unsafe]
|
||||||
```
|
```
|
||||||
|
|
||||||
注意删除 dnode 不等于停止相应的进程。实际中推荐先将一个 dnode 删除之后再停止其所对应的进程。
|
注意删除 dnode 不等于停止相应的进程。实际中推荐先将一个 dnode 删除之后再停止其所对应的进程。
|
||||||
|
|
||||||
|
只有在线节点可以被删除。如果要强制删除离线节点,需要执行强制删除操作, 即指定force选项。
|
||||||
|
|
||||||
|
当节点上存在单副本,并且节点处于离线,如果要强制删除该节点,需要执行非安全删除,即制定unsafe,并且数据不可再恢复。
|
||||||
|
|
||||||
## 修改数据节点配置
|
## 修改数据节点配置
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
|
|
@ -109,7 +109,7 @@ WebSocket 连接方式除此之外还支持 Windows X64系统上运行的 32 位
|
||||||
|
|
||||||
## 版本历史
|
## 版本历史
|
||||||
|
|
||||||
| taos_odbc版本 | 主要变化 | TDengine 版本 |
|
| taos_odbc 版本 | 主要变化 | TDengine 版本 |
|
||||||
| :----------- | :-------------------------------------------------------------------------------------------------- | :---------------- |
|
| :----------- | :-------------------------------------------------------------------------------------------------- | :---------------- |
|
||||||
| v1.1.0 | 1. 支持视图功能;<br/>2. 支持 VARBINARY/GEOMETRY 数据类型; | 3.3.3.0及更高版本 |
|
| v1.1.0 | 1. 支持视图功能;<br/>2. 支持 VARBINARY/GEOMETRY 数据类型; | 3.3.3.0及更高版本 |
|
||||||
| v1.0.2 | 支持 CP1252 字符编码; | 3.2.3.0及更高版本 |
|
| v1.0.2 | 支持 CP1252 字符编码; | 3.2.3.0及更高版本 |
|
||||||
|
@ -145,7 +145,7 @@ WebSocket 连接方式除此之外还支持 Windows X64系统上运行的 32 位
|
||||||
|
|
||||||
## API 参考
|
## API 参考
|
||||||
|
|
||||||
本节按功能分类汇总了 ODBC API,关于完整的 ODBC API 参考,请访问 http://msdn.microsoft.com/en-us/library/ms714177.aspx 的ODBC程序员参考页面。
|
本节按功能分类汇总了 ODBC API,关于完整的 ODBC API 参考,请访问 http://msdn.microsoft.com/en-us/library/ms714177.aspx 的 ODBC 程序员参考页面。
|
||||||
|
|
||||||
### 数据源和驱动程序管理
|
### 数据源和驱动程序管理
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ extern int32_t tsS3PageCacheSize;
|
||||||
extern int32_t tsS3UploadDelaySec;
|
extern int32_t tsS3UploadDelaySec;
|
||||||
|
|
||||||
int32_t s3Init();
|
int32_t s3Init();
|
||||||
|
int32_t s3Begin();
|
||||||
|
void s3End();
|
||||||
int32_t s3CheckCfg();
|
int32_t s3CheckCfg();
|
||||||
int32_t s3PutObjectFromFile(const char *file, const char *object);
|
int32_t s3PutObjectFromFile(const char *file, const char *object);
|
||||||
int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp);
|
int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp);
|
||||||
|
|
|
@ -29,6 +29,8 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_QNODES "ins_qnodes"
|
#define TSDB_INS_TABLE_QNODES "ins_qnodes"
|
||||||
#define TSDB_INS_TABLE_BNODES "ins_bnodes" // no longer used
|
#define TSDB_INS_TABLE_BNODES "ins_bnodes" // no longer used
|
||||||
#define TSDB_INS_TABLE_SNODES "ins_snodes"
|
#define TSDB_INS_TABLE_SNODES "ins_snodes"
|
||||||
|
#define TSDB_INS_TABLE_ANODES "ins_anodes"
|
||||||
|
#define TSDB_INS_TABLE_ANODES_FULL "ins_anodes_full"
|
||||||
#define TSDB_INS_TABLE_ARBGROUPS "ins_arbgroups"
|
#define TSDB_INS_TABLE_ARBGROUPS "ins_arbgroups"
|
||||||
#define TSDB_INS_TABLE_CLUSTER "ins_cluster"
|
#define TSDB_INS_TABLE_CLUSTER "ins_cluster"
|
||||||
#define TSDB_INS_TABLE_DATABASES "ins_databases"
|
#define TSDB_INS_TABLE_DATABASES "ins_databases"
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_UTIL_ANAL_H_
|
||||||
|
#define _TD_UTIL_ANAL_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
#include "thash.h"
|
||||||
|
#include "tjson.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ANAL_FORECAST_DEFAULT_ROWS 10
|
||||||
|
#define ANAL_FORECAST_DEFAULT_CONF 95
|
||||||
|
#define ANAL_FORECAST_DEFAULT_WNCHECK 1
|
||||||
|
#define ANAL_FORECAST_MAX_ROWS 10000
|
||||||
|
#define ANAL_ANOMALY_WINDOW_MAX_ROWS 10000
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EAnalAlgoType type;
|
||||||
|
int32_t anode;
|
||||||
|
int32_t urlLen;
|
||||||
|
char *url;
|
||||||
|
} SAnalUrl;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ANAL_BUF_TYPE_JSON = 0,
|
||||||
|
ANAL_BUF_TYPE_JSON_COL = 1,
|
||||||
|
ANAL_BUF_TYPE_OTHERS,
|
||||||
|
} EAnalBufType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ANAL_HTTP_TYPE_GET = 0,
|
||||||
|
ANAL_HTTP_TYPE_POST,
|
||||||
|
} EAnalHttpType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TdFilePtr filePtr;
|
||||||
|
char fileName[TSDB_FILENAME_LEN + 10];
|
||||||
|
int64_t numOfRows;
|
||||||
|
} SAnalColBuf;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EAnalBufType bufType;
|
||||||
|
TdFilePtr filePtr;
|
||||||
|
char fileName[TSDB_FILENAME_LEN];
|
||||||
|
int32_t numOfCols;
|
||||||
|
SAnalColBuf *pCols;
|
||||||
|
} SAnalBuf;
|
||||||
|
|
||||||
|
int32_t taosAnalInit();
|
||||||
|
void taosAnalCleanup();
|
||||||
|
SJson *taosAnalSendReqRetJson(const char *url, EAnalHttpType type, SAnalBuf *pBuf);
|
||||||
|
|
||||||
|
int32_t taosAnalGetAlgoUrl(const char *algoName, EAnalAlgoType type, char *url, int32_t urlLen);
|
||||||
|
bool taosAnalGetOptStr(const char *option, const char *optName, char *optValue, int32_t optMaxLen);
|
||||||
|
bool taosAnalGetOptInt(const char *option, const char *optName, int64_t *optValue);
|
||||||
|
int64_t taosAnalGetVersion();
|
||||||
|
void taosAnalUpdate(int64_t newVer, SHashObj *pHash);
|
||||||
|
|
||||||
|
int32_t tsosAnalBufOpen(SAnalBuf *pBuf, int32_t numOfCols);
|
||||||
|
int32_t taosAnalBufWriteOptStr(SAnalBuf *pBuf, const char *optName, const char *optVal);
|
||||||
|
int32_t taosAnalBufWriteOptInt(SAnalBuf *pBuf, const char *optName, int64_t optVal);
|
||||||
|
int32_t taosAnalBufWriteOptFloat(SAnalBuf *pBuf, const char *optName, float optVal);
|
||||||
|
int32_t taosAnalBufWriteColMeta(SAnalBuf *pBuf, int32_t colIndex, int32_t colType, const char *colName);
|
||||||
|
int32_t taosAnalBufWriteDataBegin(SAnalBuf *pBuf);
|
||||||
|
int32_t taosAnalBufWriteColBegin(SAnalBuf *pBuf, int32_t colIndex);
|
||||||
|
int32_t taosAnalBufWriteColData(SAnalBuf *pBuf, int32_t colIndex, int32_t colType, void *colValue);
|
||||||
|
int32_t taosAnalBufWriteColEnd(SAnalBuf *pBuf, int32_t colIndex);
|
||||||
|
int32_t taosAnalBufWriteDataEnd(SAnalBuf *pBuf);
|
||||||
|
int32_t taosAnalBufClose(SAnalBuf *pBuf);
|
||||||
|
void taosAnalBufDestroy(SAnalBuf *pBuf);
|
||||||
|
|
||||||
|
const char *taosAnalAlgoStr(EAnalAlgoType algoType);
|
||||||
|
EAnalAlgoType taosAnalAlgoInt(const char *algoName);
|
||||||
|
const char *taosAnalAlgoUrlStr(EAnalAlgoType algoType);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /*_TD_UTIL_ANAL_H_*/
|
|
@ -42,21 +42,21 @@ typedef enum {
|
||||||
} EEncryptScope;
|
} EEncryptScope;
|
||||||
|
|
||||||
// cluster
|
// cluster
|
||||||
extern char tsFirst[];
|
extern char tsFirst[];
|
||||||
extern char tsSecond[];
|
extern char tsSecond[];
|
||||||
extern char tsLocalFqdn[];
|
extern char tsLocalFqdn[];
|
||||||
extern char tsLocalEp[];
|
extern char tsLocalEp[];
|
||||||
extern char tsVersionName[];
|
extern char tsVersionName[];
|
||||||
extern uint16_t tsServerPort;
|
extern uint16_t tsServerPort;
|
||||||
extern int32_t tsVersion;
|
extern int32_t tsVersion;
|
||||||
extern int32_t tsStatusInterval;
|
extern int32_t tsStatusInterval;
|
||||||
extern int32_t tsNumOfSupportVnodes;
|
extern int32_t tsNumOfSupportVnodes;
|
||||||
extern char tsEncryptAlgorithm[];
|
extern char tsEncryptAlgorithm[];
|
||||||
extern char tsEncryptScope[];
|
extern char tsEncryptScope[];
|
||||||
extern EEncryptAlgor tsiEncryptAlgorithm;
|
extern EEncryptAlgor tsiEncryptAlgorithm;
|
||||||
extern EEncryptScope tsiEncryptScope;
|
extern EEncryptScope tsiEncryptScope;
|
||||||
//extern char tsAuthCode[];
|
// extern char tsAuthCode[];
|
||||||
extern char tsEncryptKey[];
|
extern char tsEncryptKey[];
|
||||||
|
|
||||||
// common
|
// common
|
||||||
extern int32_t tsMaxShellConns;
|
extern int32_t tsMaxShellConns;
|
||||||
|
@ -71,6 +71,8 @@ extern int32_t tsTagFilterResCacheSize;
|
||||||
// queue & threads
|
// queue & threads
|
||||||
extern int32_t tsNumOfRpcThreads;
|
extern int32_t tsNumOfRpcThreads;
|
||||||
extern int32_t tsNumOfRpcSessions;
|
extern int32_t tsNumOfRpcSessions;
|
||||||
|
extern int32_t tsShareConnLimit;
|
||||||
|
extern int32_t tsReadTimeout;
|
||||||
extern int32_t tsTimeToGetAvailableConn;
|
extern int32_t tsTimeToGetAvailableConn;
|
||||||
extern int32_t tsKeepAliveIdle;
|
extern int32_t tsKeepAliveIdle;
|
||||||
extern int32_t tsNumOfCommitThreads;
|
extern int32_t tsNumOfCommitThreads;
|
||||||
|
@ -264,8 +266,8 @@ extern bool tsExperimental;
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
||||||
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd,
|
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs);
|
SArray *pArgs);
|
||||||
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
|
int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs,
|
||||||
bool tsc);
|
bool tsc);
|
||||||
void taosCleanupCfg();
|
void taosCleanupCfg();
|
||||||
|
|
|
@ -159,6 +159,8 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_ARBGROUP,
|
TSDB_MGMT_TABLE_ARBGROUP,
|
||||||
TSDB_MGMT_TABLE_ENCRYPTIONS,
|
TSDB_MGMT_TABLE_ENCRYPTIONS,
|
||||||
TSDB_MGMT_TABLE_USER_FULL,
|
TSDB_MGMT_TABLE_USER_FULL,
|
||||||
|
TSDB_MGMT_TABLE_ANODE,
|
||||||
|
TSDB_MGMT_TABLE_ANODE_FULL,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
|
||||||
|
@ -260,6 +262,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_COUNT_WINDOW,
|
QUERY_NODE_COUNT_WINDOW,
|
||||||
QUERY_NODE_COLUMN_OPTIONS,
|
QUERY_NODE_COLUMN_OPTIONS,
|
||||||
QUERY_NODE_TSMA_OPTIONS,
|
QUERY_NODE_TSMA_OPTIONS,
|
||||||
|
QUERY_NODE_ANOMALY_WINDOW,
|
||||||
|
|
||||||
// Statement nodes are used in parser and planner module.
|
// Statement nodes are used in parser and planner module.
|
||||||
QUERY_NODE_SET_OPERATOR = 100,
|
QUERY_NODE_SET_OPERATOR = 100,
|
||||||
|
@ -345,6 +348,9 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_CREATE_VIEW_STMT,
|
QUERY_NODE_CREATE_VIEW_STMT,
|
||||||
QUERY_NODE_DROP_VIEW_STMT,
|
QUERY_NODE_DROP_VIEW_STMT,
|
||||||
QUERY_NODE_CREATE_SUBTABLE_FROM_FILE_CLAUSE,
|
QUERY_NODE_CREATE_SUBTABLE_FROM_FILE_CLAUSE,
|
||||||
|
QUERY_NODE_CREATE_ANODE_STMT,
|
||||||
|
QUERY_NODE_DROP_ANODE_STMT,
|
||||||
|
QUERY_NODE_UPDATE_ANODE_STMT,
|
||||||
|
|
||||||
// show statement nodes
|
// show statement nodes
|
||||||
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
|
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
|
||||||
|
@ -386,6 +392,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
||||||
QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
|
QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
|
||||||
QUERY_NODE_SHOW_TSMAS_STMT,
|
QUERY_NODE_SHOW_TSMAS_STMT,
|
||||||
|
QUERY_NODE_SHOW_ANODES_STMT,
|
||||||
|
QUERY_NODE_SHOW_ANODES_FULL_STMT,
|
||||||
QUERY_NODE_CREATE_TSMA_STMT,
|
QUERY_NODE_CREATE_TSMA_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
||||||
QUERY_NODE_DROP_TSMA_STMT,
|
QUERY_NODE_DROP_TSMA_STMT,
|
||||||
|
@ -408,6 +416,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_LOGIC_PLAN,
|
QUERY_NODE_LOGIC_PLAN,
|
||||||
QUERY_NODE_LOGIC_PLAN_GROUP_CACHE,
|
QUERY_NODE_LOGIC_PLAN_GROUP_CACHE,
|
||||||
QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL,
|
QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL,
|
||||||
|
QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC,
|
||||||
|
|
||||||
// physical plan node
|
// physical plan node
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN = 1100,
|
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN = 1100,
|
||||||
|
@ -458,6 +467,9 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT,
|
QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_ANOMALY,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC,
|
||||||
} ENodeType;
|
} ENodeType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -971,6 +983,7 @@ typedef struct SEpSet {
|
||||||
SEp eps[TSDB_MAX_REPLICA];
|
SEp eps[TSDB_MAX_REPLICA];
|
||||||
} SEpSet;
|
} SEpSet;
|
||||||
|
|
||||||
|
|
||||||
int32_t tEncodeSEpSet(SEncoder* pEncoder, const SEpSet* pEp);
|
int32_t tEncodeSEpSet(SEncoder* pEncoder, const SEpSet* pEp);
|
||||||
int32_t tDecodeSEpSet(SDecoder* pDecoder, SEpSet* pEp);
|
int32_t tDecodeSEpSet(SDecoder* pDecoder, SEpSet* pEp);
|
||||||
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
|
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
|
||||||
|
@ -1092,6 +1105,22 @@ typedef struct {
|
||||||
int32_t tSerializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
|
int32_t tSerializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
|
||||||
int32_t tDeserializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
|
int32_t tDeserializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t dnodeId;
|
||||||
|
int64_t analVer;
|
||||||
|
} SRetrieveAnalAlgoReq;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t ver;
|
||||||
|
SHashObj* hash; // algoname:algotype -> SAnalUrl
|
||||||
|
} SRetrieveAnalAlgoRsp;
|
||||||
|
|
||||||
|
int32_t tSerializeRetrieveAnalAlgoReq(void* buf, int32_t bufLen, SRetrieveAnalAlgoReq* pReq);
|
||||||
|
int32_t tDeserializeRetrieveAnalAlgoReq(void* buf, int32_t bufLen, SRetrieveAnalAlgoReq* pReq);
|
||||||
|
int32_t tSerializeRetrieveAnalAlgoRsp(void* buf, int32_t bufLen, SRetrieveAnalAlgoRsp* pRsp);
|
||||||
|
int32_t tDeserializeRetrieveAnalAlgoRsp(void* buf, int32_t bufLen, SRetrieveAnalAlgoRsp* pRsp);
|
||||||
|
void tFreeRetrieveAnalAlgoRsp(SRetrieveAnalAlgoRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
|
@ -1766,6 +1795,7 @@ typedef struct {
|
||||||
SArray* pVloads; // array of SVnodeLoad
|
SArray* pVloads; // array of SVnodeLoad
|
||||||
int32_t statusSeq;
|
int32_t statusSeq;
|
||||||
int64_t ipWhiteVer;
|
int64_t ipWhiteVer;
|
||||||
|
int64_t analVer;
|
||||||
} SStatusReq;
|
} SStatusReq;
|
||||||
|
|
||||||
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
|
@ -1831,6 +1861,7 @@ typedef struct {
|
||||||
SArray* pDnodeEps; // Array of SDnodeEp
|
SArray* pDnodeEps; // Array of SDnodeEp
|
||||||
int32_t statusSeq;
|
int32_t statusSeq;
|
||||||
int64_t ipWhiteVer;
|
int64_t ipWhiteVer;
|
||||||
|
int64_t analVer;
|
||||||
} SStatusRsp;
|
} SStatusRsp;
|
||||||
|
|
||||||
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
|
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
|
||||||
|
@ -2377,6 +2408,30 @@ typedef struct {
|
||||||
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||||
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t urlLen;
|
||||||
|
int32_t sqlLen;
|
||||||
|
char* url;
|
||||||
|
char* sql;
|
||||||
|
} SMCreateAnodeReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateAnodeReq(void* buf, int32_t bufLen, SMCreateAnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSMCreateAnodeReq(void* buf, int32_t bufLen, SMCreateAnodeReq* pReq);
|
||||||
|
void tFreeSMCreateAnodeReq(SMCreateAnodeReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t anodeId;
|
||||||
|
int32_t sqlLen;
|
||||||
|
char* sql;
|
||||||
|
} SMDropAnodeReq, SMUpdateAnodeReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMDropAnodeReq(void* buf, int32_t bufLen, SMDropAnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSMDropAnodeReq(void* buf, int32_t bufLen, SMDropAnodeReq* pReq);
|
||||||
|
void tFreeSMDropAnodeReq(SMDropAnodeReq* pReq);
|
||||||
|
int32_t tSerializeSMUpdateAnodeReq(void* buf, int32_t bufLen, SMUpdateAnodeReq* pReq);
|
||||||
|
int32_t tDeserializeSMUpdateAnodeReq(void* buf, int32_t bufLen, SMUpdateAnodeReq* pReq);
|
||||||
|
void tFreeSMUpdateAnodeReq(SMUpdateAnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t hbSeq;
|
int32_t hbSeq;
|
||||||
|
|
|
@ -125,6 +125,11 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_ENCRYPT_KEY, "create-encrypt-key", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_ENCRYPT_KEY, "create-encrypt-key", NULL, NULL)
|
||||||
|
// mnode msg overload
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_ANODE, "create-anode", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_UPDATE_ANODE, "update-anode", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_DROP_ANODE, "drop-anode", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_RETRIEVE_ANAL_ALGO, "retrieve-anal-algo", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_DND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_DND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_MND_MSG) // 1<<8
|
TD_NEW_MSG_SEG(TDMT_MND_MSG) // 1<<8
|
||||||
|
@ -324,6 +329,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_EXPLAIN, "explain", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_EXPLAIN, "explain", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SCH_TASK_NOTIFY, "task-notify", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SCH_TASK_NOTIFY, "task-notify", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SCH_TASK_RELEASE, "task-release", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_SCH_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_SCH_MSG)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,335 +69,341 @@
|
||||||
#define TK_NK_DOT 51
|
#define TK_NK_DOT 51
|
||||||
#define TK_WITH 52
|
#define TK_WITH 52
|
||||||
#define TK_ENCRYPT_KEY 53
|
#define TK_ENCRYPT_KEY 53
|
||||||
#define TK_DNODE 54
|
#define TK_ANODE 54
|
||||||
#define TK_PORT 55
|
#define TK_UPDATE 55
|
||||||
#define TK_DNODES 56
|
#define TK_ANODES 56
|
||||||
#define TK_RESTORE 57
|
#define TK_DNODE 57
|
||||||
#define TK_NK_IPTOKEN 58
|
#define TK_PORT 58
|
||||||
#define TK_FORCE 59
|
#define TK_DNODES 59
|
||||||
#define TK_UNSAFE 60
|
#define TK_RESTORE 60
|
||||||
#define TK_CLUSTER 61
|
#define TK_NK_IPTOKEN 61
|
||||||
#define TK_LOCAL 62
|
#define TK_FORCE 62
|
||||||
#define TK_QNODE 63
|
#define TK_UNSAFE 63
|
||||||
#define TK_BNODE 64
|
#define TK_CLUSTER 64
|
||||||
#define TK_SNODE 65
|
#define TK_LOCAL 65
|
||||||
#define TK_MNODE 66
|
#define TK_QNODE 66
|
||||||
#define TK_VNODE 67
|
#define TK_BNODE 67
|
||||||
#define TK_DATABASE 68
|
#define TK_SNODE 68
|
||||||
#define TK_USE 69
|
#define TK_MNODE 69
|
||||||
#define TK_FLUSH 70
|
#define TK_VNODE 70
|
||||||
#define TK_TRIM 71
|
#define TK_DATABASE 71
|
||||||
#define TK_S3MIGRATE 72
|
#define TK_USE 72
|
||||||
#define TK_COMPACT 73
|
#define TK_FLUSH 73
|
||||||
#define TK_IF 74
|
#define TK_TRIM 74
|
||||||
#define TK_NOT 75
|
#define TK_S3MIGRATE 75
|
||||||
#define TK_EXISTS 76
|
#define TK_COMPACT 76
|
||||||
#define TK_BUFFER 77
|
#define TK_IF 77
|
||||||
#define TK_CACHEMODEL 78
|
#define TK_NOT 78
|
||||||
#define TK_CACHESIZE 79
|
#define TK_EXISTS 79
|
||||||
#define TK_COMP 80
|
#define TK_BUFFER 80
|
||||||
#define TK_DURATION 81
|
#define TK_CACHEMODEL 81
|
||||||
#define TK_NK_VARIABLE 82
|
#define TK_CACHESIZE 82
|
||||||
#define TK_MAXROWS 83
|
#define TK_COMP 83
|
||||||
#define TK_MINROWS 84
|
#define TK_DURATION 84
|
||||||
#define TK_KEEP 85
|
#define TK_NK_VARIABLE 85
|
||||||
#define TK_PAGES 86
|
#define TK_MAXROWS 86
|
||||||
#define TK_PAGESIZE 87
|
#define TK_MINROWS 87
|
||||||
#define TK_TSDB_PAGESIZE 88
|
#define TK_KEEP 88
|
||||||
#define TK_PRECISION 89
|
#define TK_PAGES 89
|
||||||
#define TK_REPLICA 90
|
#define TK_PAGESIZE 90
|
||||||
#define TK_VGROUPS 91
|
#define TK_TSDB_PAGESIZE 91
|
||||||
#define TK_SINGLE_STABLE 92
|
#define TK_PRECISION 92
|
||||||
#define TK_RETENTIONS 93
|
#define TK_REPLICA 93
|
||||||
#define TK_SCHEMALESS 94
|
#define TK_VGROUPS 94
|
||||||
#define TK_WAL_LEVEL 95
|
#define TK_SINGLE_STABLE 95
|
||||||
#define TK_WAL_FSYNC_PERIOD 96
|
#define TK_RETENTIONS 96
|
||||||
#define TK_WAL_RETENTION_PERIOD 97
|
#define TK_SCHEMALESS 97
|
||||||
#define TK_WAL_RETENTION_SIZE 98
|
#define TK_WAL_LEVEL 98
|
||||||
#define TK_WAL_ROLL_PERIOD 99
|
#define TK_WAL_FSYNC_PERIOD 99
|
||||||
#define TK_WAL_SEGMENT_SIZE 100
|
#define TK_WAL_RETENTION_PERIOD 100
|
||||||
#define TK_STT_TRIGGER 101
|
#define TK_WAL_RETENTION_SIZE 101
|
||||||
#define TK_TABLE_PREFIX 102
|
#define TK_WAL_ROLL_PERIOD 102
|
||||||
#define TK_TABLE_SUFFIX 103
|
#define TK_WAL_SEGMENT_SIZE 103
|
||||||
#define TK_S3_CHUNKSIZE 104
|
#define TK_STT_TRIGGER 104
|
||||||
#define TK_S3_KEEPLOCAL 105
|
#define TK_TABLE_PREFIX 105
|
||||||
#define TK_S3_COMPACT 106
|
#define TK_TABLE_SUFFIX 106
|
||||||
#define TK_KEEP_TIME_OFFSET 107
|
#define TK_S3_CHUNKSIZE 107
|
||||||
#define TK_ENCRYPT_ALGORITHM 108
|
#define TK_S3_KEEPLOCAL 108
|
||||||
#define TK_NK_COLON 109
|
#define TK_S3_COMPACT 109
|
||||||
#define TK_BWLIMIT 110
|
#define TK_KEEP_TIME_OFFSET 110
|
||||||
#define TK_START 111
|
#define TK_ENCRYPT_ALGORITHM 111
|
||||||
#define TK_TIMESTAMP 112
|
#define TK_NK_COLON 112
|
||||||
#define TK_END 113
|
#define TK_BWLIMIT 113
|
||||||
#define TK_TABLE 114
|
#define TK_START 114
|
||||||
#define TK_NK_LP 115
|
#define TK_TIMESTAMP 115
|
||||||
#define TK_NK_RP 116
|
#define TK_END 116
|
||||||
#define TK_USING 117
|
#define TK_TABLE 117
|
||||||
#define TK_FILE 118
|
#define TK_NK_LP 118
|
||||||
#define TK_STABLE 119
|
#define TK_NK_RP 119
|
||||||
#define TK_COLUMN 120
|
#define TK_USING 120
|
||||||
#define TK_MODIFY 121
|
#define TK_FILE 121
|
||||||
#define TK_RENAME 122
|
#define TK_STABLE 122
|
||||||
#define TK_TAG 123
|
#define TK_COLUMN 123
|
||||||
#define TK_SET 124
|
#define TK_MODIFY 124
|
||||||
#define TK_NK_EQ 125
|
#define TK_RENAME 125
|
||||||
#define TK_TAGS 126
|
#define TK_TAG 126
|
||||||
#define TK_BOOL 127
|
#define TK_SET 127
|
||||||
#define TK_TINYINT 128
|
#define TK_NK_EQ 128
|
||||||
#define TK_SMALLINT 129
|
#define TK_TAGS 129
|
||||||
#define TK_INT 130
|
#define TK_BOOL 130
|
||||||
#define TK_INTEGER 131
|
#define TK_TINYINT 131
|
||||||
#define TK_BIGINT 132
|
#define TK_SMALLINT 132
|
||||||
#define TK_FLOAT 133
|
#define TK_INT 133
|
||||||
#define TK_DOUBLE 134
|
#define TK_INTEGER 134
|
||||||
#define TK_BINARY 135
|
#define TK_BIGINT 135
|
||||||
#define TK_NCHAR 136
|
#define TK_FLOAT 136
|
||||||
#define TK_UNSIGNED 137
|
#define TK_DOUBLE 137
|
||||||
#define TK_JSON 138
|
#define TK_BINARY 138
|
||||||
#define TK_VARCHAR 139
|
#define TK_NCHAR 139
|
||||||
#define TK_MEDIUMBLOB 140
|
#define TK_UNSIGNED 140
|
||||||
#define TK_BLOB 141
|
#define TK_JSON 141
|
||||||
#define TK_VARBINARY 142
|
#define TK_VARCHAR 142
|
||||||
#define TK_GEOMETRY 143
|
#define TK_MEDIUMBLOB 143
|
||||||
#define TK_DECIMAL 144
|
#define TK_BLOB 144
|
||||||
#define TK_COMMENT 145
|
#define TK_VARBINARY 145
|
||||||
#define TK_MAX_DELAY 146
|
#define TK_GEOMETRY 146
|
||||||
#define TK_WATERMARK 147
|
#define TK_DECIMAL 147
|
||||||
#define TK_ROLLUP 148
|
#define TK_COMMENT 148
|
||||||
#define TK_TTL 149
|
#define TK_MAX_DELAY 149
|
||||||
#define TK_SMA 150
|
#define TK_WATERMARK 150
|
||||||
#define TK_DELETE_MARK 151
|
#define TK_ROLLUP 151
|
||||||
#define TK_FIRST 152
|
#define TK_TTL 152
|
||||||
#define TK_LAST 153
|
#define TK_SMA 153
|
||||||
#define TK_SHOW 154
|
#define TK_DELETE_MARK 154
|
||||||
#define TK_FULL 155
|
#define TK_FIRST 155
|
||||||
#define TK_PRIVILEGES 156
|
#define TK_LAST 156
|
||||||
#define TK_DATABASES 157
|
#define TK_SHOW 157
|
||||||
#define TK_TABLES 158
|
#define TK_FULL 158
|
||||||
#define TK_STABLES 159
|
#define TK_PRIVILEGES 159
|
||||||
#define TK_MNODES 160
|
#define TK_DATABASES 160
|
||||||
#define TK_QNODES 161
|
#define TK_TABLES 161
|
||||||
#define TK_ARBGROUPS 162
|
#define TK_STABLES 162
|
||||||
#define TK_FUNCTIONS 163
|
#define TK_MNODES 163
|
||||||
#define TK_INDEXES 164
|
#define TK_QNODES 164
|
||||||
#define TK_ACCOUNTS 165
|
#define TK_ARBGROUPS 165
|
||||||
#define TK_APPS 166
|
#define TK_FUNCTIONS 166
|
||||||
#define TK_CONNECTIONS 167
|
#define TK_INDEXES 167
|
||||||
#define TK_LICENCES 168
|
#define TK_ACCOUNTS 168
|
||||||
#define TK_GRANTS 169
|
#define TK_APPS 169
|
||||||
#define TK_LOGS 170
|
#define TK_CONNECTIONS 170
|
||||||
#define TK_MACHINES 171
|
#define TK_LICENCES 171
|
||||||
#define TK_ENCRYPTIONS 172
|
#define TK_GRANTS 172
|
||||||
#define TK_QUERIES 173
|
#define TK_LOGS 173
|
||||||
#define TK_SCORES 174
|
#define TK_MACHINES 174
|
||||||
#define TK_TOPICS 175
|
#define TK_ENCRYPTIONS 175
|
||||||
#define TK_VARIABLES 176
|
#define TK_QUERIES 176
|
||||||
#define TK_BNODES 177
|
#define TK_SCORES 177
|
||||||
#define TK_SNODES 178
|
#define TK_TOPICS 178
|
||||||
#define TK_TRANSACTIONS 179
|
#define TK_VARIABLES 179
|
||||||
#define TK_DISTRIBUTED 180
|
#define TK_BNODES 180
|
||||||
#define TK_CONSUMERS 181
|
#define TK_SNODES 181
|
||||||
#define TK_SUBSCRIPTIONS 182
|
#define TK_TRANSACTIONS 182
|
||||||
#define TK_VNODES 183
|
#define TK_DISTRIBUTED 183
|
||||||
#define TK_ALIVE 184
|
#define TK_CONSUMERS 184
|
||||||
#define TK_VIEWS 185
|
#define TK_SUBSCRIPTIONS 185
|
||||||
#define TK_VIEW 186
|
#define TK_VNODES 186
|
||||||
#define TK_COMPACTS 187
|
#define TK_ALIVE 187
|
||||||
#define TK_NORMAL 188
|
#define TK_VIEWS 188
|
||||||
#define TK_CHILD 189
|
#define TK_VIEW 189
|
||||||
#define TK_LIKE 190
|
#define TK_COMPACTS 190
|
||||||
#define TK_TBNAME 191
|
#define TK_NORMAL 191
|
||||||
#define TK_QTAGS 192
|
#define TK_CHILD 192
|
||||||
#define TK_AS 193
|
#define TK_LIKE 193
|
||||||
#define TK_SYSTEM 194
|
#define TK_TBNAME 194
|
||||||
#define TK_TSMA 195
|
#define TK_QTAGS 195
|
||||||
#define TK_INTERVAL 196
|
#define TK_AS 196
|
||||||
#define TK_RECURSIVE 197
|
#define TK_SYSTEM 197
|
||||||
#define TK_TSMAS 198
|
#define TK_TSMA 198
|
||||||
#define TK_FUNCTION 199
|
#define TK_INTERVAL 199
|
||||||
#define TK_INDEX 200
|
#define TK_RECURSIVE 200
|
||||||
#define TK_COUNT 201
|
#define TK_TSMAS 201
|
||||||
#define TK_LAST_ROW 202
|
#define TK_FUNCTION 202
|
||||||
#define TK_META 203
|
#define TK_INDEX 203
|
||||||
#define TK_ONLY 204
|
#define TK_COUNT 204
|
||||||
#define TK_TOPIC 205
|
#define TK_LAST_ROW 205
|
||||||
#define TK_CONSUMER 206
|
#define TK_META 206
|
||||||
#define TK_GROUP 207
|
#define TK_ONLY 207
|
||||||
#define TK_DESC 208
|
#define TK_TOPIC 208
|
||||||
#define TK_DESCRIBE 209
|
#define TK_CONSUMER 209
|
||||||
#define TK_RESET 210
|
#define TK_GROUP 210
|
||||||
#define TK_QUERY 211
|
#define TK_DESC 211
|
||||||
#define TK_CACHE 212
|
#define TK_DESCRIBE 212
|
||||||
#define TK_EXPLAIN 213
|
#define TK_RESET 213
|
||||||
#define TK_ANALYZE 214
|
#define TK_QUERY 214
|
||||||
#define TK_VERBOSE 215
|
#define TK_CACHE 215
|
||||||
#define TK_NK_BOOL 216
|
#define TK_EXPLAIN 216
|
||||||
#define TK_RATIO 217
|
#define TK_ANALYZE 217
|
||||||
#define TK_NK_FLOAT 218
|
#define TK_VERBOSE 218
|
||||||
#define TK_OUTPUTTYPE 219
|
#define TK_NK_BOOL 219
|
||||||
#define TK_AGGREGATE 220
|
#define TK_RATIO 220
|
||||||
#define TK_BUFSIZE 221
|
#define TK_NK_FLOAT 221
|
||||||
#define TK_LANGUAGE 222
|
#define TK_OUTPUTTYPE 222
|
||||||
#define TK_REPLACE 223
|
#define TK_AGGREGATE 223
|
||||||
#define TK_STREAM 224
|
#define TK_BUFSIZE 224
|
||||||
#define TK_INTO 225
|
#define TK_LANGUAGE 225
|
||||||
#define TK_PAUSE 226
|
#define TK_REPLACE 226
|
||||||
#define TK_RESUME 227
|
#define TK_STREAM 227
|
||||||
#define TK_PRIMARY 228
|
#define TK_INTO 228
|
||||||
#define TK_KEY 229
|
#define TK_PAUSE 229
|
||||||
#define TK_TRIGGER 230
|
#define TK_RESUME 230
|
||||||
#define TK_AT_ONCE 231
|
#define TK_PRIMARY 231
|
||||||
#define TK_WINDOW_CLOSE 232
|
#define TK_KEY 232
|
||||||
#define TK_IGNORE 233
|
#define TK_TRIGGER 233
|
||||||
#define TK_EXPIRED 234
|
#define TK_AT_ONCE 234
|
||||||
#define TK_FILL_HISTORY 235
|
#define TK_WINDOW_CLOSE 235
|
||||||
#define TK_UPDATE 236
|
#define TK_IGNORE 236
|
||||||
#define TK_SUBTABLE 237
|
#define TK_EXPIRED 237
|
||||||
#define TK_UNTREATED 238
|
#define TK_FILL_HISTORY 238
|
||||||
#define TK_KILL 239
|
#define TK_SUBTABLE 239
|
||||||
#define TK_CONNECTION 240
|
#define TK_UNTREATED 240
|
||||||
#define TK_TRANSACTION 241
|
#define TK_KILL 241
|
||||||
#define TK_BALANCE 242
|
#define TK_CONNECTION 242
|
||||||
#define TK_VGROUP 243
|
#define TK_TRANSACTION 243
|
||||||
#define TK_LEADER 244
|
#define TK_BALANCE 244
|
||||||
#define TK_MERGE 245
|
#define TK_VGROUP 245
|
||||||
#define TK_REDISTRIBUTE 246
|
#define TK_LEADER 246
|
||||||
#define TK_SPLIT 247
|
#define TK_MERGE 247
|
||||||
#define TK_DELETE 248
|
#define TK_REDISTRIBUTE 248
|
||||||
#define TK_INSERT 249
|
#define TK_SPLIT 249
|
||||||
#define TK_NK_BIN 250
|
#define TK_DELETE 250
|
||||||
#define TK_NK_HEX 251
|
#define TK_INSERT 251
|
||||||
#define TK_NULL 252
|
#define TK_NK_BIN 252
|
||||||
#define TK_NK_QUESTION 253
|
#define TK_NK_HEX 253
|
||||||
#define TK_NK_ALIAS 254
|
#define TK_NULL 254
|
||||||
#define TK_NK_ARROW 255
|
#define TK_NK_QUESTION 255
|
||||||
#define TK_ROWTS 256
|
#define TK_NK_ALIAS 256
|
||||||
#define TK_QSTART 257
|
#define TK_NK_ARROW 257
|
||||||
#define TK_QEND 258
|
#define TK_ROWTS 258
|
||||||
#define TK_QDURATION 259
|
#define TK_QSTART 259
|
||||||
#define TK_WSTART 260
|
#define TK_QEND 260
|
||||||
#define TK_WEND 261
|
#define TK_QDURATION 261
|
||||||
#define TK_WDURATION 262
|
#define TK_WSTART 262
|
||||||
#define TK_IROWTS 263
|
#define TK_WEND 263
|
||||||
#define TK_ISFILLED 264
|
#define TK_WDURATION 264
|
||||||
#define TK_CAST 265
|
#define TK_IROWTS 265
|
||||||
#define TK_POSITION 266
|
#define TK_ISFILLED 266
|
||||||
#define TK_IN 267
|
#define TK_FLOW 267
|
||||||
#define TK_FOR 268
|
#define TK_FHIGH 268
|
||||||
#define TK_NOW 269
|
#define TK_FROWTS 269
|
||||||
#define TK_TODAY 270
|
#define TK_CAST 270
|
||||||
#define TK_RAND 271
|
#define TK_POSITION 271
|
||||||
#define TK_SUBSTR 272
|
#define TK_IN 272
|
||||||
#define TK_SUBSTRING 273
|
#define TK_FOR 273
|
||||||
#define TK_BOTH 274
|
#define TK_NOW 274
|
||||||
#define TK_TRAILING 275
|
#define TK_TODAY 275
|
||||||
#define TK_LEADING 276
|
#define TK_RAND 276
|
||||||
#define TK_TIMEZONE 277
|
#define TK_SUBSTR 277
|
||||||
#define TK_CLIENT_VERSION 278
|
#define TK_SUBSTRING 278
|
||||||
#define TK_SERVER_VERSION 279
|
#define TK_BOTH 279
|
||||||
#define TK_SERVER_STATUS 280
|
#define TK_TRAILING 280
|
||||||
#define TK_CURRENT_USER 281
|
#define TK_LEADING 281
|
||||||
#define TK_PI 282
|
#define TK_TIMEZONE 282
|
||||||
#define TK_CASE 283
|
#define TK_CLIENT_VERSION 283
|
||||||
#define TK_WHEN 284
|
#define TK_SERVER_VERSION 284
|
||||||
#define TK_THEN 285
|
#define TK_SERVER_STATUS 285
|
||||||
#define TK_ELSE 286
|
#define TK_CURRENT_USER 286
|
||||||
#define TK_BETWEEN 287
|
#define TK_PI 287
|
||||||
#define TK_IS 288
|
#define TK_CASE 288
|
||||||
#define TK_NK_LT 289
|
#define TK_WHEN 289
|
||||||
#define TK_NK_GT 290
|
#define TK_THEN 290
|
||||||
#define TK_NK_LE 291
|
#define TK_ELSE 291
|
||||||
#define TK_NK_GE 292
|
#define TK_BETWEEN 292
|
||||||
#define TK_NK_NE 293
|
#define TK_IS 293
|
||||||
#define TK_MATCH 294
|
#define TK_NK_LT 294
|
||||||
#define TK_NMATCH 295
|
#define TK_NK_GT 295
|
||||||
#define TK_CONTAINS 296
|
#define TK_NK_LE 296
|
||||||
#define TK_JOIN 297
|
#define TK_NK_GE 297
|
||||||
#define TK_INNER 298
|
#define TK_NK_NE 298
|
||||||
#define TK_LEFT 299
|
#define TK_MATCH 299
|
||||||
#define TK_RIGHT 300
|
#define TK_NMATCH 300
|
||||||
#define TK_OUTER 301
|
#define TK_CONTAINS 301
|
||||||
#define TK_SEMI 302
|
#define TK_JOIN 302
|
||||||
#define TK_ANTI 303
|
#define TK_INNER 303
|
||||||
#define TK_ASOF 304
|
#define TK_LEFT 304
|
||||||
#define TK_WINDOW 305
|
#define TK_RIGHT 305
|
||||||
#define TK_WINDOW_OFFSET 306
|
#define TK_OUTER 306
|
||||||
#define TK_JLIMIT 307
|
#define TK_SEMI 307
|
||||||
#define TK_SELECT 308
|
#define TK_ANTI 308
|
||||||
#define TK_NK_HINT 309
|
#define TK_ASOF 309
|
||||||
#define TK_DISTINCT 310
|
#define TK_WINDOW 310
|
||||||
#define TK_WHERE 311
|
#define TK_WINDOW_OFFSET 311
|
||||||
#define TK_PARTITION 312
|
#define TK_JLIMIT 312
|
||||||
#define TK_BY 313
|
#define TK_SELECT 313
|
||||||
#define TK_SESSION 314
|
#define TK_NK_HINT 314
|
||||||
#define TK_STATE_WINDOW 315
|
#define TK_DISTINCT 315
|
||||||
#define TK_EVENT_WINDOW 316
|
#define TK_WHERE 316
|
||||||
#define TK_COUNT_WINDOW 317
|
#define TK_PARTITION 317
|
||||||
#define TK_SLIDING 318
|
#define TK_BY 318
|
||||||
#define TK_FILL 319
|
#define TK_SESSION 319
|
||||||
#define TK_VALUE 320
|
#define TK_STATE_WINDOW 320
|
||||||
#define TK_VALUE_F 321
|
#define TK_EVENT_WINDOW 321
|
||||||
#define TK_NONE 322
|
#define TK_COUNT_WINDOW 322
|
||||||
#define TK_PREV 323
|
#define TK_ANOMALY_WINDOW 323
|
||||||
#define TK_NULL_F 324
|
#define TK_SLIDING 324
|
||||||
#define TK_LINEAR 325
|
#define TK_FILL 325
|
||||||
#define TK_NEXT 326
|
#define TK_VALUE 326
|
||||||
#define TK_HAVING 327
|
#define TK_VALUE_F 327
|
||||||
#define TK_RANGE 328
|
#define TK_NONE 328
|
||||||
#define TK_EVERY 329
|
#define TK_PREV 329
|
||||||
#define TK_ORDER 330
|
#define TK_NULL_F 330
|
||||||
#define TK_SLIMIT 331
|
#define TK_LINEAR 331
|
||||||
#define TK_SOFFSET 332
|
#define TK_NEXT 332
|
||||||
#define TK_LIMIT 333
|
#define TK_HAVING 333
|
||||||
#define TK_OFFSET 334
|
#define TK_RANGE 334
|
||||||
#define TK_ASC 335
|
#define TK_EVERY 335
|
||||||
#define TK_NULLS 336
|
#define TK_ORDER 336
|
||||||
#define TK_ABORT 337
|
#define TK_SLIMIT 337
|
||||||
#define TK_AFTER 338
|
#define TK_SOFFSET 338
|
||||||
#define TK_ATTACH 339
|
#define TK_LIMIT 339
|
||||||
#define TK_BEFORE 340
|
#define TK_OFFSET 340
|
||||||
#define TK_BEGIN 341
|
#define TK_ASC 341
|
||||||
#define TK_BITAND 342
|
#define TK_NULLS 342
|
||||||
#define TK_BITNOT 343
|
#define TK_ABORT 343
|
||||||
#define TK_BITOR 344
|
#define TK_AFTER 344
|
||||||
#define TK_BLOCKS 345
|
#define TK_ATTACH 345
|
||||||
#define TK_CHANGE 346
|
#define TK_BEFORE 346
|
||||||
#define TK_COMMA 347
|
#define TK_BEGIN 347
|
||||||
#define TK_CONCAT 348
|
#define TK_BITAND 348
|
||||||
#define TK_CONFLICT 349
|
#define TK_BITNOT 349
|
||||||
#define TK_COPY 350
|
#define TK_BITOR 350
|
||||||
#define TK_DEFERRED 351
|
#define TK_BLOCKS 351
|
||||||
#define TK_DELIMITERS 352
|
#define TK_CHANGE 352
|
||||||
#define TK_DETACH 353
|
#define TK_COMMA 353
|
||||||
#define TK_DIVIDE 354
|
#define TK_CONCAT 354
|
||||||
#define TK_DOT 355
|
#define TK_CONFLICT 355
|
||||||
#define TK_EACH 356
|
#define TK_COPY 356
|
||||||
#define TK_FAIL 357
|
#define TK_DEFERRED 357
|
||||||
#define TK_GLOB 358
|
#define TK_DELIMITERS 358
|
||||||
#define TK_ID 359
|
#define TK_DETACH 359
|
||||||
#define TK_IMMEDIATE 360
|
#define TK_DIVIDE 360
|
||||||
#define TK_IMPORT 361
|
#define TK_DOT 361
|
||||||
#define TK_INITIALLY 362
|
#define TK_EACH 362
|
||||||
#define TK_INSTEAD 363
|
#define TK_FAIL 363
|
||||||
#define TK_ISNULL 364
|
#define TK_GLOB 364
|
||||||
#define TK_MODULES 365
|
#define TK_ID 365
|
||||||
#define TK_NK_BITNOT 366
|
#define TK_IMMEDIATE 366
|
||||||
#define TK_NK_SEMI 367
|
#define TK_IMPORT 367
|
||||||
#define TK_NOTNULL 368
|
#define TK_INITIALLY 368
|
||||||
#define TK_OF 369
|
#define TK_INSTEAD 369
|
||||||
#define TK_PLUS 370
|
#define TK_ISNULL 370
|
||||||
#define TK_PRIVILEGE 371
|
#define TK_MODULES 371
|
||||||
#define TK_RAISE 372
|
#define TK_NK_BITNOT 372
|
||||||
#define TK_RESTRICT 373
|
#define TK_NK_SEMI 373
|
||||||
#define TK_ROW 374
|
#define TK_NOTNULL 374
|
||||||
#define TK_STAR 375
|
#define TK_OF 375
|
||||||
#define TK_STATEMENT 376
|
#define TK_PLUS 376
|
||||||
#define TK_STRICT 377
|
#define TK_PRIVILEGE 377
|
||||||
#define TK_STRING 378
|
#define TK_RAISE 378
|
||||||
#define TK_TIMES 379
|
#define TK_RESTRICT 379
|
||||||
#define TK_VALUES 380
|
#define TK_ROW 380
|
||||||
#define TK_VARIABLE 381
|
#define TK_STAR 381
|
||||||
#define TK_WAL 382
|
#define TK_STATEMENT 382
|
||||||
|
#define TK_STRICT 383
|
||||||
|
#define TK_STRING 384
|
||||||
|
#define TK_TIMES 385
|
||||||
|
#define TK_VALUES 386
|
||||||
|
#define TK_VARIABLE 387
|
||||||
|
#define TK_WAL 388
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_AZURE_H_
|
||||||
|
#define _TD_AZURE_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
#include "tmsg.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t azBegin();
|
||||||
|
void azEnd();
|
||||||
|
int32_t azCheckCfg();
|
||||||
|
int32_t azPutObjectFromFileOffset(const char *file, const char *object_name, int64_t offset, int64_t size);
|
||||||
|
int32_t azGetObjectBlock(const char *object_name, int64_t offset, int64_t size, bool check, uint8_t **ppBlock);
|
||||||
|
void azDeleteObjectsByPrefix(const char *prefix);
|
||||||
|
|
||||||
|
int32_t azPutObjectFromFile2(const char *file, const char *object, int8_t withcp);
|
||||||
|
int32_t azGetObjectsByPrefix(const char *prefix, const char *path);
|
||||||
|
int32_t azGetObjectToFile(const char *object_name, const char *fileName);
|
||||||
|
int32_t azDeleteObjects(const char *object_name[], int nobject);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _TD_AZURE_H_
|
|
@ -29,6 +29,7 @@ struct SqlFunctionCtx;
|
||||||
struct SResultRowEntryInfo;
|
struct SResultRowEntryInfo;
|
||||||
|
|
||||||
struct SFunctionNode;
|
struct SFunctionNode;
|
||||||
|
struct SExprSupp;
|
||||||
typedef struct SScalarParam SScalarParam;
|
typedef struct SScalarParam SScalarParam;
|
||||||
typedef struct SStreamState SStreamState;
|
typedef struct SStreamState SStreamState;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ typedef int32_t (*FExecProcess)(struct SqlFunctionCtx *pCtx);
|
||||||
typedef int32_t (*FExecFinalize)(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
|
typedef int32_t (*FExecFinalize)(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
|
||||||
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
typedef int32_t (*FExecCombine)(struct SqlFunctionCtx *pDestCtx, struct SqlFunctionCtx *pSourceCtx);
|
typedef int32_t (*FExecCombine)(struct SqlFunctionCtx *pDestCtx, struct SqlFunctionCtx *pSourceCtx);
|
||||||
|
typedef int32_t (*FExecDecode)(struct SqlFunctionCtx *pCtx, const char *buf, struct SResultRowEntryInfo *pResultCellInfo, int32_t version);
|
||||||
typedef int32_t (*processFuncByRow)(SArray* pCtx); // array of SqlFunctionCtx
|
typedef int32_t (*processFuncByRow)(SArray* pCtx); // array of SqlFunctionCtx
|
||||||
|
|
||||||
typedef struct SScalarFuncExecFuncs {
|
typedef struct SScalarFuncExecFuncs {
|
||||||
|
@ -57,6 +59,7 @@ typedef struct SFuncExecFuncs {
|
||||||
FExecFinalize finalize;
|
FExecFinalize finalize;
|
||||||
FExecCombine combine;
|
FExecCombine combine;
|
||||||
FExecCleanUp cleanup;
|
FExecCleanUp cleanup;
|
||||||
|
FExecDecode decode;
|
||||||
processFuncByRow processFuncByRow;
|
processFuncByRow processFuncByRow;
|
||||||
} SFuncExecFuncs;
|
} SFuncExecFuncs;
|
||||||
|
|
||||||
|
@ -65,6 +68,8 @@ typedef struct SFuncExecFuncs {
|
||||||
#define TOP_BOTTOM_QUERY_LIMIT 100
|
#define TOP_BOTTOM_QUERY_LIMIT 100
|
||||||
#define FUNCTIONS_NAME_MAX_LENGTH 32
|
#define FUNCTIONS_NAME_MAX_LENGTH 32
|
||||||
|
|
||||||
|
#define FUNCTION_RESULT_INFO_VERSION 1
|
||||||
|
|
||||||
typedef struct SResultRowEntryInfo {
|
typedef struct SResultRowEntryInfo {
|
||||||
bool initialized : 1; // output buffer has been initialized
|
bool initialized : 1; // output buffer has been initialized
|
||||||
bool complete : 1; // query has completed
|
bool complete : 1; // query has completed
|
||||||
|
@ -165,6 +170,11 @@ typedef struct STdbState {
|
||||||
void *txn;
|
void *txn;
|
||||||
} STdbState;
|
} STdbState;
|
||||||
|
|
||||||
|
typedef struct SResultRowStore {
|
||||||
|
int32_t (*resultRowPut)(struct SExprSupp *pSup, const char* inBuf, size_t inBufSize, char **outBuf, size_t *outBufSize);
|
||||||
|
int32_t (*resultRowGet)(struct SExprSupp *pSup, const char* inBuf, size_t inBufSize, char **outBuf, size_t *outBufSize);
|
||||||
|
} SResultRowStore;
|
||||||
|
|
||||||
struct SStreamState {
|
struct SStreamState {
|
||||||
STdbState *pTdbState;
|
STdbState *pTdbState;
|
||||||
struct SStreamFileState *pFileState;
|
struct SStreamFileState *pFileState;
|
||||||
|
@ -175,6 +185,8 @@ struct SStreamState {
|
||||||
int64_t streamBackendRid;
|
int64_t streamBackendRid;
|
||||||
int8_t dump;
|
int8_t dump;
|
||||||
int32_t tsIndex;
|
int32_t tsIndex;
|
||||||
|
SResultRowStore pResultRowStore;
|
||||||
|
struct SExprSupp *pExprSupp;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SFunctionStateStore {
|
typedef struct SFunctionStateStore {
|
||||||
|
|
|
@ -64,6 +64,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_UNIQUE,
|
FUNCTION_TYPE_UNIQUE,
|
||||||
FUNCTION_TYPE_STATE_COUNT,
|
FUNCTION_TYPE_STATE_COUNT,
|
||||||
FUNCTION_TYPE_STATE_DURATION,
|
FUNCTION_TYPE_STATE_DURATION,
|
||||||
|
FUNCTION_TYPE_FORECAST,
|
||||||
|
|
||||||
// math function
|
// math function
|
||||||
FUNCTION_TYPE_ABS = 1000,
|
FUNCTION_TYPE_ABS = 1000,
|
||||||
|
@ -151,6 +152,9 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_TBUID,
|
FUNCTION_TYPE_TBUID,
|
||||||
FUNCTION_TYPE_VGID,
|
FUNCTION_TYPE_VGID,
|
||||||
FUNCTION_TYPE_VGVER,
|
FUNCTION_TYPE_VGVER,
|
||||||
|
FUNCTION_TYPE_FORECAST_LOW,
|
||||||
|
FUNCTION_TYPE_FORECAST_HIGH,
|
||||||
|
FUNCTION_TYPE_FORECAST_ROWTS,
|
||||||
|
|
||||||
// internal function
|
// internal function
|
||||||
FUNCTION_TYPE_SELECT_VALUE = 3750,
|
FUNCTION_TYPE_SELECT_VALUE = 3750,
|
||||||
|
@ -265,6 +269,7 @@ bool fmIsForbidSysTableFunc(int32_t funcId);
|
||||||
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
||||||
bool fmIsInterpFunc(int32_t funcId);
|
bool fmIsInterpFunc(int32_t funcId);
|
||||||
bool fmIsLastRowFunc(int32_t funcId);
|
bool fmIsLastRowFunc(int32_t funcId);
|
||||||
|
bool fmIsForecastFunc(int32_t funcId);
|
||||||
bool fmIsNotNullOutputFunc(int32_t funcId);
|
bool fmIsNotNullOutputFunc(int32_t funcId);
|
||||||
bool fmIsSelectValueFunc(int32_t funcId);
|
bool fmIsSelectValueFunc(int32_t funcId);
|
||||||
bool fmIsSystemInfoFunc(int32_t funcId);
|
bool fmIsSystemInfoFunc(int32_t funcId);
|
||||||
|
@ -274,6 +279,7 @@ bool fmIsMultiRowsFunc(int32_t funcId);
|
||||||
bool fmIsKeepOrderFunc(int32_t funcId);
|
bool fmIsKeepOrderFunc(int32_t funcId);
|
||||||
bool fmIsCumulativeFunc(int32_t funcId);
|
bool fmIsCumulativeFunc(int32_t funcId);
|
||||||
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
|
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
|
||||||
|
bool fmIsForecastPseudoColumnFunc(int32_t funcId);
|
||||||
bool fmIsGroupKeyFunc(int32_t funcId);
|
bool fmIsGroupKeyFunc(int32_t funcId);
|
||||||
bool fmIsBlockDistFunc(int32_t funcId);
|
bool fmIsBlockDistFunc(int32_t funcId);
|
||||||
bool fmIsIgnoreNullFunc(int32_t funcId);
|
bool fmIsIgnoreNullFunc(int32_t funcId);
|
||||||
|
|
|
@ -318,6 +318,21 @@ typedef struct SAlterDnodeStmt {
|
||||||
char value[TSDB_DNODE_VALUE_LEN];
|
char value[TSDB_DNODE_VALUE_LEN];
|
||||||
} SAlterDnodeStmt;
|
} SAlterDnodeStmt;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ENodeType type;
|
||||||
|
char url[TSDB_ANAL_ANODE_URL_LEN + 3];
|
||||||
|
} SCreateAnodeStmt;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ENodeType type;
|
||||||
|
int32_t anodeId;
|
||||||
|
} SDropAnodeStmt;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ENodeType type;
|
||||||
|
int32_t anodeId;
|
||||||
|
} SUpdateAnodeStmt;
|
||||||
|
|
||||||
typedef struct SShowStmt {
|
typedef struct SShowStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SNode* pDbName; // SValueNode
|
SNode* pDbName; // SValueNode
|
||||||
|
|
|
@ -204,6 +204,11 @@ typedef struct SInterpFuncLogicNode {
|
||||||
SNode* pTimeSeries; // SColumnNode
|
SNode* pTimeSeries; // SColumnNode
|
||||||
} SInterpFuncLogicNode;
|
} SInterpFuncLogicNode;
|
||||||
|
|
||||||
|
typedef struct SForecastFuncLogicNode {
|
||||||
|
SLogicNode node;
|
||||||
|
SNodeList* pFuncs;
|
||||||
|
} SForecastFuncLogicNode;
|
||||||
|
|
||||||
typedef struct SGroupCacheLogicNode {
|
typedef struct SGroupCacheLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
bool grpColsMayBeNull;
|
bool grpColsMayBeNull;
|
||||||
|
@ -275,6 +280,7 @@ typedef enum EWindowType {
|
||||||
WINDOW_TYPE_STATE,
|
WINDOW_TYPE_STATE,
|
||||||
WINDOW_TYPE_EVENT,
|
WINDOW_TYPE_EVENT,
|
||||||
WINDOW_TYPE_COUNT,
|
WINDOW_TYPE_COUNT,
|
||||||
|
WINDOW_TYPE_ANOMALY
|
||||||
} EWindowType;
|
} EWindowType;
|
||||||
|
|
||||||
typedef enum EWindowAlgorithm {
|
typedef enum EWindowAlgorithm {
|
||||||
|
@ -315,6 +321,8 @@ typedef struct SWindowLogicNode {
|
||||||
int64_t windowCount;
|
int64_t windowCount;
|
||||||
int64_t windowSliding;
|
int64_t windowSliding;
|
||||||
SNodeList* pTsmaSubplans;
|
SNodeList* pTsmaSubplans;
|
||||||
|
SNode* pAnomalyExpr;
|
||||||
|
char anomalyOpt[TSDB_ANAL_ALGO_OPTION_LEN];
|
||||||
} SWindowLogicNode;
|
} SWindowLogicNode;
|
||||||
|
|
||||||
typedef struct SFillLogicNode {
|
typedef struct SFillLogicNode {
|
||||||
|
@ -325,6 +333,7 @@ typedef struct SFillLogicNode {
|
||||||
SNode* pWStartTs;
|
SNode* pWStartTs;
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
|
SNodeList* pFillNullExprs;
|
||||||
} SFillLogicNode;
|
} SFillLogicNode;
|
||||||
|
|
||||||
typedef struct SSortLogicNode {
|
typedef struct SSortLogicNode {
|
||||||
|
@ -507,6 +516,12 @@ typedef struct SInterpFuncPhysiNode {
|
||||||
SNode* pTimeSeries; // SColumnNode
|
SNode* pTimeSeries; // SColumnNode
|
||||||
} SInterpFuncPhysiNode;
|
} SInterpFuncPhysiNode;
|
||||||
|
|
||||||
|
typedef struct SForecastFuncPhysiNode {
|
||||||
|
SPhysiNode node;
|
||||||
|
SNodeList* pExprs;
|
||||||
|
SNodeList* pFuncs;
|
||||||
|
} SForecastFuncPhysiNode;
|
||||||
|
|
||||||
typedef struct SSortMergeJoinPhysiNode {
|
typedef struct SSortMergeJoinPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
EJoinType joinType;
|
EJoinType joinType;
|
||||||
|
@ -663,6 +678,7 @@ typedef struct SFillPhysiNode {
|
||||||
SNode* pWStartTs; // SColumnNode
|
SNode* pWStartTs; // SColumnNode
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
STimeWindow timeRange;
|
STimeWindow timeRange;
|
||||||
|
SNodeList* pFillNullExprs;
|
||||||
} SFillPhysiNode;
|
} SFillPhysiNode;
|
||||||
|
|
||||||
typedef SFillPhysiNode SStreamFillPhysiNode;
|
typedef SFillPhysiNode SStreamFillPhysiNode;
|
||||||
|
@ -704,6 +720,12 @@ typedef struct SCountWinodwPhysiNode {
|
||||||
|
|
||||||
typedef SCountWinodwPhysiNode SStreamCountWinodwPhysiNode;
|
typedef SCountWinodwPhysiNode SStreamCountWinodwPhysiNode;
|
||||||
|
|
||||||
|
typedef struct SAnomalyWindowPhysiNode {
|
||||||
|
SWindowPhysiNode window;
|
||||||
|
SNode* pAnomalyKey;
|
||||||
|
char anomalyOpt[TSDB_ANAL_ALGO_OPTION_LEN];
|
||||||
|
} SAnomalyWindowPhysiNode;
|
||||||
|
|
||||||
typedef struct SSortPhysiNode {
|
typedef struct SSortPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pExprs; // these are expression list of order_by_clause and parameter expression of aggregate function
|
SNodeList* pExprs; // these are expression list of order_by_clause and parameter expression of aggregate function
|
||||||
|
|
|
@ -347,6 +347,13 @@ typedef struct SCountWindowNode {
|
||||||
int64_t windowSliding;
|
int64_t windowSliding;
|
||||||
} SCountWindowNode;
|
} SCountWindowNode;
|
||||||
|
|
||||||
|
typedef struct SAnomalyWindowNode {
|
||||||
|
ENodeType type; // QUERY_NODE_ANOMALY_WINDOW
|
||||||
|
SNode* pCol; // timestamp primary key
|
||||||
|
SNode* pExpr;
|
||||||
|
char anomalyOpt[TSDB_ANAL_ALGO_OPTION_LEN];
|
||||||
|
} SAnomalyWindowNode;
|
||||||
|
|
||||||
typedef enum EFillMode {
|
typedef enum EFillMode {
|
||||||
FILL_MODE_NONE = 1,
|
FILL_MODE_NONE = 1,
|
||||||
FILL_MODE_VALUE,
|
FILL_MODE_VALUE,
|
||||||
|
@ -442,6 +449,8 @@ typedef struct SSelectStmt {
|
||||||
bool hasTailFunc;
|
bool hasTailFunc;
|
||||||
bool hasInterpFunc;
|
bool hasInterpFunc;
|
||||||
bool hasInterpPseudoColFunc;
|
bool hasInterpPseudoColFunc;
|
||||||
|
bool hasForecastFunc;
|
||||||
|
bool hasForecastPseudoColFunc;
|
||||||
bool hasLastRowFunc;
|
bool hasLastRowFunc;
|
||||||
bool hasLastFunc;
|
bool hasLastFunc;
|
||||||
bool hasTimeLineFunc;
|
bool hasTimeLineFunc;
|
||||||
|
|
|
@ -139,6 +139,7 @@ int32_t mavgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam
|
||||||
int32_t hllScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t hllScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t csumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t csumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t diffScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t diffScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t forecastScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
|
@ -236,7 +236,7 @@ typedef struct {
|
||||||
void* vnode; // not available to encoder and decoder
|
void* vnode; // not available to encoder and decoder
|
||||||
FTbSink* tbSinkFunc;
|
FTbSink* tbSinkFunc;
|
||||||
STSchema* pTSchema;
|
STSchema* pTSchema;
|
||||||
SSHashObj* pTblInfo;
|
SSHashObj* pTbInfo;
|
||||||
} STaskSinkTb;
|
} STaskSinkTb;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_TCS_H_
|
||||||
|
#define _TD_TCS_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
#include "tmsg.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int8_t tsS3Enabled;
|
||||||
|
extern int8_t tsS3EnabledCfg;
|
||||||
|
|
||||||
|
extern int32_t tsS3UploadDelaySec;
|
||||||
|
extern int32_t tsS3BlockSize;
|
||||||
|
extern int32_t tsS3BlockCacheSize;
|
||||||
|
extern int32_t tsS3PageCacheSize;
|
||||||
|
|
||||||
|
extern int8_t tsS3StreamEnabled;
|
||||||
|
|
||||||
|
int32_t tcsInit();
|
||||||
|
void tcsUninit();
|
||||||
|
|
||||||
|
int32_t tcsCheckCfg();
|
||||||
|
|
||||||
|
int32_t tcsPutObjectFromFileOffset(const char *file, const char *object_name, int64_t offset, int64_t size);
|
||||||
|
int32_t tcsGetObjectBlock(const char *object_name, int64_t offset, int64_t size, bool check, uint8_t **ppBlock);
|
||||||
|
|
||||||
|
void tcsDeleteObjectsByPrefix(const char *prefix);
|
||||||
|
|
||||||
|
int32_t tcsPutObjectFromFile2(const char *file, const char *object, int8_t withcp);
|
||||||
|
int32_t tcsGetObjectsByPrefix(const char *prefix, const char *path);
|
||||||
|
int32_t tcsDeleteObjects(const char *object_name[], int nobject);
|
||||||
|
int32_t tcsGetObjectToFile(const char *object_name, const char *fileName);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _TD_TCS_H_
|
|
@ -63,6 +63,10 @@ typedef struct SRpcHandleInfo {
|
||||||
int8_t forbiddenIp;
|
int8_t forbiddenIp;
|
||||||
int8_t notFreeAhandle;
|
int8_t notFreeAhandle;
|
||||||
int8_t compressed;
|
int8_t compressed;
|
||||||
|
int64_t seqNum; // msg seq
|
||||||
|
int64_t qId; // queryId Get from client, other req's qId = -1;
|
||||||
|
int32_t refIdMgt;
|
||||||
|
int32_t msgType;
|
||||||
} SRpcHandleInfo;
|
} SRpcHandleInfo;
|
||||||
|
|
||||||
typedef struct SRpcMsg {
|
typedef struct SRpcMsg {
|
||||||
|
@ -124,9 +128,13 @@ typedef struct SRpcInit {
|
||||||
int32_t connLimitLock;
|
int32_t connLimitLock;
|
||||||
int32_t timeToGetConn;
|
int32_t timeToGetConn;
|
||||||
int8_t supportBatch; // 0: no batch, 1. batch
|
int8_t supportBatch; // 0: no batch, 1. batch
|
||||||
int32_t batchSize;
|
int32_t shareConnLimit;
|
||||||
int8_t notWaitAvaliableConn; // 1: wait to get, 0: no wait
|
int8_t shareConn; // 0: no share, 1. share
|
||||||
void *parent;
|
int8_t notWaitAvaliableConn; // 1: wait to get, 0: no wait
|
||||||
|
int8_t startReadTimer;
|
||||||
|
int64_t readTimeout; // s
|
||||||
|
|
||||||
|
void *parent;
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -144,6 +152,7 @@ typedef struct {
|
||||||
SHashObj *args;
|
SHashObj *args;
|
||||||
SRpcBrokenlinkVal brokenVal;
|
SRpcBrokenlinkVal brokenVal;
|
||||||
void (*freeFunc)(const void *arg);
|
void (*freeFunc)(const void *arg);
|
||||||
|
int64_t st;
|
||||||
} SRpcCtx;
|
} SRpcCtx;
|
||||||
|
|
||||||
int32_t rpcInit();
|
int32_t rpcInit();
|
||||||
|
|
|
@ -130,14 +130,15 @@ int taosSetAutoDelFile(char *path);
|
||||||
bool lastErrorIsFileNotExist();
|
bool lastErrorIsFileNotExist();
|
||||||
|
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
#define STUB_RAND_NETWORK_ERR(status) \
|
#define STUB_RAND_NETWORK_ERR(ret) \
|
||||||
do { \
|
do { \
|
||||||
if (tsEnableRandErr && (tsRandErrScope & RAND_ERR_NETWORK)) { \
|
if (tsEnableRandErr && (tsRandErrScope & RAND_ERR_NETWORK)) { \
|
||||||
uint32_t r = taosRand() % tsRandErrDivisor; \
|
uint32_t r = taosRand() % tsRandErrDivisor; \
|
||||||
if ((r + 1) <= tsRandErrChance) { \
|
if ((r + 1) <= tsRandErrChance) { \
|
||||||
status = TSDB_CODE_RPC_NETWORK_UNAVAIL; \
|
ret = TSDB_CODE_RPC_NETWORK_UNAVAIL; \
|
||||||
} \
|
uError("random network error: %s, %s", tstrerror(ret), __func__); \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
#else
|
#else
|
||||||
#define STUB_RAND_NETWORK_ERR(status)
|
#define STUB_RAND_NETWORK_ERR(status)
|
||||||
|
|
|
@ -137,6 +137,7 @@ int32_t taosShutDownSocketRDWR(TdSocketPtr pSocket);
|
||||||
int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer);
|
int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer);
|
||||||
int32_t taosSetNonblocking(TdSocketPtr pSocket, int32_t on);
|
int32_t taosSetNonblocking(TdSocketPtr pSocket, int32_t on);
|
||||||
int32_t taosSetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void *optval, int32_t optlen);
|
int32_t taosSetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void *optval, int32_t optlen);
|
||||||
|
int32_t taosSetSockOpt2(int32_t fd);
|
||||||
int32_t taosGetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void *optval, int32_t *optlen);
|
int32_t taosGetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void *optval, int32_t *optlen);
|
||||||
int32_t taosWriteMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
int32_t taosWriteMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
||||||
int32_t taosReadMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
int32_t taosReadMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
||||||
|
@ -159,7 +160,7 @@ TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, st
|
||||||
int32_t taosGetSocketName(TdSocketPtr pSocket, struct sockaddr *destAddr, int *addrLen);
|
int32_t taosGetSocketName(TdSocketPtr pSocket, struct sockaddr *destAddr, int *addrLen);
|
||||||
|
|
||||||
int32_t taosBlockSIGPIPE();
|
int32_t taosBlockSIGPIPE();
|
||||||
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip);
|
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip);
|
||||||
int32_t taosGetFqdn(char *);
|
int32_t taosGetFqdn(char *);
|
||||||
void tinet_ntoa(char *ipstr, uint32_t ip);
|
void tinet_ntoa(char *ipstr, uint32_t ip);
|
||||||
uint32_t ip2uint(const char *const ip_addr);
|
uint32_t ip2uint(const char *const ip_addr);
|
||||||
|
|
|
@ -89,9 +89,9 @@ int32_t taosResetTerminalMode();
|
||||||
snprintf(array[size], STACKSIZE, "0x%lx : (%s+0x%lx) [0x%lx]\n", (long)pc, fname, (long)offset, (long)pc); \
|
snprintf(array[size], STACKSIZE, "0x%lx : (%s+0x%lx) [0x%lx]\n", (long)pc, fname, (long)offset, (long)pc); \
|
||||||
} \
|
} \
|
||||||
if (ignoreNum < size && size > 0) { \
|
if (ignoreNum < size && size > 0) { \
|
||||||
offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
|
offset = tsnprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
|
||||||
for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
|
for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
|
||||||
offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \
|
offset += tsnprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \
|
||||||
array[i]); \
|
array[i]); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -140,9 +140,9 @@ int32_t taosResetTerminalMode();
|
||||||
char **strings = backtrace_symbols(array, size); \
|
char **strings = backtrace_symbols(array, size); \
|
||||||
int32_t offset = 0; \
|
int32_t offset = 0; \
|
||||||
if (strings != NULL) { \
|
if (strings != NULL) { \
|
||||||
offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
|
offset = tsnprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
|
||||||
for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
|
for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
|
||||||
offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \
|
offset += tsnprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \
|
||||||
strings[i]); \
|
strings[i]); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -193,7 +193,7 @@ int32_t taosResetTerminalMode();
|
||||||
snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \
|
snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \
|
||||||
for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
|
for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
|
||||||
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
|
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
|
||||||
offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", \
|
offset += tsnprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", \
|
||||||
(ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \
|
(ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -94,9 +94,9 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_HTTP_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0025)
|
#define TSDB_CODE_HTTP_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0025)
|
||||||
#define TSDB_CODE_RPC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0026)
|
#define TSDB_CODE_RPC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0026)
|
||||||
#define TSDB_CODE_RPC_ASYNC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0027)
|
#define TSDB_CODE_RPC_ASYNC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0027)
|
||||||
|
#define TSDB_CODE_RPC_ASYNC_IN_PROCESS TAOS_DEF_ERROR_CODE(0, 0x0028)
|
||||||
|
#define TSDB_CODE_RPC_NO_STATE TAOS_DEF_ERROR_CODE(0, 0x0029)
|
||||||
|
#define TSDB_CODE_RPC_STATE_DROPED TAOS_DEF_ERROR_CODE(0, 0x002A)
|
||||||
|
|
||||||
//common & util
|
//common & util
|
||||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
||||||
|
@ -476,6 +476,26 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_DNODE_INVALID_MONITOR_PARAS TAOS_DEF_ERROR_CODE(0, 0x0429)
|
#define TSDB_CODE_DNODE_INVALID_MONITOR_PARAS TAOS_DEF_ERROR_CODE(0, 0x0429)
|
||||||
#define TSDB_CODE_MNODE_STOPPED TAOS_DEF_ERROR_CODE(0, 0x042A)
|
#define TSDB_CODE_MNODE_STOPPED TAOS_DEF_ERROR_CODE(0, 0x042A)
|
||||||
|
|
||||||
|
// anode
|
||||||
|
#define TSDB_CODE_MND_ANODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0430)
|
||||||
|
#define TSDB_CODE_MND_ANODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0431)
|
||||||
|
#define TSDB_CODE_MND_ANODE_TOO_LONG_URL TAOS_DEF_ERROR_CODE(0, 0x0432)
|
||||||
|
#define TSDB_CODE_MND_ANODE_INVALID_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0433)
|
||||||
|
#define TSDB_CODE_MND_ANODE_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0434)
|
||||||
|
#define TSDB_CODE_MND_ANODE_INVALID_ALGO_TYPE TAOS_DEF_ERROR_CODE(0, 0x0435)
|
||||||
|
#define TSDB_CODE_MND_ANODE_TOO_MANY_ALGO TAOS_DEF_ERROR_CODE(0, 0x0436)
|
||||||
|
#define TSDB_CODE_MND_ANODE_TOO_LONG_ALGO_NAME TAOS_DEF_ERROR_CODE(0, 0x0437)
|
||||||
|
#define TSDB_CODE_MND_ANODE_TOO_MANY_ALGO_TYPE TAOS_DEF_ERROR_CODE(0, 0x0438)
|
||||||
|
|
||||||
|
// analysis
|
||||||
|
#define TSDB_CODE_ANAL_URL_RSP_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x0440)
|
||||||
|
#define TSDB_CODE_ANAL_URL_CANT_ACCESS TAOS_DEF_ERROR_CODE(0, 0x0441)
|
||||||
|
#define TSDB_CODE_ANAL_ALGO_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0442)
|
||||||
|
#define TSDB_CODE_ANAL_ALGO_NOT_LOAD TAOS_DEF_ERROR_CODE(0, 0x0443)
|
||||||
|
#define TSDB_CODE_ANAL_BUF_INVALID_TYPE TAOS_DEF_ERROR_CODE(0, 0x0444)
|
||||||
|
#define TSDB_CODE_ANAL_ANODE_RETURN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0445)
|
||||||
|
#define TSDB_CODE_ANAL_ANODE_TOO_MANY_ROWS TAOS_DEF_ERROR_CODE(0, 0x0446)
|
||||||
|
|
||||||
// mnode-sma
|
// mnode-sma
|
||||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||||
#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481)
|
#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481)
|
||||||
|
@ -867,6 +887,10 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_PAR_TAG_NAME_DUPLICATED TAOS_DEF_ERROR_CODE(0, 0x267F)
|
#define TSDB_CODE_PAR_TAG_NAME_DUPLICATED TAOS_DEF_ERROR_CODE(0, 0x267F)
|
||||||
#define TSDB_CODE_PAR_NOT_ALLOWED_DIFFERENT_BY_ROW_FUNC TAOS_DEF_ERROR_CODE(0, 0x2680)
|
#define TSDB_CODE_PAR_NOT_ALLOWED_DIFFERENT_BY_ROW_FUNC TAOS_DEF_ERROR_CODE(0, 0x2680)
|
||||||
#define TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2681)
|
#define TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2681)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2682)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2683)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_OPT TAOS_DEF_ERROR_CODE(0, 0x2684)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_FORECAST_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x2685)
|
||||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
|
@ -893,6 +917,11 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E)
|
#define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E)
|
||||||
#define TSDB_CODE_FUNC_HISTOGRAM_ERROR TAOS_DEF_ERROR_CODE(0, 0x280F)
|
#define TSDB_CODE_FUNC_HISTOGRAM_ERROR TAOS_DEF_ERROR_CODE(0, 0x280F)
|
||||||
#define TSDB_CODE_FUNC_PERCENTILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2810)
|
#define TSDB_CODE_FUNC_PERCENTILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2810)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_RANGE TAOS_DEF_ERROR_CODE(0, 0x2811)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_PRIMTS TAOS_DEF_ERROR_CODE(0, 0x2812)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_PK TAOS_DEF_ERROR_CODE(0, 0x2813)
|
||||||
|
#define TSDB_CODE_FUNC_FUNTION_PARA_HAS_COL TAOS_DEF_ERROR_CODE(0, 0x2814)
|
||||||
|
#define TSDB_CODE_FUNC_FUNCTION_HISTO_TYPE TAOS_DEF_ERROR_CODE(0, 0x2815)
|
||||||
|
|
||||||
|
|
||||||
//udf
|
//udf
|
||||||
|
|
|
@ -334,6 +334,12 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_SLOW_QUERY_SQL_LEN 512
|
#define TSDB_SLOW_QUERY_SQL_LEN 512
|
||||||
#define TSDB_SHOW_SUBQUERY_LEN 1000
|
#define TSDB_SHOW_SUBQUERY_LEN 1000
|
||||||
#define TSDB_LOG_VAR_LEN 32
|
#define TSDB_LOG_VAR_LEN 32
|
||||||
|
#define TSDB_ANAL_ANODE_URL_LEN 128
|
||||||
|
#define TSDB_ANAL_ALGO_NAME_LEN 64
|
||||||
|
#define TSDB_ANAL_ALGO_TYPE_LEN 24
|
||||||
|
#define TSDB_ANAL_ALGO_KEY_LEN (TSDB_ANAL_ALGO_NAME_LEN + 9)
|
||||||
|
#define TSDB_ANAL_ALGO_URL_LEN (TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN + 1)
|
||||||
|
#define TSDB_ANAL_ALGO_OPTION_LEN 256
|
||||||
|
|
||||||
#define TSDB_MAX_EP_NUM 10
|
#define TSDB_MAX_EP_NUM 10
|
||||||
|
|
||||||
|
@ -645,6 +651,12 @@ enum { RAND_ERR_MEMORY = 1, RAND_ERR_FILE = 2, RAND_ERR_NETWORK = 4 };
|
||||||
#define MONITOR_TAG_VALUE_LEN 300
|
#define MONITOR_TAG_VALUE_LEN 300
|
||||||
#define MONITOR_METRIC_NAME_LEN 100
|
#define MONITOR_METRIC_NAME_LEN 100
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ANAL_ALGO_TYPE_ANOMALY_DETECT = 0,
|
||||||
|
ANAL_ALGO_TYPE_FORECAST = 1,
|
||||||
|
ANAL_ALGO_TYPE_END,
|
||||||
|
} EAnalAlgoType;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,7 +68,10 @@ int32_t tjsonAddItemToArray(SJson* pJson, SJson* pItem);
|
||||||
SJson* tjsonGetObjectItem(const SJson* pJson, const char* pName);
|
SJson* tjsonGetObjectItem(const SJson* pJson, const char* pName);
|
||||||
int32_t tjsonGetObjectName(const SJson* pJson, char** pName);
|
int32_t tjsonGetObjectName(const SJson* pJson, char** pName);
|
||||||
int32_t tjsonGetObjectValueString(const SJson* pJson, char** pStringValue);
|
int32_t tjsonGetObjectValueString(const SJson* pJson, char** pStringValue);
|
||||||
|
void tjsonGetObjectValueBigInt(const SJson* pJson, int64_t* pVal);
|
||||||
|
void tjsonGetObjectValueDouble(const SJson* pJson, double* pVal);
|
||||||
int32_t tjsonGetStringValue(const SJson* pJson, const char* pName, char* pVal);
|
int32_t tjsonGetStringValue(const SJson* pJson, const char* pName, char* pVal);
|
||||||
|
int32_t tjsonGetStringValue2(const SJson* pJson, const char* pName, char* pVal, int32_t maxLen);
|
||||||
int32_t tjsonDupStringValue(const SJson* pJson, const char* pName, char** pVal);
|
int32_t tjsonDupStringValue(const SJson* pJson, const char* pName, char** pVal);
|
||||||
int32_t tjsonGetBigIntValue(const SJson* pJson, const char* pName, int64_t* pVal);
|
int32_t tjsonGetBigIntValue(const SJson* pJson, const char* pName, int64_t* pVal);
|
||||||
int32_t tjsonGetIntValue(const SJson* pJson, const char* pName, int32_t* pVal);
|
int32_t tjsonGetIntValue(const SJson* pJson, const char* pName, int32_t* pVal);
|
||||||
|
|
|
@ -57,6 +57,7 @@ extern int32_t rpcDebugFlag;
|
||||||
extern int32_t qDebugFlag;
|
extern int32_t qDebugFlag;
|
||||||
extern int32_t stDebugFlag;
|
extern int32_t stDebugFlag;
|
||||||
extern int32_t wDebugFlag;
|
extern int32_t wDebugFlag;
|
||||||
|
extern int32_t azDebugFlag;
|
||||||
extern int32_t sDebugFlag;
|
extern int32_t sDebugFlag;
|
||||||
extern int32_t tsdbDebugFlag;
|
extern int32_t tsdbDebugFlag;
|
||||||
extern int32_t tqDebugFlag;
|
extern int32_t tqDebugFlag;
|
||||||
|
@ -123,8 +124,8 @@ void taosReleaseCrashLogFile(TdFilePtr pFile, bool truncateFile);
|
||||||
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", DEBUG_INFO, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", DEBUG_INFO, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
|
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
|
||||||
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", DEBUG_TRACE, uDebugFlag, __VA_ARGS__); }}
|
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", DEBUG_TRACE, uDebugFlag, __VA_ARGS__); }}
|
||||||
#define uDebugL(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLongString("UTL ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
|
#define uDebugL(...){ if (uDebugFlag & DEBUG_DEBUG) { taosPrintLongString("UTL ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
|
||||||
#define uInfoL(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLongString("UTL ", DEBUG_INFO, uDebugFlag, __VA_ARGS__); }}
|
#define uInfoL(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLongString("UTL ", DEBUG_INFO, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
#define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }
|
#define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }
|
||||||
#define pPrint(...) { taosPrintLog("APP ", DEBUG_INFO, 255, __VA_ARGS__); }
|
#define pPrint(...) { taosPrintLog("APP ", DEBUG_INFO, 255, __VA_ARGS__); }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
aux_source_directory(src CLIENT_SRC)
|
aux_source_directory(src CLIENT_SRC)
|
||||||
|
|
||||||
IF (TD_ENTERPRISE)
|
if(TD_ENTERPRISE)
|
||||||
LIST(APPEND CLIENT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/clientView.c)
|
LIST(APPEND CLIENT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/clientView.c)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
if(TD_WINDOWS)
|
if(TD_WINDOWS)
|
||||||
add_library(taos SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taos.rc.in)
|
add_library(taos SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taos.rc.in)
|
||||||
|
|
|
@ -370,7 +370,10 @@ int32_t openTransporter(const char *user, const char *auth, int32_t numOfThread,
|
||||||
connLimitNum = TMAX(connLimitNum, 10);
|
connLimitNum = TMAX(connLimitNum, 10);
|
||||||
connLimitNum = TMIN(connLimitNum, 1000);
|
connLimitNum = TMIN(connLimitNum, 1000);
|
||||||
rpcInit.connLimitNum = connLimitNum;
|
rpcInit.connLimitNum = connLimitNum;
|
||||||
|
rpcInit.shareConnLimit = tsShareConnLimit;
|
||||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||||
|
rpcInit.startReadTimer = 1;
|
||||||
|
rpcInit.readTimeout = tsReadTimeout;
|
||||||
|
|
||||||
int32_t code = taosVersionStrToInt(version, &(rpcInit.compatibilityVer));
|
int32_t code = taosVersionStrToInt(version, &(rpcInit.compatibilityVer));
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
|
|
@ -410,7 +410,6 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||||
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
|
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
|
||||||
|
|
||||||
// int64_t transporterId = 0;
|
|
||||||
int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, NULL, pSendMsg);
|
int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, NULL, pSendMsg);
|
||||||
if (code) {
|
if (code) {
|
||||||
doRequestCallback(pRequest, code);
|
doRequestCallback(pRequest, code);
|
||||||
|
@ -1923,19 +1922,19 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
// TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
||||||
// const char* db, int dbLen, uint16_t port) {
|
// const char* db, int dbLen, uint16_t port) {
|
||||||
// char ipStr[TSDB_EP_LEN] = {0};
|
// char ipStr[TSDB_EP_LEN] = {0};
|
||||||
// char dbStr[TSDB_DB_NAME_LEN] = {0};
|
// char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||||
// char userStr[TSDB_USER_LEN] = {0};
|
// char userStr[TSDB_USER_LEN] = {0};
|
||||||
// char passStr[TSDB_PASSWORD_LEN] = {0};
|
// char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||||
//
|
//
|
||||||
// tstrncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
// tstrncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
||||||
// tstrncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
// tstrncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
||||||
// tstrncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
// tstrncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||||
// tstrncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
// tstrncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||||
// return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
// return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||||
//}
|
// }
|
||||||
|
|
||||||
void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||||
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||||
|
@ -2303,7 +2302,8 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%.9lf", jsonVd);
|
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%.9lf", jsonVd);
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
||||||
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%s",
|
||||||
|
(*((char*)jsonInnerData) == 1) ? "true" : "false");
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else {
|
} else {
|
||||||
tscError("doConvertJson error: invalid type:%d", jsonInnerType);
|
tscError("doConvertJson error: invalid type:%d", jsonInnerType);
|
||||||
|
@ -2572,6 +2572,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
|
||||||
connLimitNum = TMIN(connLimitNum, 500);
|
connLimitNum = TMIN(connLimitNum, 500);
|
||||||
rpcInit.connLimitNum = connLimitNum;
|
rpcInit.connLimitNum = connLimitNum;
|
||||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||||
|
rpcInit.readTimeout = tsReadTimeout;
|
||||||
if (TSDB_CODE_SUCCESS != taosVersionStrToInt(version, &(rpcInit.compatibilityVer))) {
|
if (TSDB_CODE_SUCCESS != taosVersionStrToInt(version, &(rpcInit.compatibilityVer))) {
|
||||||
tscError("faild to convert taos version from str to int, errcode:%s", terrstr());
|
tscError("faild to convert taos version from str to int, errcode:%s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void taos_cleanup(void) {
|
||||||
taosCloseRef(id);
|
taosCloseRef(id);
|
||||||
|
|
||||||
nodesDestroyAllocatorSet();
|
nodesDestroyAllocatorSet();
|
||||||
cleanupAppInfo();
|
// cleanupAppInfo();
|
||||||
rpcCleanup();
|
rpcCleanup();
|
||||||
tscDebug("rpc cleanup");
|
tscDebug("rpc cleanup");
|
||||||
|
|
||||||
|
@ -492,53 +492,53 @@ int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row[i] == NULL) {
|
if (row[i] == NULL) {
|
||||||
len += snprintf(str + len, size - len, "%s", TSDB_DATA_NULL_STR);
|
len += tsnprintf(str + len, size - len, "%s", TSDB_DATA_NULL_STR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fields[i].type) {
|
switch (fields[i].type) {
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
len += snprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
len += snprintf(str + len, size - len, "%u", *((uint8_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%u", *((uint8_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
len += snprintf(str + len, size - len, "%d", *((int16_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%d", *((int16_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
len += snprintf(str + len, size - len, "%u", *((uint16_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%u", *((uint16_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
len += snprintf(str + len, size - len, "%d", *((int32_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%d", *((int32_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
len += snprintf(str + len, size - len, "%u", *((uint32_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%u", *((uint32_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
len += snprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
len += snprintf(str + len, size - len, "%" PRIu64, *((uint64_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%" PRIu64, *((uint64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
float fv = 0;
|
float fv = 0;
|
||||||
fv = GET_FLOAT_VAL(row[i]);
|
fv = GET_FLOAT_VAL(row[i]);
|
||||||
len += snprintf(str + len, size - len, "%f", fv);
|
len += tsnprintf(str + len, size - len, "%f", fv);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
double dv = 0;
|
double dv = 0;
|
||||||
dv = GET_DOUBLE_VAL(row[i]);
|
dv = GET_DOUBLE_VAL(row[i]);
|
||||||
len += snprintf(str + len, size - len, "%lf", dv);
|
len += tsnprintf(str + len, size - len, "%lf", dv);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
|
@ -576,11 +576,11 @@ int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
len += snprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
len += snprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
len += tsnprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,121 +1,122 @@
|
||||||
aux_source_directory(src COMMON_SRC)
|
aux_source_directory(src COMMON_SRC)
|
||||||
IF (TD_ENTERPRISE)
|
|
||||||
LIST(APPEND COMMON_SRC ${TD_ENTERPRISE_DIR}/src/plugins/common/src/tglobal.c)
|
if(TD_ENTERPRISE)
|
||||||
ENDIF()
|
LIST(APPEND COMMON_SRC ${TD_ENTERPRISE_DIR}/src/plugins/common/src/tglobal.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(common STATIC ${COMMON_SRC})
|
add_library(common STATIC ${COMMON_SRC})
|
||||||
|
|
||||||
if (DEFINED GRANT_CFG_INCLUDE_DIR)
|
if(DEFINED GRANT_CFG_INCLUDE_DIR)
|
||||||
add_definitions(-DGRANTS_CFG)
|
add_definitions(-DGRANTS_CFG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF (TD_GRANT)
|
if(TD_GRANT)
|
||||||
ADD_DEFINITIONS(-D_GRANT)
|
ADD_DEFINITIONS(-D_GRANT)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
IF (TD_STORAGE)
|
if(TD_STORAGE)
|
||||||
ADD_DEFINITIONS(-D_STORAGE)
|
ADD_DEFINITIONS(-D_STORAGE)
|
||||||
TARGET_LINK_LIBRARIES(common PRIVATE storage)
|
TARGET_LINK_LIBRARIES(common PRIVATE storage)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
IF (TD_ENTERPRISE)
|
if(TD_ENTERPRISE)
|
||||||
IF(${BUILD_WITH_S3})
|
if(${BUILD_WITH_S3})
|
||||||
add_definitions(-DUSE_S3)
|
add_definitions(-DUSE_S3)
|
||||||
ELSEIF(${BUILD_WITH_COS})
|
ELSEIF(${BUILD_WITH_COS})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
common
|
common
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
PRIVATE "${GRANT_CFG_INCLUDE_DIR}"
|
PRIVATE "${GRANT_CFG_INCLUDE_DIR}"
|
||||||
)
|
)
|
||||||
IF(${TD_WINDOWS})
|
|
||||||
target_include_directories(
|
if(${TD_WINDOWS})
|
||||||
common
|
target_include_directories(
|
||||||
PRIVATE "${TD_SOURCE_DIR}/contrib/pthread"
|
common
|
||||||
PRIVATE "${TD_SOURCE_DIR}/contrib/msvcregex"
|
PRIVATE "${TD_SOURCE_DIR}/contrib/pthread"
|
||||||
)
|
PRIVATE "${TD_SOURCE_DIR}/contrib/msvcregex"
|
||||||
ENDIF ()
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
common
|
common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
INTERFACE api
|
INTERFACE api
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${BUILD_S3})
|
if(${BUILD_S3})
|
||||||
|
if(${BUILD_WITH_S3})
|
||||||
|
target_include_directories(
|
||||||
|
common
|
||||||
|
|
||||||
if(${BUILD_WITH_S3})
|
PUBLIC "$ENV{HOME}/.cos-local.2/include"
|
||||||
target_include_directories(
|
)
|
||||||
common
|
|
||||||
|
|
||||||
PUBLIC "$ENV{HOME}/.cos-local.2/include"
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||||
)
|
set(CMAKE_PREFIX_PATH $ENV{HOME}/.cos-local.2)
|
||||||
|
find_library(S3_LIBRARY s3)
|
||||||
|
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(XML2_LIBRARY xml2)
|
||||||
|
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
target_link_libraries(
|
||||||
|
common
|
||||||
|
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
# s3
|
||||||
set(CMAKE_PREFIX_PATH $ENV{HOME}/.cos-local.2)
|
PUBLIC ${S3_LIBRARY}
|
||||||
find_library(S3_LIBRARY s3)
|
PUBLIC ${CURL_LIBRARY}
|
||||||
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
PUBLIC ${SSL_LIBRARY}
|
||||||
find_library(XML2_LIBRARY xml2)
|
PUBLIC ${CRYPTO_LIBRARY}
|
||||||
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
PUBLIC ${XML2_LIBRARY}
|
||||||
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
)
|
||||||
target_link_libraries(
|
|
||||||
common
|
|
||||||
|
|
||||||
# s3
|
add_definitions(-DUSE_S3)
|
||||||
PUBLIC ${S3_LIBRARY}
|
endif()
|
||||||
PUBLIC ${CURL_LIBRARY}
|
|
||||||
PUBLIC ${SSL_LIBRARY}
|
|
||||||
PUBLIC ${CRYPTO_LIBRARY}
|
|
||||||
PUBLIC ${XML2_LIBRARY}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_definitions(-DUSE_S3)
|
if(${BUILD_WITH_COS})
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||||
|
find_library(APR_LIBRARY apr-1 PATHS /usr/local/apr/lib/)
|
||||||
|
find_library(APR_UTIL_LIBRARY aprutil-1 PATHS /usr/local/apr/lib/)
|
||||||
|
find_library(MINIXML_LIBRARY mxml)
|
||||||
|
find_library(CURL_LIBRARY curl)
|
||||||
|
target_link_libraries(
|
||||||
|
common
|
||||||
|
|
||||||
|
# s3
|
||||||
|
PUBLIC cos_c_sdk_static
|
||||||
|
PUBLIC ${APR_UTIL_LIBRARY}
|
||||||
|
PUBLIC ${APR_LIBRARY}
|
||||||
|
PUBLIC ${MINIXML_LIBRARY}
|
||||||
|
PUBLIC ${CURL_LIBRARY}
|
||||||
|
)
|
||||||
|
|
||||||
|
# s3
|
||||||
|
FIND_PROGRAM(APR_CONFIG_BIN NAMES apr-config apr-1-config PATHS /usr/bin /usr/local/bin /usr/local/apr/bin/)
|
||||||
|
|
||||||
|
if(APR_CONFIG_BIN)
|
||||||
|
EXECUTE_PROCESS(
|
||||||
|
COMMAND ${APR_CONFIG_BIN} --includedir
|
||||||
|
OUTPUT_VARIABLE APR_INCLUDE_DIR
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${BUILD_WITH_COS})
|
include_directories(${APR_INCLUDE_DIR})
|
||||||
|
target_include_directories(
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
common
|
||||||
find_library(APR_LIBRARY apr-1 PATHS /usr/local/apr/lib/)
|
PUBLIC "${TD_SOURCE_DIR}/contrib/cos-c-sdk-v5/cos_c_sdk"
|
||||||
find_library(APR_UTIL_LIBRARY aprutil-1 PATHS /usr/local/apr/lib/)
|
PUBLIC "$ENV{HOME}/.cos-local.1/include"
|
||||||
find_library(MINIXML_LIBRARY mxml)
|
)
|
||||||
find_library(CURL_LIBRARY curl)
|
|
||||||
target_link_libraries(
|
|
||||||
common
|
|
||||||
|
|
||||||
# s3
|
|
||||||
PUBLIC cos_c_sdk_static
|
|
||||||
PUBLIC ${APR_UTIL_LIBRARY}
|
|
||||||
PUBLIC ${APR_LIBRARY}
|
|
||||||
PUBLIC ${MINIXML_LIBRARY}
|
|
||||||
PUBLIC ${CURL_LIBRARY}
|
|
||||||
)
|
|
||||||
|
|
||||||
# s3
|
|
||||||
FIND_PROGRAM(APR_CONFIG_BIN NAMES apr-config apr-1-config PATHS /usr/bin /usr/local/bin /usr/local/apr/bin/)
|
|
||||||
IF (APR_CONFIG_BIN)
|
|
||||||
EXECUTE_PROCESS(
|
|
||||||
COMMAND ${APR_CONFIG_BIN} --includedir
|
|
||||||
OUTPUT_VARIABLE APR_INCLUDE_DIR
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
include_directories (${APR_INCLUDE_DIR})
|
|
||||||
target_include_directories(
|
|
||||||
common
|
|
||||||
PUBLIC "${TD_SOURCE_DIR}/contrib/cos-c-sdk-v5/cos_c_sdk"
|
|
||||||
PUBLIC "$ENV{HOME}/.cos-local.1/include"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_definitions(-DUSE_COS)
|
|
||||||
endif(${BUILD_WITH_COS})
|
|
||||||
|
|
||||||
|
add_definitions(-DUSE_COS)
|
||||||
|
endif(${BUILD_WITH_COS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
ADD_SUBDIRECTORY(test)
|
ADD_SUBDIRECTORY(test)
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
|
@ -89,20 +89,8 @@ static void s3DumpCfgByEp(int8_t epIndex) {
|
||||||
|
|
||||||
int32_t s3CheckCfg() {
|
int32_t s3CheckCfg() {
|
||||||
int32_t code = 0, lino = 0;
|
int32_t code = 0, lino = 0;
|
||||||
int8_t i = 0;
|
|
||||||
|
|
||||||
if (!tsS3Enabled) {
|
for (int8_t i = 0; i < tsS3EpNum; i++) {
|
||||||
(void)fprintf(stderr, "s3 not configured.\n");
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = s3Begin();
|
|
||||||
if (code != 0) {
|
|
||||||
(void)fprintf(stderr, "failed to initialize s3.\n");
|
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; i < tsS3EpNum; i++) {
|
|
||||||
(void)fprintf(stdout, "test s3 ep (%d/%d):\n", i + 1, tsS3EpNum);
|
(void)fprintf(stdout, "test s3 ep (%d/%d):\n", i + 1, tsS3EpNum);
|
||||||
s3DumpCfgByEp(i);
|
s3DumpCfgByEp(i);
|
||||||
|
|
||||||
|
@ -192,7 +180,7 @@ int32_t s3CheckCfg() {
|
||||||
(void)fprintf(stdout, "=================================================================\n");
|
(void)fprintf(stdout, "=================================================================\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
s3End();
|
// s3End();
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
@ -1529,6 +1517,8 @@ void s3EvictCache(const char *path, long object_size) {}
|
||||||
#include "cos_http_io.h"
|
#include "cos_http_io.h"
|
||||||
#include "cos_log.h"
|
#include "cos_log.h"
|
||||||
|
|
||||||
|
int32_t s3Begin() { TAOS_RETURN(TSDB_CODE_SUCCESS); }
|
||||||
|
|
||||||
int32_t s3Init() {
|
int32_t s3Init() {
|
||||||
if (cos_http_io_initialize(NULL, 0) != COSE_OK) {
|
if (cos_http_io_initialize(NULL, 0) != COSE_OK) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1967,6 +1957,10 @@ long s3Size(const char *object_name) {
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int32_t s3Init() { return 0; }
|
int32_t s3Init() { return 0; }
|
||||||
|
int32_t s3Begin() { TAOS_RETURN(TSDB_CODE_SUCCESS); }
|
||||||
|
|
||||||
|
void s3End() {}
|
||||||
|
int32_t s3CheckCfg() { return 0; }
|
||||||
int32_t s3PutObjectFromFile(const char *file, const char *object) { return 0; }
|
int32_t s3PutObjectFromFile(const char *file, const char *object) { return 0; }
|
||||||
int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp) { return 0; }
|
int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp) { return 0; }
|
||||||
int32_t s3PutObjectFromFileOffset(const char *file, const char *object_name, int64_t offset, int64_t size) { return 0; }
|
int32_t s3PutObjectFromFileOffset(const char *file, const char *object_name, int64_t offset, int64_t size) { return 0; }
|
||||||
|
|
|
@ -160,7 +160,11 @@ int32_t startRsync() {
|
||||||
code = system(cmd);
|
code = system(cmd);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
uError("[rsync] cmd:%s start server failed, code:%d," ERRNO_ERR_FORMAT, cmd, code, ERRNO_ERR_DATA);
|
uError("[rsync] cmd:%s start server failed, code:%d," ERRNO_ERR_FORMAT, cmd, code, ERRNO_ERR_DATA);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (errno == 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
uInfo("[rsync] cmd:%s start server successful", cmd);
|
uInfo("[rsync] cmd:%s start server successful", cmd);
|
||||||
}
|
}
|
||||||
|
@ -358,4 +362,4 @@ int32_t deleteRsync(const char* id) {
|
||||||
|
|
||||||
uDebug("[rsync] delete data:%s successful", id);
|
uDebug("[rsync] delete data:%s successful", id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,6 +399,20 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
||||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema anodesSchema[] = {
|
||||||
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
|
{.name = "url", .bytes = TSDB_ANAL_ANODE_URL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||||
|
{.name = "update_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema anodesFullSchema[] = {
|
||||||
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
|
{.name = "type", .bytes = TSDB_ANAL_ALGO_TYPE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "algo", .bytes = TSDB_ANAL_ALGO_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema tsmaSchema[] = {
|
static const SSysDbTableSchema tsmaSchema[] = {
|
||||||
{.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
@ -473,6 +487,8 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
|
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
|
||||||
{TSDB_INS_TABLE_ENCRYPTIONS, encryptionsSchema, tListLen(encryptionsSchema), true},
|
{TSDB_INS_TABLE_ENCRYPTIONS, encryptionsSchema, tListLen(encryptionsSchema), true},
|
||||||
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
||||||
|
{TSDB_INS_TABLE_ANODES, anodesSchema, tListLen(anodesSchema), true},
|
||||||
|
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema connectionsSchema[] = {
|
static const SSysDbTableSchema connectionsSchema[] = {
|
||||||
|
|
|
@ -56,6 +56,8 @@ int32_t tsShellActivityTimer = 3; // second
|
||||||
// queue & threads
|
// queue & threads
|
||||||
int32_t tsNumOfRpcThreads = 1;
|
int32_t tsNumOfRpcThreads = 1;
|
||||||
int32_t tsNumOfRpcSessions = 30000;
|
int32_t tsNumOfRpcSessions = 30000;
|
||||||
|
int32_t tsShareConnLimit = 10;
|
||||||
|
int32_t tsReadTimeout = 900;
|
||||||
int32_t tsTimeToGetAvailableConn = 500000;
|
int32_t tsTimeToGetAvailableConn = 500000;
|
||||||
int32_t tsKeepAliveIdle = 60;
|
int32_t tsKeepAliveIdle = 60;
|
||||||
|
|
||||||
|
@ -179,12 +181,12 @@ int32_t tsRedirectFactor = 2;
|
||||||
int32_t tsRedirectMaxPeriod = 1000;
|
int32_t tsRedirectMaxPeriod = 1000;
|
||||||
int32_t tsMaxRetryWaitTime = 10000;
|
int32_t tsMaxRetryWaitTime = 10000;
|
||||||
bool tsUseAdapter = false;
|
bool tsUseAdapter = false;
|
||||||
int32_t tsMetaCacheMaxSize = -1; // MB
|
int32_t tsMetaCacheMaxSize = -1; // MB
|
||||||
int32_t tsSlowLogThreshold = 10; // seconds
|
int32_t tsSlowLogThreshold = 10; // seconds
|
||||||
int32_t tsSlowLogThresholdTest = INT32_MAX; // seconds
|
int32_t tsSlowLogThresholdTest = INT32_MAX; // seconds
|
||||||
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN] = ""; // seconds
|
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN] = ""; // seconds
|
||||||
int32_t tsSlowLogScope = SLOW_LOG_TYPE_QUERY;
|
int32_t tsSlowLogScope = SLOW_LOG_TYPE_QUERY;
|
||||||
char* tsSlowLogScopeString = "query";
|
char *tsSlowLogScopeString = "query";
|
||||||
int32_t tsSlowLogMaxLen = 4096;
|
int32_t tsSlowLogMaxLen = 4096;
|
||||||
int32_t tsTimeSeriesThreshold = 50;
|
int32_t tsTimeSeriesThreshold = 50;
|
||||||
bool tsMultiResultFunctionStarReturnTags = false;
|
bool tsMultiResultFunctionStarReturnTags = false;
|
||||||
|
@ -306,6 +308,7 @@ char tsS3AppId[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<appid>"};
|
||||||
int8_t tsS3Enabled = false;
|
int8_t tsS3Enabled = false;
|
||||||
int8_t tsS3EnabledCfg = false;
|
int8_t tsS3EnabledCfg = false;
|
||||||
int8_t tsS3Oss[TSDB_MAX_EP_NUM] = {false};
|
int8_t tsS3Oss[TSDB_MAX_EP_NUM] = {false};
|
||||||
|
int8_t tsS3Ablob = false;
|
||||||
int8_t tsS3StreamEnabled = false;
|
int8_t tsS3StreamEnabled = false;
|
||||||
|
|
||||||
int8_t tsS3Https[TSDB_MAX_EP_NUM] = {true};
|
int8_t tsS3Https[TSDB_MAX_EP_NUM] = {true};
|
||||||
|
@ -322,7 +325,6 @@ int32_t tsMaxTsmaNum = 3;
|
||||||
int32_t tsMaxTsmaCalcDelay = 600;
|
int32_t tsMaxTsmaCalcDelay = 600;
|
||||||
int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d
|
int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d
|
||||||
|
|
||||||
|
|
||||||
#define TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, pName) \
|
#define TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, pName) \
|
||||||
if ((pItem = cfgGetItem(pCfg, pName)) == NULL) { \
|
if ((pItem = cfgGetItem(pCfg, pName)) == NULL) { \
|
||||||
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); \
|
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); \
|
||||||
|
@ -361,7 +363,7 @@ static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSD
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, name);
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, name);
|
||||||
|
|
||||||
char *strDup = NULL;
|
char *strDup = NULL;
|
||||||
if ((strDup = taosStrdup(pItem->str))== NULL){
|
if ((strDup = taosStrdup(pItem->str)) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -435,6 +437,7 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
||||||
}
|
}
|
||||||
tsS3Https[i] = (strstr(tsS3Endpoint[i], "https://") != NULL);
|
tsS3Https[i] = (strstr(tsS3Endpoint[i], "https://") != NULL);
|
||||||
tsS3Oss[i] = (strstr(tsS3Endpoint[i], "aliyuncs.") != NULL);
|
tsS3Oss[i] = (strstr(tsS3Endpoint[i], "aliyuncs.") != NULL);
|
||||||
|
tsS3Ablob = (strstr(tsS3Endpoint[i], ".blob.core.windows.net") != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsS3BucketName[0] != '<') {
|
if (tsS3BucketName[0] != '<') {
|
||||||
|
@ -450,7 +453,9 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SConfig *taosGetCfg() { return tsCfg; }
|
struct SConfig *taosGetCfg() {
|
||||||
|
return tsCfg;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
||||||
char *apolloUrl) {
|
char *apolloUrl) {
|
||||||
|
@ -539,6 +544,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "vDebugFlag", vDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "vDebugFlag", vDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "mDebugFlag", mDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "mDebugFlag", mDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "wDebugFlag", wDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "wDebugFlag", wDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "azDebugFlag", azDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER));
|
||||||
|
@ -572,7 +578,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(
|
TAOS_CHECK_RETURN(
|
||||||
cfgAddInt32(pCfg, "compressMsgSize", tsCompressMsgSize, -1, 100000000, CFG_SCOPE_BOTH, CFG_DYN_CLIENT));
|
cfgAddInt32(pCfg, "compressMsgSize", tsCompressMsgSize, -1, 100000000, CFG_SCOPE_BOTH, CFG_DYN_CLIENT));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 4, CFG_SCOPE_CLIENT, CFG_DYN_ENT_CLIENT));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 4, CFG_SCOPE_CLIENT, CFG_DYN_ENT_CLIENT));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "queryTableNotExistAsEmpty", tsQueryTbNotExistAsEmpty, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
TAOS_CHECK_RETURN(
|
||||||
|
cfgAddBool(pCfg, "queryTableNotExistAsEmpty", tsQueryTbNotExistAsEmpty, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableQueryHb", tsEnableQueryHb, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableQueryHb", tsEnableQueryHb, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableScience", tsEnableScience, CFG_SCOPE_CLIENT, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableScience", tsEnableScience, CFG_SCOPE_CLIENT, CFG_DYN_NONE));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
||||||
|
@ -600,16 +607,23 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(
|
TAOS_CHECK_RETURN(
|
||||||
cfgAddInt32(pCfg, "metaCacheMaxSize", tsMetaCacheMaxSize, -1, INT32_MAX, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
cfgAddInt32(pCfg, "metaCacheMaxSize", tsMetaCacheMaxSize, -1, INT32_MAX, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "randErrorChance", tsRandErrChance, 0, 10000, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "randErrorChance", tsRandErrChance, 0, 10000, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "randErrorDivisor", tsRandErrDivisor, 1, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
TAOS_CHECK_RETURN(
|
||||||
|
cfgAddInt64(pCfg, "randErrorDivisor", tsRandErrDivisor, 1, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "randErrorScope", tsRandErrScope, 0, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "randErrorScope", tsRandErrScope, 0, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_BOTH));
|
||||||
|
|
||||||
tsNumOfRpcThreads = tsNumOfCores / 2;
|
tsNumOfRpcThreads = tsNumOfCores / 2;
|
||||||
tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 2, TSDB_MAX_RPC_THREADS);
|
tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, TSDB_MAX_RPC_THREADS);
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfRpcThreads", tsNumOfRpcThreads, 1, 1024, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfRpcThreads", tsNumOfRpcThreads, 1, 1024, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
|
||||||
tsNumOfRpcSessions = TRANGE(tsNumOfRpcSessions, 100, 100000);
|
tsNumOfRpcSessions = TRANGE(tsNumOfRpcSessions, 100, 100000);
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfRpcSessions", tsNumOfRpcSessions, 1, 100000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfRpcSessions", tsNumOfRpcSessions, 1, 100000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
|
||||||
|
tsShareConnLimit = TRANGE(tsShareConnLimit, 1, 512);
|
||||||
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "shareConnLimit", tsShareConnLimit, 1, 512, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
|
||||||
|
tsReadTimeout = TRANGE(tsReadTimeout, 64, 24 * 3600 * 7);
|
||||||
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "readTimeout", tsReadTimeout, 64, 24 * 3600 * 7, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
|
||||||
tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 10000000);
|
tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 10000000);
|
||||||
TAOS_CHECK_RETURN(
|
TAOS_CHECK_RETURN(
|
||||||
cfgAddInt32(pCfg, "timeToGetAvailableConn", tsTimeToGetAvailableConn, 20, 1000000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
cfgAddInt32(pCfg, "timeToGetAvailableConn", tsTimeToGetAvailableConn, 20, 1000000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
@ -865,8 +879,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
pItem = cfgGetItem(pCfg, "numOfRpcThreads");
|
pItem = cfgGetItem(pCfg, "numOfRpcThreads");
|
||||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||||
tsNumOfRpcThreads = numOfCores / 2;
|
tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, TSDB_MAX_RPC_THREADS);
|
||||||
tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 2, TSDB_MAX_RPC_THREADS);
|
|
||||||
pItem->i32 = tsNumOfRpcThreads;
|
pItem->i32 = tsNumOfRpcThreads;
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
}
|
}
|
||||||
|
@ -878,6 +891,20 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pItem = cfgGetItem(pCfg, "shareConnLimit");
|
||||||
|
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||||
|
tsShareConnLimit = TRANGE(tsShareConnLimit, 1, 512);
|
||||||
|
pItem->i32 = tsShareConnLimit;
|
||||||
|
pItem->stype = stype;
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem = cfgGetItem(pCfg, "readTimeout");
|
||||||
|
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||||
|
tsReadTimeout = TRANGE(tsReadTimeout, 64, 24 * 3600 * 7);
|
||||||
|
pItem->i32 = tsReadTimeout;
|
||||||
|
pItem->stype = stype;
|
||||||
|
}
|
||||||
|
|
||||||
pItem = cfgGetItem(pCfg, "timeToGetAvailableConn");
|
pItem = cfgGetItem(pCfg, "timeToGetAvailableConn");
|
||||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||||
tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 1000000);
|
tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 1000000);
|
||||||
|
@ -1039,6 +1066,9 @@ static int32_t taosSetServerLogCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "wDebugFlag");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "wDebugFlag");
|
||||||
wDebugFlag = pItem->i32;
|
wDebugFlag = pItem->i32;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "azDebugFlag");
|
||||||
|
azDebugFlag = pItem->i32;
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "sDebugFlag");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "sDebugFlag");
|
||||||
sDebugFlag = pItem->i32;
|
sDebugFlag = pItem->i32;
|
||||||
|
|
||||||
|
@ -1083,9 +1113,9 @@ int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope) {
|
||||||
|
|
||||||
int32_t slowScope = 0;
|
int32_t slowScope = 0;
|
||||||
|
|
||||||
char* scope = NULL;
|
char *scope = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
while((scope = strsep(&pScopeStr, "|")) != NULL){
|
while ((scope = strsep(&pScopeStr, "|")) != NULL) {
|
||||||
taosMemoryFreeClear(tmp);
|
taosMemoryFreeClear(tmp);
|
||||||
tmp = taosStrdup(scope);
|
tmp = taosStrdup(scope);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
|
@ -1142,13 +1172,13 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
||||||
(void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
(void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "firstEp");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "firstEp");
|
||||||
SEp firstEp = {0};
|
SEp firstEp = {0};
|
||||||
TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pItem->str) == 0 ? defaultFirstEp : pItem->str, &firstEp));
|
TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pItem->str) == 0 ? defaultFirstEp : pItem->str, &firstEp));
|
||||||
(void)snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port);
|
(void)snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port);
|
||||||
TAOS_CHECK_RETURN(cfgSetItem(pCfg, "firstEp", tsFirst, pItem->stype, true));
|
TAOS_CHECK_RETURN(cfgSetItem(pCfg, "firstEp", tsFirst, pItem->stype, true));
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "secondEp");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "secondEp");
|
||||||
SEp secondEp = {0};
|
SEp secondEp = {0};
|
||||||
TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pItem->str) == 0 ? defaultFirstEp : pItem->str, &secondEp));
|
TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pItem->str) == 0 ? defaultFirstEp : pItem->str, &secondEp));
|
||||||
(void)snprintf(tsSecond, sizeof(tsSecond), "%s:%u", secondEp.fqdn, secondEp.port);
|
(void)snprintf(tsSecond, sizeof(tsSecond), "%s:%u", secondEp.fqdn, secondEp.port);
|
||||||
TAOS_CHECK_RETURN(cfgSetItem(pCfg, "secondEp", tsSecond, pItem->stype, true));
|
TAOS_CHECK_RETURN(cfgSetItem(pCfg, "secondEp", tsSecond, pItem->stype, true));
|
||||||
|
@ -1252,6 +1282,12 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcSessions");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcSessions");
|
||||||
tsNumOfRpcSessions = pItem->i32;
|
tsNumOfRpcSessions = pItem->i32;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "shareConnLimit");
|
||||||
|
tsShareConnLimit = pItem->i32;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "readTimeout");
|
||||||
|
tsReadTimeout = pItem->i32;
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeToGetAvailableConn");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeToGetAvailableConn");
|
||||||
tsTimeToGetAvailableConn = pItem->i32;
|
tsTimeToGetAvailableConn = pItem->i32;
|
||||||
|
|
||||||
|
@ -1353,6 +1389,12 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcSessions");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcSessions");
|
||||||
tsNumOfRpcSessions = pItem->i32;
|
tsNumOfRpcSessions = pItem->i32;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "shareConnLimit");
|
||||||
|
tsShareConnLimit = pItem->i32;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "readTimeout");
|
||||||
|
tsReadTimeout = pItem->i32;
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeToGetAvailableConn");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeToGetAvailableConn");
|
||||||
tsTimeToGetAvailableConn = pItem->i32;
|
tsTimeToGetAvailableConn = pItem->i32;
|
||||||
|
|
||||||
|
@ -1651,8 +1693,8 @@ static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag);
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
|
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
SConfig *pCfg = NULL;
|
SConfig *pCfg = NULL;
|
||||||
|
|
||||||
if (tsCfg == NULL) {
|
if (tsCfg == NULL) {
|
||||||
|
@ -1724,7 +1766,7 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE), NULL, _exit);
|
TAOS_CHECK_GOTO(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE), NULL, _exit);
|
||||||
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "debugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER), NULL, _exit);
|
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "debugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER), NULL, _exit);
|
||||||
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) ,NULL, _exit);
|
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER), NULL, _exit);
|
||||||
|
|
||||||
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) {
|
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) {
|
||||||
(void)printf("failed to load cfg since %s\n", tstrerror(code));
|
(void)printf("failed to load cfg since %s\n", tstrerror(code));
|
||||||
|
@ -1753,7 +1795,7 @@ _exit:
|
||||||
|
|
||||||
static int32_t taosCheckGlobalCfg() {
|
static int32_t taosCheckGlobalCfg() {
|
||||||
uint32_t ipv4 = 0;
|
uint32_t ipv4 = 0;
|
||||||
int32_t code = taosGetIpv4FromFqdn(tsLocalFqdn, &ipv4);
|
int32_t code = taosGetIpv4FromFqdn(tsLocalFqdn, &ipv4);
|
||||||
if (code) {
|
if (code) {
|
||||||
uError("failed to get ip from fqdn:%s since %s, dnode can not be initialized", tsLocalFqdn, tstrerror(code));
|
uError("failed to get ip from fqdn:%s since %s, dnode can not be initialized", tsLocalFqdn, tstrerror(code));
|
||||||
TAOS_RETURN(TSDB_CODE_RPC_FQDN_ERROR);
|
TAOS_RETURN(TSDB_CODE_RPC_FQDN_ERROR);
|
||||||
|
@ -1858,7 +1900,7 @@ typedef struct {
|
||||||
|
|
||||||
static int32_t taosCfgSetOption(OptionNameAndVar *pOptions, int32_t optionSize, SConfigItem *pItem, bool isDebugflag) {
|
static int32_t taosCfgSetOption(OptionNameAndVar *pOptions, int32_t optionSize, SConfigItem *pItem, bool isDebugflag) {
|
||||||
int32_t code = TSDB_CODE_CFG_NOT_FOUND;
|
int32_t code = TSDB_CODE_CFG_NOT_FOUND;
|
||||||
char *name = pItem->name;
|
char *name = pItem->name;
|
||||||
for (int32_t d = 0; d < optionSize; ++d) {
|
for (int32_t d = 0; d < optionSize; ++d) {
|
||||||
const char *optName = pOptions[d].optionName;
|
const char *optName = pOptions[d].optionName;
|
||||||
if (strcasecmp(name, optName) != 0) continue;
|
if (strcasecmp(name, optName) != 0) continue;
|
||||||
|
@ -1951,13 +1993,14 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
||||||
|
|
||||||
{ // 'bool/int32_t/int64_t/float/double' variables with general modification function
|
{ // 'bool/int32_t/int64_t/float/double' variables with general modification function
|
||||||
static OptionNameAndVar debugOptions[] = {
|
static OptionNameAndVar debugOptions[] = {
|
||||||
{"dDebugFlag", &dDebugFlag}, {"vDebugFlag", &vDebugFlag}, {"mDebugFlag", &mDebugFlag},
|
{"dDebugFlag", &dDebugFlag}, {"vDebugFlag", &vDebugFlag}, {"mDebugFlag", &mDebugFlag},
|
||||||
{"wDebugFlag", &wDebugFlag}, {"sDebugFlag", &sDebugFlag}, {"tsdbDebugFlag", &tsdbDebugFlag},
|
{"wDebugFlag", &wDebugFlag}, {"azDebugFlag", &azDebugFlag}, {"sDebugFlag", &sDebugFlag},
|
||||||
{"tqDebugFlag", &tqDebugFlag}, {"fsDebugFlag", &fsDebugFlag}, {"udfDebugFlag", &udfDebugFlag},
|
{"tsdbDebugFlag", &tsdbDebugFlag}, {"tqDebugFlag", &tqDebugFlag}, {"fsDebugFlag", &fsDebugFlag},
|
||||||
{"smaDebugFlag", &smaDebugFlag}, {"idxDebugFlag", &idxDebugFlag}, {"tdbDebugFlag", &tdbDebugFlag},
|
{"udfDebugFlag", &udfDebugFlag}, {"smaDebugFlag", &smaDebugFlag}, {"idxDebugFlag", &idxDebugFlag},
|
||||||
{"tmrDebugFlag", &tmrDebugFlag}, {"uDebugFlag", &uDebugFlag}, {"smaDebugFlag", &smaDebugFlag},
|
{"tdbDebugFlag", &tdbDebugFlag}, {"tmrDebugFlag", &tmrDebugFlag}, {"uDebugFlag", &uDebugFlag},
|
||||||
{"rpcDebugFlag", &rpcDebugFlag}, {"qDebugFlag", &qDebugFlag}, {"metaDebugFlag", &metaDebugFlag},
|
{"smaDebugFlag", &smaDebugFlag}, {"rpcDebugFlag", &rpcDebugFlag}, {"qDebugFlag", &qDebugFlag},
|
||||||
{"stDebugFlag", &stDebugFlag}, {"sndDebugFlag", &sndDebugFlag}, {"tqClientDebug", &tqClientDebug},
|
{"metaDebugFlag", &metaDebugFlag}, {"stDebugFlag", &stDebugFlag}, {"sndDebugFlag", &sndDebugFlag},
|
||||||
|
{"tqClientDebug", &tqClientDebug},
|
||||||
};
|
};
|
||||||
|
|
||||||
static OptionNameAndVar options[] = {{"audit", &tsEnableAudit},
|
static OptionNameAndVar options[] = {{"audit", &tsEnableAudit},
|
||||||
|
@ -2053,8 +2096,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
|
||||||
}
|
}
|
||||||
case 'f': {
|
case 'f': {
|
||||||
if (strcasecmp("fqdn", name) == 0) {
|
if (strcasecmp("fqdn", name) == 0) {
|
||||||
SConfigItem* pFqdnItem = cfgGetItem(pCfg, "fqdn");
|
SConfigItem *pFqdnItem = cfgGetItem(pCfg, "fqdn");
|
||||||
SConfigItem* pServerPortItem = cfgGetItem(pCfg, "serverPort");
|
SConfigItem *pServerPortItem = cfgGetItem(pCfg, "serverPort");
|
||||||
SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp");
|
SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp");
|
||||||
if (pFqdnItem == NULL || pServerPortItem == NULL || pFirstEpItem == NULL) {
|
if (pFqdnItem == NULL || pServerPortItem == NULL || pFirstEpItem == NULL) {
|
||||||
uError("failed to get fqdn or serverPort or firstEp from cfg");
|
uError("failed to get fqdn or serverPort or firstEp from cfg");
|
||||||
|
@ -2069,7 +2112,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
|
||||||
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
||||||
(void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
(void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
SEp firstEp = {0};
|
SEp firstEp = {0};
|
||||||
TAOS_CHECK_GOTO(
|
TAOS_CHECK_GOTO(
|
||||||
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp), &lino,
|
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp), &lino,
|
||||||
_out);
|
_out);
|
||||||
|
@ -2109,8 +2152,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
|
||||||
}
|
}
|
||||||
case 'l': {
|
case 'l': {
|
||||||
if (strcasecmp("locale", name) == 0) {
|
if (strcasecmp("locale", name) == 0) {
|
||||||
SConfigItem* pLocaleItem = cfgGetItem(pCfg, "locale");
|
SConfigItem *pLocaleItem = cfgGetItem(pCfg, "locale");
|
||||||
SConfigItem* pCharsetItem = cfgGetItem(pCfg, "charset");
|
SConfigItem *pCharsetItem = cfgGetItem(pCfg, "charset");
|
||||||
if (pLocaleItem == NULL || pCharsetItem == NULL) {
|
if (pLocaleItem == NULL || pCharsetItem == NULL) {
|
||||||
uError("failed to get locale or charset from cfg");
|
uError("failed to get locale or charset from cfg");
|
||||||
code = TSDB_CODE_CFG_NOT_FOUND;
|
code = TSDB_CODE_CFG_NOT_FOUND;
|
||||||
|
@ -2183,7 +2226,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
|
||||||
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
||||||
(void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
(void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
||||||
SEp firstEp = {0};
|
SEp firstEp = {0};
|
||||||
TAOS_CHECK_GOTO(
|
TAOS_CHECK_GOTO(
|
||||||
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp), &lino,
|
taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp), &lino,
|
||||||
_out);
|
_out);
|
||||||
|
@ -2314,7 +2357,7 @@ int32_t taosSetGlobalDebugFlag(int32_t flag) { return taosSetAllDebugFlag(tsCfg,
|
||||||
// NOTE: set all command does not change the tmrDebugFlag
|
// NOTE: set all command does not change the tmrDebugFlag
|
||||||
static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag) {
|
static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag) {
|
||||||
if (flag < 0) TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
if (flag < 0) TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
if (flag == 0) TAOS_RETURN(TSDB_CODE_SUCCESS); // just ignore
|
if (flag == 0) TAOS_RETURN(TSDB_CODE_SUCCESS); // just ignore
|
||||||
|
|
||||||
SArray *noNeedToSetVars = NULL;
|
SArray *noNeedToSetVars = NULL;
|
||||||
SConfigItem *pItem = NULL;
|
SConfigItem *pItem = NULL;
|
||||||
|
@ -2335,6 +2378,7 @@ static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag) {
|
||||||
taosCheckAndSetDebugFlag(&vDebugFlag, "vDebugFlag", flag, noNeedToSetVars);
|
taosCheckAndSetDebugFlag(&vDebugFlag, "vDebugFlag", flag, noNeedToSetVars);
|
||||||
taosCheckAndSetDebugFlag(&mDebugFlag, "mDebugFlag", flag, noNeedToSetVars);
|
taosCheckAndSetDebugFlag(&mDebugFlag, "mDebugFlag", flag, noNeedToSetVars);
|
||||||
taosCheckAndSetDebugFlag(&wDebugFlag, "wDebugFlag", flag, noNeedToSetVars);
|
taosCheckAndSetDebugFlag(&wDebugFlag, "wDebugFlag", flag, noNeedToSetVars);
|
||||||
|
taosCheckAndSetDebugFlag(&azDebugFlag, "azDebugFlag", flag, noNeedToSetVars);
|
||||||
taosCheckAndSetDebugFlag(&sDebugFlag, "sDebugFlag", flag, noNeedToSetVars);
|
taosCheckAndSetDebugFlag(&sDebugFlag, "sDebugFlag", flag, noNeedToSetVars);
|
||||||
taosCheckAndSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag, noNeedToSetVars);
|
taosCheckAndSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag, noNeedToSetVars);
|
||||||
taosCheckAndSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag, noNeedToSetVars);
|
taosCheckAndSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag, noNeedToSetVars);
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#define TD_MSG_RANGE_CODE_
|
#define TD_MSG_RANGE_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
|
#include "tanal.h"
|
||||||
#include "tcol.h"
|
#include "tcol.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
|
@ -1453,6 +1454,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->ipWhiteVer));
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->ipWhiteVer));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->analVer));
|
||||||
TAOS_CHECK_EXIT(tSerializeSMonitorParas(&encoder, &pReq->clusterCfg.monitorParas));
|
TAOS_CHECK_EXIT(tSerializeSMonitorParas(&encoder, &pReq->clusterCfg.monitorParas));
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
@ -1576,6 +1578,10 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->ipWhiteVer));
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->ipWhiteVer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->analVer));
|
||||||
|
}
|
||||||
|
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
TAOS_CHECK_EXIT(tDeserializeSMonitorParas(&decoder, &pReq->clusterCfg.monitorParas));
|
TAOS_CHECK_EXIT(tDeserializeSMonitorParas(&decoder, &pReq->clusterCfg.monitorParas));
|
||||||
}
|
}
|
||||||
|
@ -1652,6 +1658,7 @@ int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->statusSeq));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->statusSeq));
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pRsp->ipWhiteVer));
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pRsp->ipWhiteVer));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pRsp->analVer));
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1704,6 +1711,10 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->ipWhiteVer));
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->ipWhiteVer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->analVer));
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
_exit:
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -2045,6 +2056,156 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeRetrieveAnalAlgoReq(void *buf, int32_t bufLen, SRetrieveAnalAlgoReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->dnodeId));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->analVer));
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeRetrieveAnalAlgoReq(void *buf, int32_t bufLen, SRetrieveAnalAlgoReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->dnodeId));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->analVer));
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeRetrieveAnalAlgoRsp(void *buf, int32_t bufLen, SRetrieveAnalAlgoRsp *pRsp) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
int32_t numOfAlgos = 0;
|
||||||
|
void *pIter = taosHashIterate(pRsp->hash, NULL);
|
||||||
|
while (pIter != NULL) {
|
||||||
|
SAnalUrl *pUrl = pIter;
|
||||||
|
size_t nameLen = 0;
|
||||||
|
const char *name = taosHashGetKey(pIter, &nameLen);
|
||||||
|
if (nameLen > 0 && nameLen <= TSDB_ANAL_ALGO_KEY_LEN && pUrl->urlLen > 0) {
|
||||||
|
numOfAlgos++;
|
||||||
|
}
|
||||||
|
pIter = taosHashIterate(pRsp->hash, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pRsp->ver));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, numOfAlgos));
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pRsp->hash, NULL);
|
||||||
|
while (pIter != NULL) {
|
||||||
|
SAnalUrl *pUrl = pIter;
|
||||||
|
size_t nameLen = 0;
|
||||||
|
const char *name = taosHashGetKey(pIter, &nameLen);
|
||||||
|
if (nameLen > 0 && pUrl->urlLen > 0) {
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, nameLen));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)name, nameLen));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pUrl->anode));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pUrl->type));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pUrl->urlLen));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)pUrl->url, pUrl->urlLen));
|
||||||
|
}
|
||||||
|
pIter = taosHashIterate(pRsp->hash, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeRetrieveAnalAlgoRsp(void *buf, int32_t bufLen, SRetrieveAnalAlgoRsp *pRsp) {
|
||||||
|
if (pRsp->hash == NULL) {
|
||||||
|
pRsp->hash = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
|
if (pRsp->hash == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_BUFFER;
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
int32_t numOfAlgos = 0;
|
||||||
|
int32_t nameLen;
|
||||||
|
int32_t type;
|
||||||
|
char name[TSDB_ANAL_ALGO_KEY_LEN];
|
||||||
|
SAnalUrl url = {0};
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->ver));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &numOfAlgos));
|
||||||
|
|
||||||
|
for (int32_t f = 0; f < numOfAlgos; ++f) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &nameLen));
|
||||||
|
if (nameLen > 0 && nameLen <= TSDB_ANAL_ALGO_NAME_LEN) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &url.anode));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &type));
|
||||||
|
url.type = (EAnalAlgoType)type;
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &url.urlLen));
|
||||||
|
if (url.urlLen > 0) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, (void **)&url.url, NULL) < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(taosHashPut(pRsp->hash, name, nameLen, &url, sizeof(SAnalUrl)));
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeRetrieveAnalAlgoRsp(SRetrieveAnalAlgoRsp *pRsp) {
|
||||||
|
void *pIter = taosHashIterate(pRsp->hash, NULL);
|
||||||
|
while (pIter != NULL) {
|
||||||
|
SAnalUrl *pUrl = (SAnalUrl *)pIter;
|
||||||
|
taosMemoryFree(pUrl->url);
|
||||||
|
pIter = taosHashIterate(pRsp->hash, pIter);
|
||||||
|
}
|
||||||
|
taosHashCleanup(pRsp->hash);
|
||||||
|
|
||||||
|
pRsp->hash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void tFreeSCreateUserReq(SCreateUserReq *pReq) {
|
void tFreeSCreateUserReq(SCreateUserReq *pReq) {
|
||||||
FREESQL();
|
FREESQL();
|
||||||
taosMemoryFreeClear(pReq->pIpRanges);
|
taosMemoryFreeClear(pReq->pIpRanges);
|
||||||
|
@ -2962,6 +3123,108 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateAnodeReq(void *buf, int32_t bufLen, SMCreateAnodeReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->urlLen));
|
||||||
|
if (pReq->urlLen > 0) {
|
||||||
|
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)pReq->url, pReq->urlLen));
|
||||||
|
}
|
||||||
|
ENCODESQL();
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCreateAnodeReq(void *buf, int32_t bufLen, SMCreateAnodeReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->urlLen));
|
||||||
|
if (pReq->urlLen > 0) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, (void **)&pReq->url, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
DECODESQL();
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSMCreateAnodeReq(SMCreateAnodeReq *pReq) {
|
||||||
|
taosMemoryFreeClear(pReq->url);
|
||||||
|
FREESQL();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMDropAnodeReq(void *buf, int32_t bufLen, SMDropAnodeReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->anodeId));
|
||||||
|
ENCODESQL();
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMDropAnodeReq(void *buf, int32_t bufLen, SMDropAnodeReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->anodeId));
|
||||||
|
DECODESQL();
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSMDropAnodeReq(SMDropAnodeReq *pReq) { FREESQL(); }
|
||||||
|
|
||||||
|
int32_t tSerializeSMUpdateAnodeReq(void *buf, int32_t bufLen, SMUpdateAnodeReq *pReq) {
|
||||||
|
return tSerializeSMDropAnodeReq(buf, bufLen, pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMUpdateAnodeReq(void *buf, int32_t bufLen, SMUpdateAnodeReq *pReq) {
|
||||||
|
return tDeserializeSMDropAnodeReq(buf, bufLen, pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSMUpdateAnodeReq(SMUpdateAnodeReq *pReq) { tFreeSMDropAnodeReq(pReq); }
|
||||||
|
|
||||||
int32_t tSerializeSCreateDnodeReq(void *buf, int32_t bufLen, SCreateDnodeReq *pReq) {
|
int32_t tSerializeSCreateDnodeReq(void *buf, int32_t bufLen, SCreateDnodeReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
|
@ -10,29 +10,28 @@ add_subdirectory(test)
|
||||||
aux_source_directory(exe EXEC_SRC)
|
aux_source_directory(exe EXEC_SRC)
|
||||||
add_executable(taosd ${EXEC_SRC})
|
add_executable(taosd ${EXEC_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
taosd
|
taosd
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (TD_ENTERPRISE)
|
IF(TD_ENTERPRISE)
|
||||||
IF(${BUILD_WITH_S3})
|
IF(${BUILD_WITH_S3})
|
||||||
add_definitions(-DUSE_S3)
|
add_definitions(-DUSE_S3)
|
||||||
ELSEIF(${BUILD_WITH_COS})
|
ELSEIF(${BUILD_WITH_COS})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
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)
|
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")
|
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
|
||||||
ELSE ()
|
ELSE()
|
||||||
SET(LINK_JEMALLOC "")
|
SET(LINK_JEMALLOC "")
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
|
||||||
ADD_DEPENDENCIES(taosd jemalloc)
|
|
||||||
target_link_libraries(taosd dnode crypt ${LINK_JEMALLOC})
|
|
||||||
ELSE ()
|
|
||||||
target_link_libraries(taosd dnode crypt)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
|
IF(TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||||
|
ADD_DEPENDENCIES(taosd jemalloc)
|
||||||
|
target_link_libraries(taosd dnode crypt ${LINK_JEMALLOC})
|
||||||
|
ELSE()
|
||||||
|
target_link_libraries(taosd dnode crypt)
|
||||||
|
ENDIF()
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "jemalloc/jemalloc.h"
|
#include "jemalloc/jemalloc.h"
|
||||||
#endif
|
#endif
|
||||||
#include "dmUtil.h"
|
#include "dmUtil.h"
|
||||||
|
#include "tcs.h"
|
||||||
|
|
||||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||||
#include "cus_name.h"
|
#include "cus_name.h"
|
||||||
|
@ -182,7 +183,6 @@ static void dmSetSignalHandle() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
extern bool generateNewMeta;
|
|
||||||
|
|
||||||
extern bool generateNewMeta;
|
extern bool generateNewMeta;
|
||||||
|
|
||||||
|
@ -331,10 +331,9 @@ static int32_t dmCheckS3() {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
cfgDumpCfgS3(pCfg, 0, true);
|
cfgDumpCfgS3(pCfg, 0, true);
|
||||||
#if defined(USE_S3)
|
|
||||||
extern int32_t s3CheckCfg();
|
|
||||||
|
|
||||||
code = s3CheckCfg();
|
#if defined(USE_S3)
|
||||||
|
code = tcsCheckCfg();
|
||||||
#endif
|
#endif
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
aux_source_directory(src MGMT_DNODE)
|
aux_source_directory(src MGMT_DNODE)
|
||||||
add_library(mgmt_dnode STATIC ${MGMT_DNODE})
|
add_library(mgmt_dnode STATIC ${MGMT_DNODE})
|
||||||
if (DEFINED GRANT_CFG_INCLUDE_DIR)
|
|
||||||
|
if(DEFINED GRANT_CFG_INCLUDE_DIR)
|
||||||
add_definitions(-DGRANTS_CFG)
|
add_definitions(-DGRANTS_CFG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF (NOT BUILD_DM_MODULE)
|
if(NOT BUILD_DM_MODULE)
|
||||||
MESSAGE(STATUS "NOT BUILD_DM_MODULE")
|
MESSAGE(STATUS "NOT BUILD_DM_MODULE")
|
||||||
target_link_directories(
|
target_link_directories(
|
||||||
mgmt_dnode
|
mgmt_dnode
|
||||||
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/dm_static"
|
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/dm_static"
|
||||||
)
|
)
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "BUILD_DM_MODULE")
|
MESSAGE(STATUS "BUILD_DM_MODULE")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
mgmt_dnode
|
mgmt_dnode
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
PUBLIC "${GRANT_CFG_INCLUDE_DIR}"
|
PUBLIC "${GRANT_CFG_INCLUDE_DIR}"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mgmt_dnode node_util dmodule
|
mgmt_dnode node_util dmodule
|
||||||
)
|
)
|
|
@ -18,6 +18,7 @@
|
||||||
#include "dmInt.h"
|
#include "dmInt.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
#include "tanal.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
|
|
||||||
extern SConfig *tsCfg;
|
extern SConfig *tsCfg;
|
||||||
|
@ -73,7 +74,7 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead,
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.msgType = TDMT_MND_RETRIEVE_IP_WHITE,
|
.msgType = TDMT_MND_RETRIEVE_IP_WHITE,
|
||||||
.info.ahandle = (void *)0x9527,
|
.info.ahandle = 0,
|
||||||
.info.notFreeAhandle = 1,
|
.info.notFreeAhandle = 1,
|
||||||
.info.refId = 0,
|
.info.refId = 0,
|
||||||
.info.noResp = 0,
|
.info.noResp = 0,
|
||||||
|
@ -88,6 +89,46 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmMayShouldUpdateAnalFunc(SDnodeMgmt *pMgmt, int64_t newVer) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int64_t oldVer = taosAnalGetVersion();
|
||||||
|
if (oldVer == newVer) return;
|
||||||
|
dDebug("analysis on dnode ver:%" PRId64 ", status ver:%" PRId64, oldVer, newVer);
|
||||||
|
|
||||||
|
SRetrieveAnalAlgoReq req = {.dnodeId = pMgmt->pData->dnodeId, .analVer = oldVer};
|
||||||
|
int32_t contLen = tSerializeRetrieveAnalAlgoReq(NULL, 0, &req);
|
||||||
|
if (contLen < 0) {
|
||||||
|
dError("failed to serialize analysis function ver request since %s", tstrerror(contLen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
contLen = tSerializeRetrieveAnalAlgoReq(pHead, contLen, &req);
|
||||||
|
if (contLen < 0) {
|
||||||
|
rpcFreeCont(pHead);
|
||||||
|
dError("failed to serialize analysis function ver request since %s", tstrerror(contLen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.pCont = pHead,
|
||||||
|
.contLen = contLen,
|
||||||
|
.msgType = TDMT_MND_RETRIEVE_ANAL_ALGO,
|
||||||
|
.info.ahandle = (void *)0x9527,
|
||||||
|
.info.refId = 0,
|
||||||
|
.info.noResp = 0,
|
||||||
|
.info.handle = 0,
|
||||||
|
};
|
||||||
|
SEpSet epset = {0};
|
||||||
|
|
||||||
|
(void)dmGetMnodeEpSet(pMgmt->pData, &epset);
|
||||||
|
|
||||||
|
code = rpcSendRequest(pMgmt->msgCb.clientRpc, &epset, &rpcMsg, NULL);
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to send retrieve analysis func ver request since %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
const STraceId *trace = &pRsp->info.traceId;
|
const STraceId *trace = &pRsp->info.traceId;
|
||||||
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
||||||
|
@ -115,6 +156,7 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps);
|
dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps);
|
||||||
}
|
}
|
||||||
dmMayShouldUpdateIpWhiteList(pMgmt, statusRsp.ipWhiteVer);
|
dmMayShouldUpdateIpWhiteList(pMgmt, statusRsp.ipWhiteVer);
|
||||||
|
dmMayShouldUpdateAnalFunc(pMgmt, statusRsp.analVer);
|
||||||
}
|
}
|
||||||
tFreeSStatusRsp(&statusRsp);
|
tFreeSStatusRsp(&statusRsp);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +229,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
pMgmt->statusSeq++;
|
pMgmt->statusSeq++;
|
||||||
req.statusSeq = pMgmt->statusSeq;
|
req.statusSeq = pMgmt->statusSeq;
|
||||||
req.ipWhiteVer = pMgmt->pData->ipWhiteVer;
|
req.ipWhiteVer = pMgmt->pData->ipWhiteVer;
|
||||||
|
req.analVer = taosAnalGetVersion();
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||||
if (contLen < 0) {
|
if (contLen < 0) {
|
||||||
|
@ -206,7 +249,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead,
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.msgType = TDMT_MND_STATUS,
|
.msgType = TDMT_MND_STATUS,
|
||||||
.info.ahandle = (void *)0x9527,
|
.info.ahandle = 0,
|
||||||
.info.notFreeAhandle = 1,
|
.info.notFreeAhandle = 1,
|
||||||
.info.refId = 0,
|
.info.refId = 0,
|
||||||
.info.noResp = 0,
|
.info.noResp = 0,
|
||||||
|
@ -279,7 +322,7 @@ void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) {
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead,
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.msgType = TDMT_MND_NOTIFY,
|
.msgType = TDMT_MND_NOTIFY,
|
||||||
.info.ahandle = (void *)0x9527,
|
.info.ahandle = 0,
|
||||||
.info.notFreeAhandle = 1,
|
.info.notFreeAhandle = 1,
|
||||||
.info.refId = 0,
|
.info.refId = 0,
|
||||||
.info.noResp = 1,
|
.info.noResp = 1,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmInt.h"
|
#include "dmInt.h"
|
||||||
#include "libs/function/tudf.h"
|
#include "libs/function/tudf.h"
|
||||||
|
#include "tanal.h"
|
||||||
|
|
||||||
static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) {
|
static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -84,6 +85,10 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
dError("failed to start udfd since %s", tstrerror(code));
|
dError("failed to start udfd since %s", tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((code = taosAnalInit()) != 0) {
|
||||||
|
dError("failed to init analysis env since %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
pOutput->pMgmt = pMgmt;
|
pOutput->pMgmt = pMgmt;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,9 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DNODE_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DNODE_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ANODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_UPDATE_ANODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_ANODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -180,6 +183,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_ANAL_ALGO, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_WHITELIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_WHITELIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -208,7 +212,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_VIEW_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_VIEW_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATIS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STATIS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_CLUSTER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_CLUSTER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ENCRYPT_KEY, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ENCRYPT_KEY, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -203,6 +203,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
SVnodeObj **ppVnodes = NULL;
|
SVnodeObj **ppVnodes = NULL;
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
int32_t nBytes = snprintf(file, sizeof(file), "%s%svnodes_tmp.json", pMgmt->path, TD_DIRSEP);
|
int32_t nBytes = snprintf(file, sizeof(file), "%s%svnodes_tmp.json", pMgmt->path, TD_DIRSEP);
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
if (nBytes <= 0 || nBytes >= sizeof(file)) {
|
||||||
|
@ -215,8 +216,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfVnodes = 0;
|
int32_t numOfVnodes = 0;
|
||||||
code = vmGetVnodeListFromHash(pMgmt, &numOfVnodes, &ppVnodes);
|
TAOS_CHECK_GOTO(vmGetVnodeListFromHash(pMgmt, &numOfVnodes, &ppVnodes), &lino, _OVER);
|
||||||
if (code) goto _OVER;
|
|
||||||
|
|
||||||
// terrno = TSDB_CODE_OUT_OF_MEMORY;
|
// terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
pJson = tjsonCreateObject();
|
pJson = tjsonCreateObject();
|
||||||
|
@ -224,36 +224,41 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if ((code = vmEncodeVnodeList(pJson, ppVnodes, numOfVnodes)) != 0) goto _OVER;
|
TAOS_CHECK_GOTO(vmEncodeVnodeList(pJson, ppVnodes, numOfVnodes), &lino, _OVER);
|
||||||
|
|
||||||
buffer = tjsonToString(pJson);
|
buffer = tjsonToString(pJson);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
lino = __LINE__;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
lino = __LINE__;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
lino = __LINE__;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
lino = __LINE__;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosCloseFile(&pFile);
|
code = taosCloseFile(&pFile);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
lino = __LINE__;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), &lino, _OVER);
|
||||||
|
|
||||||
dInfo("succeed to write vnodes file:%s, vnodes:%d", realfile, numOfVnodes);
|
dInfo("succeed to write vnodes file:%s, vnodes:%d", realfile, numOfVnodes);
|
||||||
|
|
||||||
|
@ -272,7 +277,8 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
dError("failed to write vnodes file:%s since %s, vnodes:%d", realfile, tstrerror(code), numOfVnodes);
|
dError("failed to write vnodes file:%s at line:%d since %s, vnodes:%d", realfile, lino, tstrerror(code),
|
||||||
|
numOfVnodes);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,17 +415,43 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// taosThreadMutexLock(&pMgmt->createLock);
|
code = taosThreadMutexLock(&pMgmt->createLock);
|
||||||
|
if (code != 0) {
|
||||||
|
dError("vgId:%d, failed to lock since %s", req.vgId, tstrerror(code));
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
code = vmWriteVnodeListToFile(pMgmt);
|
code = vmWriteVnodeListToFile(pMgmt);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno != 0 ? terrno : code;
|
code = terrno != 0 ? terrno : code;
|
||||||
// taosThreadMutexUnlock(&pMgmt->createLock);
|
int32_t ret = taosThreadMutexUnlock(&pMgmt->createLock);
|
||||||
|
if (ret != 0) {
|
||||||
|
dError("vgId:%d, failed to unlock since %s", req.vgId, tstrerror(ret));
|
||||||
|
}
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
// taosThreadMutexUnlock(&pMgmt->createLock);
|
int32_t ret = taosThreadMutexUnlock(&pMgmt->createLock);
|
||||||
|
if (ret != 0) {
|
||||||
|
dError("vgId:%d, failed to unlock since %s", req.vgId, tstrerror(ret));
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
int32_t r = 0;
|
||||||
|
r = taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to lock since %s", req.vgId, tstrerror(r));
|
||||||
|
}
|
||||||
|
if (r == 0) {
|
||||||
|
dInfo("vgId:%d, remove from hash", req.vgId);
|
||||||
|
r = taosHashRemove(pMgmt->hash, &req.vgId, sizeof(int32_t));
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to remove vnode since %s", req.vgId, tstrerror(r));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r = taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
if (r != 0) {
|
||||||
|
dError("vgId:%d, failed to unlock since %s", req.vgId, tstrerror(r));
|
||||||
|
}
|
||||||
vnodeClose(pImpl);
|
vnodeClose(pImpl);
|
||||||
vnodeDestroy(0, path, pMgmt->pTfs, 0);
|
vnodeDestroy(0, path, pMgmt->pTfs, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1037,7 +1063,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TRIM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TRIM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_S3MIGRATE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_S3MIGRATE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMultiMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_VNODE_TYPE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_VNODE_TYPE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
aux_source_directory(src IMPLEMENT_SRC)
|
aux_source_directory(src IMPLEMENT_SRC)
|
||||||
add_library(dnode STATIC ${IMPLEMENT_SRC})
|
add_library(dnode STATIC ${IMPLEMENT_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dnode mgmt_mnode mgmt_qnode mgmt_snode mgmt_vnode mgmt_dnode monitorfw
|
dnode mgmt_mnode mgmt_qnode mgmt_snode mgmt_vnode mgmt_dnode monitorfw tcs
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (TD_ENTERPRISE)
|
IF(TD_ENTERPRISE)
|
||||||
IF(${BUILD_WITH_S3})
|
IF(${BUILD_WITH_S3})
|
||||||
add_definitions(-DUSE_S3)
|
add_definitions(-DUSE_S3)
|
||||||
ELSEIF(${BUILD_WITH_COS})
|
ELSEIF(${BUILD_WITH_COS})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF (DEFINED GRANT_CFG_INCLUDE_DIR)
|
IF(DEFINED GRANT_CFG_INCLUDE_DIR)
|
||||||
add_definitions(-DGRANTS_CFG)
|
add_definitions(-DGRANTS_CFG)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
dnode
|
dnode
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "libs/function/tudf.h"
|
#include "libs/function/tudf.h"
|
||||||
#include "tgrant.h"
|
#include "tgrant.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
|
#include "tcs.h"
|
||||||
|
#include "tanal.h"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define DM_INIT_AUDIT() \
|
#define DM_INIT_AUDIT() \
|
||||||
|
@ -97,9 +99,9 @@ static bool dmDataSpaceAvailable() {
|
||||||
static int32_t dmCheckDiskSpace() {
|
static int32_t dmCheckDiskSpace() {
|
||||||
// availability
|
// availability
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
code = osUpdate();
|
code = osUpdate();
|
||||||
if(code != 0) {
|
if (code != 0) {
|
||||||
code = 0; // ignore the error, just log it
|
code = 0; // ignore the error, just log it
|
||||||
dError("failed to update os info since %s", tstrerror(code));
|
dError("failed to update os info since %s", tstrerror(code));
|
||||||
}
|
}
|
||||||
if (!dmDataSpaceAvailable()) {
|
if (!dmDataSpaceAvailable()) {
|
||||||
|
@ -162,13 +164,6 @@ static int32_t dmCheckDataDirVersionWrapper() {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if defined(USE_S3)
|
|
||||||
|
|
||||||
extern int32_t s3Begin();
|
|
||||||
extern void s3End();
|
|
||||||
extern int8_t tsS3Enabled;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t dmInit() {
|
int32_t dmInit() {
|
||||||
dInfo("start to init dnode env");
|
dInfo("start to init dnode env");
|
||||||
|
@ -186,7 +181,7 @@ int32_t dmInit() {
|
||||||
if ((code = dmInitDnode(dmInstance())) != 0) return code;
|
if ((code = dmInitDnode(dmInstance())) != 0) return code;
|
||||||
if ((code = InitRegexCache() != 0)) return code;
|
if ((code = InitRegexCache() != 0)) return code;
|
||||||
#if defined(USE_S3)
|
#if defined(USE_S3)
|
||||||
if ((code = s3Begin()) != 0) return code;
|
if ((code = tcsInit()) != 0) return code;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dInfo("dnode env is initialized");
|
dInfo("dnode env is initialized");
|
||||||
|
@ -214,12 +209,13 @@ void dmCleanup() {
|
||||||
dError("failed to close udfc");
|
dError("failed to close udfc");
|
||||||
}
|
}
|
||||||
udfStopUdfd();
|
udfStopUdfd();
|
||||||
|
taosAnalCleanup();
|
||||||
taosStopCacheRefreshWorker();
|
taosStopCacheRefreshWorker();
|
||||||
(void)dmDiskClose();
|
(void)dmDiskClose();
|
||||||
DestroyRegexCache();
|
DestroyRegexCache();
|
||||||
|
|
||||||
#if defined(USE_S3)
|
#if defined(USE_S3)
|
||||||
s3End();
|
tcsUninit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dInfo("dnode env is cleaned up");
|
dInfo("dnode env is cleaned up");
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
|
#include "tanal.h"
|
||||||
#include "tversion.h"
|
#include "tversion.h"
|
||||||
|
|
||||||
static inline void dmSendRsp(SRpcMsg *pMsg) {
|
static inline void dmSendRsp(SRpcMsg *pMsg) {
|
||||||
|
@ -106,6 +107,16 @@ static bool dmIsForbiddenIp(int8_t forbidden, char *user, uint32_t clientIp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmUpdateAnalFunc(SDnodeData *pData, void *pTrans, SRpcMsg *pRpc) {
|
||||||
|
SRetrieveAnalAlgoRsp rsp = {0};
|
||||||
|
if (tDeserializeRetrieveAnalAlgoRsp(pRpc->pCont, pRpc->contLen, &rsp) == 0) {
|
||||||
|
taosAnalUpdate(rsp.ver, rsp.hash);
|
||||||
|
rsp.hash = NULL;
|
||||||
|
}
|
||||||
|
tFreeRetrieveAnalAlgoRsp(&rsp);
|
||||||
|
rpcFreeCont(pRpc->pCont);
|
||||||
|
}
|
||||||
|
|
||||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -154,6 +165,9 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
case TDMT_MND_RETRIEVE_IP_WHITE_RSP:
|
case TDMT_MND_RETRIEVE_IP_WHITE_RSP:
|
||||||
dmUpdateRpcIpWhite(&pDnode->data, pTrans->serverRpc, pRpc);
|
dmUpdateRpcIpWhite(&pDnode->data, pTrans->serverRpc, pRpc);
|
||||||
return;
|
return;
|
||||||
|
case TDMT_MND_RETRIEVE_ANAL_ALGO_RSP:
|
||||||
|
dmUpdateAnalFunc(&pDnode->data, pTrans->serverRpc, pRpc);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +267,7 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsReq(pRpc)) {
|
if (IsReq(pRpc)) {
|
||||||
SRpcMsg rsp = {.code = code, .info = pRpc->info};
|
SRpcMsg rsp = {.code = code, .info = pRpc->info, .msgType = pRpc->msgType + 1};
|
||||||
if (code == TSDB_CODE_MNODE_NOT_FOUND) {
|
if (code == TSDB_CODE_MNODE_NOT_FOUND) {
|
||||||
dmBuildMnodeRedirectRsp(pDnode, &rsp);
|
dmBuildMnodeRedirectRsp(pDnode, &rsp);
|
||||||
}
|
}
|
||||||
|
@ -397,16 +411,19 @@ int32_t dmInitClient(SDnode *pDnode) {
|
||||||
|
|
||||||
rpcInit.noDelayFp = rpcNoDelayMsg;
|
rpcInit.noDelayFp = rpcNoDelayMsg;
|
||||||
|
|
||||||
int32_t connLimitNum = tsNumOfRpcSessions / (tsNumOfRpcThreads * 3) / 2;
|
int32_t connLimitNum = tsNumOfRpcSessions / (tsNumOfRpcThreads * 3);
|
||||||
connLimitNum = TMAX(connLimitNum, 10);
|
connLimitNum = TMAX(connLimitNum, 10);
|
||||||
connLimitNum = TMIN(connLimitNum, 500);
|
connLimitNum = TMIN(connLimitNum, 500);
|
||||||
|
|
||||||
rpcInit.connLimitNum = connLimitNum;
|
rpcInit.connLimitNum = connLimitNum;
|
||||||
rpcInit.connLimitLock = 1;
|
rpcInit.connLimitLock = 1;
|
||||||
rpcInit.supportBatch = 1;
|
rpcInit.supportBatch = 1;
|
||||||
rpcInit.batchSize = 8 * 1024;
|
rpcInit.shareConnLimit = tsShareConnLimit * 2;
|
||||||
|
rpcInit.shareConn = 1;
|
||||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||||
rpcInit.notWaitAvaliableConn = 0;
|
rpcInit.notWaitAvaliableConn = 0;
|
||||||
|
rpcInit.startReadTimer = 1;
|
||||||
|
rpcInit.readTimeout = tsReadTimeout;
|
||||||
|
|
||||||
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
||||||
dError("failed to convert version string:%s to int", version);
|
dError("failed to convert version string:%s to int", version);
|
||||||
|
@ -452,8 +469,10 @@ int32_t dmInitStatusClient(SDnode *pDnode) {
|
||||||
rpcInit.connLimitNum = connLimitNum;
|
rpcInit.connLimitNum = connLimitNum;
|
||||||
rpcInit.connLimitLock = 1;
|
rpcInit.connLimitLock = 1;
|
||||||
rpcInit.supportBatch = 1;
|
rpcInit.supportBatch = 1;
|
||||||
rpcInit.batchSize = 8 * 1024;
|
rpcInit.shareConnLimit = tsShareConnLimit * 2;
|
||||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||||
|
rpcInit.startReadTimer = 0;
|
||||||
|
rpcInit.readTimeout = 0;
|
||||||
|
|
||||||
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
||||||
dError("failed to convert version string:%s to int", version);
|
dError("failed to convert version string:%s to int", version);
|
||||||
|
@ -500,8 +519,11 @@ int32_t dmInitSyncClient(SDnode *pDnode) {
|
||||||
rpcInit.connLimitNum = connLimitNum;
|
rpcInit.connLimitNum = connLimitNum;
|
||||||
rpcInit.connLimitLock = 1;
|
rpcInit.connLimitLock = 1;
|
||||||
rpcInit.supportBatch = 1;
|
rpcInit.supportBatch = 1;
|
||||||
rpcInit.batchSize = 8 * 1024;
|
rpcInit.shareConnLimit = tsShareConnLimit * 8;
|
||||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||||
|
rpcInit.startReadTimer = 1;
|
||||||
|
rpcInit.readTimeout = tsReadTimeout;
|
||||||
|
|
||||||
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
||||||
dError("failed to convert version string:%s to int", version);
|
dError("failed to convert version string:%s to int", version);
|
||||||
}
|
}
|
||||||
|
@ -555,6 +577,7 @@ int32_t dmInitServer(SDnode *pDnode) {
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
|
rpcInit.shareConnLimit = tsShareConnLimit * 16;
|
||||||
|
|
||||||
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
if (taosVersionStrToInt(version, &(rpcInit.compatibilityVer)) != 0) {
|
||||||
dError("failed to convert version string:%s to int", version);
|
dError("failed to convert version string:%s to int", version);
|
||||||
|
|
|
@ -1,41 +1,46 @@
|
||||||
aux_source_directory(src MNODE_SRC)
|
aux_source_directory(src MNODE_SRC)
|
||||||
IF (TD_PRIVILEGE)
|
|
||||||
|
if(TD_PRIVILEGE)
|
||||||
ADD_DEFINITIONS(-D_PRIVILEGE)
|
ADD_DEFINITIONS(-D_PRIVILEGE)
|
||||||
ENDIF ()
|
endif()
|
||||||
IF (TD_ENTERPRISE)
|
|
||||||
|
if(TD_ENTERPRISE)
|
||||||
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/privilege/src/privilege.c)
|
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/privilege/src/privilege.c)
|
||||||
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndDb.c)
|
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndDb.c)
|
||||||
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndVgroup.c)
|
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndVgroup.c)
|
||||||
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndDnode.c)
|
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/mnode/src/mndDnode.c)
|
||||||
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/mndView.c)
|
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/view/src/mndView.c)
|
||||||
|
|
||||||
IF(${BUILD_WITH_S3})
|
if(${BUILD_WITH_S3})
|
||||||
add_definitions(-DUSE_S3)
|
add_definitions(-DUSE_S3)
|
||||||
ELSEIF(${BUILD_WITH_COS})
|
ELSEIF(${BUILD_WITH_COS})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
ENDIF ()
|
if(${BUILD_WITH_ANALYSIS})
|
||||||
|
add_definitions(-DUSE_ANAL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(mnode STATIC ${MNODE_SRC})
|
add_library(mnode STATIC ${MNODE_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
mnode
|
mnode
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode"
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mnode scheduler sdb wal transport cjson sync monitor executor qworker stream parser audit monitorfw
|
mnode scheduler sdb wal transport cjson sync monitor executor qworker stream parser audit monitorfw
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (DEFINED GRANT_CFG_INCLUDE_DIR)
|
if(DEFINED GRANT_CFG_INCLUDE_DIR)
|
||||||
add_definitions(-DGRANTS_CFG)
|
add_definitions(-DGRANTS_CFG)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF (TD_GRANT)
|
if(TD_GRANT)
|
||||||
TARGET_LINK_LIBRARIES(mnode grant)
|
TARGET_LINK_LIBRARIES(mnode grant)
|
||||||
ADD_DEFINITIONS(-D_GRANT)
|
ADD_DEFINITIONS(-D_GRANT)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_MND_ANODE_H_
|
||||||
|
#define _TD_MND_ANODE_H_
|
||||||
|
|
||||||
|
#include "mndInt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t mndInitAnode(SMnode *pMnode);
|
||||||
|
void mndCleanupAnode(SMnode *pMnode);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_MND_ANODE_H_*/
|
|
@ -78,6 +78,9 @@ typedef enum {
|
||||||
MND_OPER_DROP_VIEW,
|
MND_OPER_DROP_VIEW,
|
||||||
MND_OPER_CONFIG_CLUSTER,
|
MND_OPER_CONFIG_CLUSTER,
|
||||||
MND_OPER_BALANCE_VGROUP_LEADER,
|
MND_OPER_BALANCE_VGROUP_LEADER,
|
||||||
|
MND_OPER_CREATE_ANODE,
|
||||||
|
MND_OPER_UPDATE_ANODE,
|
||||||
|
MND_OPER_DROP_ANODE
|
||||||
} EOperType;
|
} EOperType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -232,6 +235,24 @@ typedef struct {
|
||||||
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||||
} SDnodeObj;
|
} SDnodeObj;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t nameLen;
|
||||||
|
char* name;
|
||||||
|
} SAnodeAlgo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t id;
|
||||||
|
int64_t createdTime;
|
||||||
|
int64_t updateTime;
|
||||||
|
int32_t version;
|
||||||
|
int32_t urlLen;
|
||||||
|
int32_t numOfAlgos;
|
||||||
|
int32_t status;
|
||||||
|
SRWLatch lock;
|
||||||
|
char* url;
|
||||||
|
SArray** algos;
|
||||||
|
} SAnodeObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
|
|
|
@ -0,0 +1,903 @@
|
||||||
|
/*
|
||||||
|
* 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 _DEFAULT_SOURCE
|
||||||
|
#include "mndAnode.h"
|
||||||
|
#include "audit.h"
|
||||||
|
#include "mndDnode.h"
|
||||||
|
#include "mndPrivilege.h"
|
||||||
|
#include "mndShow.h"
|
||||||
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
#include "tanal.h"
|
||||||
|
#include "tjson.h"
|
||||||
|
|
||||||
|
#ifdef USE_ANAL
|
||||||
|
|
||||||
|
#define TSDB_ANODE_VER_NUMBER 1
|
||||||
|
#define TSDB_ANODE_RESERVE_SIZE 64
|
||||||
|
|
||||||
|
static SSdbRaw *mndAnodeActionEncode(SAnodeObj *pObj);
|
||||||
|
static SSdbRow *mndAnodeActionDecode(SSdbRaw *pRaw);
|
||||||
|
static int32_t mndAnodeActionInsert(SSdb *pSdb, SAnodeObj *pObj);
|
||||||
|
static int32_t mndAnodeActionUpdate(SSdb *pSdb, SAnodeObj *pOld, SAnodeObj *pNew);
|
||||||
|
static int32_t mndAnodeActionDelete(SSdb *pSdb, SAnodeObj *pObj);
|
||||||
|
static int32_t mndProcessCreateAnodeReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessUpdateAnodeReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessDropAnodeReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessAnalAlgoReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndRetrieveAnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
|
static void mndCancelGetNextAnode(SMnode *pMnode, void *pIter);
|
||||||
|
static int32_t mndRetrieveAnodesFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
|
static void mndCancelGetNextAnodeFull(SMnode *pMnode, void *pIter);
|
||||||
|
static int32_t mndGetAnodeAlgoList(const char *url, SAnodeObj *pObj);
|
||||||
|
static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status, int32_t statusLen);
|
||||||
|
|
||||||
|
int32_t mndInitAnode(SMnode *pMnode) {
|
||||||
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_ANODE,
|
||||||
|
.keyType = SDB_KEY_INT32,
|
||||||
|
.encodeFp = (SdbEncodeFp)mndAnodeActionEncode,
|
||||||
|
.decodeFp = (SdbDecodeFp)mndAnodeActionDecode,
|
||||||
|
.insertFp = (SdbInsertFp)mndAnodeActionInsert,
|
||||||
|
.updateFp = (SdbUpdateFp)mndAnodeActionUpdate,
|
||||||
|
.deleteFp = (SdbDeleteFp)mndAnodeActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ANODE, mndProcessCreateAnodeReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_UPDATE_ANODE, mndProcessUpdateAnodeReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_ANODE, mndProcessDropAnodeReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_RETRIEVE_ANAL_ALGO, mndProcessAnalAlgoReq);
|
||||||
|
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ANODE, mndRetrieveAnodes);
|
||||||
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_ANODE, mndCancelGetNextAnode);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ANODE_FULL, mndRetrieveAnodesFull);
|
||||||
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_ANODE_FULL, mndCancelGetNextAnodeFull);
|
||||||
|
|
||||||
|
return sdbSetTable(pMnode->pSdb, table);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mndCleanupAnode(SMnode *pMnode) {}
|
||||||
|
|
||||||
|
SAnodeObj *mndAcquireAnode(SMnode *pMnode, int32_t anodeId) {
|
||||||
|
SAnodeObj *pObj = sdbAcquire(pMnode->pSdb, SDB_ANODE, &anodeId);
|
||||||
|
if (pObj == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
|
||||||
|
terrno = TSDB_CODE_MND_ANODE_NOT_EXIST;
|
||||||
|
}
|
||||||
|
return pObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mndReleaseAnode(SMnode *pMnode, SAnodeObj *pObj) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSdbRaw *mndAnodeActionEncode(SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
int32_t rawDataLen = sizeof(SAnodeObj) + TSDB_ANODE_RESERVE_SIZE + pObj->urlLen;
|
||||||
|
for (int32_t t = 0; t < pObj->numOfAlgos; ++t) {
|
||||||
|
SArray *algos = pObj->algos[t];
|
||||||
|
for (int32_t a = 0; a < (int32_t)taosArrayGetSize(algos); ++a) {
|
||||||
|
SAnodeAlgo *algo = taosArrayGet(algos, a);
|
||||||
|
rawDataLen += (2 * sizeof(int32_t) + algo->nameLen);
|
||||||
|
}
|
||||||
|
rawDataLen += sizeof(int32_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_ANODE, TSDB_ANODE_VER_NUMBER, rawDataLen);
|
||||||
|
if (pRaw == NULL) goto _OVER;
|
||||||
|
|
||||||
|
int32_t dataPos = 0;
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pObj->id, _OVER)
|
||||||
|
SDB_SET_INT64(pRaw, dataPos, pObj->createdTime, _OVER)
|
||||||
|
SDB_SET_INT64(pRaw, dataPos, pObj->updateTime, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pObj->version, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pObj->urlLen, _OVER)
|
||||||
|
SDB_SET_BINARY(pRaw, dataPos, pObj->url, pObj->urlLen, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pObj->numOfAlgos, _OVER)
|
||||||
|
for (int32_t i = 0; i < pObj->numOfAlgos; ++i) {
|
||||||
|
SArray *algos = pObj->algos[i];
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, (int32_t)taosArrayGetSize(algos), _OVER)
|
||||||
|
for (int32_t j = 0; j < (int32_t)taosArrayGetSize(algos); ++j) {
|
||||||
|
SAnodeAlgo *algo = taosArrayGet(algos, j);
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, algo->nameLen, _OVER)
|
||||||
|
SDB_SET_BINARY(pRaw, dataPos, algo->name, algo->nameLen, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, 0, _OVER) // reserved
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDB_SET_RESERVE(pRaw, dataPos, TSDB_ANODE_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
|
terrno = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (terrno != 0) {
|
||||||
|
mError("anode:%d, failed to encode to raw:%p since %s", pObj->id, pRaw, terrstr());
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrace("anode:%d, encode to raw:%p, row:%p", pObj->id, pRaw, pObj);
|
||||||
|
return pRaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSdbRow *mndAnodeActionDecode(SSdbRaw *pRaw) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
SSdbRow *pRow = NULL;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
|
||||||
|
int8_t sver = 0;
|
||||||
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||||
|
|
||||||
|
if (sver != TSDB_ANODE_VER_NUMBER) {
|
||||||
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pRow = sdbAllocRow(sizeof(SAnodeObj));
|
||||||
|
if (pRow == NULL) goto _OVER;
|
||||||
|
|
||||||
|
pObj = sdbGetRowObj(pRow);
|
||||||
|
if (pObj == NULL) goto _OVER;
|
||||||
|
|
||||||
|
int32_t dataPos = 0;
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pObj->id, _OVER)
|
||||||
|
SDB_GET_INT64(pRaw, dataPos, &pObj->createdTime, _OVER)
|
||||||
|
SDB_GET_INT64(pRaw, dataPos, &pObj->updateTime, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pObj->version, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pObj->urlLen, _OVER)
|
||||||
|
|
||||||
|
if (pObj->urlLen > 0) {
|
||||||
|
pObj->url = taosMemoryCalloc(pObj->urlLen, 1);
|
||||||
|
if (pObj->url == NULL) goto _OVER;
|
||||||
|
SDB_GET_BINARY(pRaw, dataPos, pObj->url, pObj->urlLen, _OVER)
|
||||||
|
}
|
||||||
|
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pObj->numOfAlgos, _OVER)
|
||||||
|
if (pObj->numOfAlgos > 0) {
|
||||||
|
pObj->algos = taosMemoryCalloc(pObj->numOfAlgos, sizeof(SArray *));
|
||||||
|
if (pObj->algos == NULL) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pObj->numOfAlgos; ++i) {
|
||||||
|
int32_t numOfAlgos = 0;
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &numOfAlgos, _OVER)
|
||||||
|
|
||||||
|
pObj->algos[i] = taosArrayInit(2, sizeof(SAnodeAlgo));
|
||||||
|
if (pObj->algos[i] == NULL) goto _OVER;
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < numOfAlgos; ++j) {
|
||||||
|
SAnodeAlgo algoObj = {0};
|
||||||
|
int32_t reserved = 0;
|
||||||
|
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &algoObj.nameLen, _OVER)
|
||||||
|
if (algoObj.nameLen > 0) {
|
||||||
|
algoObj.name = taosMemoryCalloc(algoObj.nameLen, 1);
|
||||||
|
if (algoObj.name == NULL) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDB_GET_BINARY(pRaw, dataPos, algoObj.name, algoObj.nameLen, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &reserved, _OVER);
|
||||||
|
|
||||||
|
if (taosArrayPush(pObj->algos[i], &algoObj) == NULL) goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDB_GET_RESERVE(pRaw, dataPos, TSDB_ANODE_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
|
terrno = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (terrno != 0) {
|
||||||
|
mError("anode:%d, failed to decode from raw:%p since %s", pObj == NULL ? 0 : pObj->id, pRaw, terrstr());
|
||||||
|
if (pObj != NULL) {
|
||||||
|
taosMemoryFreeClear(pObj->url);
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pRow);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrace("anode:%d, decode from raw:%p, row:%p", pObj->id, pRaw, pObj);
|
||||||
|
return pRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndFreeAnode(SAnodeObj *pObj) {
|
||||||
|
taosMemoryFreeClear(pObj->url);
|
||||||
|
for (int32_t i = 0; i < pObj->numOfAlgos; ++i) {
|
||||||
|
SArray *algos = pObj->algos[i];
|
||||||
|
for (int32_t j = 0; j < (int32_t)taosArrayGetSize(algos); ++j) {
|
||||||
|
SAnodeAlgo *algo = taosArrayGet(algos, j);
|
||||||
|
taosMemoryFreeClear(algo->name);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(algos);
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pObj->algos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndAnodeActionInsert(SSdb *pSdb, SAnodeObj *pObj) {
|
||||||
|
mTrace("anode:%d, perform insert action, row:%p", pObj->id, pObj);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndAnodeActionDelete(SSdb *pSdb, SAnodeObj *pObj) {
|
||||||
|
mTrace("anode:%d, perform delete action, row:%p", pObj->id, pObj);
|
||||||
|
mndFreeAnode(pObj);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndAnodeActionUpdate(SSdb *pSdb, SAnodeObj *pOld, SAnodeObj *pNew) {
|
||||||
|
mTrace("anode:%d, perform update action, old row:%p new row:%p", pOld->id, pOld, pNew);
|
||||||
|
|
||||||
|
taosWLockLatch(&pOld->lock);
|
||||||
|
int32_t numOfAlgos = pNew->numOfAlgos;
|
||||||
|
void *algos = pNew->algos;
|
||||||
|
pNew->numOfAlgos = pOld->numOfAlgos;
|
||||||
|
pNew->algos = pOld->algos;
|
||||||
|
pOld->numOfAlgos = numOfAlgos;
|
||||||
|
pOld->algos = algos;
|
||||||
|
pOld->updateTime = pNew->updateTime;
|
||||||
|
pOld->version = pNew->version;
|
||||||
|
taosWUnLockLatch(&pOld->lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetCreateAnodeRedoLogs(STrans *pTrans, SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SSdbRaw *pRedoRaw = mndAnodeActionEncode(pObj);
|
||||||
|
if (pRedoRaw == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw));
|
||||||
|
TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING));
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetCreateAnodeUndoLogs(STrans *pTrans, SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SSdbRaw *pUndoRaw = mndAnodeActionEncode(pObj);
|
||||||
|
if (pUndoRaw == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
TAOS_CHECK_RETURN(mndTransAppendUndolog(pTrans, pUndoRaw));
|
||||||
|
TAOS_CHECK_RETURN(sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED));
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetCreateAnodeCommitLogs(STrans *pTrans, SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SSdbRaw *pCommitRaw = mndAnodeActionEncode(pObj);
|
||||||
|
if (pCommitRaw == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
TAOS_CHECK_RETURN(mndTransAppendCommitlog(pTrans, pCommitRaw));
|
||||||
|
TAOS_CHECK_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndCreateAnode(SMnode *pMnode, SRpcMsg *pReq, SMCreateAnodeReq *pCreate) {
|
||||||
|
int32_t code = -1;
|
||||||
|
STrans *pTrans = NULL;
|
||||||
|
|
||||||
|
SAnodeObj anodeObj = {0};
|
||||||
|
anodeObj.id = sdbGetMaxId(pMnode->pSdb, SDB_ANODE);
|
||||||
|
anodeObj.createdTime = taosGetTimestampMs();
|
||||||
|
anodeObj.updateTime = anodeObj.createdTime;
|
||||||
|
anodeObj.version = 0;
|
||||||
|
anodeObj.urlLen = pCreate->urlLen;
|
||||||
|
if (anodeObj.urlLen > TSDB_ANAL_ANODE_URL_LEN) {
|
||||||
|
code = TSDB_CODE_MND_ANODE_TOO_LONG_URL;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
anodeObj.url = taosMemoryCalloc(1, pCreate->urlLen);
|
||||||
|
if (anodeObj.url == NULL) goto _OVER;
|
||||||
|
(void)memcpy(anodeObj.url, pCreate->url, pCreate->urlLen);
|
||||||
|
|
||||||
|
code = mndGetAnodeAlgoList(anodeObj.url, &anodeObj);
|
||||||
|
if (code != 0) goto _OVER;
|
||||||
|
|
||||||
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-anode");
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
mndTransSetSerial(pTrans);
|
||||||
|
|
||||||
|
mInfo("trans:%d, used to create anode:%s as anode:%d", pTrans->id, pCreate->url, anodeObj.id);
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(mndSetCreateAnodeRedoLogs(pTrans, &anodeObj), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndSetCreateAnodeUndoLogs(pTrans, &anodeObj), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndSetCreateAnodeCommitLogs(pTrans, &anodeObj), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndFreeAnode(&anodeObj);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SAnodeObj *mndAcquireAnodeByURL(SMnode *pMnode, char *url) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
while (1) {
|
||||||
|
SAnodeObj *pAnode = NULL;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_ANODE, pIter, (void **)&pAnode);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (strcasecmp(url, pAnode->url) == 0) {
|
||||||
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
return pAnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pAnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
terrno = TSDB_CODE_MND_ANODE_NOT_EXIST;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessCreateAnodeReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = -1;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
SMCreateAnodeReq createReq = {0};
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(tDeserializeSMCreateAnodeReq(pReq->pCont, pReq->contLen, &createReq), NULL, _OVER);
|
||||||
|
|
||||||
|
mInfo("anode:%s, start to create", createReq.url);
|
||||||
|
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_ANODE), NULL, _OVER);
|
||||||
|
|
||||||
|
pObj = mndAcquireAnodeByURL(pMnode, createReq.url);
|
||||||
|
if (pObj != NULL) {
|
||||||
|
code = TSDB_CODE_MND_ANODE_ALREADY_EXIST;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateAnode(pMnode, pReq, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
mError("anode:%s, failed to create since %s", createReq.url, tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseAnode(pMnode, pObj);
|
||||||
|
tFreeSMCreateAnodeReq(&createReq);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndUpdateAnode(SMnode *pMnode, SAnodeObj *pAnode, SRpcMsg *pReq) {
|
||||||
|
mInfo("anode:%d, start to update", pAnode->id);
|
||||||
|
int32_t code = -1;
|
||||||
|
STrans *pTrans = NULL;
|
||||||
|
SAnodeObj anodeObj = {0};
|
||||||
|
anodeObj.id = pAnode->id;
|
||||||
|
anodeObj.updateTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
code = mndGetAnodeAlgoList(pAnode->url, &anodeObj);
|
||||||
|
if (code != 0) goto _OVER;
|
||||||
|
|
||||||
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-anode");
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
mInfo("trans:%d, used to update anode:%d", pTrans->id, anodeObj.id);
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(mndSetCreateAnodeCommitLogs(pTrans, &anodeObj), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndFreeAnode(&anodeObj);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndUpdateAllAnodes(SMnode *pMnode, SRpcMsg *pReq) {
|
||||||
|
mInfo("update all anodes");
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t rows = 0;
|
||||||
|
int32_t numOfRows = sdbGetSize(pSdb, SDB_ANODE);
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
while (1) {
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
ESdbStatus objStatus = 0;
|
||||||
|
pIter = sdbFetchAll(pSdb, SDB_ANODE, pIter, (void **)&pObj, &objStatus, true);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
rows++;
|
||||||
|
void *transReq = NULL;
|
||||||
|
if (rows == numOfRows) transReq = pReq;
|
||||||
|
code = mndUpdateAnode(pMnode, pObj, transReq);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
if (code != 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code == 0 && rows == numOfRows) {
|
||||||
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessUpdateAnodeReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = -1;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
SMUpdateAnodeReq updateReq = {0};
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(tDeserializeSMUpdateAnodeReq(pReq->pCont, pReq->contLen, &updateReq), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_UPDATE_ANODE), NULL, _OVER);
|
||||||
|
|
||||||
|
if (updateReq.anodeId == -1) {
|
||||||
|
code = mndUpdateAllAnodes(pMnode, pReq);
|
||||||
|
} else {
|
||||||
|
pObj = mndAcquireAnode(pMnode, updateReq.anodeId);
|
||||||
|
if (pObj == NULL) {
|
||||||
|
code = TSDB_CODE_MND_ANODE_NOT_EXIST;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
code = mndUpdateAnode(pMnode, pObj, pReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
if (updateReq.anodeId != -1) {
|
||||||
|
mError("anode:%d, failed to update since %s", updateReq.anodeId, tstrerror(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseAnode(pMnode, pObj);
|
||||||
|
tFreeSMUpdateAnodeReq(&updateReq);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetDropAnodeRedoLogs(STrans *pTrans, SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SSdbRaw *pRedoRaw = mndAnodeActionEncode(pObj);
|
||||||
|
if (pRedoRaw == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw));
|
||||||
|
TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING));
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetDropAnodeCommitLogs(STrans *pTrans, SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SSdbRaw *pCommitRaw = mndAnodeActionEncode(pObj);
|
||||||
|
if (pCommitRaw == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
TAOS_CHECK_RETURN(mndTransAppendCommitlog(pTrans, pCommitRaw));
|
||||||
|
TAOS_CHECK_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED));
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetDropAnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SAnodeObj *pObj, bool force) {
|
||||||
|
if (pObj == NULL) return 0;
|
||||||
|
TAOS_CHECK_RETURN(mndSetDropAnodeRedoLogs(pTrans, pObj));
|
||||||
|
TAOS_CHECK_RETURN(mndSetDropAnodeCommitLogs(pTrans, pObj));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndDropAnode(SMnode *pMnode, SRpcMsg *pReq, SAnodeObj *pObj) {
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-anode");
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
mndTransSetSerial(pTrans);
|
||||||
|
|
||||||
|
mInfo("trans:%d, used to drop anode:%d", pTrans->id, pObj->id);
|
||||||
|
TAOS_CHECK_GOTO(mndSetDropAnodeInfoToTrans(pMnode, pTrans, pObj, false), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessDropAnodeReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = -1;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
SMDropAnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(tDeserializeSMDropAnodeReq(pReq->pCont, pReq->contLen, &dropReq), NULL, _OVER);
|
||||||
|
|
||||||
|
mInfo("anode:%d, start to drop", dropReq.anodeId);
|
||||||
|
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_ANODE), NULL, _OVER);
|
||||||
|
|
||||||
|
if (dropReq.anodeId <= 0) {
|
||||||
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pObj = mndAcquireAnode(pMnode, dropReq.anodeId);
|
||||||
|
if (pObj == NULL) {
|
||||||
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropAnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
mError("anode:%d, failed to drop since %s", dropReq.anodeId, tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseAnode(pMnode, pObj);
|
||||||
|
tFreeSMDropAnodeReq(&dropReq);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndRetrieveAnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
int32_t cols = 0;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
char buf[TSDB_ANAL_ANODE_URL_LEN + VARSTR_HEADER_SIZE];
|
||||||
|
char status[64];
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
while (numOfRows < rows) {
|
||||||
|
pShow->pIter = sdbFetch(pSdb, SDB_ANODE, pShow->pIter, (void **)&pObj);
|
||||||
|
if (pShow->pIter == NULL) break;
|
||||||
|
|
||||||
|
cols = 0;
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(buf, pObj->url, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)buf, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
status[0] = 0;
|
||||||
|
if (mndGetAnodeStatus(pObj, status, 64) == 0) {
|
||||||
|
STR_TO_VARSTR(buf, status);
|
||||||
|
} else {
|
||||||
|
STR_TO_VARSTR(buf, "offline");
|
||||||
|
}
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->updateTime, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
numOfRows++;
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != 0) sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
pShow->numOfRows += numOfRows;
|
||||||
|
return numOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndCancelGetNextAnode(SMnode *pMnode, void *pIter) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
sdbCancelFetchByType(pSdb, pIter, SDB_ANODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndRetrieveAnodesFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
int32_t cols = 0;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
char buf[TSDB_ANAL_ALGO_NAME_LEN + VARSTR_HEADER_SIZE];
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
while (numOfRows < rows) {
|
||||||
|
pShow->pIter = sdbFetch(pSdb, SDB_ANODE, pShow->pIter, (void **)&pObj);
|
||||||
|
if (pShow->pIter == NULL) break;
|
||||||
|
|
||||||
|
for (int32_t t = 0; t < pObj->numOfAlgos; ++t) {
|
||||||
|
SArray *algos = pObj->algos[t];
|
||||||
|
|
||||||
|
for (int32_t a = 0; a < taosArrayGetSize(algos); ++a) {
|
||||||
|
SAnodeAlgo *algo = taosArrayGet(algos, a);
|
||||||
|
|
||||||
|
cols = 0;
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
STR_TO_VARSTR(buf, taosAnalAlgoStr(t));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
STR_TO_VARSTR(buf, algo->name);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
|
if (code != 0) goto _end;
|
||||||
|
|
||||||
|
numOfRows++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != 0) sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
pShow->numOfRows += numOfRows;
|
||||||
|
return numOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndCancelGetNextAnodeFull(SMnode *pMnode, void *pIter) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
sdbCancelFetchByType(pSdb, pIter, SDB_ANODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndDecodeAlgoList(SJson *pJson, SAnodeObj *pObj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t protocol = 0;
|
||||||
|
double tmp = 0;
|
||||||
|
char buf[TSDB_ANAL_ALGO_NAME_LEN + 1] = {0};
|
||||||
|
|
||||||
|
code = tjsonGetDoubleValue(pJson, "protocol", &tmp);
|
||||||
|
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
protocol = (int32_t)(tmp * 1000);
|
||||||
|
if (protocol != 100 && protocol != 1000) return TSDB_CODE_MND_ANODE_INVALID_PROTOCOL;
|
||||||
|
|
||||||
|
code = tjsonGetDoubleValue(pJson, "version", &tmp);
|
||||||
|
pObj->version = (int32_t)(tmp * 1000);
|
||||||
|
#if 0
|
||||||
|
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
if (pObj->version <= 0) return TSDB_CODE_MND_ANODE_INVALID_VERSION;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SJson *details = tjsonGetObjectItem(pJson, "details");
|
||||||
|
if (details == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
int32_t numOfDetails = tjsonGetArraySize(details);
|
||||||
|
|
||||||
|
pObj->algos = taosMemoryCalloc(ANAL_ALGO_TYPE_END, sizeof(SArray *));
|
||||||
|
if (pObj->algos == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
pObj->numOfAlgos = ANAL_ALGO_TYPE_END;
|
||||||
|
for (int32_t i = 0; i < ANAL_ALGO_TYPE_END; ++i) {
|
||||||
|
pObj->algos[i] = taosArrayInit(4, sizeof(SAnodeAlgo));
|
||||||
|
if (pObj->algos[i] == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t d = 0; d < numOfDetails; ++d) {
|
||||||
|
SJson *detail = tjsonGetArrayItem(details, d);
|
||||||
|
if (detail == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
|
||||||
|
code = tjsonGetStringValue2(detail, "type", buf, sizeof(buf));
|
||||||
|
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
EAnalAlgoType type = taosAnalAlgoInt(buf);
|
||||||
|
if (type < 0 || type >= ANAL_ALGO_TYPE_END) return TSDB_CODE_MND_ANODE_INVALID_ALGO_TYPE;
|
||||||
|
|
||||||
|
SJson *algos = tjsonGetObjectItem(detail, "algo");
|
||||||
|
if (algos == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
int32_t numOfAlgos = tjsonGetArraySize(algos);
|
||||||
|
for (int32_t a = 0; a < numOfAlgos; ++a) {
|
||||||
|
SJson *algo = tjsonGetArrayItem(algos, a);
|
||||||
|
if (algo == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
|
||||||
|
code = tjsonGetStringValue2(algo, "name", buf, sizeof(buf));
|
||||||
|
if (code < 0) return TSDB_CODE_MND_ANODE_TOO_LONG_ALGO_NAME;
|
||||||
|
|
||||||
|
SAnodeAlgo algoObj = {0};
|
||||||
|
algoObj.nameLen = strlen(buf) + 1;
|
||||||
|
if (algoObj.nameLen <= 1) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
algoObj.name = taosMemoryCalloc(algoObj.nameLen, 1);
|
||||||
|
tstrncpy(algoObj.name, buf, algoObj.nameLen);
|
||||||
|
|
||||||
|
if (taosArrayPush(pObj->algos[type], &algoObj) == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndGetAnodeAlgoList(const char *url, SAnodeObj *pObj) {
|
||||||
|
char anodeUrl[TSDB_ANAL_ANODE_URL_LEN + 1] = {0};
|
||||||
|
snprintf(anodeUrl, TSDB_ANAL_ANODE_URL_LEN, "%s/%s", url, "list");
|
||||||
|
|
||||||
|
SJson *pJson = taosAnalSendReqRetJson(anodeUrl, ANAL_HTTP_TYPE_GET, NULL);
|
||||||
|
if (pJson == NULL) return terrno;
|
||||||
|
|
||||||
|
int32_t code = mndDecodeAlgoList(pJson, pObj);
|
||||||
|
if (pJson != NULL) tjsonDelete(pJson);
|
||||||
|
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status, int32_t statusLen) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t protocol = 0;
|
||||||
|
double tmp = 0;
|
||||||
|
char anodeUrl[TSDB_ANAL_ANODE_URL_LEN + 1] = {0};
|
||||||
|
snprintf(anodeUrl, TSDB_ANAL_ANODE_URL_LEN, "%s/%s", pObj->url, "status");
|
||||||
|
|
||||||
|
SJson *pJson = taosAnalSendReqRetJson(anodeUrl, ANAL_HTTP_TYPE_GET, NULL);
|
||||||
|
if (pJson == NULL) return terrno;
|
||||||
|
|
||||||
|
code = tjsonGetDoubleValue(pJson, "protocol", &tmp);
|
||||||
|
if (code < 0) {
|
||||||
|
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
protocol = (int32_t)(tmp * 1000);
|
||||||
|
if (protocol != 100 && protocol != 1000) {
|
||||||
|
code = TSDB_CODE_MND_ANODE_INVALID_PROTOCOL;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tjsonGetStringValue2(pJson, "status", status, statusLen);
|
||||||
|
if (code < 0) {
|
||||||
|
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
if (strlen(status) == 0) {
|
||||||
|
code = TSDB_CODE_MND_ANODE_INVALID_PROTOCOL;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (pJson != NULL) tjsonDelete(pJson);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessAnalAlgoReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
int32_t code = -1;
|
||||||
|
SAnodeObj *pObj = NULL;
|
||||||
|
SAnalUrl url;
|
||||||
|
int32_t nameLen;
|
||||||
|
char name[TSDB_ANAL_ALGO_KEY_LEN];
|
||||||
|
SRetrieveAnalAlgoReq req = {0};
|
||||||
|
SRetrieveAnalAlgoRsp rsp = {0};
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(tDeserializeRetrieveAnalAlgoReq(pReq->pCont, pReq->contLen, &req), NULL, _OVER);
|
||||||
|
|
||||||
|
rsp.ver = sdbGetTableVer(pSdb, SDB_ANODE);
|
||||||
|
if (req.analVer != rsp.ver) {
|
||||||
|
mInfo("dnode:%d, update analysis old ver:%" PRId64 " to new ver:%" PRId64, req.dnodeId, req.analVer, rsp.ver);
|
||||||
|
rsp.hash = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
|
if (rsp.hash == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
while (1) {
|
||||||
|
SAnodeObj *pAnode = NULL;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_ANODE, pIter, (void **)&pAnode);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
url.anode = pAnode->id;
|
||||||
|
for (int32_t t = 0; t < pAnode->numOfAlgos; ++t) {
|
||||||
|
SArray *algos = pAnode->algos[t];
|
||||||
|
url.type = t;
|
||||||
|
|
||||||
|
for (int32_t a = 0; a < taosArrayGetSize(algos); ++a) {
|
||||||
|
SAnodeAlgo *algo = taosArrayGet(algos, a);
|
||||||
|
nameLen = 1 + tsnprintf(name, sizeof(name) - 1, "%d:%s", url.type, algo->name);
|
||||||
|
|
||||||
|
SAnalUrl *pOldUrl = taosHashAcquire(rsp.hash, name, nameLen);
|
||||||
|
if (pOldUrl == NULL || (pOldUrl != NULL && pOldUrl->anode < url.anode)) {
|
||||||
|
if (pOldUrl != NULL) {
|
||||||
|
taosMemoryFreeClear(pOldUrl->url);
|
||||||
|
if (taosHashRemove(rsp.hash, name, nameLen) != 0) {
|
||||||
|
sdbRelease(pSdb, pAnode);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
url.url = taosMemoryMalloc(TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN + 1);
|
||||||
|
if (url.url == NULL) {
|
||||||
|
sdbRelease(pSdb, pAnode);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
url.urlLen = 1 + tsnprintf(url.url, TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN, "%s/%s", pAnode->url,
|
||||||
|
taosAnalAlgoUrlStr(url.type));
|
||||||
|
if (taosHashPut(rsp.hash, name, nameLen, &url, sizeof(SAnalUrl)) != 0) {
|
||||||
|
taosMemoryFree(url.url);
|
||||||
|
sdbRelease(pSdb, pAnode);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pAnode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeRetrieveAnalAlgoRsp(NULL, 0, &rsp);
|
||||||
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
(void)tSerializeRetrieveAnalAlgoRsp(pHead, contLen, &rsp);
|
||||||
|
|
||||||
|
pReq->info.rspLen = contLen;
|
||||||
|
pReq->info.rsp = pHead;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
tFreeRetrieveAnalAlgoRsp(&rsp);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static int32_t mndProcessUnsupportReq(SRpcMsg *pReq) { return TSDB_CODE_OPS_NOT_SUPPORT; }
|
||||||
|
static int32_t mndRetrieveUnsupport(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndInitAnode(SMnode *pMnode) {
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ANODE, mndProcessUnsupportReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_UPDATE_ANODE, mndProcessUnsupportReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_ANODE, mndProcessUnsupportReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_RETRIEVE_ANAL_ALGO, mndProcessUnsupportReq);
|
||||||
|
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ANODE, mndRetrieveUnsupport);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ANODE_FULL, mndRetrieveUnsupport);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mndCleanupAnode(SMnode *pMnode) {}
|
||||||
|
|
||||||
|
#endif
|
|
@ -15,13 +15,10 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndArbGroup.h"
|
#include "mndArbGroup.h"
|
||||||
#include "audit.h"
|
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndPrivilege.h"
|
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
|
||||||
#define ARBGROUP_VER_NUMBER 1
|
#define ARBGROUP_VER_NUMBER 1
|
||||||
|
@ -245,11 +242,11 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
(void)memcpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
}
|
}
|
||||||
pOld->isSync = pNew->isSync;
|
pOld->isSync = pNew->isSync;
|
||||||
pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId;
|
pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId;
|
||||||
(void)memcpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
||||||
pOld->version++;
|
pOld->version++;
|
||||||
|
|
||||||
|
@ -834,12 +831,12 @@ static int32_t mndProcessArbUpdateGroupBatchReq(SRpcMsg *pReq) {
|
||||||
newGroup.dbUid = pUpdateGroup->dbUid;
|
newGroup.dbUid = pUpdateGroup->dbUid;
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
newGroup.members[i].info.dnodeId = pUpdateGroup->members[i].dnodeId;
|
newGroup.members[i].info.dnodeId = pUpdateGroup->members[i].dnodeId;
|
||||||
(void)memcpy(newGroup.members[i].state.token, pUpdateGroup->members[i].token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(newGroup.members[i].state.token, pUpdateGroup->members[i].token, TSDB_ARB_TOKEN_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
newGroup.isSync = pUpdateGroup->isSync;
|
newGroup.isSync = pUpdateGroup->isSync;
|
||||||
newGroup.assignedLeader.dnodeId = pUpdateGroup->assignedLeader.dnodeId;
|
newGroup.assignedLeader.dnodeId = pUpdateGroup->assignedLeader.dnodeId;
|
||||||
(void)memcpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
||||||
newGroup.version = pUpdateGroup->version;
|
newGroup.version = pUpdateGroup->version;
|
||||||
|
|
||||||
|
@ -897,7 +894,7 @@ static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index) {
|
||||||
SArbGroupMember *pMember = &pGroup->members[index];
|
SArbGroupMember *pMember = &pGroup->members[index];
|
||||||
|
|
||||||
pGroup->assignedLeader.dnodeId = pMember->info.dnodeId;
|
pGroup->assignedLeader.dnodeId = pMember->info.dnodeId;
|
||||||
(void)strncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pGroup->assignedLeader.acked = false;
|
pGroup->assignedLeader.acked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +976,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
||||||
|
|
||||||
// update token
|
// update token
|
||||||
mndArbGroupDupObj(pGroup, pNewGroup);
|
mndArbGroupDupObj(pGroup, pNewGroup);
|
||||||
(void)memcpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE);
|
||||||
pNewGroup->isSync = false;
|
pNewGroup->isSync = false;
|
||||||
|
|
||||||
bool resetAssigned = false;
|
bool resetAssigned = false;
|
||||||
|
|
|
@ -730,6 +730,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
pMnode->ipWhiteVer = mndGetIpWhiteVer(pMnode);
|
pMnode->ipWhiteVer = mndGetIpWhiteVer(pMnode);
|
||||||
|
|
||||||
|
int64_t analVer = sdbGetTableVer(pMnode->pSdb, SDB_ANODE);
|
||||||
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||||
|
@ -738,7 +739,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
||||||
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
||||||
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
|
||||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
bool analVerChanged = (analVer != statusReq.analVer);
|
||||||
|
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged || analVerChanged ||
|
||||||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
|
@ -862,6 +864,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
SStatusRsp statusRsp = {0};
|
SStatusRsp statusRsp = {0};
|
||||||
statusRsp.statusSeq++;
|
statusRsp.statusSeq++;
|
||||||
|
statusRsp.analVer = analVer;
|
||||||
statusRsp.dnodeVer = dnodeVer;
|
statusRsp.dnodeVer = dnodeVer;
|
||||||
statusRsp.dnodeCfg.dnodeId = pDnode->id;
|
statusRsp.dnodeCfg.dnodeId = pDnode->id;
|
||||||
statusRsp.dnodeCfg.clusterId = pMnode->clusterId;
|
statusRsp.dnodeCfg.clusterId = pMnode->clusterId;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndAcct.h"
|
#include "mndAcct.h"
|
||||||
#include "mndArbGroup.h"
|
#include "mndArbGroup.h"
|
||||||
|
#include "mndAnode.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndCompact.h"
|
#include "mndCompact.h"
|
||||||
#include "mndCompactDetail.h"
|
#include "mndCompactDetail.h"
|
||||||
|
@ -236,7 +237,7 @@ static void mndPullupGrant(SMnode *pMnode) {
|
||||||
.pCont = pReq,
|
.pCont = pReq,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.info.notFreeAhandle = 1,
|
.info.notFreeAhandle = 1,
|
||||||
.info.ahandle = (void *)0x9527};
|
.info.ahandle = 0};
|
||||||
// TODO check return value
|
// TODO check return value
|
||||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||||
|
@ -608,6 +609,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
|
||||||
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-mnode", mndInitMnode, mndCleanupMnode));
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-mnode", mndInitMnode, mndCleanupMnode));
|
||||||
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-qnode", mndInitQnode, mndCleanupQnode));
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-qnode", mndInitQnode, mndCleanupQnode));
|
||||||
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-snode", mndInitSnode, mndCleanupSnode));
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-snode", mndInitSnode, mndCleanupSnode));
|
||||||
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-anode", mndInitAnode, mndCleanupAnode));
|
||||||
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-arbgroup", mndInitArbGroup, mndCleanupArbGroup));
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-arbgroup", mndInitArbGroup, mndCleanupArbGroup));
|
||||||
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-dnode", mndInitDnode, mndCleanupDnode));
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-dnode", mndInitDnode, mndCleanupDnode));
|
||||||
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser));
|
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser));
|
||||||
|
|
|
@ -30,9 +30,9 @@ void mndPostProcessQueryMsg(SRpcMsg *pMsg) {
|
||||||
(void)qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
(void)qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndProcessQueryMsg(SRpcMsg *pMsg, SQueueInfo* pInfo) {
|
int32_t mndProcessQueryMsg(SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
|
|
||||||
SReadHandle handle = {.mnd = pMnode, .pMsgCb = &pMnode->msgCb, .pWorkerCb = pInfo->workerCb};
|
SReadHandle handle = {.mnd = pMnode, .pMsgCb = &pMnode->msgCb, .pWorkerCb = pInfo->workerCb};
|
||||||
|
|
||||||
|
@ -67,26 +67,25 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg, SQueueInfo* pInfo) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void mnodeFreeSBatchRspMsg(void *p) {
|
||||||
static FORCE_INLINE void mnodeFreeSBatchRspMsg(void* p) {
|
|
||||||
if (NULL == p) {
|
if (NULL == p) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SBatchRspMsg* pRsp = (SBatchRspMsg*)p;
|
SBatchRspMsg *pRsp = (SBatchRspMsg *)p;
|
||||||
rpcFreeCont(pRsp->msg);
|
rpcFreeCont(pRsp->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t rspSize = 0;
|
int32_t rspSize = 0;
|
||||||
SBatchReq batchReq = {0};
|
SBatchReq batchReq = {0};
|
||||||
SBatchMsg req = {0};
|
SBatchMsg req = {0};
|
||||||
SBatchRspMsg rsp = {0};
|
SBatchRspMsg rsp = {0};
|
||||||
SBatchRsp batchRsp = {0};
|
SBatchRsp batchRsp = {0};
|
||||||
SRpcMsg reqMsg = *pMsg;
|
SRpcMsg reqMsg = *pMsg;
|
||||||
void *pRsp = NULL;
|
void *pRsp = NULL;
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
|
|
||||||
if ((code = tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) != 0) {
|
if ((code = tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) != 0) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -94,7 +93,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
|
int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
|
||||||
if (msgNum >= MAX_META_MSG_IN_BATCH) {
|
if (msgNum >= MAX_META_MSG_IN_BATCH) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
mError("too many msgs %d in mnode batch meta req", msgNum);
|
mError("too many msgs %d in mnode batch meta req", msgNum);
|
||||||
|
@ -108,7 +107,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < msgNum; ++i) {
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
SBatchMsg* req = taosArrayGet(batchReq.pMsgs, i);
|
SBatchMsg *req = taosArrayGet(batchReq.pMsgs, i);
|
||||||
|
|
||||||
reqMsg.msgType = req->msgType;
|
reqMsg.msgType = req->msgType;
|
||||||
reqMsg.pCont = req->msg;
|
reqMsg.pCont = req->msg;
|
||||||
|
|
|
@ -68,6 +68,10 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_QNODE;
|
type = TSDB_MGMT_TABLE_QNODE;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_SNODE;
|
type = TSDB_MGMT_TABLE_SNODE;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_ANODES, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_ANODE;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_ANODES_FULL, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_ANODE_FULL;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_ARBGROUP;
|
type = TSDB_MGMT_TABLE_ARBGROUP;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
|
||||||
|
|
|
@ -2252,7 +2252,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
||||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||||
len += snprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
len += tsnprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
||||||
((SExprNode *)pFunc)->userAlias);
|
((SExprNode *)pFunc)->userAlias);
|
||||||
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
||||||
len = TSDB_MAX_SAVED_SQL_LEN;
|
len = TSDB_MAX_SAVED_SQL_LEN;
|
||||||
|
|
|
@ -4,7 +4,7 @@ aux_source_directory(. MNODE_ARBGROUP_TEST_SRC)
|
||||||
add_executable(arbgroupTest ${MNODE_ARBGROUP_TEST_SRC})
|
add_executable(arbgroupTest ${MNODE_ARBGROUP_TEST_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
arbgroupTest
|
arbgroupTest
|
||||||
PRIVATE dnode nodes planner gtest qcom
|
PRIVATE dnode nodes planner gtest qcom tcs
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test(
|
add_test(
|
||||||
|
|
|
@ -161,7 +161,8 @@ typedef enum {
|
||||||
SDB_COMPACT_DETAIL = 25,
|
SDB_COMPACT_DETAIL = 25,
|
||||||
SDB_GRANT = 26, // grant log
|
SDB_GRANT = 26, // grant log
|
||||||
SDB_ARBGROUP = 27,
|
SDB_ARBGROUP = 27,
|
||||||
SDB_MAX = 28
|
SDB_ANODE = 28,
|
||||||
|
SDB_MAX = 29
|
||||||
} ESdbType;
|
} ESdbType;
|
||||||
|
|
||||||
typedef struct SSdbRaw {
|
typedef struct SSdbRaw {
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#define SDB_RESERVE_SIZE 512
|
#define SDB_RESERVE_SIZE 512
|
||||||
#define SDB_FILE_VER 1
|
#define SDB_FILE_VER 1
|
||||||
|
|
||||||
|
#define SDB_TABLE_SIZE_EXTRA SDB_MAX
|
||||||
|
#define SDB_RESERVE_SIZE_EXTRA (512 - (SDB_TABLE_SIZE_EXTRA - SDB_TABLE_SIZE) * 2 * sizeof(int64_t))
|
||||||
|
|
||||||
static int32_t sdbDeployData(SSdb *pSdb) {
|
static int32_t sdbDeployData(SSdb *pSdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
mInfo("start to deploy sdb");
|
mInfo("start to deploy sdb");
|
||||||
|
@ -154,7 +157,38 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char reserve[SDB_RESERVE_SIZE] = {0};
|
// for sdb compatibility
|
||||||
|
for (int32_t i = SDB_TABLE_SIZE; i < SDB_TABLE_SIZE_EXTRA; ++i) {
|
||||||
|
int64_t maxId = 0;
|
||||||
|
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
|
||||||
|
if (ret < 0) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
if (ret != sizeof(int64_t)) {
|
||||||
|
code = TSDB_CODE_FILE_CORRUPTED;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
if (i < SDB_MAX) {
|
||||||
|
pSdb->maxId[i] = maxId;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t ver = 0;
|
||||||
|
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
|
||||||
|
if (ret < 0) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
if (ret != sizeof(int64_t)) {
|
||||||
|
code = TSDB_CODE_FILE_CORRUPTED;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
if (i < SDB_MAX) {
|
||||||
|
pSdb->tableVer[i] = ver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char reserve[SDB_RESERVE_SIZE_EXTRA] = {0};
|
||||||
ret = taosReadFile(pFile, reserve, sizeof(reserve));
|
ret = taosReadFile(pFile, reserve, sizeof(reserve));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -207,7 +241,26 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char reserve[SDB_RESERVE_SIZE] = {0};
|
// for sdb compatibility
|
||||||
|
for (int32_t i = SDB_TABLE_SIZE; i < SDB_TABLE_SIZE_EXTRA; ++i) {
|
||||||
|
int64_t maxId = 0;
|
||||||
|
if (i < SDB_MAX) {
|
||||||
|
maxId = pSdb->maxId[i];
|
||||||
|
}
|
||||||
|
if (taosWriteFile(pFile, &maxId, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t ver = 0;
|
||||||
|
if (i < SDB_MAX) {
|
||||||
|
ver = pSdb->tableVer[i];
|
||||||
|
}
|
||||||
|
if (taosWriteFile(pFile, &ver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char reserve[SDB_RESERVE_SIZE_EXTRA] = {0};
|
||||||
if (taosWriteFile(pFile, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
if (taosWriteFile(pFile, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,8 @@ const char *sdbTableName(ESdbType type) {
|
||||||
return "grant";
|
return "grant";
|
||||||
case SDB_ARBGROUP:
|
case SDB_ARBGROUP:
|
||||||
return "arb_group";
|
return "arb_group";
|
||||||
|
case SDB_ANODE:
|
||||||
|
return "anode";
|
||||||
default:
|
default:
|
||||||
return "undefine";
|
return "undefine";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,26 @@
|
||||||
# vnode
|
# vnode
|
||||||
add_subdirectory(src/tqCommon)
|
add_subdirectory(src/tqCommon)
|
||||||
add_library(vnode STATIC "")
|
add_library(vnode STATIC "")
|
||||||
|
|
||||||
if(${TD_DARWIN})
|
if(${TD_DARWIN})
|
||||||
target_compile_options(vnode PRIVATE -Wno-error=single-bit-bitfield-constant-conversion)
|
target_compile_options(vnode PRIVATE -Wno-error=single-bit-bitfield-constant-conversion)
|
||||||
endif(${TD_DARWIN})
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
set(
|
set(
|
||||||
VNODE_SOURCE_FILES
|
VNODE_SOURCE_FILES
|
||||||
"src/vnd/vnodeOpen.c"
|
"src/vnd/vnodeOpen.c"
|
||||||
"src/vnd/vnodeBufPool.c"
|
"src/vnd/vnodeBufPool.c"
|
||||||
"src/vnd/vnodeCfg.c"
|
"src/vnd/vnodeCfg.c"
|
||||||
"src/vnd/vnodeCommit.c"
|
"src/vnd/vnodeCommit.c"
|
||||||
"src/vnd/vnodeQuery.c"
|
"src/vnd/vnodeQuery.c"
|
||||||
"src/vnd/vnodeModule.c"
|
"src/vnd/vnodeModule.c"
|
||||||
"src/vnd/vnodeSvr.c"
|
"src/vnd/vnodeSvr.c"
|
||||||
"src/vnd/vnodeSync.c"
|
"src/vnd/vnodeSync.c"
|
||||||
"src/vnd/vnodeSnapshot.c"
|
"src/vnd/vnodeSnapshot.c"
|
||||||
"src/vnd/vnodeRetention.c"
|
"src/vnd/vnodeRetention.c"
|
||||||
"src/vnd/vnodeInitApi.c"
|
"src/vnd/vnodeInitApi.c"
|
||||||
"src/vnd/vnodeAsync.c"
|
"src/vnd/vnodeAsync.c"
|
||||||
"src/vnd/vnodeHash.c"
|
"src/vnd/vnodeHash.c"
|
||||||
|
|
||||||
# meta
|
# meta
|
||||||
"src/meta/metaOpen.c"
|
"src/meta/metaOpen.c"
|
||||||
|
@ -40,23 +42,23 @@ set(
|
||||||
"src/sma/smaSnapshot.c"
|
"src/sma/smaSnapshot.c"
|
||||||
"src/sma/smaTimeRange.c"
|
"src/sma/smaTimeRange.c"
|
||||||
|
|
||||||
# # tsdb
|
# # tsdb
|
||||||
# "src/tsdb/tsdbCommit.c"
|
# "src/tsdb/tsdbCommit.c"
|
||||||
# "src/tsdb/tsdbFile.c"
|
# "src/tsdb/tsdbFile.c"
|
||||||
# "src/tsdb/tsdbFS.c"
|
# "src/tsdb/tsdbFS.c"
|
||||||
# "src/tsdb/tsdbOpen.c"
|
# "src/tsdb/tsdbOpen.c"
|
||||||
# "src/tsdb/tsdbMemTable.c"
|
# "src/tsdb/tsdbMemTable.c"
|
||||||
# "src/tsdb/tsdbRead.c"
|
# "src/tsdb/tsdbRead.c"
|
||||||
# "src/tsdb/tsdbCache.c"
|
# "src/tsdb/tsdbCache.c"
|
||||||
# "src/tsdb/tsdbWrite.c"
|
# "src/tsdb/tsdbWrite.c"
|
||||||
# "src/tsdb/tsdbReaderWriter.c"
|
# "src/tsdb/tsdbReaderWriter.c"
|
||||||
# "src/tsdb/tsdbUtil.c"
|
# "src/tsdb/tsdbUtil.c"
|
||||||
# "src/tsdb/tsdbSnapshot.c"
|
# "src/tsdb/tsdbSnapshot.c"
|
||||||
# "src/tsdb/tsdbCacheRead.c"
|
# "src/tsdb/tsdbCacheRead.c"
|
||||||
# "src/tsdb/tsdbRetention.c"
|
# "src/tsdb/tsdbRetention.c"
|
||||||
# "src/tsdb/tsdbDiskData.c"
|
# "src/tsdb/tsdbDiskData.c"
|
||||||
# "src/tsdb/tsdbMergeTree.c"
|
# "src/tsdb/tsdbMergeTree.c"
|
||||||
# "src/tsdb/tsdbDataIter.c"
|
# "src/tsdb/tsdbDataIter.c"
|
||||||
|
|
||||||
# tq
|
# tq
|
||||||
"src/tq/tq.c"
|
"src/tq/tq.c"
|
||||||
|
@ -71,14 +73,13 @@ set(
|
||||||
"src/tq/tqSnapshot.c"
|
"src/tq/tqSnapshot.c"
|
||||||
"src/tq/tqStreamStateSnap.c"
|
"src/tq/tqStreamStateSnap.c"
|
||||||
"src/tq/tqStreamTaskSnap.c"
|
"src/tq/tqStreamTaskSnap.c"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
aux_source_directory("src/tsdb/" TSDB_SOURCE_FILES)
|
aux_source_directory("src/tsdb/" TSDB_SOURCE_FILES)
|
||||||
list(
|
list(
|
||||||
APPEND
|
APPEND
|
||||||
VNODE_SOURCE_FILES
|
VNODE_SOURCE_FILES
|
||||||
${TSDB_SOURCE_FILES}
|
${TSDB_SOURCE_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(
|
target_sources(
|
||||||
|
@ -87,38 +88,38 @@ target_sources(
|
||||||
${VNODE_SOURCE_FILES}
|
${VNODE_SOURCE_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (TD_VNODE_PLUGINS)
|
if(TD_VNODE_PLUGINS)
|
||||||
target_sources(
|
target_sources(
|
||||||
vnode
|
vnode
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/tsdbCompact.c
|
${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/tsdbCompact.c
|
||||||
${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/tsdbCompactMonitor.c
|
${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/tsdbCompactMonitor.c
|
||||||
${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/vnodeCompact.c
|
${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/vnodeCompact.c
|
||||||
)
|
)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
# IF (NOT ${TD_LINUX})
|
# if (NOT ${TD_LINUX})
|
||||||
# target_include_directories(
|
# target_include_directories(
|
||||||
# vnode
|
# vnode
|
||||||
# PUBLIC "inc"
|
# PUBLIC "inc"
|
||||||
# PUBLIC "src/inc"
|
# PUBLIC "src/inc"
|
||||||
# PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
# PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
# PUBLIC "${TD_SOURCE_DIR}/contrib/rocksdb/include"
|
# PUBLIC "${TD_SOURCE_DIR}/contrib/rocksdb/include"
|
||||||
# )
|
# )
|
||||||
# ELSE()
|
# ELSE()
|
||||||
# target_include_directories(
|
# target_include_directories(
|
||||||
# vnode
|
# vnode
|
||||||
# PUBLIC "inc"
|
# PUBLIC "inc"
|
||||||
# PUBLIC "src/inc"
|
# PUBLIC "src/inc"
|
||||||
# PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
# PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
# )
|
# )
|
||||||
#ENDIF(NOT ${TD_LINUX})
|
# endif(NOT ${TD_LINUX})
|
||||||
|
if(${BUILD_CONTRIB})
|
||||||
if (${BUILD_CONTRIB})
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
vnode
|
vnode
|
||||||
PUBLIC "inc"
|
PUBLIC "inc"
|
||||||
PUBLIC "src/inc"
|
PUBLIC "src/inc"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/tcs"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
||||||
|
@ -129,24 +130,26 @@ else()
|
||||||
vnode
|
vnode
|
||||||
PUBLIC "inc"
|
PUBLIC "inc"
|
||||||
PUBLIC "src/inc"
|
PUBLIC "src/inc"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/tcs"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
||||||
)
|
)
|
||||||
if (${TD_LINUX})
|
|
||||||
target_include_directories(
|
if(${TD_LINUX})
|
||||||
vnode
|
target_include_directories(
|
||||||
|
vnode
|
||||||
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/rocksdb_static"
|
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/rocksdb_static"
|
||||||
)
|
)
|
||||||
target_link_directories(
|
target_link_directories(
|
||||||
vnode
|
vnode
|
||||||
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/rocksdb_static"
|
PUBLIC "${TD_SOURCE_DIR}/deps/${TD_DEPS_DIR}/rocksdb_static"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_directories(
|
target_link_directories(
|
||||||
vnode
|
vnode
|
||||||
PUBLIC "${CMAKE_BINARY_DIR}/build/lib"
|
PUBLIC "${CMAKE_BINARY_DIR}/build/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -164,10 +167,11 @@ target_link_libraries(
|
||||||
PUBLIC tdb
|
PUBLIC tdb
|
||||||
PUBLIC audit
|
PUBLIC audit
|
||||||
PUBLIC crypt
|
PUBLIC crypt
|
||||||
|
PUBLIC tcs
|
||||||
|
|
||||||
# PUBLIC bdb
|
# PUBLIC bdb
|
||||||
# PUBLIC scalar
|
# PUBLIC scalar
|
||||||
#PUBLIC zstd
|
# PUBLIC zstd
|
||||||
PUBLIC rocksdb
|
PUBLIC rocksdb
|
||||||
PUBLIC transport
|
PUBLIC transport
|
||||||
PUBLIC stream
|
PUBLIC stream
|
||||||
|
@ -175,9 +179,9 @@ target_link_libraries(
|
||||||
PUBLIC tqCommon
|
PUBLIC tqCommon
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (TD_GRANT)
|
if(TD_GRANT)
|
||||||
TARGET_LINK_LIBRARIES(vnode PUBLIC grant)
|
TARGET_LINK_LIBRARIES(vnode PUBLIC grant)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(vnode PUBLIC -DMETA_REFACT)
|
target_compile_definitions(vnode PUBLIC -DMETA_REFACT)
|
||||||
|
|
||||||
|
|
|
@ -746,13 +746,13 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOutputInfo->tbSink.pTblInfo = tSimpleHashInit(10240, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
pOutputInfo->tbSink.pTbInfo = tSimpleHashInit(10240, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
||||||
if (pOutputInfo->tbSink.pTblInfo == NULL) {
|
if (pOutputInfo->tbSink.pTbInfo == NULL) {
|
||||||
tqError("vgId:%d failed init sink tableInfo, code:%s", vgId, tstrerror(terrno));
|
tqError("vgId:%d failed init sink tableInfo, code:%s", vgId, tstrerror(terrno));
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
tSimpleHashSetFreeFp(pOutputInfo->tbSink.pTblInfo, freePtr);
|
tSimpleHashSetFreeFp(pOutputInfo->tbSink.pTbInfo, freePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
|
#define IS_NEW_SUBTB_RULE(_t) (((_t)->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER) && ((_t)->subtableWithoutMd5 != 1))
|
||||||
|
|
||||||
typedef struct STableSinkInfo {
|
typedef struct STableSinkInfo {
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
tstr name;
|
tstr name;
|
||||||
|
@ -35,16 +37,22 @@ static int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema
|
||||||
int64_t earlyTs, const char* id);
|
int64_t earlyTs, const char* id);
|
||||||
static int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkInfo* pTableSinkInfo,
|
static int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkInfo* pTableSinkInfo,
|
||||||
const char* dstTableName, int64_t* uid);
|
const char* dstTableName, int64_t* uid);
|
||||||
static int32_t doPutIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId,
|
|
||||||
const char* id);
|
|
||||||
static int32_t doRemoveFromCache(SSHashObj* pSinkTableMap, uint64_t groupId, const char* id);
|
|
||||||
static bool isValidDstChildTable(SMetaReader* pReader, int32_t vgId, const char* ctbName, int64_t suid);
|
static bool isValidDstChildTable(SMetaReader* pReader, int32_t vgId, const char* ctbName, int64_t suid);
|
||||||
static int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const char* stbFullName,
|
static int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const char* stbFullName,
|
||||||
int32_t numOfTags);
|
int32_t numOfTags);
|
||||||
static int32_t createDefaultTagColName(SArray** pColNameList);
|
static int32_t createDefaultTagColName(SArray** pColNameList);
|
||||||
static int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName,
|
static int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock,
|
||||||
int64_t gid, bool newSubTableRule);
|
const char* stbFullName, int64_t gid, bool newSubTableRule);
|
||||||
static int32_t doCreateSinkInfo(const char* pDstTableName, STableSinkInfo** pInfo);
|
static int32_t doCreateSinkTableInfo(const char* pDstTableName, STableSinkInfo** pInfo);
|
||||||
|
static int32_t doPutSinkTableInfoIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId,
|
||||||
|
const char* id);
|
||||||
|
static bool doGetSinkTableInfoFromCache(SSHashObj* pTableInfoMap, uint64_t groupId, STableSinkInfo** pInfo);
|
||||||
|
static int32_t doRemoveSinkTableInfoInCache(SSHashObj* pSinkTableMap, uint64_t groupId, const char* id);
|
||||||
|
static int32_t checkTagSchema(SStreamTask* pTask, SVnode* pVnode);
|
||||||
|
static void reubuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVnode* pVnode, int64_t earlyTs);
|
||||||
|
static int32_t handleResultBlockMsg(SStreamTask* pTask, SSDataBlock* pDataBlock, int32_t index, SVnode* pVnode,
|
||||||
|
int64_t earlyTs);
|
||||||
|
|
||||||
int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* pDataBlock, SBatchDeleteReq* deleteReq,
|
int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* pDataBlock, SBatchDeleteReq* deleteReq,
|
||||||
const char* pIdStr, bool newSubTableRule) {
|
const char* pIdStr, bool newSubTableRule) {
|
||||||
|
@ -81,7 +89,8 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
||||||
|
|
||||||
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
||||||
name[varDataLen(varTbName)] = '\0';
|
name[varDataLen(varTbName)] = '\0';
|
||||||
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name, groupId) && groupId != 0 && stbFullName) {
|
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name, groupId) && groupId != 0 &&
|
||||||
|
stbFullName) {
|
||||||
int32_t code = buildCtbNameAddGroupId(stbFullName, name, groupId, cap);
|
int32_t code = buildCtbNameAddGroupId(stbFullName, name, groupId, cap);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -161,16 +170,6 @@ end:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tqGetTableInfo(SSHashObj* pTableInfoMap, uint64_t groupId, STableSinkInfo** pInfo) {
|
|
||||||
void* pVal = tSimpleHashGet(pTableInfoMap, &groupId, sizeof(uint64_t));
|
|
||||||
if (pVal) {
|
|
||||||
*pInfo = *(STableSinkInfo**)pVal;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tqPutReqToQueue(SVnode* pVnode, SVCreateTbBatchReq* pReqs) {
|
static int32_t tqPutReqToQueue(SVnode* pVnode, SVCreateTbBatchReq* pReqs) {
|
||||||
void* buf = NULL;
|
void* buf = NULL;
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
@ -201,7 +200,7 @@ int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const
|
||||||
int32_t code = tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
int32_t code = tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
pCreateTableReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name));
|
pCreateTableReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name));
|
||||||
if (pCreateTableReq->ctb.stbName == NULL) { // ignore this error code
|
if (pCreateTableReq->ctb.stbName == NULL) { // ignore this error code
|
||||||
tqError("failed to duplicate the stb name:%s, failed to init create-table msg and create req table", stbFullName);
|
tqError("failed to duplicate the stb name:%s, failed to init create-table msg and create req table", stbFullName);
|
||||||
code = terrno;
|
code = terrno;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +230,7 @@ int32_t createDefaultTagColName(SArray** pColNameList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName,
|
int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName,
|
||||||
int64_t gid, bool newSubTableRule) {
|
int64_t gid, bool newSubTableRule) {
|
||||||
if (pDataBlock->info.parTbName[0]) {
|
if (pDataBlock->info.parTbName[0]) {
|
||||||
if (newSubTableRule && !isAutoTableName(pDataBlock->info.parTbName) &&
|
if (newSubTableRule && !isAutoTableName(pDataBlock->info.parTbName) &&
|
||||||
!alreadyAddGroupId(pDataBlock->info.parTbName, gid) && gid != 0 && stbFullName) {
|
!alreadyAddGroupId(pDataBlock->info.parTbName, gid) && gid != 0 && stbFullName) {
|
||||||
|
@ -245,18 +244,17 @@ int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock*
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
// tqDebug("gen name from:%s", pDataBlock->info.parTbName);
|
// tqDebug("gen name from:%s", pDataBlock->info.parTbName);
|
||||||
} else {
|
} else {
|
||||||
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
||||||
if (pCreateTableReq->name == NULL) {
|
if (pCreateTableReq->name == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
// tqDebug("copy name:%s", pDataBlock->info.parTbName);
|
// tqDebug("copy name:%s", pDataBlock->info.parTbName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32_t code = buildCtbNameByGroupId(stbFullName, gid, &pCreateTableReq->name);
|
int32_t code = buildCtbNameByGroupId(stbFullName, gid, &pCreateTableReq->name);
|
||||||
return code;
|
return code;
|
||||||
// tqDebug("gen name from stbFullName:%s gid:%"PRId64, stbFullName, gid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -264,16 +262,20 @@ int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock*
|
||||||
|
|
||||||
static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* pDataBlock,
|
static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* pDataBlock,
|
||||||
SStreamTask* pTask, int64_t suid) {
|
SStreamTask* pTask, int64_t suid) {
|
||||||
STSchema* pTSchema = pTask->outputInfo.tbSink.pTSchema;
|
STSchema* pTSchema = pTask->outputInfo.tbSink.pTSchema;
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
SArray* tagArray = taosArrayInit(4, sizeof(STagVal));
|
SArray* tagArray = NULL;
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
int32_t vgId = pTask->pMeta->vgId;
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
STableSinkInfo* pInfo = NULL;
|
||||||
|
SVCreateTbBatchReq reqs = {0};
|
||||||
|
SArray* crTblArray = NULL;
|
||||||
|
|
||||||
tqDebug("s-task:%s build create %d table(s) msg", id, rows);
|
tqDebug("s-task:%s build create %d table(s) msg", id, rows);
|
||||||
SVCreateTbBatchReq reqs = {0};
|
|
||||||
SArray* crTblArray = reqs.pArray = taosArrayInit(1, sizeof(SVCreateTbReq));
|
tagArray = taosArrayInit(4, sizeof(STagVal));
|
||||||
|
crTblArray = reqs.pArray = taosArrayInit(1, sizeof(SVCreateTbReq));
|
||||||
if ((NULL == reqs.pArray) || (tagArray == NULL)) {
|
if ((NULL == reqs.pArray) || (tagArray == NULL)) {
|
||||||
tqError("s-task:%s failed to init create table msg, code:%s", id, tstrerror(terrno));
|
tqError("s-task:%s failed to init create table msg, code:%s", id, tstrerror(terrno));
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
@ -291,6 +293,7 @@ static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, S
|
||||||
tqError("s-task:%s vgId:%d failed to init create table msg", id, vgId);
|
tqError("s-task:%s vgId:%d failed to init create table msg", id, vgId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayClear(tagArray);
|
taosArrayClear(tagArray);
|
||||||
|
|
||||||
if (size == 2) {
|
if (size == 2) {
|
||||||
|
@ -356,8 +359,7 @@ static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = setCreateTableMsgTableName(pCreateTbReq, pDataBlock, stbFullName, gid,
|
code = setCreateTableMsgTableName(pCreateTbReq, pDataBlock, stbFullName, gid, IS_NEW_SUBTB_RULE(pTask));
|
||||||
pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1);
|
|
||||||
if (code) {
|
if (code) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
@ -368,16 +370,15 @@ static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, S
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableSinkInfo* pInfo = NULL;
|
bool alreadyCached = doGetSinkTableInfoFromCache(pTask->outputInfo.tbSink.pTbInfo, gid, &pInfo);
|
||||||
bool alreadyCached = tqGetTableInfo(pTask->outputInfo.tbSink.pTblInfo, gid, &pInfo);
|
|
||||||
if (!alreadyCached) {
|
if (!alreadyCached) {
|
||||||
code = doCreateSinkInfo(pCreateTbReq->name, &pInfo);
|
code = doCreateSinkTableInfo(pCreateTbReq->name, &pInfo);
|
||||||
if (code) {
|
if (code) {
|
||||||
tqError("vgId:%d failed to create sink tableInfo for table:%s, s-task:%s", vgId, pCreateTbReq->name, id);
|
tqError("vgId:%d failed to create sink tableInfo for table:%s, s-task:%s", vgId, pCreateTbReq->name, id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = doPutIntoCache(pTask->outputInfo.tbSink.pTblInfo, pInfo, gid, id);
|
code = doPutSinkTableInfoIntoCache(pTask->outputInfo.tbSink.pTbInfo, pInfo, gid, id);
|
||||||
if (code) {
|
if (code) {
|
||||||
tqError("vgId:%d failed to put sink tableInfo:%s into cache, s-task:%s", vgId, pCreateTbReq->name, id);
|
tqError("vgId:%d failed to put sink tableInfo:%s into cache, s-task:%s", vgId, pCreateTbReq->name, id);
|
||||||
}
|
}
|
||||||
|
@ -465,45 +466,45 @@ int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, c
|
||||||
|
|
||||||
k += 1;
|
k += 1;
|
||||||
} else {
|
} else {
|
||||||
// check for the existance of primary key
|
// check for the existance of primary key
|
||||||
if (pNewRow->numOfPKs == 0) {
|
if (pNewRow->numOfPKs == 0) {
|
||||||
|
void* p = taosArrayPush(pFinal, &pNewRow);
|
||||||
|
if (p == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
k += 1;
|
||||||
|
j += 1;
|
||||||
|
tRowDestroy(pOldRow);
|
||||||
|
} else {
|
||||||
|
numOfPk = pNewRow->numOfPKs;
|
||||||
|
|
||||||
|
SRowKey kNew, kOld;
|
||||||
|
tRowGetKey(pNewRow, &kNew);
|
||||||
|
tRowGetKey(pOldRow, &kOld);
|
||||||
|
|
||||||
|
int32_t ret = tRowKeyCompare(&kNew, &kOld);
|
||||||
|
if (ret <= 0) {
|
||||||
void* p = taosArrayPush(pFinal, &pNewRow);
|
void* p = taosArrayPush(pFinal, &pNewRow);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
k += 1;
|
|
||||||
j += 1;
|
j += 1;
|
||||||
tRowDestroy(pOldRow);
|
|
||||||
} else {
|
|
||||||
numOfPk = pNewRow->numOfPKs;
|
|
||||||
|
|
||||||
SRowKey kNew, kOld;
|
|
||||||
tRowGetKey(pNewRow, &kNew);
|
|
||||||
tRowGetKey(pOldRow, &kOld);
|
|
||||||
|
|
||||||
int32_t ret = tRowKeyCompare(&kNew, &kOld);
|
|
||||||
if (ret <= 0) {
|
|
||||||
void* p = taosArrayPush(pFinal, &pNewRow);
|
|
||||||
if (p == NULL) {
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
j += 1;
|
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
k += 1;
|
|
||||||
tRowDestroy(pOldRow);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
void* p = taosArrayPush(pFinal, &pOldRow);
|
|
||||||
if (p == NULL) {
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
k += 1;
|
k += 1;
|
||||||
|
tRowDestroy(pOldRow);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
void* p = taosArrayPush(pFinal, &pOldRow);
|
||||||
|
if (p == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
k += 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,8 +528,8 @@ int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, c
|
||||||
taosArrayDestroy(pExisted->aRowP);
|
taosArrayDestroy(pExisted->aRowP);
|
||||||
pExisted->aRowP = pFinal;
|
pExisted->aRowP = pFinal;
|
||||||
|
|
||||||
tqTrace("s-task:%s rows merged, final rows:%d, pk:%d uid:%" PRId64 ", existed auto-create table:%d, new-block:%d",
|
tqTrace("s-task:%s rows merged, final rows:%d, pk:%d uid:%" PRId64 ", existed auto-create table:%d, new-block:%d", id,
|
||||||
id, (int32_t)taosArrayGetSize(pFinal), numOfPk, pExisted->uid, (pExisted->pCreateTbReq != NULL),
|
(int32_t)taosArrayGetSize(pFinal), numOfPk, pExisted->uid, (pExisted->pCreateTbReq != NULL),
|
||||||
(pNew->pCreateTbReq != NULL));
|
(pNew->pCreateTbReq != NULL));
|
||||||
|
|
||||||
tdDestroySVCreateTbReq(pNew->pCreateTbReq);
|
tdDestroySVCreateTbReq(pNew->pCreateTbReq);
|
||||||
|
@ -727,7 +728,7 @@ int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDat
|
||||||
dataIndex++;
|
dataIndex++;
|
||||||
} else {
|
} else {
|
||||||
void* colData = colDataGetData(pColData, j);
|
void* colData = colDataGetData(pColData, j);
|
||||||
if (IS_VAR_DATA_TYPE(pCol->type)) { // address copy, no value
|
if (IS_VAR_DATA_TYPE(pCol->type)) { // address copy, no value
|
||||||
SValue sv =
|
SValue sv =
|
||||||
(SValue){.type = pCol->type, .nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)};
|
(SValue){.type = pCol->type, .nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)};
|
||||||
SColVal cv = COL_VAL_VALUE(pCol->colId, sv);
|
SColVal cv = COL_VAL_VALUE(pCol->colId, sv);
|
||||||
|
@ -806,7 +807,7 @@ int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doCreateSinkInfo(const char* pDstTableName, STableSinkInfo** pInfo) {
|
int32_t doCreateSinkTableInfo(const char* pDstTableName, STableSinkInfo** pInfo) {
|
||||||
int32_t nameLen = strlen(pDstTableName);
|
int32_t nameLen = strlen(pDstTableName);
|
||||||
(*pInfo) = taosMemoryCalloc(1, sizeof(STableSinkInfo) + nameLen + 1);
|
(*pInfo) = taosMemoryCalloc(1, sizeof(STableSinkInfo) + nameLen + 1);
|
||||||
if (*pInfo == NULL) {
|
if (*pInfo == NULL) {
|
||||||
|
@ -830,7 +831,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
STableSinkInfo* pTableSinkInfo = NULL;
|
STableSinkInfo* pTableSinkInfo = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
bool alreadyCached = tqGetTableInfo(pTask->outputInfo.tbSink.pTblInfo, groupId, &pTableSinkInfo);
|
bool alreadyCached = doGetSinkTableInfoFromCache(pTask->outputInfo.tbSink.pTbInfo, groupId, &pTableSinkInfo);
|
||||||
|
|
||||||
if (alreadyCached) {
|
if (alreadyCached) {
|
||||||
if (dstTableName[0] == 0) { // data block does not set the destination table name
|
if (dstTableName[0] == 0) { // data block does not set the destination table name
|
||||||
|
@ -870,7 +871,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = doCreateSinkInfo(dstTableName, &pTableSinkInfo);
|
code = doCreateSinkTableInfo(dstTableName, &pTableSinkInfo);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
tqDebug("s-task:%s build new sinkTableInfo to add cache, dstTable:%s", id, dstTableName);
|
tqDebug("s-task:%s build new sinkTableInfo to add cache, dstTable:%s", id, dstTableName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -906,14 +907,14 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
|
|
||||||
SArray* pTagArray = taosArrayInit(pTSchema->numOfCols + 1, sizeof(STagVal));
|
SArray* pTagArray = taosArrayInit(pTSchema->numOfCols + 1, sizeof(STagVal));
|
||||||
if (pTagArray == NULL) {
|
if (pTagArray == NULL) {
|
||||||
|
tqError("s-task:%s failed to build auto create submit msg in sink, vgId:%d, due to %s", id, vgId,
|
||||||
|
tstrerror(terrno));
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE;
|
pTableData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||||
code =
|
code = buildAutoCreateTableReq(stbFullName, suid, pTSchema->numOfCols + 1, pDataBlock, pTagArray,
|
||||||
buildAutoCreateTableReq(stbFullName, suid, pTSchema->numOfCols + 1, pDataBlock, pTagArray,
|
IS_NEW_SUBTB_RULE(pTask), &pTableData->pCreateTbReq);
|
||||||
(pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1),
|
|
||||||
&pTableData->pCreateTbReq);
|
|
||||||
taosArrayDestroy(pTagArray);
|
taosArrayDestroy(pTagArray);
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -923,12 +924,12 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableSinkInfo->uid = 0;
|
pTableSinkInfo->uid = 0;
|
||||||
code = doPutIntoCache(pTask->outputInfo.tbSink.pTblInfo, pTableSinkInfo, groupId, id);
|
code = doPutSinkTableInfoIntoCache(pTask->outputInfo.tbSink.pTbInfo, pTableSinkInfo, groupId, id);
|
||||||
} else {
|
} else {
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
tqError("s-task:%s vgId:%d dst-table:%s not auto-created, and not create in tsdb, discard data", id,
|
tqError("s-task:%s vgId:%d dst-table:%s not auto-created, and not create in tsdb, discard data", id, vgId,
|
||||||
vgId, dstTableName);
|
dstTableName);
|
||||||
return TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
return TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -944,7 +945,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
pTableSinkInfo->uid = mr.me.uid;
|
pTableSinkInfo->uid = mr.me.uid;
|
||||||
|
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
code = doPutIntoCache(pTask->outputInfo.tbSink.pTblInfo, pTableSinkInfo, groupId, id);
|
code = doPutSinkTableInfoIntoCache(pTask->outputInfo.tbSink.pTbInfo, pTableSinkInfo, groupId, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -952,8 +953,8 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||||
SSubmitTbData* pTableData, int64_t earlyTs, const char* id) {
|
SSubmitTbData* pTableData, int64_t earlyTs, const char* id) {
|
||||||
int32_t numOfRows = pDataBlock->info.rows;
|
int32_t numOfRows = pDataBlock->info.rows;
|
||||||
char* dstTableName = pDataBlock->info.parTbName;
|
char* dstTableName = pDataBlock->info.parTbName;
|
||||||
|
|
||||||
|
@ -975,6 +976,43 @@ int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t checkTagSchema(SStreamTask* pTask, SVnode* pVnode) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
const char* id = pTask->id.idStr;
|
||||||
|
STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
|
||||||
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
|
|
||||||
|
if (pTask->outputInfo.tbSink.pTagSchema == NULL) {
|
||||||
|
SMetaReader mer1 = {0};
|
||||||
|
metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
|
||||||
|
|
||||||
|
code = metaReaderGetTableEntryByUid(&mer1, pOutputInfo->tbSink.stbUid);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("s-task:%s vgId:%d failed to get the dst stable, failed to sink results", id, vgId);
|
||||||
|
metaReaderClear(&mer1);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutputInfo->tbSink.pTagSchema = tCloneSSchemaWrapper(&mer1.me.stbEntry.schemaTag);
|
||||||
|
metaReaderClear(&mer1);
|
||||||
|
|
||||||
|
if (pOutputInfo->tbSink.pTagSchema == NULL) {
|
||||||
|
tqError("s-task:%s failed to clone tag schema, code:%s, failed to sink results", id, tstrerror(terrno));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSchemaWrapper* pTagSchema = pOutputInfo->tbSink.pTagSchema;
|
||||||
|
SSchema* pCol1 = &pTagSchema->pSchema[0];
|
||||||
|
if (pTagSchema->nCols == 1 && pCol1->type == TSDB_DATA_TYPE_UBIGINT && strcmp(pCol1->name, "group_id") == 0) {
|
||||||
|
pOutputInfo->tbSink.autoCreateCtb = true;
|
||||||
|
} else {
|
||||||
|
pOutputInfo->tbSink.autoCreateCtb = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
const SArray* pBlocks = (const SArray*)data;
|
const SArray* pBlocks = (const SArray*)data;
|
||||||
SVnode* pVnode = (SVnode*)vnode;
|
SVnode* pVnode = (SVnode*)vnode;
|
||||||
|
@ -988,27 +1026,9 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
int64_t earlyTs = tsdbGetEarliestTs(pVnode->pTsdb);
|
int64_t earlyTs = tsdbGetEarliestTs(pVnode->pTsdb);
|
||||||
STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
|
STaskOutputInfo* pOutputInfo = &pTask->outputInfo;
|
||||||
|
|
||||||
if (pTask->outputInfo.tbSink.pTagSchema == NULL) {
|
code = checkTagSchema(pTask, pVnode);
|
||||||
SMetaReader mer1 = {0};
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
|
return;
|
||||||
|
|
||||||
code = metaReaderGetTableEntryByUid(&mer1, pOutputInfo->tbSink.stbUid);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tqError("s-task:%s vgId:%d failed to get the dst stable, failed to sink results", id, vgId);
|
|
||||||
metaReaderClear(&mer1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOutputInfo->tbSink.pTagSchema = tCloneSSchemaWrapper(&mer1.me.stbEntry.schemaTag);
|
|
||||||
metaReaderClear(&mer1);
|
|
||||||
|
|
||||||
SSchemaWrapper* pTagSchema = pOutputInfo->tbSink.pTagSchema;
|
|
||||||
SSchema* pCol1 = &pTagSchema->pSchema[0];
|
|
||||||
if (pTagSchema->nCols == 1 && pCol1->type == TSDB_DATA_TYPE_UBIGINT && strcmp(pCol1->name, "group_id") == 0) {
|
|
||||||
pOutputInfo->tbSink.autoCreateCtb = true;
|
|
||||||
} else {
|
|
||||||
pOutputInfo->tbSink.autoCreateCtb = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onlySubmitData = hasOnlySubmitData(pBlocks, numOfBlocks);
|
bool onlySubmitData = hasOnlySubmitData(pBlocks, numOfBlocks);
|
||||||
|
@ -1033,144 +1053,16 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
} else if (pDataBlock->info.type == STREAM_CHECKPOINT) {
|
} else if (pDataBlock->info.type == STREAM_CHECKPOINT) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
pTask->execInfo.sink.numOfBlocks += 1;
|
code = handleResultBlockMsg(pTask, pDataBlock, i, pVnode, earlyTs);
|
||||||
|
|
||||||
SSubmitReq2 submitReq = {.aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData))};
|
|
||||||
if (submitReq.aSubmitTbData == NULL) {
|
|
||||||
code = terrno;
|
|
||||||
tqError("s-task:%s vgId:%d failed to prepare submit msg in sink task, code:%s", id, vgId, tstrerror(code));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = TD_REQ_FROM_APP};
|
|
||||||
code = setDstTableDataUid(pVnode, pTask, pDataBlock, stbFullName, &tbData);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tqError("vgId:%d s-task:%s dst-table not exist, stb:%s discard stream results", vgId, id, stbFullName);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, earlyTs, id);
|
|
||||||
if (code != TSDB_CODE_SUCCESS || tbData.aRowP == NULL) {
|
|
||||||
if (tbData.pCreateTbReq != NULL) {
|
|
||||||
tdDestroySVCreateTbReq(tbData.pCreateTbReq);
|
|
||||||
(void) doRemoveFromCache(pTask->outputInfo.tbSink.pTblInfo, pDataBlock->info.id.groupId, id);
|
|
||||||
tbData.pCreateTbReq = NULL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* p = taosArrayPush(submitReq.aSubmitTbData, &tbData);
|
|
||||||
if (p == NULL) {
|
|
||||||
tqDebug("vgId:%d, s-task:%s failed to build submit msg, data lost", vgId, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = doBuildAndSendSubmitMsg(pVnode, pTask, &submitReq, 1);
|
|
||||||
if (code) { // failed and continue
|
|
||||||
tqDebug("vgId:%d, s-task:%s submit msg failed, data lost", vgId, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tqDebug("vgId:%d, s-task:%s write %d stream resBlock(s) into table, merge submit msg", vgId, id, numOfBlocks);
|
tqDebug("vgId:%d, s-task:%s write %d stream resBlock(s) into table, merge submit msg", vgId, id, numOfBlocks);
|
||||||
SHashObj* pTableIndexMap =
|
if (streamTaskShouldStop(pTask)) {
|
||||||
taosHashInit(numOfBlocks, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
|
||||||
|
|
||||||
SSubmitReq2 submitReq = {.aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData))};
|
|
||||||
if (submitReq.aSubmitTbData == NULL) {
|
|
||||||
code = terrno;
|
|
||||||
tqError("s-task:%s vgId:%d failed to prepare submit msg in sink task, code:%s", id, vgId, tstrerror(code));
|
|
||||||
taosHashCleanup(pTableIndexMap);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasSubmit = false;
|
reubuildAndSendMultiResBlock(pTask, pBlocks, pVnode, earlyTs);
|
||||||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
|
||||||
if (streamTaskShouldStop(pTask)) {
|
|
||||||
taosHashCleanup(pTableIndexMap);
|
|
||||||
tDestroySubmitReq(&submitReq, TSDB_MSG_FLG_ENCODE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
|
||||||
if (pDataBlock == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pDataBlock->info.type == STREAM_CHECKPOINT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasSubmit = true;
|
|
||||||
pTask->execInfo.sink.numOfBlocks += 1;
|
|
||||||
uint64_t groupId = pDataBlock->info.id.groupId;
|
|
||||||
|
|
||||||
SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = TD_REQ_FROM_APP};
|
|
||||||
|
|
||||||
int32_t* index = taosHashGet(pTableIndexMap, &groupId, sizeof(groupId));
|
|
||||||
if (index == NULL) { // no data yet, append it
|
|
||||||
code = setDstTableDataUid(pVnode, pTask, pDataBlock, stbFullName, &tbData);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tqError("vgId:%d dst-table gid:%" PRId64 " not exist, discard stream results", vgId, groupId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, earlyTs, id);
|
|
||||||
if (code != TSDB_CODE_SUCCESS || tbData.aRowP == NULL) {
|
|
||||||
if (tbData.pCreateTbReq != NULL) {
|
|
||||||
tdDestroySVCreateTbReq(tbData.pCreateTbReq);
|
|
||||||
(void) doRemoveFromCache(pTask->outputInfo.tbSink.pTblInfo, groupId, id);
|
|
||||||
tbData.pCreateTbReq = NULL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* p = taosArrayPush(submitReq.aSubmitTbData, &tbData);
|
|
||||||
if (p == NULL) {
|
|
||||||
tqError("vgId:%d, s-task:%s failed to build submit msg, data lost", vgId, id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t size = (int32_t)taosArrayGetSize(submitReq.aSubmitTbData) - 1;
|
|
||||||
code = taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size));
|
|
||||||
if (code) {
|
|
||||||
tqError("vgId:%d, s-task:%s failed to put group into index map, code:%s", vgId, id, tstrerror(code));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, earlyTs, id);
|
|
||||||
if (code != TSDB_CODE_SUCCESS || tbData.aRowP == NULL) {
|
|
||||||
if (tbData.pCreateTbReq != NULL) {
|
|
||||||
tdDestroySVCreateTbReq(tbData.pCreateTbReq);
|
|
||||||
tbData.pCreateTbReq = NULL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSubmitTbData* pExisted = taosArrayGet(submitReq.aSubmitTbData, *index);
|
|
||||||
if (pExisted == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = doMergeExistedRows(pExisted, &tbData, id);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pTask->execInfo.sink.numOfRows += pDataBlock->info.rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosHashCleanup(pTableIndexMap);
|
|
||||||
|
|
||||||
if (hasSubmit) {
|
|
||||||
code = doBuildAndSendSubmitMsg(pVnode, pTask, &submitReq, numOfBlocks);
|
|
||||||
if (code) { // failed and continue
|
|
||||||
tqError("vgId:%d failed to build and send submit msg", vgId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tDestroySubmitReq(&submitReq, TSDB_MSG_FLG_ENCODE);
|
|
||||||
tqDebug("vgId:%d, s-task:%s write results completed", vgId, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1190,7 +1082,7 @@ bool hasOnlySubmitData(const SArray* pBlocks, int32_t numOfBlocks) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doPutIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId, const char* id) {
|
int32_t doPutSinkTableInfoIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId, const char* id) {
|
||||||
int32_t code = tSimpleHashPut(pSinkTableMap, &groupId, sizeof(uint64_t), &pTableSinkInfo, POINTER_BYTES);
|
int32_t code = tSimpleHashPut(pSinkTableMap, &groupId, sizeof(uint64_t), &pTableSinkInfo, POINTER_BYTES);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFreeClear(pTableSinkInfo);
|
taosMemoryFreeClear(pTableSinkInfo);
|
||||||
|
@ -1202,7 +1094,17 @@ int32_t doPutIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doRemoveFromCache(SSHashObj* pSinkTableMap, uint64_t groupId, const char* id) {
|
bool doGetSinkTableInfoFromCache(SSHashObj* pTableInfoMap, uint64_t groupId, STableSinkInfo** pInfo) {
|
||||||
|
void* pVal = tSimpleHashGet(pTableInfoMap, &groupId, sizeof(uint64_t));
|
||||||
|
if (pVal) {
|
||||||
|
*pInfo = *(STableSinkInfo**)pVal;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t doRemoveSinkTableInfoInCache(SSHashObj* pSinkTableMap, uint64_t groupId, const char* id) {
|
||||||
if (tSimpleHashGetSize(pSinkTableMap) == 0) {
|
if (tSimpleHashGetSize(pSinkTableMap) == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1223,8 +1125,8 @@ int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock*
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = tqBuildDeleteReq(pVnode->pTq, stbFullName, pDataBlock, &deleteReq, pTask->id.idStr,
|
int32_t code =
|
||||||
pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1);
|
tqBuildDeleteReq(pVnode->pTq, stbFullName, pDataBlock, &deleteReq, pTask->id.idStr, IS_NEW_SUBTB_RULE(pTask));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1262,3 +1164,155 @@ int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock*
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reubuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVnode* pVnode, int64_t earlyTs) {
|
||||||
|
int32_t code = 0;
|
||||||
|
const char* id = pTask->id.idStr;
|
||||||
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
|
int32_t numOfBlocks = taosArrayGetSize(pBlocks);
|
||||||
|
int64_t suid = pTask->outputInfo.tbSink.stbUid;
|
||||||
|
STSchema* pTSchema = pTask->outputInfo.tbSink.pTSchema;
|
||||||
|
char* stbFullName = pTask->outputInfo.tbSink.stbFullName;
|
||||||
|
|
||||||
|
SHashObj* pTableIndexMap =
|
||||||
|
taosHashInit(numOfBlocks, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
|
SSubmitReq2 submitReq = {.aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData))};
|
||||||
|
if (submitReq.aSubmitTbData == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
tqError("s-task:%s vgId:%d failed to prepare submit msg in sink task, code:%s", id, vgId, tstrerror(code));
|
||||||
|
taosHashCleanup(pTableIndexMap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasSubmit = false;
|
||||||
|
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||||
|
if (pDataBlock == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDataBlock->info.type == STREAM_CHECKPOINT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasSubmit = true;
|
||||||
|
pTask->execInfo.sink.numOfBlocks += 1;
|
||||||
|
uint64_t groupId = pDataBlock->info.id.groupId;
|
||||||
|
|
||||||
|
SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = TD_REQ_FROM_APP};
|
||||||
|
|
||||||
|
int32_t* index = taosHashGet(pTableIndexMap, &groupId, sizeof(groupId));
|
||||||
|
if (index == NULL) { // no data yet, append it
|
||||||
|
code = setDstTableDataUid(pVnode, pTask, pDataBlock, stbFullName, &tbData);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("vgId:%d dst-table gid:%" PRId64 " not exist, discard stream results", vgId, groupId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, earlyTs, id);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || tbData.aRowP == NULL) {
|
||||||
|
if (tbData.pCreateTbReq != NULL) {
|
||||||
|
tdDestroySVCreateTbReq(tbData.pCreateTbReq);
|
||||||
|
(void)doRemoveSinkTableInfoInCache(pTask->outputInfo.tbSink.pTbInfo, groupId, id);
|
||||||
|
tbData.pCreateTbReq = NULL;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* p = taosArrayPush(submitReq.aSubmitTbData, &tbData);
|
||||||
|
if (p == NULL) {
|
||||||
|
tqError("vgId:%d, s-task:%s failed to build submit msg, data lost", vgId, id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t size = (int32_t)taosArrayGetSize(submitReq.aSubmitTbData) - 1;
|
||||||
|
code = taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size));
|
||||||
|
if (code) {
|
||||||
|
tqError("vgId:%d, s-task:%s failed to put group into index map, code:%s", vgId, id, tstrerror(code));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = tqSetDstTableDataPayload(suid, pTSchema, i, pDataBlock, &tbData, earlyTs, id);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || tbData.aRowP == NULL) {
|
||||||
|
if (tbData.pCreateTbReq != NULL) {
|
||||||
|
tdDestroySVCreateTbReq(tbData.pCreateTbReq);
|
||||||
|
tbData.pCreateTbReq = NULL;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSubmitTbData* pExisted = taosArrayGet(submitReq.aSubmitTbData, *index);
|
||||||
|
if (pExisted == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = doMergeExistedRows(pExisted, &tbData, id);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pTask->execInfo.sink.numOfRows += pDataBlock->info.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pTableIndexMap);
|
||||||
|
|
||||||
|
if (hasSubmit) {
|
||||||
|
code = doBuildAndSendSubmitMsg(pVnode, pTask, &submitReq, numOfBlocks);
|
||||||
|
if (code) { // failed and continue
|
||||||
|
tqError("vgId:%d failed to build and send submit msg", vgId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tDestroySubmitReq(&submitReq, TSDB_MSG_FLG_ENCODE);
|
||||||
|
tqDebug("vgId:%d, s-task:%s write results completed", vgId, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t handleResultBlockMsg(SStreamTask* pTask, SSDataBlock* pDataBlock, int32_t index, SVnode* pVnode, int64_t earlyTs) {
|
||||||
|
int32_t code = 0;
|
||||||
|
STSchema* pTSchema = pTask->outputInfo.tbSink.pTSchema;
|
||||||
|
int64_t suid = pTask->outputInfo.tbSink.stbUid;
|
||||||
|
const char* id = pTask->id.idStr;
|
||||||
|
int32_t vgId = TD_VID(pVnode);
|
||||||
|
char* stbFullName = pTask->outputInfo.tbSink.stbFullName;
|
||||||
|
|
||||||
|
pTask->execInfo.sink.numOfBlocks += 1;
|
||||||
|
|
||||||
|
SSubmitReq2 submitReq = {.aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData))};
|
||||||
|
if (submitReq.aSubmitTbData == NULL) {
|
||||||
|
tqError("s-task:%s vgId:%d failed to prepare submit msg in sink task, code:%s", id, vgId, tstrerror(terrno));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = TD_REQ_FROM_APP};
|
||||||
|
code = setDstTableDataUid(pVnode, pTask, pDataBlock, stbFullName, &tbData);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("vgId:%d s-task:%s dst-table not exist, stb:%s discard stream results", vgId, id, stbFullName);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tqSetDstTableDataPayload(suid, pTSchema, index, pDataBlock, &tbData, earlyTs, id);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || tbData.aRowP == NULL) {
|
||||||
|
if (tbData.pCreateTbReq != NULL) {
|
||||||
|
tdDestroySVCreateTbReq(tbData.pCreateTbReq);
|
||||||
|
(void)doRemoveSinkTableInfoInCache(pTask->outputInfo.tbSink.pTbInfo, pDataBlock->info.id.groupId, id);
|
||||||
|
tbData.pCreateTbReq = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* p = taosArrayPush(submitReq.aSubmitTbData, &tbData);
|
||||||
|
if (p == NULL) {
|
||||||
|
tqDebug("vgId:%d, s-task:%s failed to build submit msg, code:%s, data lost", vgId, id, tstrerror(terrno));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = doBuildAndSendSubmitMsg(pVnode, pTask, &submitReq, 1);
|
||||||
|
if (code) { // failed and continue
|
||||||
|
tqDebug("vgId:%d, s-task:%s submit msg failed, code:%s data lost", vgId, id, tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
* 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/>.
|
||||||
*/
|
*/
|
||||||
#include "cos.h"
|
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
#include "tcs.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbDataFileRW.h"
|
#include "tsdbDataFileRW.h"
|
||||||
#include "tsdbIter.h"
|
#include "tsdbIter.h"
|
||||||
|
@ -1258,7 +1258,8 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pLastCol || cmp_res < 0 || (cmp_res == 0 && !COL_VAL_IS_NONE(pColVal))) {
|
if (NULL == pLastCol || cmp_res < 0 || (cmp_res == 0 && !COL_VAL_IS_NONE(pColVal))) {
|
||||||
SLastCol lastColTmp = {.rowKey = *pRowKey, .colVal = *pColVal, .dirty = 0, .cacheStatus = TSDB_LAST_CACHE_VALID};
|
SLastCol lastColTmp = {
|
||||||
|
.rowKey = *pRowKey, .colVal = *pColVal, .dirty = 0, .cacheStatus = TSDB_LAST_CACHE_VALID};
|
||||||
if ((code = tsdbCachePutToRocksdb(pTsdb, &idxKey->key, &lastColTmp)) != TSDB_CODE_SUCCESS) {
|
if ((code = tsdbCachePutToRocksdb(pTsdb, &idxKey->key, &lastColTmp)) != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("tsdb/cache: vgId:%d, put rocks failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino,
|
tsdbError("tsdb/cache: vgId:%d, put rocks failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
@ -1705,8 +1706,7 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
||||||
if (pLastCol && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
if (pLastCol && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
||||||
code = tsdbCachePutToLRU(pTsdb, &idxKey->key, pLastCol, 0);
|
code = tsdbCachePutToLRU(pTsdb, &idxKey->key, pLastCol, 0);
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code));
|
||||||
tstrerror(code));
|
|
||||||
taosMemoryFreeClear(pToFree);
|
taosMemoryFreeClear(pToFree);
|
||||||
TAOS_CHECK_EXIT(code);
|
TAOS_CHECK_EXIT(code);
|
||||||
}
|
}
|
||||||
|
@ -3519,7 +3519,7 @@ static int32_t tsdbCacheLoadBlockS3(STsdbFD *pFD, uint8_t **ppBlock) {
|
||||||
|
|
||||||
int64_t block_offset = (pFD->blkno - 1) * tsS3BlockSize * pFD->szPage;
|
int64_t block_offset = (pFD->blkno - 1) * tsS3BlockSize * pFD->szPage;
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(s3GetObjectBlock(pFD->objName, block_offset, tsS3BlockSize * pFD->szPage, 0, ppBlock));
|
TAOS_CHECK_RETURN(tcsGetObjectBlock(pFD->objName, block_offset, tsS3BlockSize * pFD->szPage, 0, ppBlock));
|
||||||
|
|
||||||
tsdbTrace("block:%p load from s3", *ppBlock);
|
tsdbTrace("block:%p load from s3", *ppBlock);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tsdbFile2.h"
|
#include "tsdbFile2.h"
|
||||||
#include "cos.h"
|
#include "tcs.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
// to_json
|
// to_json
|
||||||
|
@ -318,7 +318,7 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
|
||||||
}
|
}
|
||||||
*(dot + 1) = 0;
|
*(dot + 1) = 0;
|
||||||
|
|
||||||
s3DeleteObjectsByPrefix(object_name_prefix);
|
tcsDeleteObjectsByPrefix(object_name_prefix);
|
||||||
|
|
||||||
// remove local last chunk file
|
// remove local last chunk file
|
||||||
dot = strrchr(lc_path, '.');
|
dot = strrchr(lc_path, '.');
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cos.h"
|
|
||||||
#include "crypt.h"
|
#include "crypt.h"
|
||||||
|
#include "tcs.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbDef.h"
|
#include "tsdbDef.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
@ -391,7 +391,7 @@ static int32_t tsdbReadFileBlock(STsdbFD *pFD, int64_t offset, int64_t size, boo
|
||||||
|
|
||||||
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - object_name_prefix), "%d.data", chunkno);
|
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - object_name_prefix), "%d.data", chunkno);
|
||||||
|
|
||||||
code = s3GetObjectBlock(object_name_prefix, cOffset, nRead, check, &pBlock);
|
code = tcsGetObjectBlock(object_name_prefix, cOffset, nRead, check, &pBlock);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
memcpy(buf + n, pBlock, nRead);
|
memcpy(buf + n, pBlock, nRead);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cos.h"
|
#include "tcs.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbFS2.h"
|
#include "tsdbFS2.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
@ -426,35 +426,6 @@ static int32_t tsdbS3FidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int32_t s3Kee
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbCopyFileS3(SRTNer *rtner, const STFileObj *from, const STFile *to) {
|
|
||||||
int32_t code = 0;
|
|
||||||
int32_t lino = 0;
|
|
||||||
|
|
||||||
char fname[TSDB_FILENAME_LEN];
|
|
||||||
TdFilePtr fdFrom = NULL;
|
|
||||||
// TdFilePtr fdTo = NULL;
|
|
||||||
|
|
||||||
tsdbTFileName(rtner->tsdb, to, fname);
|
|
||||||
|
|
||||||
fdFrom = taosOpenFile(from->fname, TD_FILE_READ);
|
|
||||||
if (fdFrom == NULL) {
|
|
||||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *object_name = taosDirEntryBaseName(fname);
|
|
||||||
TAOS_CHECK_GOTO(s3PutObjectFromFile2(from->fname, object_name, 1), &lino, _exit);
|
|
||||||
|
|
||||||
_exit:
|
|
||||||
if (code) {
|
|
||||||
tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
|
|
||||||
tstrerror(code));
|
|
||||||
}
|
|
||||||
if (taosCloseFile(&fdFrom) != 0) {
|
|
||||||
tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int64_t size, int64_t chunksize) {
|
static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int64_t size, int64_t chunksize) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
@ -519,7 +490,7 @@ static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int
|
||||||
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - object_name_prefix), "%d.data", cn);
|
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - object_name_prefix), "%d.data", cn);
|
||||||
int64_t c_offset = chunksize * (cn - fobj->f->lcn);
|
int64_t c_offset = chunksize * (cn - fobj->f->lcn);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(s3PutObjectFromFileOffset(fname, object_name_prefix, c_offset, chunksize), &lino, _exit);
|
TAOS_CHECK_GOTO(tcsPutObjectFromFileOffset(fname, object_name_prefix, c_offset, chunksize), &lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy last chunk
|
// copy last chunk
|
||||||
|
@ -618,7 +589,7 @@ static int32_t tsdbMigrateDataFileS3(SRTNer *rtner, const STFileObj *fobj, int64
|
||||||
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - object_name_prefix), "%d.data", cn);
|
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - object_name_prefix), "%d.data", cn);
|
||||||
int64_t c_offset = chunksize * (cn - 1);
|
int64_t c_offset = chunksize * (cn - 1);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(s3PutObjectFromFileOffset(fobj->fname, object_name_prefix, c_offset, chunksize), &lino, _exit);
|
TAOS_CHECK_GOTO(tcsPutObjectFromFileOffset(fobj->fname, object_name_prefix, c_offset, chunksize), &lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy last chunk
|
// copy last chunk
|
||||||
|
@ -741,8 +712,6 @@ _exit:
|
||||||
int32_t tsdbAsyncS3Migrate(STsdb *tsdb, int64_t now) {
|
int32_t tsdbAsyncS3Migrate(STsdb *tsdb, int64_t now) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
extern int8_t tsS3EnabledCfg;
|
|
||||||
|
|
||||||
int32_t expired = grantCheck(TSDB_GRANT_OBJECT_STORAGE);
|
int32_t expired = grantCheck(TSDB_GRANT_OBJECT_STORAGE);
|
||||||
if (expired && tsS3Enabled) {
|
if (expired && tsS3Enabled) {
|
||||||
tsdbWarn("s3 grant expired: %d", expired);
|
tsdbWarn("s3 grant expired: %d", expired);
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cos.h"
|
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
|
#include "tcs.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId) {
|
||||||
if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) {
|
if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) {
|
||||||
char vnode_prefix[TSDB_FILENAME_LEN];
|
char vnode_prefix[TSDB_FILENAME_LEN];
|
||||||
snprintf(vnode_prefix, TSDB_FILENAME_LEN, "%d/v%df", nodeId, vgId);
|
snprintf(vnode_prefix, TSDB_FILENAME_LEN, "%d/v%df", nodeId, vgId);
|
||||||
s3DeleteObjectsByPrefix(vnode_prefix);
|
tcsDeleteObjectsByPrefix(vnode_prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,6 @@ add_subdirectory(stream)
|
||||||
add_subdirectory(planner)
|
add_subdirectory(planner)
|
||||||
add_subdirectory(qworker)
|
add_subdirectory(qworker)
|
||||||
add_subdirectory(geometry)
|
add_subdirectory(geometry)
|
||||||
add_subdirectory(command)
|
add_subdirectory(command)
|
||||||
|
add_subdirectory(azure)
|
||||||
|
add_subdirectory(tcs)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
aux_source_directory(src AUDIT_SRC)
|
aux_source_directory(src AUDIT_SRC)
|
||||||
IF (TD_ENTERPRISE)
|
|
||||||
|
IF(TD_ENTERPRISE)
|
||||||
LIST(APPEND AUDIT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/audit/src/audit.c)
|
LIST(APPEND AUDIT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/audit/src/audit.c)
|
||||||
ENDIF ()
|
ENDIF()
|
||||||
|
|
||||||
add_library(audit STATIC ${AUDIT_SRC})
|
add_library(audit STATIC ${AUDIT_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
# if(${TD_LINUX})
|
||||||
|
aux_source_directory(src AZ_SRC)
|
||||||
|
|
||||||
|
add_library(az STATIC ${AZ_SRC})
|
||||||
|
|
||||||
|
if(${BUILD_S3})
|
||||||
|
add_definitions(-DUSE_S3)
|
||||||
|
target_link_libraries(
|
||||||
|
az
|
||||||
|
PUBLIC _azure_sdk
|
||||||
|
PUBLIC crypt
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
az
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/azure"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
az
|
||||||
|
PUBLIC cjson
|
||||||
|
PUBLIC os
|
||||||
|
PUBLIC util
|
||||||
|
PUBLIC common
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${BUILD_TEST})
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif(${BUILD_TEST})
|
||||||
|
|
||||||
|
# endif(${TD_LINUX})
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue