Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
2f1e5287
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2f1e5287
编写于
4月 17, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
差异文件
[td-98] merge develop branch
上级
13f1efd8
d41b2308
变更
73
展开全部
隐藏空白更改
内联
并排
Showing
73 changed file
with
1976 addition
and
1250 deletion
+1976
-1250
.travis.yml
.travis.yml
+197
-107
CMakeLists.txt
CMakeLists.txt
+5
-4
cmake/define.inc
cmake/define.inc
+6
-13
cmake/input.inc
cmake/input.inc
+0
-8
cmake/platform.inc
cmake/platform.inc
+12
-0
src/common/src/tstring.c
src/common/src/tstring.c
+0
-0
src/dnode/CMakeLists.txt
src/dnode/CMakeLists.txt
+3
-10
src/dnode/inc/dnodeMClient.h
src/dnode/inc/dnodeMClient.h
+0
-3
src/dnode/inc/dnodeModule.h
src/dnode/inc/dnodeModule.h
+3
-3
src/dnode/src/dnodeMClient.c
src/dnode/src/dnodeMClient.c
+18
-18
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+4
-1
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+1
-1
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+76
-73
src/inc/dnode.h
src/inc/dnode.h
+5
-3
src/inc/mnode.h
src/inc/mnode.h
+0
-237
src/inc/query.h
src/inc/query.h
+12
-12
src/inc/tacct.h
src/inc/tacct.h
+21
-4
src/inc/tadmin.h
src/inc/tadmin.h
+3
-8
src/inc/taosdef.h
src/inc/taosdef.h
+10
-3
src/inc/taosmsg.h
src/inc/taosmsg.h
+2
-1
src/inc/treplica.h
src/inc/treplica.h
+11
-15
src/inc/tsdb.h
src/inc/tsdb.h
+19
-72
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+12
-29
src/mnode/inc/mgmtDb.h
src/mnode/inc/mgmtDb.h
+2
-2
src/mnode/inc/mgmtDef.h
src/mnode/inc/mgmtDef.h
+246
-0
src/mnode/inc/mgmtDnode.h
src/mnode/inc/mgmtDnode.h
+16
-24
src/mnode/inc/mgmtLog.h
src/mnode/inc/mgmtLog.h
+68
-0
src/mnode/inc/mgmtMnode.h
src/mnode/inc/mgmtMnode.h
+24
-22
src/mnode/inc/mgmtProfile.h
src/mnode/inc/mgmtProfile.h
+1
-1
src/mnode/inc/mgmtShell.h
src/mnode/inc/mgmtShell.h
+1
-1
src/mnode/inc/mgmtTable.h
src/mnode/inc/mgmtTable.h
+1
-4
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+1
-1
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+1
-3
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+154
-22
src/mnode/src/mgmtDClient.c
src/mnode/src/mgmtDClient.c
+6
-4
src/mnode/src/mgmtDServer.c
src/mnode/src/mgmtDServer.c
+5
-3
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+17
-15
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+381
-130
src/mnode/src/mgmtGrant.c
src/mnode/src/mgmtGrant.c
+1
-1
src/mnode/src/mgmtMain.c
src/mnode/src/mgmtMain.c
+49
-54
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+211
-59
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+10
-6
src/mnode/src/mgmtReplica.c
src/mnode/src/mgmtReplica.c
+19
-12
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+12
-8
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+13
-18
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+32
-30
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+13
-10
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+22
-17
src/os/darwin/src/tdarwin.c
src/os/darwin/src/tdarwin.c
+5
-0
src/os/linux/src/tlinux.c
src/os/linux/src/tlinux.c
+8
-5
src/os/windows/src/twintimer.c
src/os/windows/src/twintimer.c
+5
-1
src/plugins/http/CMakeLists.txt
src/plugins/http/CMakeLists.txt
+2
-2
src/plugins/http/inc/httpHandle.h
src/plugins/http/inc/httpHandle.h
+26
-3
src/plugins/http/src/httpSystem.c
src/plugins/http/src/httpSystem.c
+7
-20
src/plugins/monitor/src/monitorSystem.c
src/plugins/monitor/src/monitorSystem.c
+22
-2
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+0
-1
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+16
-7
src/rpc/CMakeLists.txt
src/rpc/CMakeLists.txt
+1
-1
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+49
-22
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+1
-1
src/util/CMakeLists.txt
src/util/CMakeLists.txt
+0
-4
src/util/inc/tlog.h
src/util/inc/tlog.h
+0
-81
src/util/inc/tsched.h
src/util/inc/tsched.h
+3
-8
src/util/inc/tutil.h
src/util/inc/tutil.h
+1
-0
src/util/src/talgo.c
src/util/src/talgo.c
+2
-0
src/util/src/tglobalcfg.c
src/util/src/tglobalcfg.c
+1
-6
src/util/src/ttimer.c
src/util/src/ttimer.c
+16
-8
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
src/wal/src/walMain.c
src/wal/src/walMain.c
+42
-1
tests/pytest/insert/basic.py
tests/pytest/insert/basic.py
+2
-2
tests/pytest/simpletest.sh
tests/pytest/simpletest.sh
+1
-1
tests/test-all.sh
tests/test-all.sh
+39
-0
tests/tsim/inc/sim.h
tests/tsim/inc/sim.h
+0
-1
未找到文件。
.travis.yml
浏览文件 @
2f1e5287
#
# Configuration
#
git
:
depth
:
1
language
:
c
compiler
:
-
clang
-
gcc
os
:
-
linux
# - osx
before_install
:
-
|-
case $TRAVIS_OS_NAME in
linux)
sudo apt -y update
sudo apt -y install python-pip python3-pip python-setuptools python3-setuptools
;;
esac
addons
:
coverity_scan
:
# GitHub project metadata
# ** specific to your project **
project
:
name
:
TDengine
version
:
2.x
description
:
TDengine
# Where email notification of build analysis results will be sent
notification_email
:
sdsang@taosdata.com
# Commands to prepare for build_command
# ** likely specific to your build **
build_command_prepend
:
cmake ..
# The command that will be added as an argument to "cov-build" to compile your project for analysis,
# ** likely specific to your build **
build_command
:
cmake --build .
# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
# Take care in resource usage, and consider the build frequency allowances per
# https://scan.coverity.com/faq#frequency
branch_pattern
:
coverity_scan
before_script
:
-
mkdir debug
-
cd debug
script
:
-
cmake ..
-
cmake --build . || exit $?
-
|-
case $TRAVIS_OS_NAME in
linux)
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
sudo make install
cd ../tests/script
sudo ./test.sh 2>&1 | grep 'success\|failed' | tee out.txt
total_success=`grep success out.txt | wc -l`
if [ "$total_success" -gt "0" ]; then
total_success=`expr $total_success - 1`
echo -e "${GREEN} ### Total $total_success TSIM case(s) succeed! ### ${NC}"
fi
total_failed=`grep failed out.txt | wc -l`
if [ "$total_failed" -ne "0" ]; then
echo -e "${RED} ### Total $total_failed TSIM case(s) failed! ### ${NC}"
exit $total_failed
fi
pip install --user ../../src/connector/python/linux/python2/
pip3 install --user ../../src/connector/python/linux/python3/
cd ../pytest
sudo ./simpletest.sh 2>&1 | grep 'successfully executed\|failed' | tee pytest-out.txt
total_py_success=`grep 'successfully executed' pytest-out.txt | wc -l`
if [ "$total_py_success" -gt "0" ]; then
echo -e "${GREEN} ### Total $total_py_success python case(s) succeed! ### ${NC}"
fi
total_py_failed=`grep 'failed' pytest-out.txt | wc -l`
if [ "$total_py_failed" -ne "0" ]; then
echo -e "${RED} ### Total $total_py_failed python case(s) failed! ### ${NC}"
exit $total_py_failed
fi
;;
esac
#
# Build Matrix
#
matrix
:
-
os
:
linux
language
:
c
git
:
-
depth
:
1
compiler
:
gcc
env
:
DESC="linux/gcc build and test"
addons
:
apt
:
packages
:
...
...
@@ -120,8 +25,193 @@ matrix:
-
python3-pip
-
python3-setuptools
# - os: osx
# addons:
# homebrew:
# - cmake
before_install
:
-
sudo apt update -y -qq
-
sudo apt install -y net-tools python-pip python-setuptools python3-pip python3-setuptools
before_script
:
-
cd ${TRAVIS_BUILD_DIR}
-
mkdir debug
-
cd debug
script
:
-
cmake ..
-
make
after_success
:
-
|-
case $TRAVIS_OS_NAME in
linux)
cd ${TRAVIS_BUILD_DIR}/debug
sudo make install || exit $?
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
cd ${TRAVIS_BUILD_DIR}/tests
bash ./test-all.sh
if [ "$?" -ne "0" ]; then
exit $?
fi
;;
esac
-
os
:
linux
language
:
c
compiler
:
gcc
env
:
COVERITY_SCAN=true
git
:
-
depth
:
1
script
:
-
echo "this job is for coverity scan"
addons
:
coverity_scan
:
# GitHub project metadata
# ** specific to your project **
project
:
name
:
sangshuduo/TDengine
version
:
2.x
description
:
sangshuduo/TDengine
# Where email notification of build analysis results will be sent
notification_email
:
sangshuduo@gmail.com
# Commands to prepare for build_command
# ** likely specific to your build **
build_command_prepend
:
cmake ..
# The command that will be added as an argument to "cov-build" to compile your project for analysis,
# ** likely specific to your build **
build_command
:
cmake --build .
# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
# Take care in resource usage, and consider the build frequency allowances per
# https://scan.coverity.com/faq#frequency
branch_pattern
:
coverity_scan
-
os
:
linux
language
:
c
compiler
:
gcc
env
:
ENV_COVER=true
git
:
-
depth
:
1
addons
:
apt
:
packages
:
-
build-essential
-
cmake
-
net-tools
-
python-pip
-
python-setuptools
-
python3-pip
-
python3-setuptools
-
lcov
before_install
:
-
sudo apt update -y -qq
-
sudo apt install -y net-tools python-pip python-setuptools python3-pip python3-setuptools lcov
before_script
:
-
cd ${TRAVIS_BUILD_DIR}
-
mkdir debug
-
cd debug
script
:
-
cmake -DCOVER=true ..
-
make
after_success
:
-
|-
case $TRAVIS_OS_NAME in
linux)
cd ${TRAVIS_BUILD_DIR}/debug
sudo make install || exit $?
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
cd ${TRAVIS_BUILD_DIR}/tests
bash ./test-all.sh
if [ "$?" -ne "0" ]; then
exit $?
fi
cd ${TRAVIS_BUILD_DIR}
lcov -d . --capture -o coverage.info
lcov -l coverage.info || exit $?
gem install coveralls-lcov
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
coveralls-lcov coverage.info
if [ "$?" -eq "0" ]; then
echo -e "${GREEN} ## Uploaded to Coveralls.io! ## ${NC}"
else
echo -e "${RED} ## Coveralls.io not collect coverage report! ## ${NC} "
exit $?
fi
bash <(curl -s https://codecov.io/bash) -f coverage.info
if [ "$?" -eq "0" ]; then
echo -e "${GREEN} ## Uploaded to Codecov! ## ${NC} "
else
echo -e "${RED} ## Codecov did not collect coverage report! ## ${NC} "
exit $?
fi
;;
esac
-
os
:
linux
language
:
c
compiler
:
clang
env
:
DESC="linux/clang build"
git
:
-
depth
:
1
addons
:
apt
:
packages
:
-
build-essential
-
cmake
before_script
:
-
cd ${TRAVIS_BUILD_DIR}
-
mkdir debug
-
cd debug
script
:
-
cmake ..
-
make
# - os
:
osx
# language: c
# compiler: clang
# env: DESC="mac/clang build"
# git:
# - depth: 1
# addons:
# homebrew:
# - cmake
#
# script:
# - cd ${TRAVIS_BUILD_DIR}
# - mkdir debug
# - cd debug
# - cmake ..
# - make
CMakeLists.txt
浏览文件 @
2f1e5287
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
SET
(
TD_
CLUSTER
FALSE
)
SET
(
TD_
SYNC
FALSE
)
SET
(
TD_ACCOUNT FALSE
)
SET
(
TD_VPEER FALSE
)
SET
(
TD_MPEER FALSE
)
SET
(
TD_ADMIN FALSE
)
SET
(
TD_GRANT FALSE
)
SET
(
TD_COVER FALSE
)
SET
(
TD_MEM_CHECK FALSE
)
SET
(
TD_PAGMODE_LITE FALSE
)
SET
(
TD_GODLL FALSE
)
SET
(
TD_MEM_CHECK FALSE
)
SET
(
TD_COMMUNITY_DIR
${
PROJECT_SOURCE_DIR
}
)
MESSAGE
(
STATUS
"Community directory: "
${
TD_COMMUNITY_DIR
}
)
...
...
cmake/define.inc
浏览文件 @
2f1e5287
CMAKE_MINIMUM_REQUIRED
(
VERSION
2.8
)
PROJECT
(
TDengine
)
IF
(
TD_
CLUSTER
)
ADD_DEFINITIONS
(
-
D_
CLUSTER
)
IF
(
TD_
SYNC
)
ADD_DEFINITIONS
(
-
D_
SYNC
)
ENDIF
()
IF
(
TD_MPEER
)
ADD_DEFINITIONS
(
-
D_MPEER
)
ENDIF
()
IF
(
TD_VPEER
)
ADD_DEFINITIONS
(
-
D_VPEER
)
#ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=3)
ELSE
()
#ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=1)
IF
(
TD_ACCOUNT
)
ADD_DEFINITIONS
(
-
D_ACCT
)
ENDIF
()
IF
(
TD_A
CCOUNT
)
ADD_DEFINITIONS
(
-
D_A
CCOUNT
)
IF
(
TD_A
DMIN
)
ADD_DEFINITIONS
(
-
D_A
DMIN
)
ENDIF
()
IF
(
TD_GRANT
)
...
...
cmake/input.inc
浏览文件 @
2f1e5287
CMAKE_MINIMUM_REQUIRED
(
VERSION
2.8
)
PROJECT
(
TDengine
)
IF
(
$
{
CLUSTER
}
MATCHES
"true"
)
SET
(
TD_CLUSTER
TRUE
)
MESSAGE
(
STATUS
"Build with cluster plugins"
)
ELSEIF
(
$
{
CLUSTER
}
MATCHES
"false"
)
SET
(
TD_CLUSTER
FALSE
)
MESSAGE
(
STATUS
"Build without cluster plugins"
)
ENDIF
()
IF
(
$
{
ACCOUNT
}
MATCHES
"true"
)
SET
(
TD_ACCOUNT
TRUE
)
MESSAGE
(
STATUS
"Build with account plugins"
)
...
...
cmake/platform.inc
浏览文件 @
2f1e5287
...
...
@@ -122,6 +122,12 @@ IF (TD_LINUX_64)
link_libraries
(
/
usr
/
lib
/
libargp
.
a
)
ADD_DEFINITIONS
(
-
D_ALPINE
)
ENDIF
()
IF
(
$
{
COVER
}
MATCHES
"true"
)
MESSAGE
(
STATUS
"Test coverage mode, add extra flags"
)
SET
(
GCC_COVERAGE_COMPILE_FLAGS
"-fprofile-arcs -ftest-coverage"
)
SET
(
GCC_COVERAGE_LINK_FLAGS
"-lgcov --coverage"
)
SET
(
COMMON_FLAGS
"${COMMON_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}"
)
ENDIF
()
ELSEIF
(
TD_LINUX_32
)
IF
(
NOT
TD_ARM
)
EXIT
()
...
...
@@ -138,6 +144,12 @@ IF (TD_LINUX_64)
link_library
(
/
usr
/
lib
/
libargp
.
a
)
ADD_DEFINITIONS
(
-
D_ALPINE
)
ENDIF
()
IF
(
$
{
COVER
}
MATCHES
"true"
)
MESSAGE
(
STATUS
"Test coverage mode, add extra flags"
)
SET
(
GCC_COVERAGE_COMPILE_FLAGS
"-fprofile-arcs -ftest-coverage"
)
SET
(
GCC_COVERAGE_LINK_FLAGS
"-lgcov --coverage"
)
SET
(
COMMON_FLAGS
"${COMMON_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}"
)
ENDIF
()
ELSEIF
(
TD_WINDOWS_64
)
SET
(
CMAKE_GENERATOR
"NMake Makefiles"
CACHE
INTERNAL
""
FORCE
)
IF
(
NOT
TD_GODLL
)
...
...
src/
util
/src/tstring.c
→
src/
common
/src/tstring.c
浏览文件 @
2f1e5287
文件已移动
src/dnode/CMakeLists.txt
浏览文件 @
2f1e5287
...
...
@@ -21,20 +21,13 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
IF
(
TD_ACCOUNT
)
TARGET_LINK_LIBRARIES
(
taosd account
)
ENDIF
()
IF
(
TD_GRANT
)
TARGET_LINK_LIBRARIES
(
taosd grant
)
ENDIF
()
IF
(
TD_CLUSTER
)
TARGET_LINK_LIBRARIES
(
taosd cluster
)
ENDIF
()
IF
(
TD_VPEER
)
TARGET_LINK_LIBRARIES
(
taosd balance sync
)
ENDIF
()
IF
(
TD_MPEER
)
TARGET_LINK_LIBRARIES
(
taosd mpeer sync
)
IF
(
TD_SYNC
)
TARGET_LINK_LIBRARIES
(
taosd replica sync
)
ENDIF
()
SET
(
PREPARE_ENV_CMD
"prepare_env_cmd"
)
...
...
src/dnode/inc/dnodeMClient.h
浏览文件 @
2f1e5287
...
...
@@ -23,9 +23,6 @@ extern "C" {
int32_t
dnodeInitMClient
();
void
dnodeCleanupMClient
();
void
dnodeSendMsgToMnode
(
SRpcMsg
*
rpcMsg
);
uint32_t
dnodeGetMnodeMasteIp
();
void
*
dnodeGetMpeerInfos
();
int32_t
dnodeGetDnodeId
();
#ifdef __cplusplus
}
...
...
src/dnode/inc/dnodeModule.h
浏览文件 @
2f1e5287
...
...
@@ -21,9 +21,9 @@ extern "C" {
#endif
int32_t
dnodeInitModules
();
void
dnodeCleanUp
Modules
();
void
dnodeStart
Modules
();
void
dnodeProcessModuleStatus
(
uint32_t
moduleStatus
);
void
dnodeStart
Modules
();
void
dnodeCleanUp
Modules
();
void
dnodeProcessModuleStatus
(
uint32_t
moduleStatus
);
#ifdef __cplusplus
}
...
...
src/dnode/src/dnodeMClient.c
浏览文件 @
2f1e5287
...
...
@@ -23,12 +23,12 @@
#include "tsync.h"
#include "ttime.h"
#include "ttimer.h"
#include "treplica.h"
#include "dnode.h"
#include "dnodeMClient.h"
#include "dnodeModule.h"
#include "dnodeMgmt.h"
#include "vnode.h"
#include "mpeer.h"
#define MPEER_CONTENT_LEN 2000
...
...
@@ -142,9 +142,9 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
}
SDMStatusRsp
*
pStatusRsp
=
pMsg
->
pCont
;
SDMNodeInfos
*
m
peers
=
&
pStatusRsp
->
mpeer
s
;
if
(
m
peer
s
->
nodeNum
<=
0
)
{
dError
(
"status msg is invalid, num of ips is %d"
,
m
peer
s
->
nodeNum
);
SDMNodeInfos
*
m
nodes
=
&
pStatusRsp
->
mnode
s
;
if
(
m
node
s
->
nodeNum
<=
0
)
{
dError
(
"status msg is invalid, num of ips is %d"
,
m
node
s
->
nodeNum
);
taosTmrReset
(
dnodeSendStatusMsg
,
tsStatusInterval
*
1000
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
return
;
}
...
...
@@ -159,29 +159,29 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
dnodeUpdateDnodeInfo
(
pState
->
dnodeId
);
SRpcIpSet
mgmtIpSet
=
{
0
};
mgmtIpSet
.
inUse
=
m
peer
s
->
inUse
;
mgmtIpSet
.
numOfIps
=
m
peer
s
->
nodeNum
;
mgmtIpSet
.
port
=
htons
(
m
peer
s
->
nodeInfos
[
0
].
nodePort
);
for
(
int32_t
i
=
0
;
i
<
m
peer
s
->
nodeNum
;
i
++
)
{
mgmtIpSet
.
ip
[
i
]
=
htonl
(
m
peer
s
->
nodeInfos
[
i
].
nodeIp
);
mgmtIpSet
.
inUse
=
m
node
s
->
inUse
;
mgmtIpSet
.
numOfIps
=
m
node
s
->
nodeNum
;
mgmtIpSet
.
port
=
htons
(
m
node
s
->
nodeInfos
[
0
].
nodePort
);
for
(
int32_t
i
=
0
;
i
<
m
node
s
->
nodeNum
;
i
++
)
{
mgmtIpSet
.
ip
[
i
]
=
htonl
(
m
node
s
->
nodeInfos
[
i
].
nodeIp
);
}
if
(
memcmp
(
&
mgmtIpSet
,
&
tsMnodeIpList
,
sizeof
(
SRpcIpSet
))
!=
0
||
tsMnodeInfos
.
nodeNum
==
0
)
{
memcpy
(
&
tsMnodeIpList
,
&
mgmtIpSet
,
sizeof
(
SRpcIpSet
));
tsMnodeInfos
.
inUse
=
m
peer
s
->
inUse
;
tsMnodeInfos
.
nodeNum
=
m
peer
s
->
nodeNum
;
tsMnodeInfos
.
inUse
=
m
node
s
->
inUse
;
tsMnodeInfos
.
nodeNum
=
m
node
s
->
nodeNum
;
dPrint
(
"mnode ip list is changed, numOfIps:%d inUse:%d"
,
tsMnodeInfos
.
nodeNum
,
tsMnodeInfos
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
m
peer
s
->
nodeNum
;
i
++
)
{
tsMnodeInfos
.
nodeInfos
[
i
].
nodeId
=
htonl
(
m
peer
s
->
nodeInfos
[
i
].
nodeId
);
tsMnodeInfos
.
nodeInfos
[
i
].
nodeIp
=
htonl
(
m
peer
s
->
nodeInfos
[
i
].
nodeIp
);
tsMnodeInfos
.
nodeInfos
[
i
].
nodePort
=
htons
(
m
peer
s
->
nodeInfos
[
i
].
nodePort
);
strcpy
(
tsMnodeInfos
.
nodeInfos
[
i
].
nodeName
,
m
peer
s
->
nodeInfos
[
i
].
nodeName
);
for
(
int32_t
i
=
0
;
i
<
m
node
s
->
nodeNum
;
i
++
)
{
tsMnodeInfos
.
nodeInfos
[
i
].
nodeId
=
htonl
(
m
node
s
->
nodeInfos
[
i
].
nodeId
);
tsMnodeInfos
.
nodeInfos
[
i
].
nodeIp
=
htonl
(
m
node
s
->
nodeInfos
[
i
].
nodeIp
);
tsMnodeInfos
.
nodeInfos
[
i
].
nodePort
=
htons
(
m
node
s
->
nodeInfos
[
i
].
nodePort
);
strcpy
(
tsMnodeInfos
.
nodeInfos
[
i
].
nodeName
,
m
node
s
->
nodeInfos
[
i
].
nodeName
);
dPrint
(
"mnode:%d, ip:%s:%u name:%s"
,
tsMnodeInfos
.
nodeInfos
[
i
].
nodeId
,
taosIpStr
(
tsMnodeInfos
.
nodeInfos
[
i
].
nodeIp
),
tsMnodeInfos
.
nodeInfos
[
i
].
nodePort
,
tsMnodeInfos
.
nodeInfos
[
i
].
nodeName
);
}
dnodeSaveMnodeIpList
();
mpeerUpdateSync
();
replicaNotify
();
}
taosTmrReset
(
dnodeSendStatusMsg
,
tsStatusInterval
*
1000
,
NULL
,
tsDnodeTmr
,
&
tsStatusTimer
);
...
...
@@ -332,7 +332,7 @@ uint32_t dnodeGetMnodeMasteIp() {
return
tsMnodeIpList
.
ip
[
tsMnodeIpList
.
inUse
];
}
void
*
dnodeGetM
peerInfos
()
{
void
*
dnodeGetM
nodeList
()
{
return
&
tsMnodeInfos
;
}
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
2f1e5287
...
...
@@ -17,7 +17,6 @@
#include "os.h"
#include "tglobalcfg.h"
#include "tlog.h"
#include "tmodule.h"
#include "trpc.h"
#include "tutil.h"
#include "dnode.h"
...
...
@@ -229,3 +228,7 @@ static int32_t dnodeInitStorage() {
}
static
void
dnodeCleanupStorage
()
{}
bool
dnodeIsFirstDeploy
()
{
return
strcmp
(
tsMasterIp
,
tsPrivateIp
)
==
0
;
}
\ No newline at end of file
src/dnode/src/dnodeMgmt.c
浏览文件 @
2f1e5287
...
...
@@ -22,11 +22,11 @@
#include "trpc.h"
#include "tsdb.h"
#include "twal.h"
#include "vnode.h"
#include "dnodeMClient.h"
#include "dnodeMgmt.h"
#include "dnodeRead.h"
#include "dnodeWrite.h"
#include "vnode.h"
static
int32_t
dnodeOpenVnodes
();
static
void
dnodeCloseVnodes
();
...
...
src/dnode/src/dnodeModule.c
浏览文件 @
2f1e5287
...
...
@@ -15,55 +15,74 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tlog.h"
#include "tmodule.h"
#include "tglobalcfg.h"
#include "mnode.h"
#include "http.h"
#include "monitor.h"
#include "dnodeModule.h"
#include "dnode.h"
static
void
dnodeAllocModules
()
{
tsModule
[
TSDB_MOD_MGMT
].
name
=
"mgmt"
;
tsModule
[
TSDB_MOD_MGMT
].
initFp
=
mgmtInitSystem
;
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
=
mgmtCleanUpSystem
;
tsModule
[
TSDB_MOD_MGMT
].
startFp
=
mgmtStartSystem
;
tsModule
[
TSDB_MOD_MGMT
].
stopFp
=
mgmtStopSystem
;
tsModule
[
TSDB_MOD_MGMT
].
num
=
tsNumOfMPeers
;
tsModule
[
TSDB_MOD_MGMT
].
curNum
=
0
;
tsModule
[
TSDB_MOD_MGMT
].
equalVnodeNum
=
tsMgmtEqualVnodeNum
;
typedef
struct
{
bool
enable
;
char
*
name
;
int32_t
(
*
initFp
)();
int32_t
(
*
startFp
)();
void
(
*
cleanUpFp
)();
void
(
*
stopFp
)();
}
SModule
;
static
SModule
tsModule
[
TSDB_MOD_MAX
]
=
{
0
};
static
uint32_t
tsModuleStatus
=
0
;
tsModule
[
TSDB_MOD_HTTP
].
name
=
"http"
;
tsModule
[
TSDB_MOD_HTTP
].
initFp
=
httpInitSystem
;
tsModule
[
TSDB_MOD_HTTP
].
cleanUpFp
=
httpCleanUpSystem
;
tsModule
[
TSDB_MOD_HTTP
].
startFp
=
httpStartSystem
;
tsModule
[
TSDB_MOD_HTTP
].
stopFp
=
httpStopSystem
;
tsModule
[
TSDB_MOD_HTTP
].
num
=
(
tsEnableHttpModule
==
1
)
?
-
1
:
0
;
tsModule
[
TSDB_MOD_HTTP
].
curNum
=
0
;
tsModule
[
TSDB_MOD_HTTP
].
equalVnodeNum
=
0
;
static
void
dnodeSetModuleStatus
(
int32_t
module
)
{
tsModuleStatus
|=
(
1
<<
module
);
}
static
void
dnodeUnSetModuleStatus
(
int32_t
module
)
{
tsModuleStatus
&=
~
(
1
<<
module
);
}
tsModule
[
TSDB_MOD_MONITOR
].
name
=
"monitor"
;
tsModule
[
TSDB_MOD_MONITOR
].
initFp
=
monitorInitSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
cleanUpFp
=
monitorCleanUpSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
startFp
=
monitorStartSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
stopFp
=
monitorStopSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
num
=
(
tsEnableMonitorModule
==
1
)
?
-
1
:
0
;
tsModule
[
TSDB_MOD_MONITOR
].
curNum
=
0
;
tsModule
[
TSDB_MOD_MONITOR
].
equalVnodeNum
=
0
;
static
void
dnodeAllocModules
()
{
tsModule
[
TSDB_MOD_MGMT
].
name
=
false
;
tsModule
[
TSDB_MOD_MGMT
].
name
=
"mgmt"
;
tsModule
[
TSDB_MOD_MGMT
].
initFp
=
mgmtInitSystem
;
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
=
mgmtCleanUpSystem
;
tsModule
[
TSDB_MOD_MGMT
].
startFp
=
mgmtStartSystem
;
tsModule
[
TSDB_MOD_MGMT
].
stopFp
=
mgmtStopSystem
;
tsModule
[
TSDB_MOD_HTTP
].
enable
=
(
tsEnableHttpModule
==
1
);
tsModule
[
TSDB_MOD_HTTP
].
name
=
"http"
;
tsModule
[
TSDB_MOD_HTTP
].
initFp
=
httpInitSystem
;
tsModule
[
TSDB_MOD_HTTP
].
cleanUpFp
=
httpCleanUpSystem
;
tsModule
[
TSDB_MOD_HTTP
].
startFp
=
httpStartSystem
;
tsModule
[
TSDB_MOD_HTTP
].
stopFp
=
httpStopSystem
;
if
(
tsEnableHttpModule
)
{
dnodeSetModuleStatus
(
TSDB_MOD_HTTP
);
}
tsModule
[
TSDB_MOD_MONITOR
].
enable
=
(
tsEnableMonitorModule
==
1
);
tsModule
[
TSDB_MOD_MONITOR
].
name
=
"monitor"
;
tsModule
[
TSDB_MOD_MONITOR
].
initFp
=
monitorInitSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
cleanUpFp
=
monitorCleanUpSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
startFp
=
monitorStartSystem
;
tsModule
[
TSDB_MOD_MONITOR
].
stopFp
=
monitorStopSystem
;
if
(
tsEnableMonitorModule
)
{
dnodeSetModuleStatus
(
TSDB_MOD_MONITOR
);
}
}
void
dnodeCleanUpModules
()
{
for
(
int
mod
=
1
;
mod
<
TSDB_MOD_MAX
;
++
mod
)
{
if
(
tsModule
[
mod
].
num
!=
0
&&
tsModule
[
mod
].
stopFp
)
{
(
*
tsModule
[
mod
].
stopFp
)();
for
(
int
32_t
module
=
1
;
module
<
TSDB_MOD_MAX
;
++
module
)
{
if
(
tsModule
[
mod
ule
].
enable
&&
tsModule
[
module
].
stopFp
)
{
(
*
tsModule
[
mod
ule
].
stopFp
)();
}
if
(
tsModule
[
mod
].
num
!=
0
&&
tsModule
[
mod
].
cleanUpFp
)
{
(
*
tsModule
[
mod
].
cleanUpFp
)();
if
(
tsModule
[
mod
ule
].
cleanUpFp
)
{
(
*
tsModule
[
mod
ule
].
cleanUpFp
)();
}
}
if
(
tsModule
[
TSDB_MOD_MGMT
].
num
!=
0
&&
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
)
{
if
(
tsModule
[
TSDB_MOD_MGMT
].
enable
&&
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
)
{
(
*
tsModule
[
TSDB_MOD_MGMT
].
cleanUpFp
)();
}
}
...
...
@@ -71,57 +90,41 @@ void dnodeCleanUpModules() {
int32_t
dnodeInitModules
()
{
dnodeAllocModules
();
for
(
int
mod
=
0
;
mod
<
TSDB_MOD_MAX
;
++
mod
)
{
if
(
tsModule
[
mod
].
num
!=
0
&&
tsModule
[
mod
].
initFp
)
{
if
((
*
tsModule
[
mod
].
initFp
)()
!=
0
)
{
dError
(
"failed to init module
s"
);
for
(
int
32_t
module
=
0
;
module
<
TSDB_MOD_MAX
;
++
module
)
{
if
(
tsModule
[
mod
ule
].
initFp
)
{
if
((
*
tsModule
[
mod
ule
].
initFp
)()
!=
0
)
{
dError
(
"failed to init module
:%s"
,
tsModule
[
module
].
name
);
return
-
1
;
}
}
}
return
TSDB_CODE_SUCCESS
;
return
0
;
}
void
dnodeStartModules
()
{
// for (int mod = 1; mod < TSDB_MOD_MAX; ++mod
) {
// if (tsModule[mod].num != 0 && tsModule[mod
].startFp) {
// if ((*tsModule[mod
].startFp)() != 0) {
// dError("failed to start module:%d", mod
);
//
}
//
}
//
}
for
(
int32_t
module
=
1
;
module
<
TSDB_MOD_MAX
;
++
module
)
{
if
(
tsModule
[
module
].
enable
&&
tsModule
[
module
].
startFp
)
{
if
((
*
tsModule
[
module
].
startFp
)()
!=
0
)
{
dError
(
"failed to start module:%s"
,
tsModule
[
module
].
name
);
}
}
}
}
void
dnodeProcessModuleStatus
(
uint32_t
moduleStatus
)
{
if
(
moduleStatus
==
tsModuleStatus
)
return
;
dPrint
(
"module status is received, old:%d, new:%d"
,
tsModuleStatus
,
moduleStatus
);
int
news
=
moduleStatus
;
int
olds
=
tsModuleStatus
;
for
(
int
moduleType
=
0
;
moduleType
<
TSDB_MOD_MAX
;
++
moduleType
)
{
int
newStatus
=
news
&
(
1
<<
moduleType
);
int
oldStatus
=
olds
&
(
1
<<
moduleType
);
if
(
oldStatus
>
0
)
{
if
(
newStatus
==
0
)
{
if
(
tsModule
[
moduleType
].
stopFp
)
{
dPrint
(
"module:%s is stopped on this node"
,
tsModule
[
moduleType
].
name
);
(
*
tsModule
[
moduleType
].
stopFp
)();
}
}
}
else
if
(
oldStatus
==
0
)
{
if
(
newStatus
>
0
)
{
if
(
tsModule
[
moduleType
].
startFp
)
{
dPrint
(
"module:%s is started on this node"
,
tsModule
[
moduleType
].
name
);
(
*
tsModule
[
moduleType
].
startFp
)();
}
}
}
else
{
}
bool
enableMgmtModule
=
moduleStatus
&
(
1
<<
TSDB_MOD_MGMT
);
if
(
!
tsModule
[
TSDB_MOD_MGMT
].
enable
&&
enableMgmtModule
)
{
dPrint
(
"module status is received, start mgmt module"
,
tsModuleStatus
,
moduleStatus
);
tsModule
[
TSDB_MOD_MGMT
].
enable
=
true
;
dnodeSetModuleStatus
(
TSDB_MOD_MGMT
);
(
*
tsModule
[
TSDB_MOD_MGMT
].
startFp
)();
}
tsModuleStatus
=
moduleStatus
;
if
(
tsModule
[
TSDB_MOD_MGMT
].
enable
&&
!
enableMgmtModule
)
{
dPrint
(
"module status is received, stop mgmt module"
,
tsModuleStatus
,
moduleStatus
);
tsModule
[
TSDB_MOD_MGMT
].
enable
=
false
;
dnodeUnSetModuleStatus
(
TSDB_MOD_MGMT
);
(
*
tsModule
[
TSDB_MOD_MGMT
].
stopFp
)();
}
}
src/inc/dnode.h
浏览文件 @
2f1e5287
...
...
@@ -20,9 +20,6 @@
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
typedef
struct
{
int32_t
queryReqNum
;
int32_t
submitReqNum
;
...
...
@@ -44,6 +41,11 @@ void *dnodeAllocateRqueue(void *pVnode);
void
dnodeFreeRqueue
(
void
*
rqueue
);
void
dnodeSendRpcWriteRsp
(
void
*
pVnode
,
void
*
param
,
int32_t
code
);
bool
dnodeIsFirstDeploy
();
uint32_t
dnodeGetMnodeMasteIp
();
void
*
dnodeGetMnodeList
();
int32_t
dnodeGetDnodeId
();
#ifdef __cplusplus
}
#endif
...
...
src/inc/mnode.h
浏览文件 @
2f1e5287
...
...
@@ -20,248 +20,11 @@
extern
"C"
{
#endif
#include "os.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "tglobalcfg.h"
#include "thash.h"
#include "tidpool.h"
#include "tlog.h"
#include "tmempool.h"
#include "trpc.h"
#include "taosdef.h"
#include "tskiplist.h"
#include "tsocket.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
struct
_vg_obj
;
struct
_db_obj
;
struct
_acct_obj
;
struct
_user_obj
;
struct
_mnode_obj
;
typedef
struct
_mnode_obj
{
int32_t
mnodeId
;
int64_t
createdTime
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
uint32_t
privateIp
;
uint32_t
publicIp
;
uint16_t
port
;
int8_t
role
;
char
mnodeName
[
TSDB_NODE_NAME_LEN
+
1
];
}
SMnodeObj
;
typedef
struct
_dnode_obj
{
int32_t
dnodeId
;
uint32_t
privateIp
;
uint32_t
publicIp
;
uint32_t
moduleStatus
;
int64_t
createdTime
;
uint32_t
lastAccess
;
int32_t
openVnodes
;
int32_t
numOfTotalVnodes
;
// from dnode status msg, config information
uint32_t
rack
;
uint16_t
idc
;
uint16_t
slot
;
uint16_t
numOfCores
;
// from dnode status msg
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
status
;
// set in balance function
int32_t
customScore
;
// config by user
char
dnodeName
[
TSDB_NODE_NAME_LEN
+
1
];
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SVnodeLoad
vload
[
TSDB_MAX_VNODES
];
uint32_t
lastReboot
;
// time stamp for last reboot
float
score
;
// calc in balance function
float
diskAvailable
;
// from dnode status msg
int16_t
diskAvgUsage
;
// calc from sys.disk
int16_t
cpuAvgUsage
;
// calc from sys.cpu
int16_t
memoryAvgUsage
;
// calc from sys.mem
int16_t
bandwidthUsage
;
// calc from sys.band
}
SDnodeObj
;
typedef
struct
{
int32_t
dnodeId
;
uint16_t
port
;
uint32_t
privateIp
;
uint32_t
publicIp
;
}
SVnodeGid
;
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
int8_t
type
;
}
STableObj
;
typedef
struct
SSuperTableObj
{
STableObj
info
;
uint64_t
uid
;
int64_t
createdTime
;
int32_t
sversion
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
numOfTables
;
int16_t
nextColId
;
SSchema
*
schema
;
int32_t
vgLen
;
int32_t
*
vgList
;
}
SSuperTableObj
;
typedef
struct
{
STableObj
info
;
uint64_t
uid
;
int64_t
createdTime
;
int32_t
sversion
;
//used by normal table
int32_t
numOfColumns
;
//used by normal table
int32_t
sid
;
int32_t
vgId
;
char
superTableId
[
TSDB_TABLE_ID_LEN
+
1
];
int32_t
sqlLen
;
int8_t
reserved
[
1
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
//used by normal table
int32_t
refCount
;
char
*
sql
;
//used by normal table
SSchema
*
schema
;
//used by normal table
SSuperTableObj
*
superTable
;
}
SChildTableObj
;
typedef
struct
_vg_obj
{
uint32_t
vgId
;
char
dbName
[
TSDB_DB_NAME_LEN
+
1
];
int64_t
createdTime
;
SVnodeGid
vnodeGid
[
TSDB_VNODES_SUPPORT
];
int32_t
numOfVnodes
;
int32_t
lbDnodeId
;
int32_t
lbTime
;
int8_t
status
;
int8_t
inUse
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
_vg_obj
*
prev
,
*
next
;
struct
_db_obj
*
pDb
;
int32_t
numOfTables
;
void
*
idPool
;
SChildTableObj
**
tableList
;
}
SVgObj
;
typedef
struct
_db_obj
{
char
name
[
TSDB_DB_NAME_LEN
+
1
];
int8_t
status
;
int64_t
createdTime
;
SDbCfg
cfg
;
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
SVgObj
*
pHead
;
SVgObj
*
pTail
;
struct
_acct_obj
*
pAcct
;
}
SDbObj
;
typedef
struct
_user_obj
{
char
user
[
TSDB_USER_LEN
+
1
];
char
pass
[
TSDB_KEY_LEN
+
1
];
char
acct
[
TSDB_USER_LEN
+
1
];
int64_t
createdTime
;
int8_t
superAuth
;
int8_t
writeAuth
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
_acct_obj
*
pAcct
;
SQqueryList
*
pQList
;
// query list
SStreamList
*
pSList
;
// stream list
}
SUserObj
;
typedef
struct
{
int32_t
numOfUsers
;
int32_t
numOfDbs
;
int32_t
numOfTimeSeries
;
int32_t
numOfPointsPerSecond
;
int32_t
numOfConns
;
int32_t
numOfQueries
;
int32_t
numOfStreams
;
int64_t
totalStorage
;
// Total storage wrtten from this account
int64_t
compStorage
;
// Compressed storage on disk
int64_t
queryTime
;
int64_t
totalPoints
;
int64_t
inblound
;
int64_t
outbound
;
int64_t
sKey
;
int8_t
accessState
;
// Checked by mgmt heartbeat message
}
SAcctInfo
;
typedef
struct
_acct_obj
{
char
user
[
TSDB_USER_LEN
+
1
];
char
pass
[
TSDB_KEY_LEN
+
1
];
SAcctCfg
cfg
;
int32_t
acctId
;
int64_t
createdTime
;
int8_t
dirty
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SAcctInfo
acctInfo
;
pthread_mutex_t
mutex
;
}
SAcctObj
;
typedef
struct
{
int8_t
type
;
char
db
[
TSDB_DB_NAME_LEN
+
1
];
void
*
pNode
;
int16_t
numOfColumns
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfReads
;
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int16_t
bytes
[
TSDB_MAX_COLUMNS
];
void
*
signature
;
uint16_t
payloadLen
;
char
payload
[];
}
SShowObj
;
typedef
struct
{
uint8_t
msgType
;
int8_t
usePublicIp
;
int8_t
received
;
int8_t
successed
;
int8_t
expected
;
int8_t
retry
;
int8_t
maxRetry
;
int32_t
contLen
;
int32_t
code
;
void
*
ahandle
;
void
*
thandle
;
void
*
pCont
;
SAcctObj
*
pAcct
;
SDnodeObj
*
pDnode
;
SUserObj
*
pUser
;
SDbObj
*
pDb
;
SVgObj
*
pVgroup
;
STableObj
*
pTable
;
}
SQueuedMsg
;
int32_t
mgmtInitSystem
();
int32_t
mgmtStartSystem
();
void
mgmtCleanUpSystem
();
void
mgmtStopSystem
();
extern
char
version
[];
extern
void
*
tsMgmtTmr
;
extern
char
tsMnodeDir
[];
#ifdef __cplusplus
}
#endif
...
...
src/inc/query.h
浏览文件 @
2f1e5287
...
...
@@ -38,57 +38,57 @@ typedef void* qinfo_t;
* create the qinfo object according to QueryTableMsg
* @param pVnode
* @param pQueryTableMsg
* @param
pQI
nfo
* @param
qi
nfo
* @return
*/
int32_t
qCreateQueryInfo
(
void
*
pVnode
,
SQueryTableMsg
*
pQueryTableMsg
,
qinfo_t
*
pQI
nfo
);
int32_t
qCreateQueryInfo
(
void
*
pVnode
,
SQueryTableMsg
*
pQueryTableMsg
,
qinfo_t
*
qi
nfo
);
/**
* Destroy QInfo object
*
* @param
pQI
nfo
* @param
qi
nfo
* @return
*/
void
qDestroyQueryInfo
(
qinfo_t
pQI
nfo
);
void
qDestroyQueryInfo
(
qinfo_t
qi
nfo
);
/**
* the main query execution function, including query on both table and multitables,
* which are decided according to the tag or table name query conditions
*
* @param
pQI
nfo
* @param
qi
nfo
* @return
*/
void
qTableQuery
(
qinfo_t
pQI
nfo
);
void
qTableQuery
(
qinfo_t
qi
nfo
);
/**
* Retrieve the produced results information, if current query is not paused or completed,
* this function will be blocked to wait for the query execution completed or paused,
* in which case enough results have been produced already.
*
* @param
pQI
nfo
* @param
qi
nfo
* @return
*/
int32_t
qRetrieveQueryResultInfo
(
qinfo_t
pQI
nfo
);
int32_t
qRetrieveQueryResultInfo
(
qinfo_t
qi
nfo
);
/**
*
* Retrieve the actual results to fill the response message payload.
* Note that this function must be executed after qRetrieveQueryResultInfo is invoked.
*
* @param
pQI
nfo qinfo object
* @param
qi
nfo qinfo object
* @param pRsp response message
* @param contLen payload length
* @return
*/
int32_t
qDumpRetrieveResult
(
qinfo_t
pQI
nfo
,
SRetrieveTableRsp
**
pRsp
,
int32_t
*
contLen
);
int32_t
qDumpRetrieveResult
(
qinfo_t
qi
nfo
,
SRetrieveTableRsp
**
pRsp
,
int32_t
*
contLen
);
/**
* Decide if more results will be produced or not
*
* @param
pQI
nfo
* @param
qi
nfo
* @return
*/
bool
qHasMoreResultsToRetrieve
(
qinfo_t
pQI
nfo
);
bool
qHasMoreResultsToRetrieve
(
qinfo_t
qi
nfo
);
#ifdef __cplusplus
}
...
...
src/
util/src/tmodule.c
→
src/
inc/tacct.h
浏览文件 @
2f1e5287
...
...
@@ -13,8 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#
define _DEFAULT_SOURCE
#
include "tmodule.h"
#
ifndef TDENGINE_ACCT_H
#
define TDENGINE_ACCT_H
SModule
tsModule
[
TSDB_MOD_MAX
]
=
{
0
};
uint32_t
tsModuleStatus
=
0
;
\ No newline at end of file
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
enum
{
ACCT_GRANT_USER
,
ACCT_GRANT_DB
,
ACCT_GRANT_TABLE
}
EAcctGrantType
;
int32_t
acctInit
();
void
acctCleanUp
();
int32_t
acctCheck
(
void
*
pAcct
,
EAcctGrantType
type
);
#ifdef __cplusplus
}
#endif
#endif
src/inc/tadmin.h
浏览文件 @
2f1e5287
...
...
@@ -20,15 +20,10 @@
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
struct
HttpServer
;
void
adminInit
();
struct
_http_server_obj_
;
extern
void
(
*
adminInitHandleFp
)(
struct
_http_server_obj_
*
pServer
);
extern
void
(
*
opInitHandleFp
)(
struct
_http_server_obj_
*
pServer
);
void
adminInitHandle
(
struct
HttpServer
*
pServer
);
void
opInitHandle
(
struct
HttpServer
*
pServer
);
#ifdef __cplusplus
}
...
...
src/inc/taosdef.h
浏览文件 @
2f1e5287
...
...
@@ -319,11 +319,11 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_NORMAL_TABLES 1000
#define TSDB_MAX_CHILD_TABLES 100000
enum
{
typedef
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
TSDB_PRECISION_NANO
};
}
EPrecisionType
;
typedef
enum
{
TSDB_SUPER_TABLE
=
0
,
// super table
...
...
@@ -331,7 +331,14 @@ typedef enum {
TSDB_NORMAL_TABLE
=
2
,
// ordinary table
TSDB_STREAM_TABLE
=
3
,
// table created from stream computing
TSDB_TABLE_MAX
=
4
}
TSDB_TABLE_TYPE
;
}
ETableType
;
typedef
enum
{
TSDB_MOD_MGMT
,
TSDB_MOD_HTTP
,
TSDB_MOD_MONITOR
,
TSDB_MOD_MAX
}
EModuleType
;
#ifdef __cplusplus
}
...
...
src/inc/taosmsg.h
浏览文件 @
2f1e5287
...
...
@@ -584,6 +584,7 @@ typedef struct {
char
dnodeName
[
TSDB_NODE_NAME_LEN
+
1
];
uint32_t
privateIp
;
uint32_t
publicIp
;
uint32_t
moduleStatus
;
uint32_t
lastReboot
;
// time stamp for last reboot
uint16_t
numOfTotalVnodes
;
// from config file
uint16_t
openVnodes
;
...
...
@@ -608,7 +609,7 @@ typedef struct {
}
SDMNodeInfos
;
typedef
struct
{
SDMNodeInfos
m
peer
s
;
SDMNodeInfos
m
node
s
;
SDnodeState
dnodeState
;
SVnodeAccess
vnodeAccess
[];
}
SDMStatusRsp
;
...
...
src/inc/t
balance
.h
→
src/inc/t
replica
.h
浏览文件 @
2f1e5287
...
...
@@ -13,27 +13,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
BALANCE
_H
#define TDENGINE_
BALANCE
_H
#ifndef TDENGINE_
REPLICA
_H
#define TDENGINE_
REPLICA
_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
struct
SVgObj
;
struct
SDnodeObj
;
struct
_db_obj
;
struct
_vg_obj
;
struct
_dnode_obj
;
int32_t
balanceInit
();
void
balanceCleanUp
();
void
balanceNotify
();
void
balanceReset
();
int32_t
balanceAllocVnodes
(
struct
_vg_obj
*
pVgroup
);
int32_t
balanceDropDnode
(
struct
_dnode_obj
*
pDnode
);
int32_t
replicaInit
();
void
replicaCleanUp
();
void
replicaNotify
();
void
replicaReset
();
int32_t
replicaAllocVnodes
(
struct
SVgObj
*
pVgroup
);
int32_t
replicaForwardReqToPeer
(
void
*
pHead
);
int32_t
replicaDropDnode
(
struct
SDnodeObj
*
pDnode
);
#ifdef __cplusplus
}
...
...
src/
tsdb/
inc/tsdb.h
→
src/inc/tsdb.h
浏览文件 @
2f1e5287
...
...
@@ -20,10 +20,10 @@
#include <stdint.h>
#include "dataformat.h"
#include "name.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "name.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -62,14 +62,11 @@ void tsdbFreeCfg(STsdbCfg *pCfg);
// --------- TSDB REPOSITORY DEFINITION
typedef
void
tsdb_repo_t
;
// use void to hide implementation details from outside
int
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
);
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
,
STsdbAppH
*
pAppH
);
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
);
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
);
int32_t
tsdbTriggerCommit
(
tsdb_repo_t
*
repo
);
int32_t
tsdbLockRepo
(
tsdb_repo_t
*
repo
);
int32_t
tsdbUnLockRepo
(
tsdb_repo_t
*
repo
);
int
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
);
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
,
STsdbAppH
*
pAppH
);
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
);
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
);
// --------- TSDB TABLE DEFINITION
typedef
struct
{
...
...
@@ -79,7 +76,7 @@ typedef struct {
// --------- TSDB TABLE configuration
typedef
struct
{
TSDB_TABLE_TYPE
type
;
ETableType
type
;
STableId
tableId
;
int32_t
sversion
;
int64_t
superUid
;
...
...
@@ -88,7 +85,7 @@ typedef struct {
SDataRow
tagValues
;
}
STableCfg
;
int
tsdbInitTableCfg
(
STableCfg
*
config
,
TSDB_TABLE_TYPE
type
,
int64_t
uid
,
int32_t
tid
);
int
tsdbInitTableCfg
(
STableCfg
*
config
,
ETableType
type
,
int64_t
uid
,
int32_t
tid
);
int
tsdbTableSetSuperUid
(
STableCfg
*
config
,
int64_t
uid
);
int
tsdbTableSetSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
);
int
tsdbTableSetTagSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
);
...
...
@@ -101,27 +98,6 @@ int tsdbCreateTable(tsdb_repo_t *repo, STableCfg *pCfg);
int
tsdbDropTable
(
tsdb_repo_t
*
pRepo
,
STableId
tableId
);
int
tsdbAlterTable
(
tsdb_repo_t
*
repo
,
STableCfg
*
pCfg
);
typedef
struct
{
int32_t
totalLen
;
int32_t
len
;
SDataRow
row
;
}
SSubmitBlkIter
;
int
tsdbInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
SDataRow
tsdbGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
#define TSDB_SUBMIT_MSG_HEAD_SIZE sizeof(SSubmitMsg)
// SSubmitMsg Iterator
typedef
struct
{
int32_t
totalLen
;
int32_t
len
;
SSubmitBlk
*
pBlock
;
}
SSubmitMsgIter
;
int
tsdbInitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
);
SSubmitBlk
*
tsdbGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
);
// the TSDB repository info
typedef
struct
STsdbRepoInfo
{
STsdbCfg
tsdbCfg
;
...
...
@@ -139,35 +115,7 @@ typedef struct {
int64_t
tableTotalDataSize
;
// In bytes
int64_t
tableTotalDiskSize
;
// In bytes
}
STableInfo
;
STableInfo
*
tsdbGetTableInfo
(
tsdb_repo_t
*
pRepo
,
STableId
tid
);
// -- For table manipulation
/**
* Create/Alter a table in a TSDB repository handle
* @param repo the TSDB repository handle
* @param pCfg the table configurations, the upper layer should free the pointer
*
* @return 0 for success, -1 for failure and the error number is set
*/
/**
* Drop a table in a repository and free all the resources it takes
* @param pRepo the TSDB repository handle
* @param tid the ID of the table to drop
* @param error the error number to set when failure occurs
*
* @return 0 for success, -1 for failure and the error number is set
*/
/**
* Get the information of a table in the repository
* @param pRepo the TSDB repository handle
* @param tid the ID of the table to drop
* @param error the error number to set when failure occurs
*
* @return a table information handle for success, NULL for failure and the error number is set
*/
STableInfo
*
tsdbGetTableInfo
(
tsdb_repo_t
*
pRepo
,
STableId
tid
);
// -- FOR INSERT DATA
/**
...
...
@@ -181,13 +129,18 @@ int32_t tsdbInsertData(tsdb_repo_t *pRepo, SSubmitMsg *pMsg);
// -- FOR QUERY TIME SERIES DATA
typedef
void
*
tsdb_query_handle_t
;
// Use void to hide implementation details
typedef
void
*
tsdb_query_handle_t
;
// Use void to hide implementation details
typedef
struct
STableGroupList
{
// qualified table object list in group
SArray
*
pGroupList
;
int32_t
numOfTables
;
}
STableGroupList
;
// query condition to build vnode iterator
typedef
struct
STsdbQueryCond
{
STimeWindow
twindow
;
int32_t
order
;
// desc/asc order to iterate the data block
SColumnInfoData
*
colList
;
STimeWindow
twindow
;
int32_t
order
;
// desc/asc order to iterate the data block
SColumnInfoData
*
colList
;
}
STsdbQueryCond
;
typedef
struct
SBlockInfo
{
...
...
@@ -199,12 +152,6 @@ typedef struct SBlockInfo {
STableId
tableId
;
}
SBlockInfo
;
// TODO: move this data struct out of the module
//typedef struct SData {
// int32_t num;
// char * data;
//} SData;
typedef
struct
SDataBlockInfo
{
STimeWindow
window
;
int32_t
rows
;
...
...
@@ -286,7 +233,7 @@ SArray *tsdbRetrieveDataBlock(tsdb_query_handle_t *pQueryHandle, SArray *pIdList
* @param order ascending order or descending order
* @return
*/
int32_t
tsdbResetQuery
(
tsdb_query_handle_t
*
pQueryHandle
,
STimeWindow
*
window
,
tsdbpos_t
position
,
int16_t
order
);
int32_t
tsdbResetQuery
(
tsdb_query_handle_t
*
pQueryHandle
,
STimeWindow
*
window
,
tsdbpos_t
position
,
int16_t
order
);
/**
* return the access position of current query handle
...
...
src/
util/inc/tmodule
.h
→
src/
mnode/inc/mgmtAcct
.h
浏览文件 @
2f1e5287
...
...
@@ -13,42 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
TMODULE
_H
#define TDENGINE_
TMODULE
_H
#ifndef TDENGINE_
MGMT_ACCT
_H
#define TDENGINE_
MGMT_ACCT
_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include "tacct.h"
enum
_module
{
TSDB_MOD_MGMT
,
TSDB_MOD_HTTP
,
TSDB_MOD_MONITOR
,
TSDB_MOD_MAX
};
int32_t
mgmtInitAccts
();
void
mgmtCleanUpAccts
();
void
*
mgmtGetAcct
(
char
*
acctName
);
void
mgmtIncAcctRef
(
SAcctObj
*
pAcct
);
void
mgmtDecAcctRef
(
SAcctObj
*
pAcct
);
#define tsetModuleStatus(mod) \
{ tsModuleStatus |= (1 << mod); }
#define tclearModuleStatus(mod) \
{ tsModuleStatus &= ~(1 << mod); }
typedef
struct
{
char
*
name
;
int
(
*
initFp
)();
void
(
*
cleanUpFp
)();
int
(
*
startFp
)();
void
(
*
stopFp
)();
int
num
;
int
curNum
;
int
equalVnodeNum
;
}
SModule
;
extern
uint32_t
tsModuleStatus
;
extern
SModule
tsModule
[];
void
mgmtAddDbToAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
void
mgmtDropDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
void
mgmtAddUserToAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
void
mgmtDropUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtDb.h
浏览文件 @
2f1e5287
...
...
@@ -20,7 +20,7 @@
extern
"C"
{
#endif
#include "m
node
.h"
#include "m
gmtDef
.h"
enum
_TSDB_DB_STATUS
{
TSDB_DB_STATUS_READY
,
...
...
@@ -33,7 +33,7 @@ void mgmtCleanUpDbs();
SDbObj
*
mgmtGetDb
(
char
*
db
);
SDbObj
*
mgmtGetDbByTableId
(
char
*
db
);
void
mgmtIncDbRef
(
SDbObj
*
pDb
);
void
mgmt
ReleaseDb
(
SDbObj
*
pDb
);
void
mgmt
DecDbRef
(
SDbObj
*
pDb
);
bool
mgmtCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
void
mgmtDropAllDbs
(
SAcctObj
*
pAcct
);
...
...
src/mnode/inc/mgmtDef.h
0 → 100644
浏览文件 @
2f1e5287
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_MGMT_DEF_H
#define TDENGINE_MGMT_DEF_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "taosdef.h"
#include "taosmsg.h"
struct
SVgObj
;
struct
SDbObj
;
struct
SAcctObj
;
struct
SUserObj
;
struct
SMnodeObj
;
typedef
struct
SDnodeObj
{
int32_t
dnodeId
;
uint32_t
privateIp
;
uint32_t
publicIp
;
uint16_t
mnodeShellPort
;
uint16_t
mnodeDnodePort
;
uint16_t
dnodeShellPort
;
uint16_t
dnodeMnodePort
;
uint16_t
syncPort
;
int64_t
createdTime
;
uint32_t
lastAccess
;
int32_t
openVnodes
;
int32_t
totalVnodes
;
// from dnode status msg, config information
int32_t
customScore
;
// config by user
uint16_t
numOfCores
;
// from dnode status msg
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
status
;
// set in balance function
int8_t
isMgmt
;
char
dnodeName
[
TSDB_NODE_NAME_LEN
+
1
];
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SVnodeLoad
vload
[
TSDB_MAX_VNODES
];
uint32_t
moduleStatus
;
uint32_t
lastReboot
;
// time stamp for last reboot
float
score
;
// calc in balance function
float
diskAvailable
;
// from dnode status msg
int16_t
diskAvgUsage
;
// calc from sys.disk
int16_t
cpuAvgUsage
;
// calc from sys.cpu
int16_t
memoryAvgUsage
;
// calc from sys.mem
int16_t
bandwidthUsage
;
// calc from sys.band
}
SDnodeObj
;
typedef
struct
SMnodeObj
{
int32_t
mnodeId
;
int64_t
createdTime
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int8_t
role
;
SDnodeObj
*
pDnode
;
}
SMnodeObj
;
typedef
struct
{
int32_t
dnodeId
;
uint32_t
privateIp
;
uint32_t
publicIp
;
}
SVnodeGid
;
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
int8_t
type
;
}
STableObj
;
typedef
struct
SSuperTableObj
{
STableObj
info
;
uint64_t
uid
;
int64_t
createdTime
;
int32_t
sversion
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
numOfTables
;
int16_t
nextColId
;
SSchema
*
schema
;
int32_t
vgLen
;
int32_t
*
vgList
;
}
SSuperTableObj
;
typedef
struct
{
STableObj
info
;
uint64_t
uid
;
int64_t
createdTime
;
int32_t
sversion
;
//used by normal table
int32_t
numOfColumns
;
//used by normal table
int32_t
sid
;
int32_t
vgId
;
char
superTableId
[
TSDB_TABLE_ID_LEN
+
1
];
int32_t
sqlLen
;
int8_t
reserved
[
1
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
//used by normal table
int32_t
refCount
;
char
*
sql
;
//used by normal table
SSchema
*
schema
;
//used by normal table
SSuperTableObj
*
superTable
;
}
SChildTableObj
;
typedef
struct
SVgObj
{
uint32_t
vgId
;
char
dbName
[
TSDB_DB_NAME_LEN
+
1
];
int64_t
createdTime
;
SVnodeGid
vnodeGid
[
TSDB_VNODES_SUPPORT
];
int32_t
numOfVnodes
;
int32_t
lbDnodeId
;
int32_t
lbTime
;
int8_t
status
;
int8_t
inUse
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
SVgObj
*
prev
,
*
next
;
struct
SDbObj
*
pDb
;
int32_t
numOfTables
;
void
*
idPool
;
SChildTableObj
**
tableList
;
}
SVgObj
;
typedef
struct
SDbObj
{
char
name
[
TSDB_DB_NAME_LEN
+
1
];
int8_t
status
;
int64_t
createdTime
;
SDbCfg
cfg
;
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
SVgObj
*
pHead
;
SVgObj
*
pTail
;
struct
SAcctObj
*
pAcct
;
}
SDbObj
;
typedef
struct
SUserObj
{
char
user
[
TSDB_USER_LEN
+
1
];
char
pass
[
TSDB_KEY_LEN
+
1
];
char
acct
[
TSDB_USER_LEN
+
1
];
int64_t
createdTime
;
int8_t
superAuth
;
int8_t
writeAuth
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
SAcctObj
*
pAcct
;
SQqueryList
*
pQList
;
// query list
SStreamList
*
pSList
;
// stream list
}
SUserObj
;
typedef
struct
{
int32_t
numOfUsers
;
int32_t
numOfDbs
;
int32_t
numOfTimeSeries
;
int32_t
numOfPointsPerSecond
;
int32_t
numOfConns
;
int32_t
numOfQueries
;
int32_t
numOfStreams
;
int64_t
totalStorage
;
// Total storage wrtten from this account
int64_t
compStorage
;
// Compressed storage on disk
int64_t
queryTime
;
int64_t
totalPoints
;
int64_t
inblound
;
int64_t
outbound
;
int64_t
sKey
;
int8_t
accessState
;
// Checked by mgmt heartbeat message
}
SAcctInfo
;
typedef
struct
SAcctObj
{
char
user
[
TSDB_USER_LEN
+
1
];
char
pass
[
TSDB_KEY_LEN
+
1
];
SAcctCfg
cfg
;
int32_t
acctId
;
int64_t
createdTime
;
int8_t
status
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SAcctInfo
acctInfo
;
pthread_mutex_t
mutex
;
}
SAcctObj
;
typedef
struct
{
int8_t
type
;
char
db
[
TSDB_DB_NAME_LEN
+
1
];
void
*
pNode
;
int16_t
numOfColumns
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfReads
;
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int16_t
bytes
[
TSDB_MAX_COLUMNS
];
void
*
signature
;
uint16_t
payloadLen
;
char
payload
[];
}
SShowObj
;
typedef
struct
{
uint8_t
msgType
;
int8_t
usePublicIp
;
int8_t
received
;
int8_t
successed
;
int8_t
expected
;
int8_t
retry
;
int8_t
maxRetry
;
int32_t
contLen
;
int32_t
code
;
void
*
ahandle
;
void
*
thandle
;
void
*
pCont
;
SAcctObj
*
pAcct
;
SDnodeObj
*
pDnode
;
SUserObj
*
pUser
;
SDbObj
*
pDb
;
SVgObj
*
pVgroup
;
STableObj
*
pTable
;
}
SQueuedMsg
;
#ifdef __cplusplus
}
#endif
#endif
src/
inc/tcluster
.h
→
src/
mnode/inc/mgmtDnode
.h
浏览文件 @
2f1e5287
...
...
@@ -20,34 +20,26 @@
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
struct
_dnode_obj
;
enum
_TAOS_DN_STATUS
{
typedef
enum
{
TAOS_DN_STATUS_OFFLINE
,
TAOS_DN_STATUS_DROPPING
,
TAOS_DN_STATUS_BALANCING
,
TAOS_DN_STATUS_READY
};
int32_t
clusterInit
();
void
clusterCleanUp
();
char
*
clusterGetDnodeStatusStr
(
int32_t
dnodeStatus
);
bool
clusterCheckModuleInDnode
(
struct
_dnode_obj
*
pDnode
,
int
moduleType
);
void
clusterMonitorDnodeModule
();
int32_t
clusterInitDnodes
();
void
clusterCleanupDnodes
();
int32_t
clusterGetDnodesNum
();
void
*
clusterGetNextDnode
(
void
*
pNode
,
struct
_dnode_obj
**
pDnode
);
void
clusterReleaseDnode
(
struct
_dnode_obj
*
pDnode
);
void
*
clusterGetDnode
(
int32_t
dnodeId
);
void
*
clusterGetDnodeByIp
(
uint32_t
ip
);
void
clusterUpdateDnode
(
struct
_dnode_obj
*
pDnode
);
int32_t
clusterDropDnode
(
struct
_dnode_obj
*
pDnode
);
}
EDnodeStatus
;
int32_t
mgmtInitDnodes
();
void
mgmtCleanupDnodes
();
char
*
mgmtGetDnodeStatusStr
(
int32_t
dnodeStatus
);
void
mgmtMonitorDnodeModule
();
int32_t
mgmtGetDnodesNum
();
void
*
mgmtGetNextDnode
(
void
*
pNode
,
SDnodeObj
**
pDnode
);
void
mgmtReleaseDnode
(
SDnodeObj
*
pDnode
);
void
*
mgmtGetDnode
(
int32_t
dnodeId
);
void
*
mgmtGetDnodeByIp
(
uint32_t
ip
);
void
mgmtUpdateDnode
(
SDnodeObj
*
pDnode
);
int32_t
mgmtDropDnode
(
SDnodeObj
*
pDnode
);
#ifdef __cplusplus
}
...
...
src/
inc/mpeer
.h
→
src/
mnode/inc/mgmtLog
.h
浏览文件 @
2f1e5287
...
...
@@ -13,44 +13,53 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_M
PEER
_H
#define TDENGINE_M
PEER
_H
#ifndef TDENGINE_M
GMT_LOG
_H
#define TDENGINE_M
GMT_LOG
_H
#ifdef __cplusplus
extern
"C"
{
#endif
struct
_mnode_obj
;
#include "tlog.h"
enum
_TAOS_MN_STATUS
{
TAOS_MN_STATUS_OFFLINE
,
TAOS_MN_STATUS_DROPPING
,
TAOS_MN_STATUS_READY
};
// mnode log function
#define mError(...) \
if (mdebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND ", 255, __VA_ARGS__); \
}
#define mWarn(...) \
if (mdebugFlag & DEBUG_WARN) { \
tprintf("WARN MND ", mdebugFlag, __VA_ARGS__); \
}
#define mTrace(...) \
if (mdebugFlag & DEBUG_TRACE) { \
tprintf("MND ", mdebugFlag, __VA_ARGS__); \
}
#define mPrint(...) \
{ tprintf("MND ", 255, __VA_ARGS__); }
// general implementation
int32_t
mpeerInit
();
void
mpeerCleanup
();
#define mLError(...) taosLogError(__VA_ARGS__) mError(__VA_ARGS__)
#define mLWarn(...) taosLogWarn(__VA_ARGS__) mWarn(__VA_ARGS__)
#define mLPrint(...) taosLogPrint(__VA_ARGS__) mPrint(__VA_ARGS__)
// special implementation
int32_t
mpeerInitMnodes
();
void
mpeerCleanupMnodes
();
int32_t
mpeerAddMnode
(
int32_t
dnodeId
);
int32_t
mpeerRemoveMnode
(
int32_t
dnodeId
);
#define sdbError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND-SDB ", 255, __VA_ARGS__); \
}
#define sdbWarn(...) \
if (sdbDebugFlag & DEBUG_WARN) { \
tprintf("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbTrace(...) \
if (sdbDebugFlag & DEBUG_TRACE) { \
tprintf("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbPrint(...) \
{ tprintf("MND-SDB ", 255, __VA_ARGS__); }
void
*
mpeerGetMnode
(
int32_t
mnodeId
);
int32_t
mpeerGetMnodesNum
();
void
*
mpeerGetNextMnode
(
void
*
pNode
,
struct
_mnode_obj
**
pMnode
);
void
mpeerReleaseMnode
(
struct
_mnode_obj
*
pMnode
);
bool
mpeerIsMaster
();
void
mpeerGetPrivateIpList
(
SRpcIpSet
*
ipSet
);
void
mpeerGetPublicIpList
(
SRpcIpSet
*
ipSet
);
void
mpeerGetMpeerInfos
(
void
*
mpeers
);
int32_t
mpeerForwardReqToPeer
(
void
*
pHead
);
void
mpeerUpdateSync
();
#define sdbLError(...) taosLogError(__VA_ARGS__) sdbError(__VA_ARGS__)
#define sdbLWarn(...) taosLogWarn(__VA_ARGS__) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) taosLogPrint(__VA_ARGS__) sdbPrint(__VA_ARGS__)
#ifdef __cplusplus
}
...
...
src/
inc/taccount
.h
→
src/
mnode/inc/mgmtMnode
.h
浏览文件 @
2f1e5287
...
...
@@ -13,34 +13,36 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
ACCT
_H
#define TDENGINE_
ACCT
_H
#ifndef TDENGINE_
MGMT_MNODE
_H
#define TDENGINE_
MGMT_MNODE
_H
#ifdef __cplusplus
extern
"C"
{
#endif
struct
_acct_obj
;
struct
_user_obj
;
struct
_db_obj
;
struct
SMnodeObj
;
typedef
enum
{
TSDB_ACCT_USER
,
TSDB_ACCT_DB
,
TSDB_ACCT_TABLE
}
EAcctGrantType
;
int32_t
acctInit
();
void
acctCleanUp
();
void
*
acctGetAcct
(
char
*
acctName
);
void
acctIncRef
(
struct
_acct_obj
*
pAcct
);
void
acctReleaseAcct
(
struct
_acct_obj
*
pAcct
);
int32_t
acctCheck
(
struct
_acct_obj
*
pAcct
,
EAcctGrantType
type
);
void
acctAddDb
(
struct
_acct_obj
*
pAcct
,
struct
_db_obj
*
pDb
);
void
acctRemoveDb
(
struct
_acct_obj
*
pAcct
,
struct
_db_obj
*
pDb
);
void
acctAddUser
(
struct
_acct_obj
*
pAcct
,
struct
_user_obj
*
pUser
);
void
acctRemoveUser
(
struct
_acct_obj
*
pAcct
,
struct
_user_obj
*
pUser
);
TAOS_MN_STATUS_OFFLINE
,
TAOS_MN_STATUS_DROPPING
,
TAOS_MN_STATUS_READY
}
EMnodeStatus
;
int32_t
mgmtInitMnodes
();
void
mgmtCleanupMnodes
();
int32_t
mgmtAddMnode
(
int32_t
dnodeId
);
int32_t
mgmtDropMnode
(
int32_t
dnodeId
);
void
*
mgmtGetMnode
(
int32_t
mnodeId
);
int32_t
mgmtGetMnodesNum
();
void
*
mgmtGetNextMnode
(
void
*
pNode
,
struct
SMnodeObj
**
pMnode
);
void
mgmtReleaseMnode
(
struct
SMnodeObj
*
pMnode
);
bool
mgmtIsMaster
();
void
mgmtGetMnodeIpList
(
SRpcIpSet
*
ipSet
,
bool
usePublicIp
);
void
mgmtGetMnodeList
(
void
*
mpeers
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtProfile.h
浏览文件 @
2f1e5287
...
...
@@ -19,7 +19,7 @@
#ifdef __cplusplus
extern
"C"
{
#endif
#include "m
node
.h"
#include "m
gmtDef
.h"
int32_t
mgmtInitProfile
();
void
mgmtCleanUpProfile
();
...
...
src/mnode/inc/mgmtShell.h
浏览文件 @
2f1e5287
...
...
@@ -19,7 +19,7 @@
#ifdef __cplusplus
extern
"C"
{
#endif
#include "m
node
.h"
#include "m
gmtDef
.h"
int32_t
mgmtInitShell
();
void
mgmtCleanUpShell
();
...
...
src/mnode/inc/mgmtTable.h
浏览文件 @
2f1e5287
...
...
@@ -20,10 +20,7 @@
extern
"C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "mnode.h"
#include "mgmtDef.h"
int32_t
mgmtInitTables
();
void
mgmtCleanUpTables
();
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
2f1e5287
...
...
@@ -19,7 +19,7 @@
#ifdef __cplusplus
extern
"C"
{
#endif
#include "m
node
.h"
#include "m
gmtDef
.h"
int32_t
mgmtInitUsers
();
void
mgmtCleanUpUsers
();
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
2f1e5287
...
...
@@ -20,9 +20,7 @@
extern
"C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
#include "mnode.h"
#include "mgmtDef.h"
enum
_TSDB_VG_STATUS
{
TSDB_VG_STATUS_READY
,
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
2f1e5287
...
...
@@ -16,49 +16,181 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "mnode.h"
#include "taccount.h"
#include "ttime.h"
#include "tutil.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "mgmtDb.h"
#include "mgmtSdb.h"
#include "mgmtUser.h"
#ifndef _ACCOUNT
void
*
tsAcctSdb
=
NULL
;
int32_t
tsAcctUpdateSize
;
static
void
mgmtCreateRootAcct
();
static
SAcctObj
tsAcctObj
=
{
0
};
static
int32_t
mgmtActionAcctDestroy
(
SSdbOperDesc
*
pOper
)
{
SAcctObj
*
pAcct
=
pOper
->
pObj
;
pthread_mutex_destroy
(
&
pAcct
->
mutex
);
tfree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
acctInit
()
{
tsAcctObj
.
acctId
=
0
;
strcpy
(
tsAcctObj
.
user
,
"root"
);
static
int32_t
mgmtAcctActionInsert
(
SSdbOperDesc
*
pOper
)
{
SAcctObj
*
pAcct
=
pOper
->
pObj
;
memset
(
&
pAcct
->
acctInfo
,
0
,
sizeof
(
SAcctInfo
));
pthread_mutex_init
(
&
pAcct
->
mutex
,
NULL
);
return
TSDB_CODE_SUCCESS
;
}
void
acctCleanUp
()
{}
void
*
acctGetAcct
(
char
*
acctName
)
{
return
&
tsAcctObj
;
}
void
acctIncRef
(
struct
_acct_obj
*
pAcct
)
{}
void
acctReleaseAcct
(
SAcctObj
*
pAcct
)
{}
int32_t
acctCheck
(
SAcctObj
*
pAcct
,
EAcctGrantType
type
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtActionAcctDelete
(
SSdbOperDesc
*
pOper
)
{
SAcctObj
*
pAcct
=
pOper
->
pObj
;
mgmtDropAllUsers
(
pAcct
);
mgmtDropAllDbs
(
pAcct
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtActionAcctUpdate
(
SSdbOperDesc
*
pOper
)
{
SAcctObj
*
pAcct
=
pOper
->
pObj
;
SAcctObj
*
pSaved
=
mgmtGetAcct
(
pAcct
->
user
);
if
(
pAcct
!=
pSaved
)
{
memcpy
(
pSaved
,
pAcct
,
tsAcctUpdateSize
);
free
(
pAcct
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtActionActionEncode
(
SSdbOperDesc
*
pOper
)
{
SAcctObj
*
pAcct
=
pOper
->
pObj
;
memcpy
(
pOper
->
rowData
,
pAcct
,
tsAcctUpdateSize
);
pOper
->
rowSize
=
tsAcctUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtActionAcctDecode
(
SSdbOperDesc
*
pOper
)
{
SAcctObj
*
pAcct
=
(
SAcctObj
*
)
calloc
(
1
,
sizeof
(
SAcctObj
));
if
(
pAcct
==
NULL
)
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
memcpy
(
pAcct
,
pOper
->
rowData
,
tsAcctUpdateSize
);
pOper
->
pObj
=
pAcct
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtActionAcctRestored
()
{
if
(
dnodeIsFirstDeploy
())
{
mgmtCreateRootAcct
();
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtInitAccts
()
{
SAcctObj
tObj
;
tsAcctUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
;
SSdbTableDesc
tableDesc
=
{
.
tableId
=
SDB_TABLE_ACCOUNT
,
.
tableName
=
"accounts"
,
.
hashSessions
=
TSDB_MAX_ACCOUNTS
,
.
maxRowSize
=
tsAcctUpdateSize
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_STRING
,
.
insertFp
=
mgmtAcctActionInsert
,
.
deleteFp
=
mgmtActionAcctDelete
,
.
updateFp
=
mgmtActionAcctUpdate
,
.
encodeFp
=
mgmtActionActionEncode
,
.
decodeFp
=
mgmtActionAcctDecode
,
.
destroyFp
=
mgmtActionAcctDestroy
,
.
restoredFp
=
mgmtActionAcctRestored
};
#endif
tsAcctSdb
=
sdbOpenTable
(
&
tableDesc
);
if
(
tsAcctSdb
==
NULL
)
{
mError
(
"failed to init acct data"
);
return
-
1
;
}
void
acctAddDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
mTrace
(
"account table is created"
);
return
acctInit
();
}
void
mgmtCleanUpAccts
()
{
sdbCloseTable
(
tsAcctSdb
);
acctCleanUp
();
}
void
*
mgmtGetAcct
(
char
*
name
)
{
return
sdbGetRow
(
tsAcctSdb
,
name
);
}
void
mgmtIncAcctRef
(
SAcctObj
*
pAcct
)
{
sdbIncRef
(
tsAcctSdb
,
pAcct
);
}
void
mgmtDecAcctRef
(
SAcctObj
*
pAcct
)
{
sdbDecRef
(
tsAcctSdb
,
pAcct
);
}
void
mgmtAddDbToAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
atomic_add_fetch_32
(
&
pAcct
->
acctInfo
.
numOfDbs
,
1
);
pDb
->
pAcct
=
pAcct
;
acctInc
Ref
(
pAcct
);
mgmtIncAcct
Ref
(
pAcct
);
}
void
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
void
mgmtDropDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
atomic_sub_fetch_32
(
&
pAcct
->
acctInfo
.
numOfDbs
,
1
);
pDb
->
pAcct
=
NULL
;
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
}
void
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
void
mgmtAddUserToAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
atomic_add_fetch_32
(
&
pAcct
->
acctInfo
.
numOfUsers
,
1
);
pUser
->
pAcct
=
pAcct
;
acctInc
Ref
(
pAcct
);
mgmtIncAcct
Ref
(
pAcct
);
}
void
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
void
mgmtDropUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
atomic_sub_fetch_32
(
&
pAcct
->
acctInfo
.
numOfUsers
,
1
);
pUser
->
pAcct
=
NULL
;
acctReleaseAcct
(
pAcct
);
}
\ No newline at end of file
mgmtDecAcctRef
(
pAcct
);
}
static
void
mgmtCreateRootAcct
()
{
int32_t
numOfAccts
=
sdbGetNumOfRows
(
tsAcctSdb
);
if
(
numOfAccts
!=
0
)
return
;
SAcctObj
*
pAcct
=
malloc
(
sizeof
(
SAcctObj
));
memset
(
pAcct
,
0
,
sizeof
(
SAcctObj
));
strcpy
(
pAcct
->
user
,
"root"
);
taosEncryptPass
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
pAcct
->
pass
);
pAcct
->
cfg
=
(
SAcctCfg
){
.
maxUsers
=
10
,
.
maxDbs
=
64
,
.
maxTimeSeries
=
INT32_MAX
,
.
maxConnections
=
1024
,
.
maxStreams
=
1000
,
.
maxPointsPerSecond
=
10000000
,
.
maxStorage
=
INT64_MAX
,
.
maxQueryTime
=
INT64_MAX
,
.
maxInbound
=
0
,
.
maxOutbound
=
0
,
.
accessState
=
TSDB_VN_ALL_ACCCESS
};
pAcct
->
acctId
=
sdbGetId
(
tsAcctSdb
);
pAcct
->
createdTime
=
taosGetTimestampMs
();
SSdbOperDesc
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsAcctSdb
,
.
pObj
=
pAcct
,
};
sdbInsertRow
(
&
oper
);
}
#ifndef _ACCT
int32_t
acctInit
()
{
return
TSDB_CODE_SUCCESS
;
}
void
acctCleanUp
()
{}
int32_t
acctCheck
(
void
*
pAcct
,
EAcctGrantType
type
)
{
return
TSDB_CODE_SUCCESS
;
}
#endif
\ No newline at end of file
src/mnode/src/mgmtDClient.c
浏览文件 @
2f1e5287
...
...
@@ -19,12 +19,14 @@
#include "tsched.h"
#include "tsystem.h"
#include "tutil.h"
#include "tglobalcfg.h"
#include "dnode.h"
#include "mnode.h"
#include "tbalance.h"
#include "mgmtDb.h"
#include "tcluster.h"
#include "tgrant.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtMnode.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
#include "mgmtTable.h"
...
...
src/mnode/src/mgmtDServer.c
浏览文件 @
2f1e5287
...
...
@@ -20,12 +20,14 @@
#include "tsched.h"
#include "tsystem.h"
#include "tutil.h"
#include "tgrant.h"
#include "treplica.h"
#include "tglobalcfg.h"
#include "dnode.h"
#include "m
node
.h"
#include "
tbalance
.h"
#include "m
gmtDef
.h"
#include "
mgmtLog
.h"
#include "mgmtDb.h"
#include "mgmtDServer.h"
#include "tgrant.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
#include "mgmtTable.h"
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
2f1e5287
...
...
@@ -17,14 +17,16 @@
#include "os.h"
#include "taoserror.h"
#include "tutil.h"
#include "tgrant.h"
#include "tglobalcfg.h"
#include "ttime.h"
#include "name.h"
#include "m
node
.h"
#include "
taccount
.h"
#include "
tbalance
.h"
#include "m
gmtDef
.h"
#include "
mgmtLog
.h"
#include "
mgmtAcct
.h"
#include "mgmtDb.h"
#include "tcluster.h"
#include "tgrant.h"
#include "mpeer.h"
#include "mgmtDnode.h"
#include "mgmtMnode.h"
#include "mgmtShell.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
...
...
@@ -51,7 +53,7 @@ static int32_t mgmtDbActionDestroy(SSdbOperDesc *pOper) {
static
int32_t
mgmtDbActionInsert
(
SSdbOperDesc
*
pOper
)
{
SDbObj
*
pDb
=
pOper
->
pObj
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
pDb
->
pHead
=
NULL
;
pDb
->
pTail
=
NULL
;
...
...
@@ -60,7 +62,7 @@ static int32_t mgmtDbActionInsert(SSdbOperDesc *pOper) {
pDb
->
numOfSuperTables
=
0
;
if
(
pAcct
!=
NULL
)
{
acctAddDb
(
pAcct
,
pDb
);
mgmtAddDbToAcct
(
pAcct
,
pDb
);
}
else
{
mError
(
"db:%s, acct:%s info not exist in sdb"
,
pDb
->
name
,
pDb
->
cfg
.
acct
);
...
...
@@ -72,9 +74,9 @@ static int32_t mgmtDbActionInsert(SSdbOperDesc *pOper) {
static
int32_t
mgmtDbActionDelete
(
SSdbOperDesc
*
pOper
)
{
SDbObj
*
pDb
=
pOper
->
pObj
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
acctRemoveDb
(
pAcct
,
pDb
);
mgmtDropDbFromAcct
(
pAcct
,
pDb
);
mgmtDropAllChildTables
(
pDb
);
mgmtDropAllSuperTables
(
pDb
);
mgmtDropAllVgroups
(
pDb
);
...
...
@@ -156,7 +158,7 @@ void mgmtIncDbRef(SDbObj *pDb) {
return
sdbIncRef
(
tsDbSdb
,
pDb
);
}
void
mgmt
ReleaseDb
(
SDbObj
*
pDb
)
{
void
mgmt
DecDbRef
(
SDbObj
*
pDb
)
{
return
sdbDecRef
(
tsDbSdb
,
pDb
);
}
...
...
@@ -288,14 +290,14 @@ static int32_t mgmtCheckDbParams(SCMCreateDbMsg *pCreate) {
}
static
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
)
{
int32_t
code
=
acctCheck
(
pAcct
,
TSDB_ACC
T_DB
);
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRAN
T_DB
);
if
(
code
!=
0
)
{
return
code
;
}
SDbObj
*
pDb
=
mgmtGetDb
(
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
TSDB_CODE_DB_ALREADY_EXIST
;
}
...
...
@@ -641,7 +643,7 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
cols
++
;
numOfRows
++
;
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
}
pShow
->
numOfReads
+=
numOfRows
;
...
...
@@ -888,7 +890,7 @@ void mgmtDropAllDbs(SAcctObj *pAcct) {
mgmtSetDbDropping
(
pDb
);
numOfDbs
++
;
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
}
mTrace
(
"acct:%s, all dbs is is set dirty"
,
pAcct
->
user
,
numOfDbs
);
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
2f1e5287
此差异已折叠。
点击以展开。
src/mnode/src/mgmtGrant.c
浏览文件 @
2f1e5287
...
...
@@ -17,8 +17,8 @@
#ifndef _GRANT
#include "os.h"
#include "taoserror.h"
#include "tlog.h"
#include "tgrant.h"
#include "mgmtLog.h"
int32_t
grantInit
()
{
return
TSDB_CODE_SUCCESS
;
}
void
grantCleanUp
()
{}
...
...
src/mnode/src/mgmtMain.c
浏览文件 @
2f1e5287
...
...
@@ -16,14 +16,16 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tmodule.h"
#include "tsched.h"
#include "mnode.h"
#include "taccount.h"
#include "tbalance.h"
#include "tcluster.h"
#include "treplica.h"
#include "tgrant.h"
#include "mpeer.h"
#include "ttimer.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "mgmtDnode.h"
#include "mgmtMnode.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDServer.h"
...
...
@@ -33,48 +35,28 @@
#include "mgmtTable.h"
#include "mgmtShell.h"
static
int32_t
mgmtCheckMgmtRunning
();
void
*
tsMgmtTmr
=
NULL
;
static
bool
tsMgmtIsRunning
=
false
;
int32_t
mgmtInitSystem
()
{
if
(
mgmtInitShell
()
!=
0
)
{
mError
(
"failed to init shell"
);
return
-
1
;
}
struct
stat
dirstat
;
bool
fileExist
=
(
stat
(
tsMnodeDir
,
&
dirstat
)
==
0
);
bool
asMaster
=
(
strcmp
(
tsMasterIp
,
tsPrivateIp
)
==
0
);
if
(
asMaster
||
fileExist
)
{
if
(
mgmtStartSystem
()
!=
0
)
{
return
-
1
;
}
int32_t
mgmtStartSystem
()
{
if
(
tsMgmtIsRunning
)
{
mPrint
(
"TDengine mgmt module already started..."
);
return
0
;
}
return
0
;
}
int32_t
mgmtStartSystem
()
{
mPrint
(
"starting to initialize TDengine mgmt ..."
);
struct
stat
dirstat
;
if
(
stat
(
tsMnodeDir
,
&
dirstat
)
<
0
)
{
mkdir
(
tsMnodeDir
,
0755
);
}
if
(
mgmtCheckMgmtRunning
()
!=
0
)
{
mPrint
(
"TDengine mgmt module already started..."
);
return
0
;
}
tsMgmtTmr
=
taosTmrInit
((
tsMaxShellConns
)
*
3
,
200
,
3600000
,
"MND"
);
if
(
tsMgmtTmr
==
NULL
)
{
mError
(
"failed to init timer"
);
return
-
1
;
}
if
(
acctInit
()
<
0
)
{
if
(
mgmtInitAccts
()
<
0
)
{
mError
(
"failed to init accts"
);
return
-
1
;
}
...
...
@@ -89,7 +71,7 @@ int32_t mgmtStartSystem() {
return
-
1
;
}
if
(
clusterInit
()
<
0
)
{
if
(
mgmtInitDnodes
()
<
0
)
{
mError
(
"failed to init dnodes"
);
return
-
1
;
}
...
...
@@ -109,7 +91,7 @@ int32_t mgmtStartSystem() {
return
-
1
;
}
if
(
m
peerInit
()
<
0
)
{
if
(
m
gmtInitMnodes
()
<
0
)
{
mError
(
"failed to init mpeers"
);
return
-
1
;
}
...
...
@@ -119,6 +101,10 @@ int32_t mgmtStartSystem() {
return
-
1
;
}
if
(
replicaInit
()
<
0
)
{
mError
(
"failed to init replica"
)
}
if
(
mgmtInitDClient
()
<
0
)
{
return
-
1
;
}
...
...
@@ -127,52 +113,61 @@ int32_t mgmtStartSystem() {
return
-
1
;
}
if
(
balanceInit
()
<
0
)
{
mError
(
"failed to init dnode balance"
)
}
grantReset
(
TSDB_GRANT_ALL
,
0
);
tsMgmtIsRunning
=
true
;
mPrint
(
"TDengine mgmt is initialized successfully"
);
return
0
;
}
int32_t
mgmtInitSystem
()
{
if
(
mgmtInitShell
()
!=
0
)
{
mError
(
"failed to init shell"
);
return
-
1
;
}
void
mgmtStopSystem
()
{
if
(
mpeerIsMaster
())
{
mTrace
(
"it is a master mgmt node, it could not be stopped"
);
return
;
struct
stat
dirstat
;
bool
fileExist
=
(
stat
(
tsMnodeDir
,
&
dirstat
)
==
0
);
bool
asMaster
=
(
strcmp
(
tsMasterIp
,
tsPrivateIp
)
==
0
);
if
(
asMaster
||
fileExist
)
{
if
(
mgmtStartSystem
()
!=
0
)
{
return
-
1
;
}
}
mgmtCleanUpSystem
();
remove
(
tsMnodeDir
);
return
0
;
}
void
mgmtCleanUpSystem
()
{
mPrint
(
"starting to clean up mgmt"
);
grantCleanUp
();
m
peerCleanup
();
balance
CleanUp
();
m
gmtCleanupMnodes
();
replica
CleanUp
();
mgmtCleanUpShell
();
mgmtCleanupDClient
();
mgmtCleanupDServer
();
mgmtCleanUpTables
();
mgmtCleanUpVgroups
();
mgmtCleanUpDbs
();
clusterCleanUp
();
mgmtCleanupDnodes
();
mgmtCleanUpUsers
();
acctCleanUp
();
mgmtCleanUpAccts
();
sdbCleanUp
();
taosTmrCleanUp
(
tsMgmtTmr
);
tsMgmtIsRunning
=
false
;
mPrint
(
"mgmt is cleaned up"
);
}
static
int32_t
mgmtCheckMgmtRunning
()
{
if
(
tsModuleStatus
&
(
1
<<
TSDB_MOD_MGMT
))
{
return
-
1
;
void
mgmtStopSystem
()
{
if
(
mgmtIsMaster
())
{
mTrace
(
"it is a master mgmt node, it could not be stopped"
);
return
;
}
tsetModuleStatus
(
TSDB_MOD_MGMT
);
return
0
;
}
\ No newline at end of file
mgmtCleanUpSystem
();
mPrint
(
"mgmt file is removed"
);
remove
(
tsMnodeDir
);
}
src/mnode/src/mgmtMnode.c
浏览文件 @
2f1e5287
...
...
@@ -18,89 +18,146 @@
#include "taoserror.h"
#include "trpc.h"
#include "tsync.h"
#include "mpeer.h"
#include "treplica.h"
#include "tutil.h"
#include "ttime.h"
#include "tsocket.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtMnode.h"
#include "mgmtDnode.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtUser.h"
int32_t
tsMnodeIsMaster
=
true
;
static
void
*
tsMnodeSdb
=
NULL
;
static
int32_t
tsMnodeUpdateSize
=
0
;
static
int32_t
mgmtGetMnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
#ifndef _MPEER
static
int32_t
mgmtMnodeActionDestroy
(
SSdbOperDesc
*
pOper
)
{
tfree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
SMnodeObj
tsMnodeObj
=
{
0
};
static
int32_t
mgmtMnodeActionInsert
(
SSdbOperDesc
*
pOper
)
{
SMnodeObj
*
pMnode
=
pOper
->
pObj
;
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_DNODE_NOT_EXIST
;
int32_t
mpeerInitMnodes
()
{
tsMnodeObj
.
mnodeId
=
1
;
tsMnodeObj
.
privateIp
=
inet_addr
(
tsPrivateIp
);
tsMnodeObj
.
publicIp
=
inet_addr
(
tsPublicIp
);
tsMnodeObj
.
createdTime
=
taosGetTimestampMs
();
tsMnodeObj
.
role
=
TAOS_SYNC_ROLE_MASTER
;
tsMnodeObj
.
port
=
tsMnodeDnodePort
;
sprintf
(
tsMnodeObj
.
mnodeName
,
"m%d"
,
tsMnodeObj
.
mnodeId
);
pMnode
->
pDnode
=
pDnode
;
pDnode
->
isMgmt
=
true
;
mgmtReleaseDnode
(
pDnode
);
return
TSDB_CODE_SUCCESS
;
}
void
mpeerCleanupMnodes
()
{}
int32_t
mpeerAddMnode
(
int32_t
dnodeId
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
mpeerRemoveMnode
(
int32_t
dnodeId
)
{
return
TSDB_CODE_SUCCESS
;
}
void
*
mpeerGetMnode
(
int32_t
mnodeId
)
{
return
&
tsMnodeObj
;
}
int32_t
mpeerGetMnodesNum
()
{
return
1
;
}
void
mpeerReleaseMnode
(
struct
_mnode_obj
*
pMnode
)
{}
bool
mpeerIsMaster
()
{
return
tsMnodeObj
.
role
==
TAOS_SYNC_ROLE_MASTER
;
}
void
mpeerUpdateSync
()
{}
void
*
mpeerGetNextMnode
(
void
*
pNode
,
SMnodeObj
**
pMnode
)
{
if
(
*
pMnode
==
NULL
)
{
*
pMnode
=
&
tsMnodeObj
;
}
else
{
*
pMnode
=
NULL
;
}
static
int32_t
mgmtMnodeActionDelete
(
SSdbOperDesc
*
pOper
)
{
SMnodeObj
*
pMnode
=
pOper
->
pObj
;
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_DNODE_NOT_EXIST
;
pDnode
->
isMgmt
=
false
;
mgmtReleaseDnode
(
pDnode
);
return
*
pMnode
;
mTrace
(
"mnode:%d, is dropped from sdb"
,
pMnode
->
mnodeId
);
return
TSDB_CODE_SUCCESS
;
}
void
mpeerGetPrivateIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
numOfIps
=
1
;
ipSet
->
port
=
htons
(
tsMnodeObj
.
port
);
ipSet
->
ip
[
0
]
=
htonl
(
tsMnodeObj
.
privateIp
);
static
int32_t
mgmtMnodeActionUpdate
(
SSdbOperDesc
*
pOper
)
{
SMnodeObj
*
pMnode
=
pOper
->
pObj
;
SMnodeObj
*
pSaved
=
mgmtGetMnode
(
pMnode
->
mnodeId
);
if
(
pMnode
!=
pSaved
)
{
memcpy
(
pSaved
,
pMnode
,
pOper
->
rowSize
);
free
(
pMnode
);
}
return
TSDB_CODE_SUCCESS
;
}
void
mpeerGetPublicIpList
(
SRpcIpSet
*
ipSet
)
{
ipSet
->
inUse
=
0
;
ipSet
->
numOfIps
=
1
;
ipSet
->
port
=
htons
(
tsMnodeObj
.
port
)
;
ipSet
->
ip
[
0
]
=
htonl
(
tsMnodeObj
.
publicIp
)
;
static
int32_t
mgmtMnodeActionEncode
(
SSdbOperDesc
*
pOper
)
{
SMnodeObj
*
pMnode
=
pOper
->
pObj
;
memcpy
(
pOper
->
rowData
,
pMnode
,
tsMnodeUpdateSize
)
;
pOper
->
rowSize
=
tsMnodeUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
void
mpeerGetMpeerInfos
(
void
*
param
)
{
SDMNodeInfos
*
mpeers
=
param
;
mpeers
->
inUse
=
0
;
mpeers
->
nodeNum
=
1
;
mpeers
->
nodeInfos
[
0
].
nodeId
=
htonl
(
tsMnodeObj
.
mnodeId
);
mpeers
->
nodeInfos
[
0
].
nodeIp
=
htonl
(
tsMnodeObj
.
privateIp
);
mpeers
->
nodeInfos
[
0
].
nodePort
=
htons
(
tsMnodeObj
.
port
);
strcpy
(
mpeers
->
nodeInfos
[
0
].
nodeName
,
tsMnodeObj
.
mnodeName
);
static
int32_t
mgmtMnodeActionDecode
(
SSdbOperDesc
*
pOper
)
{
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
if
(
pMnode
==
NULL
)
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
memcpy
(
pMnode
,
pOper
->
rowData
,
tsMnodeUpdateSize
);
pOper
->
pObj
=
pMnode
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
mpeerForwardReqToPeer
(
void
*
pHead
)
{
static
int32_t
mgmtMnodeActionRestored
()
{
if
(
mgmtGetMnodesNum
()
==
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
mgmtGetNextMnode
(
NULL
,
&
pMnode
);
if
(
pMnode
!=
NULL
)
{
pMnode
->
role
=
TAOS_SYNC_ROLE_MASTER
;
mgmtReleaseMnode
(
pMnode
);
}
}
return
TSDB_CODE_SUCCESS
;
}
#endif
int32_t
mgmtInitMnodes
()
{
SMnodeObj
tObj
;
tsMnodeUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
;
SSdbTableDesc
tableDesc
=
{
.
tableId
=
SDB_TABLE_MNODE
,
.
tableName
=
"mnodes"
,
.
hashSessions
=
TSDB_MAX_MNODES
,
.
maxRowSize
=
tsMnodeUpdateSize
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_INT
,
.
insertFp
=
mgmtMnodeActionInsert
,
.
deleteFp
=
mgmtMnodeActionDelete
,
.
updateFp
=
mgmtMnodeActionUpdate
,
.
encodeFp
=
mgmtMnodeActionEncode
,
.
decodeFp
=
mgmtMnodeActionDecode
,
.
destroyFp
=
mgmtMnodeActionDestroy
,
.
restoredFp
=
mgmtMnodeActionRestored
};
tsMnodeSdb
=
sdbOpenTable
(
&
tableDesc
);
if
(
tsMnodeSdb
==
NULL
)
{
mError
(
"failed to init mnodes data"
);
return
-
1
;
}
int32_t
mpeerInit
()
{
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtGetMnodeMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtRetrieveMnodes
);
return
mpeerInitMnodes
();
mTrace
(
"mnodes table is created"
);
return
TSDB_CODE_SUCCESS
;
}
void
mgmtCleanupMnodes
()
{
sdbCloseTable
(
tsMnodeSdb
);
}
int32_t
mgmtGetMnodesNum
()
{
return
sdbGetNumOfRows
(
tsMnodeSdb
);
}
void
mpeerCleanup
(
)
{
mpeerCleanupMnodes
(
);
void
*
mgmtGetMnode
(
int32_t
mnodeId
)
{
return
sdbGetRow
(
tsMnodeSdb
,
&
mnodeId
);
}
static
char
*
mpeerGetMnodeRoleStr
(
int32_t
role
)
{
void
mgmtReleaseMnode
(
SMnodeObj
*
pMnode
)
{
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
}
void
*
mgmtGetNextMnode
(
void
*
pNode
,
SMnodeObj
**
pMnode
)
{
return
sdbFetchRow
(
tsMnodeSdb
,
pNode
,
(
void
**
)
pMnode
);
}
static
char
*
mgmtGetMnodeRoleStr
(
int32_t
role
)
{
switch
(
role
)
{
case
TAOS_SYNC_ROLE_OFFLINE
:
return
"offline"
;
...
...
@@ -115,6 +172,101 @@ static char *mpeerGetMnodeRoleStr(int32_t role) {
}
}
bool
mgmtIsMaster
()
{
return
tsMnodeIsMaster
;
}
void
mgmtGetMnodeIpList
(
SRpcIpSet
*
ipSet
,
bool
usePublicIp
)
{
void
*
pNode
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
pNode
=
mgmtGetNextMnode
(
pNode
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
if
(
usePublicIp
)
{
ipSet
->
ip
[
ipSet
->
numOfIps
]
=
htonl
(
pMnode
->
pDnode
->
publicIp
);
}
else
{
ipSet
->
ip
[
ipSet
->
numOfIps
]
=
htonl
(
pMnode
->
pDnode
->
privateIp
);
}
if
(
pMnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
ipSet
->
inUse
=
ipSet
->
numOfIps
;
}
ipSet
->
numOfIps
++
;
ipSet
->
port
=
htons
(
pMnode
->
pDnode
->
mnodeShellPort
);
mgmtReleaseMnode
(
pMnode
);
}
}
void
mgmtGetMnodeList
(
void
*
param
)
{
SDMNodeInfos
*
mnodes
=
param
;
mnodes
->
inUse
=
0
;
int32_t
index
=
0
;
void
*
pNode
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
pNode
=
mgmtGetNextMnode
(
pNode
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
mnodes
->
nodeInfos
[
index
].
nodeId
=
htonl
(
pMnode
->
mnodeId
);
mnodes
->
nodeInfos
[
index
].
nodeIp
=
htonl
(
pMnode
->
pDnode
->
privateIp
);
mnodes
->
nodeInfos
[
index
].
nodePort
=
htons
(
pMnode
->
pDnode
->
mnodeDnodePort
);
strcpy
(
mnodes
->
nodeInfos
[
index
].
nodeName
,
pMnode
->
pDnode
->
dnodeName
);
mPrint
(
"node:%d role:%s"
,
pMnode
->
mnodeId
,
mgmtGetMnodeRoleStr
(
pMnode
->
role
));
if
(
pMnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
mnodes
->
inUse
=
index
;
mPrint
(
"node:%d inUse:%d"
,
pMnode
->
mnodeId
,
mnodes
->
inUse
);
}
index
++
;
mgmtReleaseMnode
(
pMnode
);
}
mnodes
->
nodeNum
=
index
;
}
int32_t
mgmtAddMnode
(
int32_t
dnodeId
)
{
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
pMnode
->
mnodeId
=
dnodeId
;
pMnode
->
createdTime
=
taosGetTimestampMs
();
SSdbOperDesc
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsMnodeSdb
,
.
pObj
=
pMnode
,
};
int32_t
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pMnode
);
code
=
TSDB_CODE_SDB_ERROR
;
}
return
code
;
}
int32_t
mgmtDropMnode
(
int32_t
dnodeId
)
{
SMnodeObj
*
pMnode
=
sdbGetRow
(
tsMnodeSdb
,
&
dnodeId
);
if
(
pMnode
==
NULL
)
{
return
TSDB_CODE_DNODE_NOT_EXIST
;
}
SSdbOperDesc
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsMnodeSdb
,
.
pObj
=
pMnode
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_SDB_ERROR
;
}
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
return
code
;
}
static
int32_t
mgmtGetMnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
return
0
;
...
...
@@ -162,7 +314,7 @@ static int32_t mgmtGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
m
peer
GetMnodesNum
();
pShow
->
numOfRows
=
m
gmt
GetMnodesNum
();
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
pNode
=
NULL
;
mgmtReleaseUser
(
pUser
);
...
...
@@ -178,7 +330,7 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
char
ipstr
[
32
];
while
(
numOfRows
<
rows
)
{
pShow
->
pNode
=
m
peer
GetNextMnode
(
pShow
->
pNode
,
&
pMnode
);
pShow
->
pNode
=
m
gmt
GetNextMnode
(
pShow
->
pNode
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
cols
=
0
;
...
...
@@ -187,12 +339,12 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
*
(
int16_t
*
)
pWrite
=
pMnode
->
mnodeId
;
cols
++
;
tinet_ntoa
(
ipstr
,
pMnode
->
privateIp
);
tinet_ntoa
(
ipstr
,
pMnode
->
p
Dnode
->
p
rivateIp
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
cols
++
;
tinet_ntoa
(
ipstr
,
pMnode
->
publicIp
);
tinet_ntoa
(
ipstr
,
pMnode
->
p
Dnode
->
p
ublicIp
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
ipstr
);
cols
++
;
...
...
@@ -202,15 +354,15 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
m
peer
GetMnodeRoleStr
(
pMnode
->
role
));
strcpy
(
pWrite
,
m
gmt
GetMnodeRoleStr
(
pMnode
->
role
));
cols
++
;
numOfRows
++
;
m
peer
ReleaseMnode
(
pMnode
);
m
gmt
ReleaseMnode
(
pMnode
);
}
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
\ No newline at end of file
}
src/mnode/src/mgmtProfile.c
浏览文件 @
2f1e5287
...
...
@@ -16,10 +16,14 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "taccount.h"
#include "tcluster.h"
#include "taoserror.h"
#include "tutil.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "mgmtDnode.h"
#include "mgmtDb.h"
#include "m
peer
.h"
#include "m
gmtMnode
.h"
#include "mgmtProfile.h"
#include "mgmtShell.h"
#include "mgmtTable.h"
...
...
@@ -787,11 +791,11 @@ void mgmtFreeQueuedMsg(SQueuedMsg *pMsg) {
if
(
pMsg
!=
NULL
)
{
rpcFreeCont
(
pMsg
->
pCont
);
if
(
pMsg
->
pUser
)
mgmtReleaseUser
(
pMsg
->
pUser
);
if
(
pMsg
->
pDb
)
mgmt
ReleaseDb
(
pMsg
->
pDb
);
if
(
pMsg
->
pDb
)
mgmt
DecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pVgroup
)
mgmtReleaseVgroup
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pTable
)
mgmtDecTableRef
(
pMsg
->
pTable
);
if
(
pMsg
->
pAcct
)
acctReleaseAcct
(
pMsg
->
pAcct
);
if
(
pMsg
->
pDnode
)
cluster
ReleaseDnode
(
pMsg
->
pDnode
);
if
(
pMsg
->
pAcct
)
mgmtDecAcctRef
(
pMsg
->
pAcct
);
if
(
pMsg
->
pDnode
)
mgmt
ReleaseDnode
(
pMsg
->
pDnode
);
free
(
pMsg
);
}
}
...
...
src/mnode/src/mgmt
Balance
.c
→
src/mnode/src/mgmt
Replica
.c
浏览文件 @
2f1e5287
...
...
@@ -14,34 +14,41 @@
*/
#define _DEFAULT_SOURCE
#include "tbalance.h"
#include "mnode.h"
#include "tcluster.h"
#include "os.h"
#include "trpc.h"
#include "treplica.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtMnode.h"
#include "mgmtDnode.h"
#include "mgmtVgroup.h"
#ifndef _VPEER
int32_t
balanceInit
()
{
return
0
;
}
void
balanceCleanUp
()
{}
void
balanceNotify
()
{}
#ifndef _SYNC
int32_t
balanceAllocVnodes
(
SVgObj
*
pVgroup
)
{
int32_t
replicaInit
()
{
return
TSDB_CODE_SUCCESS
;
}
void
replicaCleanUp
()
{}
void
replicaNotify
()
{}
void
replicaReset
()
{}
int32_t
replicaForwardReqToPeer
(
void
*
pHead
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
replicaAllocVnodes
(
SVgObj
*
pVgroup
)
{
void
*
pNode
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pSelDnode
=
NULL
;
float
vnodeUsage
=
1
.
0
;
while
(
1
)
{
pNode
=
cluster
GetNextDnode
(
pNode
,
&
pDnode
);
pNode
=
mgmt
GetNextDnode
(
pNode
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
->
numOfTotalVnodes
>
0
&&
pDnode
->
openVnodes
<
pDnode
->
numOfT
otalVnodes
)
{
float
usage
=
(
float
)
pDnode
->
openVnodes
/
pDnode
->
numOfT
otalVnodes
;
if
(
pDnode
->
totalVnodes
>
0
&&
pDnode
->
openVnodes
<
pDnode
->
t
otalVnodes
)
{
float
usage
=
(
float
)
pDnode
->
openVnodes
/
pDnode
->
t
otalVnodes
;
if
(
usage
<=
vnodeUsage
)
{
pSelDnode
=
pDnode
;
vnodeUsage
=
usage
;
}
}
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
}
if
(
pSelDnode
==
NULL
)
{
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
2f1e5287
...
...
@@ -18,11 +18,13 @@
#include "taoserror.h"
#include "tlog.h"
#include "trpc.h"
#include "treplica.h"
#include "tqueue.h"
#include "twal.h"
#include "hashint.h"
#include "hashstr.h"
#include "mpeer.h"
#include "mgmtLog.h"
#include "mgmtMnode.h"
#include "mgmtSdb.h"
typedef
struct
_SSdbTable
{
...
...
@@ -67,10 +69,16 @@ static void *(*sdbGetIndexFp[])(void *handle, void *key) = {sdbGetStrHashData, s
static
void
(
*
sdbCleanUpIndexFp
[])(
void
*
handle
)
=
{
sdbCloseStrHash
,
sdbCloseIntHash
,
sdbCloseIntHash
};
static
void
*
(
*
sdbFetchRowFp
[])(
void
*
handle
,
void
*
ptr
,
void
**
ppRow
)
=
{
sdbFetchStrHashData
,
sdbFetchIntHashData
,
sdbFetchIntHashData
};
uint64_t
sdbGetVersion
()
{
return
tsSdbObj
->
version
;
}
int32_t
sdbGetId
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
autoIndex
;
}
int64_t
sdbGetNumOfRows
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
numOfRows
;
}
uint64_t
sdbGetVersion
()
{
if
(
tsSdbObj
)
return
tsSdbObj
->
version
;
else
return
0
;
}
static
char
*
sdbGetActionStr
(
int32_t
action
)
{
switch
(
action
)
{
case
SDB_ACTION_INSERT
:
...
...
@@ -131,7 +139,7 @@ int32_t sdbInit() {
sdbTrace
(
"sdb is initialized, version:%d totalRows:%d numOfTables:%d"
,
tsSdbObj
->
version
,
totalRows
,
numOfTables
);
mpeerUpdateSync
();
replicaNotify
();
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -145,10 +153,6 @@ void sdbCleanUp() {
}
}
SSdbObject
*
sdbGetObj
()
{
return
tsSdbObj
;
}
void
sdbIncRef
(
void
*
handle
,
void
*
pRow
)
{
if
(
pRow
)
{
SSdbTable
*
pTable
=
handle
;
...
...
@@ -264,7 +268,7 @@ static int32_t sdbProcessWriteFromApp(SSdbTable *pTable, SWalHead *pHead, int32_
tsSdbObj
->
version
++
;
pHead
->
version
=
tsSdbObj
->
version
;
code
=
mpeer
ForwardReqToPeer
(
pHead
);
code
=
replica
ForwardReqToPeer
(
pHead
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pthread_mutex_unlock
(
&
tsSdbObj
->
mutex
);
sdbError
(
"table:%s, failed to forward %s record:%s from file, version:%"
PRId64
", reason:%s"
,
pTable
->
tableName
,
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
2f1e5287
...
...
@@ -20,14 +20,16 @@
#include "tlog.h"
#include "trpc.h"
#include "tsched.h"
#include "tutil.h"
#include "ttimer.h"
#include "dnode.h"
#include "m
node
.h"
#include "
taccount
.h"
#include "
tbalance
.h"
#include "m
gmtDef
.h"
#include "
mgmtLog
.h"
#include "
mgmtAcct
.h"
#include "mgmtDb.h"
#include "
tcluster
.h"
#include "
mgmtDnode
.h"
#include "tgrant.h"
#include "m
peer
.h"
#include "m
gmtMnode
.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
...
...
@@ -48,6 +50,7 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *queuedMsg);
static
void
mgmtProcessConnectMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtProcessUseMsg
(
SQueuedMsg
*
queuedMsg
);
extern
void
*
tsMgmtTmr
;
static
void
*
tsMgmtShellRpc
=
NULL
;
static
void
*
tsMgmtTranQhandle
=
NULL
;
static
void
(
*
tsMgmtProcessShellMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SQueuedMsg
*
)
=
{
0
};
...
...
@@ -141,7 +144,7 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
return
;
}
if
(
!
m
peer
IsMaster
())
{
if
(
!
m
gmt
IsMaster
())
{
// rpcSendRedirectRsp(rpcMsg->handle, mgmtGetMnodeIpListForRedirect());
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_NO_MASTER
);
rpcFreeCont
(
rpcMsg
->
pCont
);
...
...
@@ -329,12 +332,8 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
return
;
}
if
(
pMsg
->
usePublicIp
)
{
mpeerGetPublicIpList
(
&
pHBRsp
->
ipList
);
}
else
{
mpeerGetPrivateIpList
(
&
pHBRsp
->
ipList
);
}
mgmtGetMnodeIpList
(
&
pHBRsp
->
ipList
,
pMsg
->
usePublicIp
);
/*
* TODO
* Dispose kill stream or kill query message
...
...
@@ -415,12 +414,8 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
pConnectRsp
->
writeAuth
=
pUser
->
writeAuth
;
pConnectRsp
->
superAuth
=
pUser
->
superAuth
;
if
(
pMsg
->
usePublicIp
)
{
mpeerGetPublicIpList
(
&
pConnectRsp
->
ipList
);
}
else
{
mpeerGetPrivateIpList
(
&
pConnectRsp
->
ipList
);
}
mgmtGetMnodeIpList
(
&
pConnectRsp
->
ipList
,
pMsg
->
usePublicIp
);
connect_over:
rpcRsp
.
code
=
code
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
2f1e5287
...
...
@@ -15,7 +15,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "ttime.h"
#include "tutil.h"
...
...
@@ -23,13 +22,16 @@
#include "taosmsg.h"
#include "tscompression.h"
#include "name.h"
#include "taccount.h"
#include "tidpool.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "mgmtDClient.h"
#include "mgmtDb.h"
#include "
tcluster
.h"
#include "
mgmtDnode
.h"
#include "mgmtDServer.h"
#include "tgrant.h"
#include "m
peer
.h"
#include "m
gmtMnode
.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
...
...
@@ -101,14 +103,14 @@ static int32_t mgmtChildTableActionInsert(SSdbOperDesc *pOper) {
mError
(
"ctable:%s, vgroup:%d not in db:%s"
,
pTable
->
info
.
tableId
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
return
TSDB_CODE_INVALID_DB
;
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
==
NULL
)
{
mError
(
"ctable:%s, account:%s not exists"
,
pTable
->
info
.
tableId
,
pDb
->
cfg
.
acct
);
return
TSDB_CODE_INVALID_ACCT
;
}
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
pTable
->
superTable
=
mgmtGetSuperTable
(
pTable
->
superTableId
);
...
...
@@ -143,14 +145,14 @@ static int32_t mgmtChildTableActionDelete(SSdbOperDesc *pOper) {
mError
(
"ctable:%s, vgroup:%d not in DB:%s"
,
pTable
->
info
.
tableId
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
return
TSDB_CODE_INVALID_DB
;
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
==
NULL
)
{
mError
(
"ctable:%s, account:%s not exists"
,
pTable
->
info
.
tableId
,
pDb
->
cfg
.
acct
);
return
TSDB_CODE_INVALID_ACCT
;
}
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
grantRestore
(
TSDB_GRANT_TIMESERIES
,
pTable
->
superTable
->
numOfColumns
-
1
);
...
...
@@ -258,7 +260,7 @@ static int32_t mgmtChildTableActionRestored() {
pNode
=
pLastNode
;
continue
;
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
...
...
@@ -401,7 +403,7 @@ static int32_t mgmtSuperTableActionInsert(SSdbOperDesc *pOper) {
if
(
pDb
!=
NULL
)
{
mgmtAddSuperTableIntoDb
(
pDb
);
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -413,7 +415,7 @@ static int32_t mgmtSuperTableActionDelete(SSdbOperDesc *pOper) {
mgmtRemoveSuperTableFromDb
(
pDb
);
mgmtDropAllChildTablesInStable
((
SSuperTableObj
*
)
pStable
);
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -923,10 +925,10 @@ static int32_t mgmtAddSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, SSc
pStable
->
numOfColumns
+=
ncols
;
pStable
->
sversion
++
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ncols
*
pStable
->
numOfTables
);
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
}
SSdbOperDesc
oper
=
{
...
...
@@ -960,10 +962,10 @@ static int32_t mgmtDropSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, ch
int32_t
schemaSize
=
sizeof
(
SSchema
)
*
(
pStable
->
numOfTags
+
pStable
->
numOfColumns
);
pStable
->
schema
=
realloc
(
pStable
->
schema
,
schemaSize
);
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
-=
pStable
->
numOfTables
;
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
}
SSdbOperDesc
oper
=
{
...
...
@@ -1029,7 +1031,7 @@ static int32_t mgmtGetShowSuperTableMeta(STableMetaMsg *pMeta, SShowObj *pShow,
pShow
->
numOfRows
=
pDb
->
numOfSuperTables
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
0
;
}
...
...
@@ -1094,7 +1096,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
}
pShow
->
numOfReads
+=
numOfRows
;
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
numOfRows
;
}
...
...
@@ -1191,14 +1193,14 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
pRsp
->
vgroups
[
vg
].
vgId
=
htonl
(
vgId
);
for
(
int32_t
vn
=
0
;
vn
<
pVgroup
->
numOfVnodes
;
++
vn
)
{
SDnodeObj
*
pDnode
=
cluster
GetDnode
(
pVgroup
->
vnodeGid
[
vn
].
dnodeId
);
SDnodeObj
*
pDnode
=
mgmt
GetDnode
(
pVgroup
->
vnodeGid
[
vn
].
dnodeId
);
if
(
pDnode
==
NULL
)
break
;
pRsp
->
vgroups
[
vg
].
ipAddr
[
vn
].
ip
=
htonl
(
pDnode
->
privateIp
);
pRsp
->
vgroups
[
vg
].
ipAddr
[
vn
].
port
=
htons
(
tsDnodeShellPort
);
pRsp
->
vgroups
[
vg
].
numOfIps
++
;
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
}
mgmtReleaseVgroup
(
pVgroup
);
...
...
@@ -1500,10 +1502,10 @@ static int32_t mgmtAddNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, SSc
pTable
->
numOfColumns
+=
ncols
;
pTable
->
sversion
++
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
+=
ncols
;
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
}
SSdbOperDesc
oper
=
{
...
...
@@ -1534,10 +1536,10 @@ static int32_t mgmtDropNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, ch
pTable
->
numOfColumns
--
;
pTable
->
sversion
++
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pDb
->
cfg
.
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
--
;
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
}
SSdbOperDesc
oper
=
{
...
...
@@ -1600,7 +1602,7 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) {
}
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SDnodeObj
*
pDnode
=
cluster
GetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
SDnodeObj
*
pDnode
=
mgmt
GetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
if
(
pDnode
==
NULL
)
break
;
if
(
usePublicIp
)
{
pMeta
->
vgroup
.
ipAddr
[
i
].
ip
=
htonl
(
pDnode
->
publicIp
);
...
...
@@ -1610,7 +1612,7 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) {
pMeta
->
vgroup
.
ipAddr
[
i
].
port
=
htonl
(
tsDnodeShellPort
);
}
pMeta
->
vgroup
.
numOfIps
++
;
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
}
pMeta
->
vgroup
.
vgId
=
htonl
(
pVgroup
->
vgId
);
...
...
@@ -1730,7 +1732,7 @@ static void mgmtDropAllChildTablesInStable(SSuperTableObj *pStable) {
}
static
SChildTableObj
*
mgmtGetTableByPos
(
uint32_t
dnodeId
,
int32_t
vnode
,
int32_t
sid
)
{
SDnodeObj
*
pObj
=
cluster
GetDnode
(
dnodeId
);
SDnodeObj
*
pObj
=
mgmt
GetDnode
(
dnodeId
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
vnode
);
if
(
pObj
==
NULL
||
pVgroup
==
NULL
)
{
...
...
@@ -1968,7 +1970,7 @@ static int32_t mgmtGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
pShow
->
numOfRows
=
pDb
->
numOfTables
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
0
;
}
...
...
@@ -2045,7 +2047,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
const
int32_t
NUM_OF_COLUMNS
=
4
;
mgmtVacuumResult
(
data
,
NUM_OF_COLUMNS
,
numOfRows
,
rows
,
pShow
);
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
numOfRows
;
}
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
2f1e5287
...
...
@@ -18,9 +18,12 @@
#include "trpc.h"
#include "ttime.h"
#include "tutil.h"
#include "taccount.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "tgrant.h"
#include "m
peer
.h"
#include "m
gmtMnode
.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtUser.h"
...
...
@@ -40,10 +43,10 @@ static int32_t mgmtUserActionDestroy(SSdbOperDesc *pOper) {
static
int32_t
mgmtUserActionInsert
(
SSdbOperDesc
*
pOper
)
{
SUserObj
*
pUser
=
pOper
->
pObj
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pUser
->
acct
);
if
(
pAcct
!=
NULL
)
{
acctAddUser
(
pAcct
,
pUser
);
mgmtAddUserToAcct
(
pAcct
,
pUser
);
}
else
{
mError
(
"user:%s, acct:%s info not exist in sdb"
,
pUser
->
user
,
pUser
->
acct
);
...
...
@@ -55,10 +58,10 @@ static int32_t mgmtUserActionInsert(SSdbOperDesc *pOper) {
static
int32_t
mgmtUserActionDelete
(
SSdbOperDesc
*
pOper
)
{
SUserObj
*
pUser
=
pOper
->
pObj
;
SAcctObj
*
pAcct
=
acc
tGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
pUser
->
acct
);
if
(
pAcct
!=
NULL
)
{
acctRemoveUser
(
pAcct
,
pUser
);
mgmtDropUserFromAcct
(
pAcct
,
pUser
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -91,12 +94,12 @@ static int32_t mgmtUserActionDecode(SSdbOperDesc *pOper) {
}
static
int32_t
mgmtUserActionRestored
()
{
if
(
strcmp
(
tsMasterIp
,
tsPrivateIp
)
==
0
)
{
SAcctObj
*
pAcct
=
acc
tGetAcct
(
"root"
);
if
(
dnodeIsFirstDeploy
()
)
{
SAcctObj
*
pAcct
=
mgm
tGetAcct
(
"root"
);
mgmtCreateUser
(
pAcct
,
"root"
,
"taosdata"
);
mgmtCreateUser
(
pAcct
,
"monitor"
,
tsInternalPass
);
mgmtCreateUser
(
pAcct
,
"_root"
,
tsInternalPass
);
acctReleaseAcct
(
pAcct
);
mgmtDecAcctRef
(
pAcct
);
}
return
0
;
...
...
@@ -167,7 +170,7 @@ static int32_t mgmtUpdateUser(SUserObj *pUser) {
}
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int32_t
code
=
acctCheck
(
pAcct
,
TSDB_ACC
T_USER
);
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRAN
T_USER
);
if
(
code
!=
0
)
{
return
code
;
}
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
2f1e5287
...
...
@@ -17,14 +17,19 @@
#include "os.h"
#include "taoserror.h"
#include "tlog.h"
#include "tbalance.h"
#include "tutil.h"
#include "tsocket.h"
#include "tidpool.h"
#include "tsync.h"
#include "tcluster.h"
#include "mnode.h"
#include "ttime.h"
#include "treplica.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtDb.h"
#include "mgmtDClient.h"
#include "mgmtDServer.h"
#include "mpeer.h"
#include "mgmtDnode.h"
#include "mgmtMnode.h"
#include "mgmtProfile.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
...
...
@@ -63,7 +68,7 @@ static int32_t mgmtVgroupActionInsert(SSdbOperDesc *pOper) {
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_INVALID_DB
;
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
pVgroup
->
pDb
=
pDb
;
pVgroup
->
prev
=
NULL
;
...
...
@@ -84,12 +89,12 @@ static int32_t mgmtVgroupActionInsert(SSdbOperDesc *pOper) {
}
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SDnodeObj
*
pDnode
=
cluster
GetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
SDnodeObj
*
pDnode
=
mgmt
GetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
if
(
pDnode
!=
NULL
)
{
pVgroup
->
vnodeGid
[
i
].
privateIp
=
pDnode
->
privateIp
;
pVgroup
->
vnodeGid
[
i
].
publicIp
=
pDnode
->
publicIp
;
atomic_add_fetch_32
(
&
pDnode
->
openVnodes
,
1
);
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
}
}
...
...
@@ -106,14 +111,14 @@ static int32_t mgmtVgroupActionDelete(SSdbOperDesc *pOper) {
mgmtRemoveVgroupFromDb
(
pVgroup
);
}
mgmt
ReleaseDb
(
pVgroup
->
pDb
);
mgmt
DecDbRef
(
pVgroup
->
pDb
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SDnodeObj
*
pDnode
=
cluster
GetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
SDnodeObj
*
pDnode
=
mgmt
GetDnode
(
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
if
(
pDnode
)
{
atomic_sub_fetch_32
(
&
pDnode
->
openVnodes
,
1
);
}
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -244,7 +249,7 @@ void mgmtCreateVgroup(SQueuedMsg *pMsg, SDbObj *pDb) {
strcpy
(
pVgroup
->
dbName
,
pDb
->
name
);
pVgroup
->
numOfVnodes
=
pDb
->
cfg
.
replications
;
pVgroup
->
createdTime
=
taosGetTimestampMs
();
if
(
balance
AllocVnodes
(
pVgroup
)
!=
0
)
{
if
(
replica
AllocVnodes
(
pVgroup
)
!=
0
)
{
mError
(
"db:%s, no enough dnode to alloc %d vnodes to vgroup"
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
free
(
pVgroup
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_ENOUGH_DNODES
);
...
...
@@ -381,18 +386,18 @@ int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
pShow
->
pNode
=
pVgroup
;
}
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
0
;
}
char
*
mgmtGetVnodeStatus
(
SVgObj
*
pVgroup
,
SVnodeGid
*
pVnode
)
{
SDnodeObj
*
pDnode
=
cluster
GetDnode
(
pVnode
->
dnodeId
);
SDnodeObj
*
pDnode
=
mgmt
GetDnode
(
pVnode
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"vgroup:%d, not exist in dnode:%d"
,
pVgroup
->
vgId
,
pDnode
->
dnodeId
);
return
"null"
;
}
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
if
(
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
return
"offline"
;
...
...
@@ -467,7 +472,7 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo
}
pShow
->
numOfReads
+=
numOfRows
;
mgmt
ReleaseDb
(
pDb
);
mgmt
DecDbRef
(
pDb
);
return
numOfRows
;
}
...
...
@@ -676,13 +681,13 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) {
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
vgId
=
htonl
(
pCfg
->
vgId
);
SDnodeObj
*
pDnode
=
cluster
GetDnode
(
pCfg
->
dnodeId
);
SDnodeObj
*
pDnode
=
mgmt
GetDnode
(
pCfg
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mTrace
(
"dnode:%s, invalid dnode"
,
taosIpStr
(
pCfg
->
dnodeId
),
pCfg
->
vgId
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_NOT_ACTIVE_VNODE
);
return
;
}
cluster
ReleaseDnode
(
pDnode
);
mgmt
ReleaseDnode
(
pDnode
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pCfg
->
vgId
);
if
(
pVgroup
==
NULL
)
{
...
...
src/os/darwin/src/tdarwin.c
浏览文件 @
2f1e5287
...
...
@@ -243,6 +243,11 @@ int taosInitTimer(void (*callback)(int), int ms) {
return
setitimer
(
ITIMER_REAL
,
&
tv
,
NULL
);
}
void
taosUninitTimer
()
{
struct
itimerval
tv
=
{
0
};
return
setitimer
(
ITIMER_REAL
,
&
tv
,
NULL
);
}
void
taosGetSystemTimezone
()
{
// get and set default timezone
SGlobalConfig
*
cfg_timezone
=
tsGetConfigOption
(
"timezone"
);
...
...
src/os/linux/src/tlinux.c
浏览文件 @
2f1e5287
...
...
@@ -286,20 +286,23 @@ void *taosProcessAlarmSignal(void *tharg) {
return
NULL
;
}
static
pthread_t
timerThread
;
int
taosInitTimer
(
void
(
*
callback
)(
int
),
int
ms
)
{
pthread_t
thread
;
pthread_attr_t
tattr
;
pthread_attr_init
(
&
tattr
);
pthread_attr_setdetachstate
(
&
tattr
,
PTHREAD_CREATE_DETACHED
);
int
code
=
pthread_create
(
&
thread
,
&
tattr
,
taosProcessAlarmSignal
,
callback
);
pthread_detach
(
thread
);
int
code
=
pthread_create
(
&
timerThread
,
&
tattr
,
taosProcessAlarmSignal
,
callback
);
pthread_attr_destroy
(
&
tattr
);
if
(
code
!=
0
)
{
tmrError
(
"failed to create timer thread"
);
return
-
1
;
}
return
0
;
}
return
thread
;
void
taosUninitTimer
()
{
pthread_cancel
(
timerThread
);
pthread_join
(
timerThread
,
NULL
);
}
ssize_t
tread
(
int
fd
,
void
*
buf
,
size_t
count
)
{
...
...
src/os/windows/src/twintimer.c
浏览文件 @
2f1e5287
...
...
@@ -30,8 +30,8 @@ void WINAPI taosWinOnTimer(UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR
}
}
static
MMRESULT
timerId
;
int
taosInitTimer
(
win_timer_f
callback
,
int
ms
)
{
MMRESULT
timerId
;
DWORD_PTR
param
=
*
((
int64_t
*
)
&
callback
);
timerId
=
timeSetEvent
(
ms
,
1
,
(
LPTIMECALLBACK
)
taosWinOnTimer
,
param
,
TIME_PERIODIC
);
...
...
@@ -41,6 +41,10 @@ int taosInitTimer(win_timer_f callback, int ms) {
return
0
;
}
void
taosUninitTimer
()
{
timeKillEvent
(
timerId
);
}
void
taosMsleep
(
int
mseconds
)
{
Sleep
(
mseconds
);
}
...
...
src/plugins/http/CMakeLists.txt
浏览文件 @
2f1e5287
...
...
@@ -15,7 +15,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
ADD_LIBRARY
(
http
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
http taos_static z
)
IF
(
TD_
CLUSTER
)
TARGET_LINK_LIBRARIES
(
http
)
IF
(
TD_
ADMIN
)
TARGET_LINK_LIBRARIES
(
http
admin
)
ENDIF
()
ENDIF
()
src/plugins/http/inc/httpHandle.h
浏览文件 @
2f1e5287
...
...
@@ -23,7 +23,7 @@
#include "taosdef.h"
#include "tutil.h"
#include "zlib.h"
#include "tlog.h"
#include "http.h"
#include "httpJson.h"
...
...
@@ -206,10 +206,10 @@ typedef struct HttpThread {
int
threadId
;
char
label
[
HTTP_LABEL_SIZE
];
bool
(
*
processData
)(
HttpContext
*
pContext
);
struct
_http_server_obj_
*
pServer
;
// handle passed by upper layer during pServer initialization
struct
HttpServer
*
pServer
;
// handle passed by upper layer during pServer initialization
}
HttpThread
;
typedef
struct
_http_server_obj_
{
typedef
struct
HttpServer
{
char
label
[
HTTP_LABEL_SIZE
];
char
serverIp
[
16
];
uint16_t
serverPort
;
...
...
@@ -313,4 +313,27 @@ const char* httpContextStateStr(HttpContextState state);
bool
httpAlterContextState
(
HttpContext
*
pContext
,
HttpContextState
srcState
,
HttpContextState
destState
);
void
httpRemoveContextFromEpoll
(
HttpThread
*
pThread
,
HttpContext
*
pContext
);
#define httpError(...) \
if (httpDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR HTP ", 255, __VA_ARGS__); \
}
#define httpWarn(...) \
if (httpDebugFlag & DEBUG_WARN) { \
tprintf("WARN HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpTrace(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
tprintf("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpDump(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpPrint(...) \
{ tprintf("HTP ", 255, __VA_ARGS__); }
#define httpLError(...) taosLogError(__VA_ARGS__) httpError(__VA_ARGS__)
#define httpLWarn(...) taosLogWarn(__VA_ARGS__) httpWarn(__VA_ARGS__)
#define httpLPrint(...) taosLogPrint(__VA_ARGS__) httpPrint(__VA_ARGS__)
#endif
src/plugins/http/src/httpSystem.c
浏览文件 @
2f1e5287
...
...
@@ -13,11 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <arpa/inet.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#define _DEFAULT_SOURCE
#include "os.h"
#include "tadmin.h"
#include "http.h"
#include "httpCode.h"
#include "httpHandle.h"
...
...
@@ -27,28 +25,17 @@
#include "tglobalcfg.h"
#include "tsocket.h"
#include "ttimer.h"
#include "gcHandle.h"
#include "httpHandle.h"
#include "restHandle.h"
#include "tgHandle.h"
#include "tlog.h"
#ifndef _ADMIN
void
(
*
adminInitHandleFp
)(
HttpServer
*
pServer
)
=
NULL
;
void
(
*
opInitHandleFp
)(
HttpServer
*
pServer
)
=
NULL
;
void
adminInitHandle
(
HttpServer
*
pServer
)
{
if
(
adminInitHandleFp
)
{
(
*
adminInitHandleFp
)(
pServer
);
}
}
void
adminInitHandle
(
HttpServer
*
pServer
)
{}
void
opInitHandle
(
HttpServer
*
pServer
)
{}
void
opInitHandle
(
HttpServer
*
pServer
)
{
if
(
opInitHandleFp
)
{
(
*
opInitHandleFp
)(
pServer
);
}
}
#endif
static
HttpServer
*
httpServer
=
NULL
;
void
taosInitNote
(
int
numOfNoteLines
,
int
maxNotes
,
char
*
lable
);
...
...
src/plugins/monitor/src/monitorSystem.c
浏览文件 @
2f1e5287
...
...
@@ -13,17 +13,37 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tlog.h"
#include "monitor.h"
#include "dnode.h"
#include "monitorSystem.h"
#include "tsclient.h"
#include "taosdef.h"
#include "tsystem.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
#include "monitorSystem.h"
#define monitorError(...) \
if (monitorDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MON ", 255, __VA_ARGS__); \
}
#define monitorWarn(...) \
if (monitorDebugFlag & DEBUG_WARN) { \
tprintf("WARN MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorTrace(...) \
if (monitorDebugFlag & DEBUG_TRACE) { \
tprintf("MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorPrint(...) \
{ tprintf("MON ", 255, __VA_ARGS__); }
#define monitorLError(...) taosLogError(__VA_ARGS__) monitorError(__VA_ARGS__)
#define monitorLWarn(...) taosLogWarn(__VA_ARGS__) monitorWarn(__VA_ARGS__)
#define monitorLPrint(...) taosLogPrint(__VA_ARGS__) monitorPrint(__VA_ARGS__)
#define SQL_LENGTH 1024
#define LOG_LEN_STR 80
...
...
src/query/inc/queryExecutor.h
浏览文件 @
2f1e5287
...
...
@@ -189,5 +189,4 @@ typedef struct SQInfo {
TSKEY
*
tsList
;
}
SQInfo
;
#endif // TDENGINE_QUERYEXECUTOR_H
src/query/src/queryExecutor.c
浏览文件 @
2f1e5287
...
...
@@ -12,7 +12,6 @@
* 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 "tsdbMain.h" //todo use TableId instead of STable object
#include "os.h"
#include "hash.h"
...
...
@@ -28,6 +27,8 @@
#include "qresultBuf.h"
#include "queryExecutor.h"
#include "queryUtil.h"
#include "query.h"
#include "tsdbMain.h" //todo use TableId instead of STable object
#define DEFAULT_INTERN_BUF_SIZE 16384L
...
...
@@ -6031,7 +6032,7 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// todo if interpolation exists, the result may be dump to client by several rounds
}
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
SQueryTableMsg
*
pQueryMsg
,
SQInfo
*
*
pQInfo
)
{
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
SQueryTableMsg
*
pQueryMsg
,
qinfo_t
*
pQInfo
)
{
assert
(
pQueryMsg
!=
NULL
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -6121,12 +6122,14 @@ _query_over:
return
TSDB_CODE_SUCCESS
;
}
void
qDestroyQueryInfo
(
SQInfo
*
pQInfo
)
{
void
qDestroyQueryInfo
(
qinfo_t
pQInfo
)
{
dTrace
(
"QInfo:%p query completed"
,
pQInfo
);
freeQInfo
(
pQInfo
);
}
void
qTableQuery
(
SQInfo
*
pQInfo
)
{
void
qTableQuery
(
qinfo_t
qinfo
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
if
(
pQInfo
==
NULL
||
pQInfo
->
signature
!=
pQInfo
)
{
dTrace
(
"%p freed abort query"
,
pQInfo
);
return
;
...
...
@@ -6148,7 +6151,9 @@ void qTableQuery(SQInfo *pQInfo) {
// vnodeDecRefCount(pQInfo);
}
int32_t
qRetrieveQueryResultInfo
(
SQInfo
*
pQInfo
)
{
int32_t
qRetrieveQueryResultInfo
(
qinfo_t
qinfo
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
if
(
pQInfo
==
NULL
||
!
isValidQInfo
(
pQInfo
))
{
return
TSDB_CODE_INVALID_QHANDLE
;
}
...
...
@@ -6166,7 +6171,9 @@ int32_t qRetrieveQueryResultInfo(SQInfo *pQInfo) {
return
pQInfo
->
code
;
}
bool
qHasMoreResultsToRetrieve
(
SQInfo
*
pQInfo
)
{
bool
qHasMoreResultsToRetrieve
(
qinfo_t
qinfo
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
if
(
pQInfo
==
NULL
||
pQInfo
->
signature
!=
pQInfo
||
pQInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
return
false
;
}
...
...
@@ -6183,7 +6190,9 @@ bool qHasMoreResultsToRetrieve(SQInfo* pQInfo) {
}
}
int32_t
qDumpRetrieveResult
(
SQInfo
*
pQInfo
,
SRetrieveTableRsp
**
pRsp
,
int32_t
*
contLen
)
{
int32_t
qDumpRetrieveResult
(
qinfo_t
qinfo
,
SRetrieveTableRsp
**
pRsp
,
int32_t
*
contLen
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
if
(
pQInfo
==
NULL
||
!
isValidQInfo
(
pQInfo
))
{
return
TSDB_CODE_INVALID_QHANDLE
;
}
...
...
src/rpc/CMakeLists.txt
浏览文件 @
2f1e5287
...
...
@@ -24,7 +24,7 @@ ELSEIF (TD_WINDOWS_64)
ENDIF
()
ADD_LIBRARY
(
trpc
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
trpc tutil lz4
)
TARGET_LINK_LIBRARIES
(
trpc tutil lz4
common
)
ADD_SUBDIRECTORY
(
test
)
src/tsdb/inc/tsdbMain.h
浏览文件 @
2f1e5287
...
...
@@ -15,9 +15,9 @@
#ifndef _TD_TSDB_MAIN_H_
#define _TD_TSDB_MAIN_H_
#include "tsdb.h"
#include "tlist.h"
#include "tglobalcfg.h"
#include "tlist.h"
#include "tsdb.h"
#include "tskiplist.h"
#include "tutil.h"
...
...
@@ -90,9 +90,9 @@ typedef struct {
STable
*
superList
;
// super table list TODO: change it to list container
void
*
map
;
// table map of (uid ===> table)
void
*
map
;
// table map of (uid ===> table)
SMetaFile
*
mfh
;
// meta file handle
SMetaFile
*
mfh
;
// meta file handle
int
maxRowBytes
;
int
maxCols
;
}
STsdbMeta
;
...
...
@@ -119,14 +119,14 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable);
#define TSDB_TABLE_OF_ID(pHandle, id) ((pHandle)->pTables)[id]
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
STsdbMeta
*
tsdbGetMeta
(
tsdb_repo_t
*
pRepo
);
STsdbMeta
*
tsdbGetMeta
(
tsdb_repo_t
*
pRepo
);
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
pMeta
,
STableCfg
*
pCfg
);
int32_t
tsdbDropTableImpl
(
STsdbMeta
*
pMeta
,
STableId
tableId
);
STable
*
tsdbIsValidTableToInsert
(
STsdbMeta
*
pMeta
,
STableId
tableId
);
// int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable);
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
int64_t
uid
);
char
*
getTupleKey
(
const
void
*
data
);
char
*
getTupleKey
(
const
void
*
data
);
// ------------------------------ TSDB CACHE INTERFACES ------------------------------
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16 * 1024 * 1024
/* 16M */
...
...
@@ -192,8 +192,8 @@ typedef struct {
}
SFileInfo
;
typedef
struct
{
int
fd
;
char
fname
[
128
];
int
fd
;
char
fname
[
128
];
SFileInfo
info
;
}
SFile
;
...
...
@@ -217,13 +217,15 @@ typedef struct {
STsdbFileH
*
tsdbInitFileH
(
char
*
dataDir
,
int
maxFiles
);
void
tsdbCloseFileH
(
STsdbFileH
*
pFileH
);
int
tsdbCreateFile
(
char
*
dataDir
,
int
fileId
,
const
char
*
suffix
,
int
maxTables
,
SFile
*
pFile
,
int
writeHeader
,
int
toClose
);
int
tsdbCreateFile
(
char
*
dataDir
,
int
fileId
,
const
char
*
suffix
,
int
maxTables
,
SFile
*
pFile
,
int
writeHeader
,
int
toClose
);
int
tsdbCreateFGroup
(
STsdbFileH
*
pFileH
,
char
*
dataDir
,
int
fid
,
int
maxTables
);
int
tsdbOpenFile
(
SFile
*
pFile
,
int
oflag
);
int
tsdbCloseFile
(
SFile
*
pFile
);
SFileGroup
*
tsdbOpenFilesForCommit
(
STsdbFileH
*
pFileH
,
int
fid
);
int
tsdbCloseFile
(
SFile
*
pFile
);
SFileGroup
*
tsdbOpenFilesForCommit
(
STsdbFileH
*
pFileH
,
int
fid
);
int
tsdbRemoveFileGroup
(
STsdbFileH
*
pFile
,
int
fid
);
#define TSDB_FGROUP_ITER_FORWARD
TSDB_ORDER_ASC
#define TSDB_FGROUP_ITER_FORWARD TSDB_ORDER_ASC
#define TSDB_FGROUP_ITER_BACKWARD TSDB_ORDER_DESC
typedef
struct
{
...
...
@@ -278,15 +280,15 @@ typedef struct {
}
SCompInfo
;
#define TSDB_COMPBLOCK_AT(pCompInfo, idx) ((pCompInfo)->blocks + (idx))
#define TSDB_COMPBLOCK_GET_START_AND_SIZE(pCompInfo, pCompBlock, size)\
do {
\
if (pCompBlock->numOfSubBlocks > 1) {
\
pCompBlock = pCompInfo->blocks + pCompBlock->offset;
\
size = pCompBlock->numOfSubBlocks;
\
} else {
\
size = 1;
\
}
\
} while (0)
#define TSDB_COMPBLOCK_GET_START_AND_SIZE(pCompInfo, pCompBlock, size)
\
do {
\
if (pCompBlock->numOfSubBlocks > 1) {
\
pCompBlock = pCompInfo->blocks + pCompBlock->offset;
\
size = pCompBlock->numOfSubBlocks;
\
} else {
\
size = 1;
\
}
\
} while (0)
// TODO: take pre-calculation into account
typedef
struct
{
...
...
@@ -304,9 +306,10 @@ typedef struct {
SCompCol
cols
[];
}
SCompData
;
STsdbFileH
*
tsdbGetFile
(
tsdb_repo_t
*
pRepo
);
STsdbFileH
*
tsdbGetFile
(
tsdb_repo_t
*
pRepo
);
int
tsdbCopyBlockDataInFile
(
SFile
*
pOutFile
,
SFile
*
pInFile
,
SCompInfo
*
pCompInfo
,
int
idx
,
int
isLast
,
SDataCols
*
pCols
);
int
tsdbCopyBlockDataInFile
(
SFile
*
pOutFile
,
SFile
*
pInFile
,
SCompInfo
*
pCompInfo
,
int
idx
,
int
isLast
,
SDataCols
*
pCols
);
int
tsdbLoadCompIdx
(
SFileGroup
*
pGroup
,
void
*
buf
,
int
maxTables
);
int
tsdbLoadCompBlocks
(
SFileGroup
*
pGroup
,
SCompIdx
*
pIdx
,
void
*
buf
);
...
...
@@ -350,6 +353,30 @@ typedef struct _tsdb_repo {
}
STsdbRepo
;
typedef
struct
{
int32_t
totalLen
;
int32_t
len
;
SDataRow
row
;
}
SSubmitBlkIter
;
int
tsdbInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
SDataRow
tsdbGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
#define TSDB_SUBMIT_MSG_HEAD_SIZE sizeof(SSubmitMsg)
// SSubmitMsg Iterator
typedef
struct
{
int32_t
totalLen
;
int32_t
len
;
SSubmitBlk
*
pBlock
;
}
SSubmitMsgIter
;
int
tsdbInitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
);
SSubmitBlk
*
tsdbGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
);
int32_t
tsdbTriggerCommit
(
tsdb_repo_t
*
repo
);
int32_t
tsdbLockRepo
(
tsdb_repo_t
*
repo
);
int32_t
tsdbUnLockRepo
(
tsdb_repo_t
*
repo
);
#ifdef __cplusplus
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
2f1e5287
...
...
@@ -387,7 +387,7 @@ int32_t tsdbInsertData(tsdb_repo_t *repo, SSubmitMsg *pMsg) {
/**
* Initialize a table configuration
*/
int
tsdbInitTableCfg
(
STableCfg
*
config
,
TSDB_TABLE_TYPE
type
,
int64_t
uid
,
int32_t
tid
)
{
int
tsdbInitTableCfg
(
STableCfg
*
config
,
ETableType
type
,
int64_t
uid
,
int32_t
tid
)
{
if
(
config
==
NULL
)
return
-
1
;
if
(
type
!=
TSDB_NORMAL_TABLE
&&
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
...
...
src/util/CMakeLists.txt
浏览文件 @
2f1e5287
...
...
@@ -107,8 +107,4 @@ ELSEIF(TD_DARWIN_64)
TARGET_LINK_LIBRARIES
(
tutil iconv pthread os
)
ENDIF
()
#IF (TD_CLUSTER)
# TARGET_LINK_LIBRARIES(tutil mstorage)
#ENDIF ()
src/util/inc/tlog.h
浏览文件 @
2f1e5287
...
...
@@ -177,87 +177,6 @@ extern uint32_t cdebugFlag;
tprintf("DND QRY ", qdebugFlag, __VA_ARGS__); \
}
// mnode log function
#define mError(...) \
if (mdebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND ", 255, __VA_ARGS__); \
}
#define mWarn(...) \
if (mdebugFlag & DEBUG_WARN) { \
tprintf("WARN MND ", mdebugFlag, __VA_ARGS__); \
}
#define mTrace(...) \
if (mdebugFlag & DEBUG_TRACE) { \
tprintf("MND ", mdebugFlag, __VA_ARGS__); \
}
#define mPrint(...) \
{ tprintf("MND ", 255, __VA_ARGS__); }
#define mLError(...) taosLogError(__VA_ARGS__) mError(__VA_ARGS__)
#define mLWarn(...) taosLogWarn(__VA_ARGS__) mWarn(__VA_ARGS__)
#define mLPrint(...) taosLogPrint(__VA_ARGS__) mPrint(__VA_ARGS__)
#define httpError(...) \
if (httpDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR HTP ", 255, __VA_ARGS__); \
}
#define httpWarn(...) \
if (httpDebugFlag & DEBUG_WARN) { \
tprintf("WARN HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpTrace(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
tprintf("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpDump(...) \
if (httpDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); \
}
#define httpPrint(...) \
{ tprintf("HTP ", 255, __VA_ARGS__); }
#define httpLError(...) taosLogError(__VA_ARGS__) httpError(__VA_ARGS__)
#define httpLWarn(...) taosLogWarn(__VA_ARGS__) httpWarn(__VA_ARGS__)
#define httpLPrint(...) taosLogPrint(__VA_ARGS__) httpPrint(__VA_ARGS__)
#define monitorError(...) \
if (monitorDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MON ", 255, __VA_ARGS__); \
}
#define monitorWarn(...) \
if (monitorDebugFlag & DEBUG_WARN) { \
tprintf("WARN MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorTrace(...) \
if (monitorDebugFlag & DEBUG_TRACE) { \
tprintf("MON ", monitorDebugFlag, __VA_ARGS__); \
}
#define monitorPrint(...) \
{ tprintf("MON ", 255, __VA_ARGS__); }
#define monitorLError(...) taosLogError(__VA_ARGS__) monitorError(__VA_ARGS__)
#define monitorLWarn(...) taosLogWarn(__VA_ARGS__) monitorWarn(__VA_ARGS__)
#define monitorLPrint(...) taosLogPrint(__VA_ARGS__) monitorPrint(__VA_ARGS__)
#define sdbError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR MND-SDB ", 255, __VA_ARGS__); \
}
#define sdbWarn(...) \
if (sdbDebugFlag & DEBUG_WARN) { \
tprintf("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbTrace(...) \
if (sdbDebugFlag & DEBUG_TRACE) { \
tprintf("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \
}
#define sdbPrint(...) \
{ tprintf("MND-SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) taosLogError(__VA_ARGS__) sdbError(__VA_ARGS__)
#define sdbLWarn(...) taosLogWarn(__VA_ARGS__) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) taosLogPrint(__VA_ARGS__) sdbPrint(__VA_ARGS__)
#ifdef __cplusplus
}
#endif
...
...
src/util/inc/tsched.h
浏览文件 @
2f1e5287
...
...
@@ -20,22 +20,17 @@
extern
"C"
{
#endif
typedef
struct
_sched_msg
{
void
(
*
fp
)(
struct
_sched_msg
*
);
typedef
struct
SSchedMsg
{
void
(
*
fp
)(
struct
SSchedMsg
*
);
void
(
*
tfp
)(
void
*
,
void
*
);
void
*
msg
;
void
*
ahandle
;
void
*
thandle
;
}
SSchedMsg
;
void
*
taosInitScheduler
(
int
queueSize
,
int
numOfThreads
,
const
char
*
label
);
void
*
taosInitSchedulerWithInfo
(
int
queueSize
,
int
numOfThreads
,
const
char
*
label
,
void
*
tmrCtrl
);
int
taosScheduleTask
(
void
*
qhandle
,
SSchedMsg
*
pMsg
);
int
taosScheduleTask
(
void
*
qhandle
,
SSchedMsg
*
pMsg
);
void
taosCleanUpScheduler
(
void
*
param
);
#ifdef __cplusplus
...
...
src/util/inc/tutil.h
浏览文件 @
2f1e5287
...
...
@@ -144,6 +144,7 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
void
getTmpfilePath
(
const
char
*
fileNamePattern
,
char
*
dstPath
);
int32_t
taosInitTimer
(
void
(
*
callback
)(
int
),
int32_t
ms
);
void
taosUninitTimer
();
bool
taosMbsToUcs4
(
char
*
mbs
,
int32_t
mbs_len
,
char
*
ucs4
,
int32_t
ucs4_max_len
);
...
...
src/util/src/talgo.c
浏览文件 @
2f1e5287
...
...
@@ -168,6 +168,7 @@ void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size,
if
(
flags
==
TD_EQ
)
{
return
bsearch
(
key
,
base
,
nmemb
,
size
,
compar
);
}
else
if
(
flags
==
TD_GE
)
{
if
(
nmemb
<=
0
)
return
NULL
;
if
((
*
compar
)(
key
,
elePtrAt
(
base
,
size
,
0
))
<=
0
)
return
elePtrAt
(
base
,
size
,
0
);
if
((
*
compar
)(
key
,
elePtrAt
(
base
,
size
,
nmemb
-
1
))
>
0
)
return
NULL
;
...
...
@@ -193,6 +194,7 @@ void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size,
}
}
}
else
if
(
flags
==
TD_LE
)
{
if
(
nmemb
<=
0
)
return
NULL
;
if
((
*
compar
)(
key
,
elePtrAt
(
base
,
size
,
nmemb
-
1
))
>=
0
)
return
elePtrAt
(
base
,
size
,
nmemb
-
1
);
if
((
*
compar
)(
key
,
elePtrAt
(
base
,
size
,
0
))
<
0
)
return
NULL
;
...
...
src/util/src/tglobalcfg.c
浏览文件 @
2f1e5287
...
...
@@ -110,12 +110,7 @@ short tsDaysPerFile = 10;
int
tsDaysToKeep
=
3650
;
int
tsReplications
=
TSDB_REPLICA_MIN_NUM
;
#ifdef _MPEER
int
tsNumOfMPeers
=
3
;
#else
int
tsNumOfMPeers
=
1
;
#endif
int
tsMaxShellConns
=
2000
;
int
tsMaxTables
=
100000
;
...
...
@@ -556,7 +551,7 @@ static void doInitGlobalConfig() {
tsInitConfigOption
(
cfg
++
,
"tblocks"
,
&
tsNumOfBlocksPerMeter
,
TSDB_CFG_VTYPE_SHORT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
,
32
,
4096
,
0
,
TSDB_CFG_UTYPE_NONE
);
#ifdef _
MPEER
#ifdef _
SYNC
tsInitConfigOption
(
cfg
++
,
"numOfMPeers"
,
&
tsNumOfMPeers
,
TSDB_CFG_VTYPE_INT
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLUSTER
,
1
,
3
,
0
,
TSDB_CFG_UTYPE_NONE
);
...
...
src/util/src/ttimer.c
浏览文件 @
2f1e5287
...
...
@@ -84,8 +84,6 @@ static tmr_ctrl_t* tmrCtrls;
static
tmr_ctrl_t
*
unusedTmrCtrl
=
NULL
;
static
void
*
tmrQhandle
;
static
int
numOfTmrCtrl
=
0
;
//static void* tmrContext = NULL;
static
int
athread
=
0
;
int
taosTmrThreads
=
1
;
...
...
@@ -519,7 +517,7 @@ static void taosTmrModuleInit(void) {
}
tmrQhandle
=
taosInitScheduler
(
10000
,
taosTmrThreads
,
"tmr"
);
athread
=
taosInitTimer
(
taosTimerLoopFunc
,
MSECONDS_PER_TICK
);
taosInitTimer
(
taosTimerLoopFunc
,
MSECONDS_PER_TICK
);
tmrTrace
(
"timer module is initialized, number of threads: %d"
,
taosTmrThreads
);
}
...
...
@@ -562,19 +560,29 @@ void taosTmrCleanUp(void* handle) {
pthread_mutex_unlock
(
&
tmrCtrlMutex
);
if
(
numOfTmrCtrl
<=
0
)
{
// pthread_cancel(athread
);
taosUninitTimer
(
);
taosCleanUpScheduler
(
tmrQhandle
);
for
(
int
i
=
0
;
i
<
tListLen
(
wheels
);
i
++
)
{
time_wheel_t
*
wheel
=
wheels
+
i
;
pthread_mutex_destroy
(
&
wheel
->
mutex
);
free
(
wheel
->
slots
);
}
pthread_mutex_destroy
(
&
tmrCtrlMutex
);
free
(
timerMap
.
slots
);
pthread_mutex_destroy
(
&
tmrCtrlMutex
);
for
(
size_t
i
=
0
;
i
<
timerMap
.
size
;
i
++
)
{
timer_list_t
*
list
=
timerMap
.
slots
+
i
;
tmr_obj_t
*
t
=
list
->
timers
;
while
(
t
!=
NULL
)
{
tmr_obj_t
*
next
=
t
->
mnext
;
free
(
t
);
t
=
next
;
}
}
free
(
timerMap
.
slots
);
free
(
tmrCtrls
);
taosCleanUpScheduler
(
tmrQhandle
);
tmrModuleInit
=
PTHREAD_ONCE_INIT
;
tmrTrace
(
"timer module is cleaned up"
);
}
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
2f1e5287
...
...
@@ -42,7 +42,7 @@ static void vnodeNotifyRole(void *ahandle, int8_t role);
static
pthread_once_t
vnodeModuleInit
=
PTHREAD_ONCE_INIT
;
#ifndef _
VPEER
#ifndef _
SYNC
tsync_h
syncStart
(
const
SSyncInfo
*
info
)
{
return
NULL
;
}
int
syncForwardToPeer
(
tsync_h
shandle
,
void
*
pHead
,
void
*
mhandle
)
{
return
0
;
}
#endif
...
...
src/wal/src/walMain.c
浏览文件 @
2f1e5287
...
...
@@ -52,6 +52,7 @@ static uint32_t walSignature = 0xFAFBFDFE;
static
int
walHandleExistingFiles
(
const
char
*
path
);
static
int
walRestoreWalFile
(
const
char
*
name
,
void
*
pVnode
,
FWalWrite
writeFp
);
static
int
walRemoveWalFiles
(
const
char
*
path
);
static
int
walMoveOldWalFilesBack
(
const
char
*
path
);
void
*
walOpen
(
const
char
*
path
,
const
SWalCfg
*
pCfg
)
{
SWal
*
pWal
=
calloc
(
sizeof
(
SWal
),
1
);
...
...
@@ -213,7 +214,11 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
}
if
(
code
==
0
)
{
code
=
walRemoveWalFiles
(
opath
);
if
(
pWal
->
keep
)
{
code
=
walMoveOldWalFilesBack
(
pWal
->
path
);
}
else
{
code
=
walRemoveWalFiles
(
opath
);
}
if
(
code
==
0
)
{
if
(
remove
(
opath
)
<
0
)
{
wError
(
"wal:%s, failed to remove directory(%s)"
,
opath
,
strerror
(
errno
));
...
...
@@ -365,4 +370,40 @@ static int walRemoveWalFiles(const char *path) {
return
code
;
}
int
walMoveOldWalFilesBack
(
const
char
*
path
)
{
char
oname
[
TSDB_FILENAME_LEN
*
3
];
char
nname
[
TSDB_FILENAME_LEN
*
3
];
char
opath
[
TSDB_FILENAME_LEN
];
struct
dirent
*
ent
;
int
plen
=
strlen
(
walPrefix
);
int
code
=
0
;
sprintf
(
opath
,
"%s/old"
,
path
);
if
(
access
(
opath
,
F_OK
)
==
0
)
{
// move all old files to wal directory
int
count
=
0
;
DIR
*
dir
=
opendir
(
opath
);
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
ent
->
d_name
,
walPrefix
,
plen
)
==
0
)
{
sprintf
(
oname
,
"%s/%s"
,
opath
,
ent
->
d_name
);
sprintf
(
nname
,
"%s/%s"
,
path
,
ent
->
d_name
);
if
(
rename
(
oname
,
nname
)
<
0
)
{
wError
(
"wal:%s, failed to move to new:%s"
,
oname
,
nname
);
code
=
-
1
;
break
;
}
count
++
;
}
}
wTrace
(
"wal:%s, %d old files are move back for keep option is set"
,
path
,
count
);
closedir
(
dir
);
}
return
code
;
}
tests/pytest/insert/basic.py
浏览文件 @
2f1e5287
...
...
@@ -41,8 +41,8 @@ class TDTestCase:
# tdSql.execute('insert into tb values (now - 7m , 10)')
# tdSql.execute('insert into tb values (now - 8m , 10)')
#
tdSql.query("select * from tb")
#
tdSql.checkRows(insertRows)
tdSql
.
query
(
"select * from tb"
)
tdSql
.
checkRows
(
insertRows
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/simpletest.sh
浏览文件 @
2f1e5287
sudo
python
3
./test.py
-f
insert/basic.py
sudo
python ./test.py
-f
insert/basic.py
tests/test-all.sh
0 → 100755
浏览文件 @
2f1e5287
#!/bin/bash
# Color setting
RED
=
'\033[0;31m'
GREEN
=
'\033[1;32m'
GREEN_DARK
=
'\033[0;32m'
GREEN_UNDERLINE
=
'\033[4;32m'
NC
=
'\033[0m'
cd
script
sudo
./test.sh 2>&1 |
grep
'success\|failed'
|
tee
out.txt
total_success
=
`
grep
success out.txt |
wc
-l
`
if
[
"
$total_success
"
-gt
"0"
]
;
then
total_success
=
`
expr
$total_success
- 1
`
echo
-e
"
${
GREEN
}
### Total
$total_success
TSIM case(s) succeed! ###
${
NC
}
"
fi
total_failed
=
`
grep
failed out.txt |
wc
-l
`
if
[
"
$total_failed
"
-ne
"0"
]
;
then
echo
-e
"
${
RED
}
### Total
$total_failed
TSIM case(s) failed! ###
${
NC
}
"
exit
$total_failed
fi
cd
../pytest
sudo
./simpletest.sh 2>&1 |
grep
'successfully executed\|failed'
|
tee
pytest-out.txt
total_py_success
=
`
grep
'successfully executed'
pytest-out.txt |
wc
-l
`
if
[
"
$total_py_success
"
-gt
"0"
]
;
then
echo
-e
"
${
GREEN
}
### Total
$total_py_success
python case(s) succeed! ###
${
NC
}
"
fi
total_py_failed
=
`
grep
'failed'
pytest-out.txt |
wc
-l
`
if
[
"
$total_py_failed
"
-ne
"0"
]
;
then
echo
-e
"
${
RED
}
### Total
$total_py_failed
python case(s) failed! ###
${
NC
}
"
exit
$total_py_failed
fi
tests/tsim/inc/sim.h
浏览文件 @
2f1e5287
...
...
@@ -23,7 +23,6 @@
#include "taos.h"
#include "tidpool.h"
#include "tlog.h"
#include "tmodule.h"
#include "tutil.h"
#define MAX_MAIN_SCRIPT_NUM 10
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录