Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b2f17cb5
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b2f17cb5
编写于
4月 25, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
差异文件
merge develop branch
上级
25e13520
0b8123f5
变更
76
显示空白变更内容
内联
并排
Showing
76 changed file
with
1044 addition
and
731 deletion
+1044
-731
.travis.yml
.travis.yml
+8
-13
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+1
-1
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+3
-3
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-0
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+2
-10
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+67
-75
src/common/src/tglobal.c
src/common/src/tglobal.c
+21
-59
src/common/src/tmessage.c
src/common/src/tmessage.c
+0
-0
src/connector/python/linux/python2/taos/cinterface.py
src/connector/python/linux/python2/taos/cinterface.py
+3
-0
src/connector/python/linux/python3/taos/cinterface.py
src/connector/python/linux/python3/taos/cinterface.py
+3
-0
src/connector/python/windows/python2/taos/cinterface.py
src/connector/python/windows/python2/taos/cinterface.py
+3
-0
src/connector/python/windows/python3/taos/cinterface.py
src/connector/python/windows/python3/taos/cinterface.py
+3
-0
src/dnode/inc/dnodeLog.h
src/dnode/inc/dnodeLog.h
+0
-4
src/dnode/src/dnodeMClient.c
src/dnode/src/dnodeMClient.c
+16
-1
src/dnode/src/dnodeMnode.c
src/dnode/src/dnodeMnode.c
+1
-1
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+2
-2
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+6
-5
src/inc/dnode.h
src/inc/dnode.h
+2
-1
src/inc/monitor.h
src/inc/monitor.h
+30
-2
src/inc/taosdef.h
src/inc/taosdef.h
+2
-5
src/inc/taoserror.h
src/inc/taoserror.h
+55
-55
src/inc/taosmsg.h
src/inc/taosmsg.h
+0
-1
src/kit/CMakeLists.txt
src/kit/CMakeLists.txt
+2
-2
src/kit/taosdump/CMakeLists.txt
src/kit/taosdump/CMakeLists.txt
+1
-0
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+3
-4
src/mnode/inc/mgmtDef.h
src/mnode/inc/mgmtDef.h
+20
-28
src/mnode/inc/mgmtLog.h
src/mnode/inc/mgmtLog.h
+7
-6
src/mnode/src/mgmtDClient.c
src/mnode/src/mgmtDClient.c
+3
-1
src/mnode/src/mgmtDServer.c
src/mnode/src/mgmtDServer.c
+8
-3
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+104
-156
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+3
-3
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+2
-0
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+11
-6
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+30
-30
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+4
-0
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+24
-21
src/plugins/http/inc/httpLog.h
src/plugins/http/inc/httpLog.h
+0
-5
src/plugins/http/src/gcHandle.c
src/plugins/http/src/gcHandle.c
+4
-2
src/plugins/http/src/gcJson.c
src/plugins/http/src/gcJson.c
+2
-4
src/plugins/http/src/httpAuth.c
src/plugins/http/src/httpAuth.c
+3
-1
src/plugins/http/src/httpCode.c
src/plugins/http/src/httpCode.c
+3
-0
src/plugins/http/src/httpHandle.c
src/plugins/http/src/httpHandle.c
+7
-10
src/plugins/http/src/httpJson.c
src/plugins/http/src/httpJson.c
+5
-10
src/plugins/http/src/httpResp.c
src/plugins/http/src/httpResp.c
+8
-9
src/plugins/http/src/httpServer.c
src/plugins/http/src/httpServer.c
+1
-0
src/plugins/http/src/httpSession.c
src/plugins/http/src/httpSession.c
+7
-9
src/plugins/http/src/httpSql.c
src/plugins/http/src/httpSql.c
+31
-30
src/plugins/http/src/httpSystem.c
src/plugins/http/src/httpSystem.c
+5
-5
src/plugins/http/src/httpUtil.c
src/plugins/http/src/httpUtil.c
+4
-3
src/plugins/http/src/restHandle.c
src/plugins/http/src/restHandle.c
+3
-1
src/plugins/http/src/restJson.c
src/plugins/http/src/restJson.c
+1
-0
src/plugins/http/src/tgHandle.c
src/plugins/http/src/tgHandle.c
+4
-3
src/plugins/http/src/tgJson.c
src/plugins/http/src/tgJson.c
+10
-9
src/plugins/monitor/inc/monitorSystem.h
src/plugins/monitor/inc/monitorSystem.h
+0
-42
src/plugins/monitor/src/monitorMain.c
src/plugins/monitor/src/monitorMain.c
+431
-0
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-1
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+20
-20
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+3
-3
src/vnode/inc/vnodeLog.h
src/vnode/inc/vnodeLog.h
+0
-4
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+3
-0
tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
+1
-1
tests/script/general/http/restful.sim
tests/script/general/http/restful.sim
+2
-2
tests/script/general/http/restful_full.sim
tests/script/general/http/restful_full.sim
+5
-5
tests/script/general/http/testSuite.sim
tests/script/general/http/testSuite.sim
+1
-2
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+2
-2
tests/script/unique/account/account_delete.sim
tests/script/unique/account/account_delete.sim
+10
-3
tests/script/unique/account/basic.sim
tests/script/unique/account/basic.sim
+1
-1
tests/script/unique/account/monitor.sim
tests/script/unique/account/monitor.sim
+0
-36
tests/script/unique/account/paras.sim
tests/script/unique/account/paras.sim
+1
-1
tests/script/unique/account/testSuite.sim
tests/script/unique/account/testSuite.sim
+3
-0
tests/script/unique/account/usage.sim
tests/script/unique/account/usage.sim
+1
-1
tests/script/unique/http/opentsdb.sim
tests/script/unique/http/opentsdb.sim
+0
-0
tests/script/unique/http/testSuite.sim
tests/script/unique/http/testSuite.sim
+2
-1
tests/script/unique/mnode/mgmt33.sim
tests/script/unique/mnode/mgmt33.sim
+3
-3
tests/script/unique/mnode/mgmt34.sim
tests/script/unique/mnode/mgmt34.sim
+3
-3
未找到文件。
.travis.yml
浏览文件 @
b2f17cb5
...
...
@@ -26,10 +26,6 @@ matrix:
-
python3-setuptools
-
valgrind
before_install
:
-
sudo apt update -y -qq
-
sudo apt install -y net-tools python-pip python-setuptools python3-pip python3-setuptools valgrind
before_script
:
-
cd ${TRAVIS_BUILD_DIR}
-
mkdir debug
...
...
@@ -44,7 +40,7 @@ matrix:
case $TRAVIS_OS_NAME in
linux)
cd ${TRAVIS_BUILD_DIR}/debug
sudo
make install || travis_terminate $?
make install || travis_terminate $?
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
...
...
@@ -63,11 +59,14 @@ matrix:
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
tail -10 mem-error-out.txt
defiMemError=`grep -m 1 'definitely lost' mem-error-out.txt | awk '{print $7}'`
memError=`grep -m 1 'ERROR SUMMARY' mem-error-out.txt | awk '{print $4}'`
if [ -n "$memError" ]; then
if [ "$memError" -gt 23 ]; then
echo -e "${RED} ## Memory errors number valgrind reports is $memError. More than our threshold! ## ${NC} "
if [ "$memError" -gt 16 ] && [ "$defiMemError" -gt 0 ]; then
echo -e "${RED} ## Memory errors number valgrind reports is $memError.\
Definitely lost is $defiMemError. More than our threshold! ## ${NC}"
travis_terminate $memError
fi
fi
...
...
@@ -131,10 +130,6 @@ matrix:
-
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
...
...
@@ -149,7 +144,7 @@ matrix:
case $TRAVIS_OS_NAME in
linux)
cd ${TRAVIS_BUILD_DIR}/debug
sudo
make install || travis_terminate $?
make install || travis_terminate $?
pip install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python2/
pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/
...
...
@@ -162,7 +157,7 @@ matrix:
travis_terminate $?
fi
sudo
pkill taosd
pkill taosd
sleep 1
cd ${TRAVIS_BUILD_DIR}
...
...
packaging/tools/makepkg.sh
浏览文件 @
b2f17cb5
...
...
@@ -43,7 +43,7 @@ lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files
=
"
${
code_dir
}
/inc/taos.h
${
code_dir
}
/inc/taoserror.h"
cfg_dir
=
"
${
top_dir
}
/packaging/cfg"
install_files
=
"
${
script_dir
}
/install.sh"
nginx_dir
=
"
${
code_dir
}
/../../enterprise/src/
module
s/web"
nginx_dir
=
"
${
code_dir
}
/../../enterprise/src/
plugin
s/web"
# Init file
#init_dir=${script_dir}/deb
...
...
src/CMakeLists.txt
浏览文件 @
b2f17cb5
...
...
@@ -15,4 +15,4 @@ ADD_SUBDIRECTORY(vnode)
ADD_SUBDIRECTORY
(
tsdb
)
ADD_SUBDIRECTORY
(
wal
)
ADD_SUBDIRECTORY
(
dnode
)
#
ADD_SUBDIRECTORY(connector/jdbc)
ADD_SUBDIRECTORY
(
connector/jdbc
)
src/client/src/TSDBJNIConnector.c
浏览文件 @
b2f17cb5
...
...
@@ -281,7 +281,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
int
code
=
taos_query
(
tscon
,
dst
);
if
(
code
!=
0
)
{
jniError
(
"jobj:%p, conn:%p, code:%
d, msg:%s"
,
jobj
,
tscon
,
code
,
taos_errstr
(
tscon
));
jniError
(
"jobj:%p, conn:%p, code:%
s, msg:%s"
,
jobj
,
tscon
,
tstrerror
(
code
)
,
taos_errstr
(
tscon
));
free
(
dst
);
return
JNI_TDENGINE_ERROR
;
}
else
{
...
...
@@ -290,9 +290,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
if
(
pSql
->
cmd
.
command
==
TSDB_SQL_INSERT
)
{
affectRows
=
taos_affected_rows
(
tscon
);
jniTrace
(
"jobj:%p, conn:%p, code:%
d, affect rows:%d"
,
jobj
,
tscon
,
code
,
affectRows
);
jniTrace
(
"jobj:%p, conn:%p, code:%
s, affect rows:%d"
,
jobj
,
tscon
,
tstrerror
(
code
)
,
affectRows
);
}
else
{
jniTrace
(
"jobj:%p, conn:%p, code:%
d"
,
jobj
,
tscon
,
code
);
jniTrace
(
"jobj:%p, conn:%p, code:%
s"
,
jobj
,
tscon
,
tstrerror
(
code
)
);
}
free
(
dst
);
...
...
src/client/src/tscServer.c
浏览文件 @
b2f17cb5
...
...
@@ -163,11 +163,13 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
tscGetQueryInfoDetailSafely
(
&
pSql
->
cmd
,
0
,
&
pQueryInfo
);
pQueryInfo
->
command
=
TSDB_SQL_HB
;
pSql
->
cmd
.
command
=
TSDB_SQL_HB
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
(
pSql
->
cmd
),
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
tfree
(
pSql
);
return
;
}
pSql
->
cmd
.
command
=
TSDB_SQL_HB
;
pSql
->
param
=
pObj
;
pSql
->
pTscObj
=
pObj
;
pSql
->
signature
=
pSql
;
...
...
src/client/src/tscSystem.c
浏览文件 @
b2f17cb5
...
...
@@ -39,7 +39,6 @@ void * tscTmr;
void
*
tscQhandle
;
void
*
tscCheckDiskUsageTmr
;
int
tsInsertHeadSize
;
char
tsLastUser
[
TSDB_USER_LEN
+
1
];
int
tscNumOfThreads
;
...
...
@@ -64,7 +63,6 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) {
rpcInit
.
label
=
"TSC-vnode"
;
rpcInit
.
numOfThreads
=
tscNumOfThreads
;
rpcInit
.
cfp
=
tscProcessMsgFromServer
;
rpcInit
.
ufp
=
tscUpdateIpSet
;
rpcInit
.
sessions
=
tsMaxVnodeConnections
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
user
=
(
char
*
)
user
;
...
...
@@ -79,13 +77,6 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) {
}
}
// not stop service, switch users
if
(
strcmp
(
tsLastUser
,
user
)
!=
0
&&
*
pMgmtConn
!=
NULL
)
{
tscTrace
(
"switch user from %s to %s"
,
user
,
tsLastUser
);
rpcClose
(
*
pMgmtConn
);
*
pMgmtConn
=
NULL
;
}
if
(
*
pMgmtConn
==
NULL
)
{
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsLocalIp
;
...
...
@@ -93,13 +84,14 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) {
rpcInit
.
label
=
"TSC-mgmt"
;
rpcInit
.
numOfThreads
=
1
;
rpcInit
.
cfp
=
tscProcessMsgFromServer
;
rpcInit
.
ufp
=
tscUpdateIpSet
;
rpcInit
.
sessions
=
tsMaxMgmtConnections
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
idleTime
=
2000
;
rpcInit
.
user
=
(
char
*
)
user
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
.
secret
=
secretEncrypt
;
strcpy
(
tsLastUser
,
user
);
*
pMgmtConn
=
rpcOpen
(
&
rpcInit
);
if
(
*
pMgmtConn
==
NULL
)
{
...
...
src/common/inc/tglobal.h
浏览文件 @
b2f17cb5
...
...
@@ -48,11 +48,9 @@ extern int32_t tsEnableCoreFile;
extern
int32_t
tsTotalMemoryMB
;
extern
int32_t
tsVersion
;
extern
int
tscEmbedded
;
extern
int32_t
tscEmbedded
;
extern
int64_t
tsMsPerDay
[
2
];
extern
char
tsMasterIp
[];
extern
char
tsSecondIp
[];
extern
uint16_t
tsMnodeDnodePort
;
...
...
@@ -61,72 +59,65 @@ extern uint16_t tsDnodeShellPort;
extern
uint16_t
tsDnodeMnodePort
;
extern
uint16_t
tsSyncPort
;
extern
int
tsStatusInterval
;
extern
int
tsShellActivityTimer
;
extern
int
tsVnodePeerHBTimer
;
extern
int
tsMgmtPeerHBTimer
;
extern
int
tsMeterMetaKeepTimer
;
extern
int
tsMetricMetaKeepTimer
;
extern
int
32_t
tsStatusInterval
;
extern
int
32_t
tsShellActivityTimer
;
extern
int
32_t
tsVnodePeerHBTimer
;
extern
int
32_t
tsMgmtPeerHBTimer
;
extern
int
32_t
tsMeterMetaKeepTimer
;
extern
int
32_t
tsMetricMetaKeepTimer
;
extern
float
tsNumOfThreadsPerCore
;
extern
float
tsRatioOfQueryThreads
;
extern
char
tsPublicIp
[];
extern
char
tsPrivateIp
[];
extern
short
tsNumOfVnodesPerCore
;
extern
short
tsNumOfTotalVnodes
;
extern
short
tsCheckHeaderFile
;
extern
int16_t
tsNumOfVnodesPerCore
;
extern
int16_t
tsNumOfTotalVnodes
;
extern
uint32_t
tsPublicIpInt
;
extern
short
tsAffectedRowsMod
;
extern
int
tsSessionsPerVnode
;
extern
int
tsAverageCacheBlocks
;
extern
int
tsCacheBlockSize
;
extern
int
tsRowsInFileBlock
;
extern
float
tsFileBlockMinPercent
;
extern
short
tsNumOfBlocksPerMeter
;
extern
short
tsCommitTime
;
// seconds
extern
short
tsCommitLog
;
extern
short
tsAsyncLog
;
extern
short
tsCompression
;
extern
short
tsDaysPerFile
;
extern
int
tsDaysToKeep
;
extern
int
tsReplications
;
extern
int
tsNumOfMPeers
;
extern
int
tsMaxShellConns
;
extern
int
tsMaxTables
;
extern
int32_t
tsMaxCacheSize
;
extern
int32_t
tsSessionsPerVnode
;
extern
int16_t
tsDaysPerFile
;
extern
int32_t
tsDaysToKeep
;
extern
int32_t
tsRowsInFileBlock
;
extern
int16_t
tsCommitTime
;
// seconds
extern
int32_t
tsTimePrecision
;
extern
int16_t
tsCompression
;
extern
int16_t
tsCommitLog
;
extern
int32_t
tsReplications
;
extern
int16_t
tsAffectedRowsMod
;
extern
int32_t
tsNumOfMPeers
;
extern
int32_t
tsMaxShellConns
;
extern
int32_t
tsMaxTables
;
extern
char
tsLocalIp
[];
extern
char
tsDefaultDB
[];
extern
char
tsDefaultUser
[];
extern
char
tsDefaultPass
[];
extern
int
tsMaxMeterConnections
;
extern
int
tsMaxVnodeConnections
;
extern
int
tsMaxMgmtConnections
;
extern
int
tsBalanceMonitorInterval
;
extern
int
tsBalanceStartInterval
;
extern
int
tsBalancePolicy
;
extern
int
tsOfflineThreshold
;
extern
int
tsMgmtEqualVnodeNum
;
extern
int
tsEnableHttp
Module
;
extern
int
tsEnableMonitorModule
;
extern
int
tsRestRowLimit
;
extern
int
tsCompressMsgSize
;
extern
int
tsMaxSQLStringLen
;
extern
int
tsMaxNumOfOrderedResults
;
extern
int
32_t
tsMaxMeterConnections
;
extern
int
32_t
tsMaxVnodeConnections
;
extern
int
32_t
tsMaxMgmtConnections
;
extern
int
32_t
tsBalanceMonitorInterval
;
extern
int
32_t
tsBalanceStartInterval
;
extern
int
32_t
tsOfflineThreshold
;
extern
int
32_t
tsMgmtEqualVnodeNum
;
extern
int32_t
tsEnableHttpModule
;
extern
int
32_t
tsEnableMonitor
Module
;
extern
int
32_t
tsRestRowLimit
;
extern
int
32_t
tsMaxSQLStringLen
;
extern
int
32_t
tsCompressMsgSize
;
extern
int
32_t
tsMaxNumOfOrderedResults
;
extern
char
tsSocketType
[
4
];
extern
int
tsTimePrecision
;
extern
int
tsMinSlidingTime
;
extern
int
tsMinIntervalTime
;
extern
int
tsMaxStreamComputDelay
;
extern
int
tsStreamCompStartDelay
;
extern
int
tsStreamCompRetryDelay
;
extern
int32_t
tsMinSlidingTime
;
extern
int32_t
tsMinIntervalTime
;
extern
int32_t
tsMaxStreamComputDelay
;
extern
int32_t
tsStreamCompStartDelay
;
extern
int32_t
tsStreamCompRetryDelay
;
extern
float
tsStreamComputDelayRatio
;
// the delayed computing ration of the whole time window
extern
int
tsProjectExecInterval
;
...
...
@@ -134,21 +125,22 @@ extern int64_t tsMaxRetentWindow;
extern
char
tsHttpIp
[];
extern
uint16_t
tsHttpPort
;
extern
int
tsHttpCacheSessions
;
extern
int
tsHttpSessionExpire
;
extern
int
tsHttpMaxThreads
;
extern
int
tsHttpEnableCompress
;
extern
int
tsHttpEnableRecordSql
;
extern
int
tsTelegrafUseFieldNum
;
extern
int
32_t
tsHttpCacheSessions
;
extern
int
32_t
tsHttpSessionExpire
;
extern
int
32_t
tsHttpMaxThreads
;
extern
int
32_t
tsHttpEnableCompress
;
extern
int
32_t
tsHttpEnableRecordSql
;
extern
int
32_t
tsTelegrafUseFieldNum
;
extern
int
tsTscEnableRecordSql
;
extern
int
tsAnyIp
;
extern
int
32_t
tsTscEnableRecordSql
;
extern
int
32_t
tsAnyIp
;
extern
char
tsMonitorDbName
[];
extern
char
tsInternalPass
[];
extern
int
tsMonitorInterval
;
extern
int
32_t
tsMonitorInterval
;
extern
int
tsNumOfLogLines
;
extern
int32_t
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
ddebugFlag
;
extern
int32_t
mdebugFlag
;
extern
int32_t
cdebugFlag
;
...
...
src/common/src/tglobal.c
浏览文件 @
b2f17cb5
...
...
@@ -74,8 +74,8 @@ int32_t tsVnodePeerHBTimer = 1; // second
int32_t
tsMgmtPeerHBTimer
=
1
;
// second
int32_t
tsMeterMetaKeepTimer
=
7200
;
// second
int32_t
tsMetricMetaKeepTimer
=
600
;
// second
int
tsRpcTimer
=
300
;
int
tsRpcMaxTime
=
600
;
// seconds;
int
32_t
tsRpcTimer
=
300
;
int
32_t
tsRpcMaxTime
=
600
;
// seconds;
float
tsNumOfThreadsPerCore
=
1
.
0
;
float
tsRatioOfQueryThreads
=
0
.
5
;
...
...
@@ -83,7 +83,6 @@ char tsPublicIp[TSDB_IPv4ADDR_LEN] = {0};
char
tsPrivateIp
[
TSDB_IPv4ADDR_LEN
]
=
{
0
};
int16_t
tsNumOfVnodesPerCore
=
8
;
int16_t
tsNumOfTotalVnodes
=
TSDB_INVALID_VNODE_NUM
;
int16_t
tsCheckHeaderFile
=
0
;
#ifdef _TD_ARM_32_
int32_t
tsSessionsPerVnode
=
100
;
...
...
@@ -91,26 +90,22 @@ int32_t tsSessionsPerVnode = 100;
int32_t
tsSessionsPerVnode
=
1000
;
#endif
int32_t
tsCacheBlockSize
=
16384
;
// 256 columns
int32_t
tsAverageCacheBlocks
=
TSDB_DEFAULT_AVG_BLOCKS
;
int32_t
tsMaxCacheSize
=
64
;
//64M
int16_t
tsDaysPerFile
=
10
;
int32_t
tsDaysToKeep
=
3650
;
int32_t
tsRowsInFileBlock
=
4096
;
int16_t
tsCommitTime
=
3600
;
// seconds
int32_t
tsTimePrecision
=
TSDB_TIME_PRECISION_MILLI
;
int16_t
tsCompression
=
TSDB_MAX_COMPRESSION_LEVEL
;
int16_t
tsCommitLog
=
1
;
int32_t
tsReplications
=
TSDB_REPLICA_MIN_NUM
;
/**
* Change the meaning of affected rows:
* 0: affected rows not include those duplicate records
* 1: affected rows include those duplicate records
*/
int16_t
tsAffectedRowsMod
=
0
;
int32_t
tsRowsInFileBlock
=
4096
;
float
tsFileBlockMinPercent
=
0
.
05
;
int16_t
tsNumOfBlocksPerMeter
=
100
;
int16_t
tsCommitTime
=
3600
;
// seconds
int16_t
tsCommitLog
=
1
;
int16_t
tsCompression
=
TSDB_MAX_COMPRESSION_LEVEL
;
int16_t
tsDaysPerFile
=
10
;
int32_t
tsDaysToKeep
=
3650
;
int32_t
tsReplications
=
TSDB_REPLICA_MIN_NUM
;
int32_t
tsNumOfMPeers
=
3
;
int32_t
tsMaxShellConns
=
2000
;
int32_t
tsMaxTables
=
100000
;
...
...
@@ -125,15 +120,16 @@ int32_t tsMaxVnodeConnections = 10000;
int32_t
tsBalanceMonitorInterval
=
2
;
// seconds
int32_t
tsBalanceStartInterval
=
300
;
// seconds
int32_t
tsBalancePolicy
=
0
;
// 1-use sys.montor
int32_t
tsOfflineThreshold
=
864000
;
// seconds 10days
int32_t
tsMgmtEqualVnodeNum
=
4
;
int32_t
tsEnableHttpModule
=
1
;
int32_t
tsEnableMonitorModule
=
0
;
int32_t
tsRestRowLimit
=
10240
;
int32_t
tsMaxSQLStringLen
=
TSDB_MAX_SQL_LEN
;
int32_t
tsNumOfLogLines
=
10000000
;
int32_t
mdebugFlag
=
135
;
int32_t
sdbDebugFlag
=
135
;
int32_t
ddebugFlag
=
131
;
...
...
@@ -146,7 +142,6 @@ int32_t qdebugFlag = 131;
int32_t
rpcDebugFlag
=
131
;
int32_t
uDebugFlag
=
131
;
int32_t
debugFlag
=
131
;
int
tsNumOfLogLines
=
10000000
;
// the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp
...
...
@@ -165,9 +160,6 @@ int32_t tsCompressMsgSize = -1;
// use UDP by default[option: udp, tcp]
char
tsSocketType
[
4
]
=
"udp"
;
// time precision, millisecond by default
int32_t
tsTimePrecision
=
TSDB_TIME_PRECISION_MILLI
;
// 10 ms for sliding time, the value will changed in case of time precision changed
int32_t
tsMinSlidingTime
=
10
;
...
...
@@ -747,11 +739,11 @@ static void doInitGlobalConfig() {
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"cache"
;
cfg
.
ptr
=
&
ts
CacheBlock
Size
;
cfg
.
ptr
=
&
ts
MaxCache
Size
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
1
00
;
cfg
.
maxValue
=
10
48576
;
cfg
.
minValue
=
1
;
cfg
.
maxValue
=
10
0000
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_BYTE
;
taosInitConfigOption
(
cfg
);
...
...
@@ -766,36 +758,6 @@ static void doInitGlobalConfig() {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"fileBlockMinPercent"
;
cfg
.
ptr
=
&
tsFileBlockMinPercent
;
cfg
.
valType
=
TAOS_CFG_VTYPE_FLOAT
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
.
0
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"ablocks"
;
cfg
.
ptr
=
&
tsAverageCacheBlocks
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_AVG_BLOCKS
;
cfg
.
maxValue
=
TSDB_MAX_AVG_BLOCKS
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"tblocks"
;
cfg
.
ptr
=
&
tsNumOfBlocksPerMeter
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT16
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
32
;
cfg
.
maxValue
=
4096
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
// login configs
cfg
.
option
=
"defaultDB"
;
cfg
.
ptr
=
tsDefaultDB
;
...
...
src/common/src/t
string
.c
→
src/common/src/t
message
.c
浏览文件 @
b2f17cb5
文件已移动
src/connector/python/linux/python2/taos/cinterface.py
浏览文件 @
b2f17cb5
...
...
@@ -316,6 +316,9 @@ class CTaosInterface(object):
blocks
=
[
None
]
*
len
(
fields
)
for
i
in
range
(
len
(
fields
)):
data
=
ctypes
.
cast
(
pblock
,
ctypes
.
POINTER
(
ctypes
.
c_void_p
))[
i
]
if
data
==
None
:
blocks
[
i
]
=
[
None
]
*
num_of_rows
continue
if
fields
[
i
][
'type'
]
not
in
_CONVERT_FUNC
:
raise
DatabaseError
(
"Invalid data type returned from database"
)
...
...
src/connector/python/linux/python3/taos/cinterface.py
浏览文件 @
b2f17cb5
...
...
@@ -316,6 +316,9 @@ class CTaosInterface(object):
blocks
=
[
None
]
*
len
(
fields
)
for
i
in
range
(
len
(
fields
)):
data
=
ctypes
.
cast
(
pblock
,
ctypes
.
POINTER
(
ctypes
.
c_void_p
))[
i
]
if
data
==
None
:
blocks
[
i
]
=
[
None
]
*
num_of_rows
continue
if
fields
[
i
][
'type'
]
not
in
_CONVERT_FUNC
:
raise
DatabaseError
(
"Invalid data type returned from database"
)
...
...
src/connector/python/windows/python2/taos/cinterface.py
浏览文件 @
b2f17cb5
...
...
@@ -316,6 +316,9 @@ class CTaosInterface(object):
blocks
=
[
None
]
*
len
(
fields
)
for
i
in
range
(
len
(
fields
)):
data
=
ctypes
.
cast
(
pblock
,
ctypes
.
POINTER
(
ctypes
.
c_void_p
))[
i
]
if
data
==
None
:
blocks
[
i
]
=
[
None
]
*
num_of_rows
continue
if
fields
[
i
][
'type'
]
not
in
_CONVERT_FUNC
:
raise
DatabaseError
(
"Invalid data type returned from database"
)
...
...
src/connector/python/windows/python3/taos/cinterface.py
浏览文件 @
b2f17cb5
...
...
@@ -316,6 +316,9 @@ class CTaosInterface(object):
blocks
=
[
None
]
*
len
(
fields
)
for
i
in
range
(
len
(
fields
)):
data
=
ctypes
.
cast
(
pblock
,
ctypes
.
POINTER
(
ctypes
.
c_void_p
))[
i
]
if
data
==
None
:
blocks
[
i
]
=
[
None
]
*
num_of_rows
continue
if
fields
[
i
][
'type'
]
not
in
_CONVERT_FUNC
:
raise
DatabaseError
(
"Invalid data type returned from database"
)
...
...
src/dnode/inc/dnodeLog.h
浏览文件 @
b2f17cb5
...
...
@@ -39,10 +39,6 @@ extern int32_t ddebugFlag;
#define dPrint(...) \
{ taosPrintLog("DND ", 255, __VA_ARGS__); }
#define dLError(...) taosLogError(__VA_ARGS__) dError(__VA_ARGS__)
#define dLWarn(...) taosLogWarn(__VA_ARGS__) dWarn(__VA_ARGS__)
#define dLPrint(...) taosLogPrint(__VA_ARGS__) dPrint(__VA_ARGS__)
#ifdef __cplusplus
}
#endif
...
...
src/dnode/src/dnodeMClient.c
浏览文件 @
b2f17cb5
...
...
@@ -59,6 +59,19 @@ void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
tsMnodeIpSet
=
*
pIpSet
;
}
void
dnodeGetMnodeIpSet
(
void
*
ipSetRaw
,
bool
usePublicIp
)
{
SRpcIpSet
*
ipSet
=
ipSetRaw
;
ipSet
->
numOfIps
=
tsMnodeInfos
.
nodeNum
;
ipSet
->
inUse
=
tsMnodeInfos
.
inUse
;
for
(
int32_t
i
=
0
;
i
<
tsMnodeInfos
.
nodeNum
;
++
i
)
{
if
(
usePublicIp
)
{
ipSet
->
ip
[
i
]
=
tsMnodeInfos
.
nodeInfos
[
i
].
nodeIp
;
}
else
{
ipSet
->
ip
[
i
]
=
tsMnodeInfos
.
nodeInfos
[
i
].
nodeIp
;
}
}
}
int32_t
dnodeInitMClient
()
{
dnodeReadDnodeCfg
();
tsRebootTime
=
taosGetTimestampSec
();
...
...
@@ -138,7 +151,9 @@ static void dnodeProcessRspFromMnode(SRpcMsg *pMsg) {
if
(
tsDnodeProcessMgmtRspFp
[
pMsg
->
msgType
])
{
(
*
tsDnodeProcessMgmtRspFp
[
pMsg
->
msgType
])(
pMsg
);
}
else
{
dError
(
"%s is not processed in mnode rpc client"
,
taosMsg
[
pMsg
->
msgType
]);
dError
(
"%s is not processed in dnode mclient"
,
taosMsg
[
pMsg
->
msgType
]);
SRpcMsg
rpcRsp
=
{.
pCont
=
0
,
.
contLen
=
0
,
.
code
=
TSDB_CODE_OPS_NOT_SUPPORT
,
.
handle
=
pMsg
->
handle
};
rpcSendResponse
(
&
rpcRsp
);
}
rpcFreeCont
(
pMsg
->
pCont
);
...
...
src/dnode/src/dnodeMnode.c
浏览文件 @
b2f17cb5
...
...
@@ -88,7 +88,7 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) {
if
(
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])
{
(
*
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])(
pMsg
);
}
else
{
dError
(
"%s is not processed in mserver"
,
taosMsg
[
pMsg
->
msgType
]);
dError
(
"%s is not processed in
dnode
mserver"
,
taosMsg
[
pMsg
->
msgType
]);
rspMsg
.
code
=
TSDB_CODE_MSG_NOT_PROCESSED
;
rpcSendResponse
(
&
rspMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
...
...
src/dnode/src/dnodeModule.c
浏览文件 @
b2f17cb5
...
...
@@ -90,7 +90,7 @@ void dnodeCleanUpModules() {
int32_t
dnodeInitModules
()
{
dnodeAllocModules
();
for
(
int32_t
module
=
0
;
module
<
TSDB_MOD_MAX
;
++
module
)
{
for
(
EModuleType
module
=
0
;
module
<
TSDB_MOD_MAX
;
++
module
)
{
if
(
tsModule
[
module
].
initFp
)
{
if
((
*
tsModule
[
module
].
initFp
)()
!=
0
)
{
dError
(
"failed to init module:%s"
,
tsModule
[
module
].
name
);
...
...
@@ -103,7 +103,7 @@ int32_t dnodeInitModules() {
}
void
dnodeStartModules
()
{
for
(
int32_t
module
=
1
;
module
<
TSDB_MOD_MAX
;
++
module
)
{
for
(
EModuleType
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
);
...
...
src/dnode/src/dnodeShell.c
浏览文件 @
b2f17cb5
...
...
@@ -20,6 +20,7 @@
#include "taosmsg.h"
#include "trpc.h"
#include "tglobal.h"
#include "http.h"
#include "dnode.h"
#include "dnodeLog.h"
#include "dnodeRead.h"
...
...
@@ -29,7 +30,7 @@
static
void
(
*
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
);
static
void
dnodeProcessMsgFromShell
(
SRpcMsg
*
pMsg
);
static
int
dnodeRetrieveUserAuthInfo
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
static
void
*
tsDnodeShellRpc
=
NULL
;
static
void
*
tsDnodeShellRpc
=
NULL
;
static
int32_t
tsDnodeQueryReqNum
=
0
;
static
int32_t
tsDnodeSubmitReqNum
=
0
;
...
...
@@ -110,7 +111,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
SDnodeStatisInfo
dnodeGetStatisInfo
()
{
SDnodeStatisInfo
info
=
{
0
};
if
(
dnodeGetRunStatus
()
==
TSDB_DNODE_RUN_STATUS_RUNING
)
{
//
info.httpReqNum = httpGetReqCount();
info
.
httpReqNum
=
httpGetReqCount
();
info
.
queryReqNum
=
atomic_exchange_32
(
&
tsDnodeQueryReqNum
,
0
);
info
.
submitReqNum
=
atomic_exchange_32
(
&
tsDnodeSubmitReqNum
,
0
);
}
...
...
src/inc/dnode.h
浏览文件 @
b2f17cb5
...
...
@@ -43,6 +43,7 @@ void dnodeSendRpcWriteRsp(void *pVnode, void *param, int32_t code);
bool
dnodeIsFirstDeploy
();
uint32_t
dnodeGetMnodeMasteIp
();
void
dnodeGetMnodeIpSet
(
void
*
ipSet
,
bool
usePublicIp
);
void
*
dnodeGetMnodeInfos
();
int32_t
dnodeGetDnodeId
();
...
...
src/inc/monitor.h
浏览文件 @
b2f17cb5
...
...
@@ -22,10 +22,38 @@ extern "C" {
#include <stdint.h>
typedef
struct
{
char
*
acctId
;
int64_t
currentPointsPerSecond
;
int64_t
maxPointsPerSecond
;
int64_t
totalTimeSeries
;
int64_t
maxTimeSeries
;
int64_t
totalStorage
;
int64_t
maxStorage
;
int64_t
totalQueryTime
;
int64_t
maxQueryTime
;
int64_t
totalInbound
;
int64_t
maxInbound
;
int64_t
totalOutbound
;
int64_t
maxOutbound
;
int64_t
totalDbs
;
int64_t
maxDbs
;
int64_t
totalUsers
;
int64_t
maxUsers
;
int64_t
totalStreams
;
int64_t
maxStreams
;
int64_t
totalConns
;
int64_t
maxConns
;
int8_t
accessState
;
}
SAcctMonitorObj
;
int32_t
monitorInitSystem
();
int32_t
monitorStartSystem
();
void
monitorStopSystem
();
void
monitorCleanUpSystem
();
void
monitorSaveAcctLog
(
SAcctMonitorObj
*
pMonObj
);
void
monitorSaveLog
(
int32_t
level
,
const
char
*
const
format
,
...);
void
monitorExecuteSQL
(
char
*
sql
);
#ifdef __cplusplus
}
...
...
src/inc/taosdef.h
浏览文件 @
b2f17cb5
...
...
@@ -218,9 +218,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_MGMT_IPS (TSDB_MAX_MPEERS+1)
#define TSDB_REPLICA_MIN_NUM 1
/*
* this is defined in CMakeList.txt
*/
#define TSDB_REPLICA_MAX_NUM 3
#define TSDB_TBNAME_COLUMN_INDEX (-1)
...
...
@@ -242,8 +239,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MIN_ROWS_IN_FILEBLOCK 200
#define TSDB_MAX_ROWS_IN_FILEBLOCK 500000
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
00
#define TSDB_MAX_CACHE_BLOCK_SIZE 10
48576
00
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
#define TSDB_MAX_CACHE_BLOCK_SIZE 10
000
00
#define TSDB_MIN_CACHE_BLOCKS 100
#define TSDB_MAX_CACHE_BLOCKS 409600
...
...
src/inc/taoserror.h
浏览文件 @
b2f17cb5
...
...
@@ -99,71 +99,71 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_TABLE, 0, 205, "not active tabl
TAOS_DEFINE_ERROR
(
TSDB_CODE_TABLE_ID_MISMATCH
,
0
,
206
,
"table id mismatch"
)
// dnode & mnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_ENOUGH_DNODES
,
0
,
30
0
,
"no enough dnodes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DNODE_ALREADY_EXIST
,
0
,
30
1
,
"dnode already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DNODE_NOT_EXIST
,
0
,
30
2
,
"dnode not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_MASTER
,
0
,
30
3
,
"no master"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_REMOVE_MASTER
,
0
,
30
4
,
"no remove master"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QUERY_ID
,
0
,
30
5
,
"invalid query id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_STREAM_ID
,
0
,
30
6
,
"invalid stream id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CONNECTION
,
0
,
30
7
,
"invalid connection"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_ERROR
,
0
,
30
8
,
"sdb error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_ENOUGH_DNODES
,
0
,
25
0
,
"no enough dnodes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DNODE_ALREADY_EXIST
,
0
,
25
1
,
"dnode already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DNODE_NOT_EXIST
,
0
,
25
2
,
"dnode not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_MASTER
,
0
,
25
3
,
"no master"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_REMOVE_MASTER
,
0
,
25
4
,
"no remove master"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QUERY_ID
,
0
,
25
5
,
"invalid query id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_STREAM_ID
,
0
,
25
6
,
"invalid stream id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CONNECTION
,
0
,
25
7
,
"invalid connection"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SDB_ERROR
,
0
,
25
8
,
"sdb error"
)
// acct
TAOS_DEFINE_ERROR
(
TSDB_CODE_ACCT_ALREADY_EXIST
,
0
,
4
00
,
"accounts already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_ACCT
,
0
,
4
01
,
"invalid account"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_ACCT_PARAMETER
,
0
,
4
02
,
"invalid account parameter"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_ACCTS
,
0
,
4
03
,
"too many accounts"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_USERS
,
0
,
4
04
,
"too many users"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_TABLES
,
0
,
4
05
,
"too many tables"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_DATABASES
,
0
,
4
06
,
"too many databases"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_TIME_SERIES
,
0
,
4
07
,
"not enough time series"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ACCT_ALREADY_EXIST
,
0
,
3
00
,
"accounts already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_ACCT
,
0
,
3
01
,
"invalid account"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_ACCT_PARAMETER
,
0
,
3
02
,
"invalid account parameter"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_ACCTS
,
0
,
3
03
,
"too many accounts"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_USERS
,
0
,
3
04
,
"too many users"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_TABLES
,
0
,
3
05
,
"too many tables"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_DATABASES
,
0
,
3
06
,
"too many databases"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_TIME_SERIES
,
0
,
3
07
,
"not enough time series"
)
// grant
TAOS_DEFINE_ERROR
(
TSDB_CODE_AUTH_FAILURE
,
0
,
40
0
,
"auth failure"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_RIGHTS
,
0
,
40
1
,
"no rights"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_WRITE_ACCESS
,
0
,
40
2
,
"no write access"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_READ_ACCESS
,
0
,
40
3
,
"no read access"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_EXPIRED
,
0
,
40
4
,
"grant expired"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_DNODE_LIMITED
,
0
,
40
5
,
"grant dnode limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_ACCT_LIMITED
,
0
,
40
6
,
"grant account limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_TIMESERIES_LIMITED
,
0
,
40
7
,
"grant timeseries limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_DB_LIMITED
,
0
,
40
8
,
"grant db limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_USER_LIMITED
,
0
,
40
9
,
"grant user limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_CONN_LIMITED
,
0
,
41
0
,
"grant conn limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_STREAM_LIMITED
,
0
,
41
1
,
"grant stream limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_SPEED_LIMITED
,
0
,
41
2
,
"grant speed limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_STORAGE_LIMITED
,
0
,
41
3
,
"grant storage limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_QUERYTIME_LIMITED
,
0
,
41
4
,
"grant query time limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_CPU_LIMITED
,
0
,
41
5
,
"grant cpu limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_AUTH_FAILURE
,
0
,
35
0
,
"auth failure"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_RIGHTS
,
0
,
35
1
,
"no rights"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_WRITE_ACCESS
,
0
,
35
2
,
"no write access"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_READ_ACCESS
,
0
,
35
3
,
"no read access"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_EXPIRED
,
0
,
35
4
,
"grant expired"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_DNODE_LIMITED
,
0
,
35
5
,
"grant dnode limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_ACCT_LIMITED
,
0
,
35
6
,
"grant account limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_TIMESERIES_LIMITED
,
0
,
35
7
,
"grant timeseries limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_DB_LIMITED
,
0
,
35
8
,
"grant db limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_USER_LIMITED
,
0
,
35
9
,
"grant user limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_CONN_LIMITED
,
0
,
36
0
,
"grant conn limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_STREAM_LIMITED
,
0
,
36
1
,
"grant stream limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_SPEED_LIMITED
,
0
,
36
2
,
"grant speed limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_STORAGE_LIMITED
,
0
,
36
3
,
"grant storage limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_QUERYTIME_LIMITED
,
0
,
36
4
,
"grant query time limited"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_CPU_LIMITED
,
0
,
36
5
,
"grant cpu limited"
)
// server
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_VGROUP_ID
,
0
,
5
00
,
"invalid vgroup id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_VNODE_ID
,
0
,
5
01
,
"invalid vnode id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NOT_ACTIVE_VNODE
,
0
,
5
02
,
"not active vnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VG_INIT_FAILED
,
0
,
5
03
,
"vg init failed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SERV_NO_DISKSPACE
,
0
,
5
04
,
"server no diskspace"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SERV_OUT_OF_MEMORY
,
0
,
5
05
,
"server out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_DISK_PERMISSIONS
,
0
,
5
06
,
"no disk permissions"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FILE_CORRUPTED
,
0
,
5
07
,
"file corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MEMORY_CORRUPTED
,
0
,
5
08
,
"memory corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_VGROUP_ID
,
0
,
4
00
,
"invalid vgroup id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_VNODE_ID
,
0
,
4
01
,
"invalid vnode id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NOT_ACTIVE_VNODE
,
0
,
4
02
,
"not active vnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VG_INIT_FAILED
,
0
,
4
03
,
"vg init failed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SERV_NO_DISKSPACE
,
0
,
4
04
,
"server no diskspace"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SERV_OUT_OF_MEMORY
,
0
,
4
05
,
"server out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_DISK_PERMISSIONS
,
0
,
4
06
,
"no disk permissions"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FILE_CORRUPTED
,
0
,
4
07
,
"file corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MEMORY_CORRUPTED
,
0
,
4
08
,
"memory corrupted"
)
// client
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CLIENT_VERSION
,
0
,
60
1
,
"invalid client version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_CLI_OUT_OF_MEMORY
,
0
,
60
2
,
"client out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_CLI_NO_DISKSPACE
,
0
,
60
3
,
"client no disk space"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_TIME_STAMP
,
0
,
60
4
,
"invalid timestamp"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_SQL
,
0
,
60
5
,
"invalid sql"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QUERY_CACHE_ERASED
,
0
,
60
6
,
"query cache erased"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QUERY_MSG
,
0
,
60
7
,
"invalid query message"
)
// failed to validate the sql expression msg by vnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_SORTED_RES_TOO_MANY
,
0
,
60
8
,
"sorted res too many"
)
// too many result for ordered super table projection query
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QHANDLE
,
0
,
60
9
,
"invalid handle"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QUERY_CANCELLED
,
0
,
61
0
,
"query cancelled"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_IE
,
0
,
61
1
,
"invalid ie"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_VALUE
,
0
,
61
2
,
"invalid value"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CLIENT_VERSION
,
0
,
45
1
,
"invalid client version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_CLI_OUT_OF_MEMORY
,
0
,
45
2
,
"client out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_CLI_NO_DISKSPACE
,
0
,
45
3
,
"client no disk space"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_TIME_STAMP
,
0
,
45
4
,
"invalid timestamp"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_SQL
,
0
,
45
5
,
"invalid sql"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QUERY_CACHE_ERASED
,
0
,
45
6
,
"query cache erased"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QUERY_MSG
,
0
,
45
7
,
"invalid query message"
)
// failed to validate the sql expression msg by vnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_SORTED_RES_TOO_MANY
,
0
,
45
8
,
"sorted res too many"
)
// too many result for ordered super table projection query
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QHANDLE
,
0
,
45
9
,
"invalid handle"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QUERY_CANCELLED
,
0
,
46
0
,
"query cancelled"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_IE
,
0
,
46
1
,
"invalid ie"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_VALUE
,
0
,
46
2
,
"invalid value"
)
// others
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_FILE_FORMAT
,
0
,
7
00
,
"invalid file format"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_FILE_FORMAT
,
0
,
5
00
,
"invalid file format"
)
#ifdef TAOS_ERROR_C
...
...
src/inc/taosmsg.h
浏览文件 @
b2f17cb5
...
...
@@ -510,7 +510,6 @@ typedef struct {
int64_t
pointsWritten
;
uint8_t
status
;
uint8_t
role
;
uint8_t
accessState
;
uint8_t
replica
;
uint8_t
reserved
[
5
];
}
SVnodeLoad
;
...
...
src/kit/CMakeLists.txt
浏览文件 @
b2f17cb5
...
...
@@ -2,5 +2,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT
(
TDengine
)
ADD_SUBDIRECTORY
(
shell
)
#
ADD_SUBDIRECTORY(taosdemo)
#
ADD_SUBDIRECTORY(taosdump)
ADD_SUBDIRECTORY
(
taosdemo
)
ADD_SUBDIRECTORY
(
taosdump
)
src/kit/taosdump/CMakeLists.txt
浏览文件 @
b2f17cb5
...
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
b2f17cb5
...
...
@@ -30,7 +30,6 @@
#include "taos.h"
#include "taosmsg.h"
#include "tglobal.h"
#include "tsclient.h"
#include "taosdef.h"
#include "tutil.h"
...
...
@@ -360,7 +359,7 @@ int main(int argc, char *argv[]) {
void
taosFreeDbInfos
()
{
if
(
dbInfos
==
NULL
)
return
;
for
(
int
i
=
0
;
i
<
tsMaxDbs
;
i
++
)
tfree
(
dbInfos
[
i
]);
for
(
int
i
=
0
;
i
<
TSDB_MAX_DBS
;
i
++
)
tfree
(
dbInfos
[
i
]);
tfree
(
dbInfos
);
}
...
...
@@ -440,7 +439,7 @@ int taosDumpOut(struct arguments *arguments) {
return
-
1
;
}
dbInfos
=
(
SDbInfo
**
)
calloc
(
tsMaxDbs
,
sizeof
(
SDbInfo
*
));
dbInfos
=
(
SDbInfo
**
)
calloc
(
TSDB_MAX_DBS
,
sizeof
(
SDbInfo
*
));
if
(
dbInfos
==
NULL
)
{
fprintf
(
stderr
,
"failed to allocate memory
\n
"
);
goto
_exit_failure
;
...
...
src/mnode/inc/mgmtDef.h
浏览文件 @
b2f17cb5
...
...
@@ -29,32 +29,6 @@ struct SAcctObj;
struct
SUserObj
;
struct
SMnodeObj
;
typedef
struct
{
char
acct
[
TSDB_USER_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
uint32_t
vgId
;
int32_t
maxSessions
;
int32_t
cacheBlockSize
;
union
{
int32_t
totalBlocks
;
float
fraction
;
}
cacheNumOfBlocks
;
int32_t
daysPerFile
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
daysToKeep
;
int32_t
commitTime
;
int32_t
rowsInFileBlock
;
int16_t
blocksPerTable
;
int8_t
compression
;
int8_t
commitLog
;
int8_t
replications
;
int8_t
repStrategy
;
int8_t
loadLatest
;
// load into mem or not
uint8_t
precision
;
// time resolution
int8_t
reserved
[
16
];
}
SDbCfg
;
typedef
struct
SDnodeObj
{
int32_t
dnodeId
;
uint32_t
privateIp
;
...
...
@@ -168,12 +142,30 @@ typedef struct SVgObj {
SChildTableObj
**
tableList
;
}
SVgObj
;
typedef
struct
{
int64_t
maxCacheSize
;
int32_t
maxTables
;
int32_t
daysPerFile
;
int32_t
daysToKeep
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
minRowsPerFileBlock
;
// minimum rows per file block
int32_t
maxRowsPerFileBlock
;
// maximum rows per file block
int32_t
commitTime
;
int8_t
precision
;
int8_t
compression
;
int8_t
commitLog
;
int8_t
replications
;
int8_t
reserved
[
16
];
}
SDbCfg
;
typedef
struct
SDbObj
{
char
name
[
TSDB_DB_NAME_LEN
+
1
];
int8_t
status
;
char
acct
[
TSDB_USER_LEN
+
1
]
;
int64_t
createdTime
;
SDbCfg
cfg
;
int8_t
reserved
[
15
];
int8_t
status
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
numOfVgroups
;
...
...
src/mnode/inc/mgmtLog.h
浏览文件 @
b2f17cb5
...
...
@@ -21,6 +21,7 @@ extern "C" {
#endif
#include "tlog.h"
#include "monitor.h"
extern
int32_t
mdebugFlag
;
extern
int32_t
sdbDebugFlag
;
...
...
@@ -41,9 +42,9 @@ extern int32_t sdbDebugFlag;
#define mPrint(...) \
{ taosPrintLog("MND ", 255, __VA_ARGS__); }
#define mLError(...) mError(__VA_ARGS__)
#define mLWarn(...) mWarn(__VA_ARGS__)
#define mLPrint(...) mPrint(__VA_ARGS__)
#define mLError(...) m
onitorSaveLog(2, __VA_ARGS__); m
Error(__VA_ARGS__)
#define mLWarn(...) m
onitorSaveLog(1, __VA_ARGS__); m
Warn(__VA_ARGS__)
#define mLPrint(...) m
onitorSaveLog(0, __VA_ARGS__); m
Print(__VA_ARGS__)
#define sdbError(...) \
if (sdbDebugFlag & DEBUG_ERROR) { \
...
...
@@ -60,9 +61,9 @@ extern int32_t sdbDebugFlag;
#define sdbPrint(...) \
{ taosPrintLog("MND-SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) sdbError(__VA_ARGS__)
#define sdbLWarn(...) sdbWarn(__VA_ARGS__)
#define sdbLPrint(...) sdbPrint(__VA_ARGS__)
#define sdbLError(...)
monitorSaveLog(2, __VA_ARGS__);
sdbError(__VA_ARGS__)
#define sdbLWarn(...)
monitorSaveLog(1, __VA_ARGS__);
sdbWarn(__VA_ARGS__)
#define sdbLPrint(...)
monitorSaveLog(0, __VA_ARGS__);
sdbPrint(__VA_ARGS__)
#ifdef __cplusplus
}
...
...
src/mnode/src/mgmtDClient.c
浏览文件 @
b2f17cb5
...
...
@@ -79,7 +79,9 @@ static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) {
if
(
mgmtProcessDnodeRspFp
[
rpcMsg
->
msgType
])
{
(
*
mgmtProcessDnodeRspFp
[
rpcMsg
->
msgType
])(
rpcMsg
);
}
else
{
mError
(
"%s is not processed in dclient"
,
taosMsg
[
rpcMsg
->
msgType
]);
mError
(
"%s is not processed in mgmt dclient"
,
taosMsg
[
rpcMsg
->
msgType
]);
SRpcMsg
rpcRsp
=
{.
pCont
=
0
,
.
contLen
=
0
,
.
code
=
TSDB_CODE_OPS_NOT_SUPPORT
,
.
handle
=
rpcMsg
->
handle
};
rpcSendResponse
(
&
rpcRsp
);
}
rpcFreeCont
(
rpcMsg
->
pCont
);
...
...
src/mnode/src/mgmtDServer.c
浏览文件 @
b2f17cb5
...
...
@@ -108,8 +108,12 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) {
bool
usePublicIp
=
false
;
SRpcIpSet
ipSet
=
{
0
};
mgmtGetMnodeIpSet
(
&
ipSet
,
usePublicIp
);
mTrace
(
"conn from dnode ip:%s redirect msg"
,
taosIpStr
(
connInfo
.
clientIp
));
ipSet
.
port
=
tsMnodeDnodePort
;
dnodeGetMnodeIpSet
(
&
ipSet
,
usePublicIp
);
mTrace
(
"conn from dnode ip:%s user:%s redirect msg, inUse:%d"
,
taosIpStr
(
connInfo
.
clientIp
),
connInfo
.
user
,
ipSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
ipSet
.
numOfIps
;
++
i
)
{
mTrace
(
"index:%d ip:%s"
,
i
,
taosIpStr
(
ipSet
.
ip
[
i
]));
}
rpcSendRedirectRsp
(
rpcMsg
->
handle
,
&
ipSet
);
return
;
}
...
...
@@ -119,7 +123,8 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) {
memcpy
(
pMsg
,
rpcMsg
,
sizeof
(
SRpcMsg
));
mgmtAddToDServerQueue
(
pMsg
);
}
else
{
mError
(
"%s is not processed in dserver"
,
taosMsg
[
rpcMsg
->
msgType
]);
mError
(
"%s is not processed in mgmt dserver"
,
taosMsg
[
rpcMsg
->
msgType
]);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_MSG_NOT_PROCESSED
);
rpcFreeCont
(
rpcMsg
->
pCont
);
}
}
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
b2f17cb5
...
...
@@ -54,7 +54,7 @@ static int32_t mgmtDbActionDestroy(SSdbOper *pOper) {
static
int32_t
mgmtDbActionInsert
(
SSdbOper
*
pOper
)
{
SDbObj
*
pDb
=
pOper
->
pObj
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
pDb
->
pHead
=
NULL
;
pDb
->
pTail
=
NULL
;
...
...
@@ -67,7 +67,7 @@ static int32_t mgmtDbActionInsert(SSdbOper *pOper) {
mgmtDecAcctRef
(
pAcct
);
}
else
{
mError
(
"db:%s, acct:%s info not exist in sdb"
,
pDb
->
name
,
pDb
->
cfg
.
acct
);
mError
(
"db:%s, acct:%s info not exist in sdb"
,
pDb
->
name
,
pDb
->
acct
);
return
TSDB_CODE_INVALID_ACCT
;
}
...
...
@@ -76,7 +76,7 @@ static int32_t mgmtDbActionInsert(SSdbOper *pOper) {
static
int32_t
mgmtDbActionDelete
(
SSdbOper
*
pOper
)
{
SDbObj
*
pDb
=
pOper
->
pObj
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
mgmtDropDbFromAcct
(
pAcct
,
pDb
);
mgmtDropAllChildTables
(
pDb
);
...
...
@@ -176,132 +176,108 @@ SDbObj *mgmtGetDbByTableId(char *tableId) {
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
}
static
int32_t
mgmtCheckD
BParams
(
SCMCreateDbMsg
*
pCreate
)
{
if
(
pC
reate
->
commitLog
<
0
||
pCreate
->
commitLog
>
2
)
{
mError
(
"invalid db option
commitLog: %d, only 0-2 allowed"
,
pCreate
->
commitLog
);
return
TSDB_CODE_INVALID_OPTION
;
static
int32_t
mgmtCheckD
bCfg
(
SDbCfg
*
pCfg
)
{
if
(
pC
fg
->
maxCacheSize
<
TSDB_MIN_CACHE_BLOCK_SIZE
||
pCfg
->
maxCacheSize
>
TSDB_MAX_CACHE_BLOCK_SIZE
)
{
mError
(
"invalid db option
maxCacheSize:%d valid range: [%d, %d]"
,
pCfg
->
maxCacheSize
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
)
;
}
if
(
pC
reate
->
replications
<
TSDB_REPLICA_MIN_NUM
||
pCreate
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mError
(
"invalid db option
replications: %d valid range: [%d, %d]"
,
pCreate
->
replications
,
TSDB_REPLICA_MIN_NUM
,
TSDB_
REPLICA_MAX_NUM
);
if
(
pC
fg
->
maxTables
<
TSDB_MIN_TABLES_PER_VNODE
||
pCfg
->
maxTables
>
TSDB_MAX_TABLES_PER_VNODE
)
{
mError
(
"invalid db option
maxTables:%d valid range: [%d, %d]"
,
pCfg
->
maxTables
,
TSDB_MIN_TABLES_PER_VNODE
,
TSDB_
MAX_TABLES_PER_VNODE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pC
reate
->
daysPerFile
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCreate
->
daysPerFile
>
TSDB_FILE_MAX_PARTITION_RANGE
)
{
mError
(
"invalid db option daysPerFile:
%d valid range: [%d, %d]"
,
pCreate
->
daysPerFile
,
TSDB_FILE_MIN_PARTITION_RANGE
,
if
(
pC
fg
->
daysPerFile
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCfg
->
daysPerFile
>
TSDB_FILE_MAX_PARTITION_RANGE
)
{
mError
(
"invalid db option daysPerFile:
%d valid range: [%d, %d]"
,
pCfg
->
daysPerFile
,
TSDB_FILE_MIN_PARTITION_RANGE
,
TSDB_FILE_MAX_PARTITION_RANGE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysToKeep1
>
pCreate
->
daysToKeep2
||
pCreate
->
daysToKeep2
>
pCreate
->
daysToKeep
)
{
mError
(
"invalid db option daystokeep1: %d, daystokeep2: %d, daystokeep: %d"
,
pCreate
->
daysToKeep1
,
pCreate
->
daysToKeep2
,
pCreate
->
daysToKeep
);
if
(
pCfg
->
daysToKeep1
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCfg
->
daysToKeep1
<
pCfg
->
daysPerFile
)
{
mError
(
"invalid db option daystokeep:%d"
,
pCfg
->
daysToKeep
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
daysToKeep1
<
TSDB_FILE_MIN_PARTITION_RANGE
||
pCreate
->
daysToKeep1
<
pCreate
->
daysPerFile
)
{
mError
(
"invalid db option daystokeep: %d"
,
pCreate
->
daysToKeep
);
if
(
pCfg
->
daysToKeep2
>
pCfg
->
daysToKeep
||
pCfg
->
daysToKeep2
<
pCfg
->
daysToKeep1
)
{
mError
(
"invalid db option daystokeep1:%d, daystokeep2:%d, daystokeep:%d"
,
pCfg
->
daysToKeep1
,
pCfg
->
daysToKeep2
,
pCfg
->
daysToKeep
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pC
reate
->
rowsInFileBlock
<
TSDB_MIN_ROWS_IN_FILEBLOCK
||
pCreate
->
rowsIn
FileBlock
>
TSDB_MAX_ROWS_IN_FILEBLOCK
)
{
mError
(
"invalid db option
rowsInFileBlock: %d valid range: [%d, %d]"
,
pCreate
->
rowsIn
FileBlock
,
if
(
pC
fg
->
minRowsPerFileBlock
<
TSDB_MIN_ROWS_IN_FILEBLOCK
||
pCfg
->
minRowsPer
FileBlock
>
TSDB_MAX_ROWS_IN_FILEBLOCK
)
{
mError
(
"invalid db option
minRowsPerFileBlock:%d valid range: [%d, %d]"
,
pCfg
->
minRowsPer
FileBlock
,
TSDB_MIN_ROWS_IN_FILEBLOCK
,
TSDB_MAX_ROWS_IN_FILEBLOCK
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
cacheBlockSize
<
TSDB_MIN_CACHE_BLOCK_SIZE
||
pCreate
->
cacheBlockSize
>
TSDB_MAX_CACHE_BLOCK_SIZE
)
{
mError
(
"invalid db option cacheBlockSize: %d valid range: [%d, %d]"
,
pCreate
->
cacheBlockSize
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
maxSessions
<
TSDB_MIN_TABLES_PER_VNODE
||
pCreate
->
maxSessions
>
TSDB_MAX_TABLES_PER_VNODE
)
{
mError
(
"invalid db option maxSessions: %d valid range: [%d, %d]"
,
pCreate
->
maxSessions
,
TSDB_MIN_TABLES_PER_VNODE
,
TSDB_MAX_TABLES_PER_VNODE
);
if
(
pCfg
->
maxRowsPerFileBlock
<
TSDB_MIN_ROWS_IN_FILEBLOCK
||
pCfg
->
maxRowsPerFileBlock
>
TSDB_MAX_ROWS_IN_FILEBLOCK
)
{
mError
(
"invalid db option maxRowsPerFileBlock:%d valid range: [%d, %d]"
,
pCfg
->
maxRowsPerFileBlock
,
TSDB_MIN_ROWS_IN_FILEBLOCK
,
TSDB_MAX_ROWS_IN_FILEBLOCK
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pC
reate
->
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
pCreate
->
precision
!=
TSDB_TIME_PRECISION_MICRO
)
{
mError
(
"invalid db option
timePrecision: %d valid value: [%d, %d]"
,
pCreate
->
precision
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_TIME_PRECISION_MICRO
);
if
(
pC
fg
->
maxRowsPerFileBlock
<
pCfg
->
minRowsPerFileBlock
)
{
mError
(
"invalid db option
minRowsPerFileBlock:%d maxRowsPerFileBlock:%d"
,
pCfg
->
minRowsPerFileBlock
,
pCfg
->
maxRowsPerFileBlock
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
TSDB_MIN_AVG_BLOCKS
||
pCreate
->
cacheNumOfBlocks
.
fraction
>
TSDB_MAX_AVG_BLOCKS
)
{
mError
(
"invalid db option ablocks: %f valid value: [%d, %d]"
,
pCreate
->
cacheNumOfBlocks
.
fraction
,
0
,
TSDB_MAX_AVG_BLOCKS
);
if
(
pCfg
->
commitTime
<
TSDB_MIN_COMMIT_TIME_INTERVAL
||
pCfg
->
commitTime
>
TSDB_MAX_COMMIT_TIME_INTERVAL
)
{
mError
(
"invalid db option commitTime:%d valid range: [%d, %d]"
,
pCfg
->
commitTime
,
TSDB_MIN_COMMIT_TIME_INTERVAL
,
TSDB_MAX_COMMIT_TIME_INTERVAL
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pC
reate
->
commitTime
<
TSDB_MIN_COMMIT_TIME_INTERVAL
||
pCreate
->
commitTime
>
TSDB_MAX_COMMIT_TIME_INTERVAL
)
{
mError
(
"invalid db option
commitTime: %d valid range: [%d, %d]"
,
pCreate
->
commitTime
,
TSDB_MIN_COMMIT_TIME_INTERVAL
,
TSDB_
MAX_COMMIT_TIME_INTERVAL
);
if
(
pC
fg
->
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
pCfg
->
precision
!=
TSDB_TIME_PRECISION_MICRO
)
{
mError
(
"invalid db option
timePrecision:%d valid value: [%d, %d]"
,
pCfg
->
precision
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_
TIME_PRECISION_MICRO
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pC
reate
->
compression
<
TSDB_MIN_COMPRESSION_LEVEL
||
pCreate
->
compression
>
TSDB_MAX_COMPRESSION_LEVEL
)
{
mError
(
"invalid db option compression:
%d valid range: [%d, %d]"
,
pCreate
->
compression
,
TSDB_MIN_COMPRESSION_LEVEL
,
if
(
pC
fg
->
compression
<
TSDB_MIN_COMPRESSION_LEVEL
||
pCfg
->
compression
>
TSDB_MAX_COMPRESSION_LEVEL
)
{
mError
(
"invalid db option compression:
%d valid range: [%d, %d]"
,
pCfg
->
compression
,
TSDB_MIN_COMPRESSION_LEVEL
,
TSDB_MAX_COMPRESSION_LEVEL
);
return
TSDB_CODE_INVALID_OPTION
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mgmtCheckDbParams
(
SCMCreateDbMsg
*
pCreate
)
{
// assign default parameters
if
(
pCreate
->
maxSessions
<
0
)
pCreate
->
maxSessions
=
tsSessionsPerVnode
;
if
(
pCreate
->
cacheBlockSize
<
0
)
pCreate
->
cacheBlockSize
=
tsCacheBlockSize
;
if
(
pCreate
->
daysPerFile
<
0
)
pCreate
->
daysPerFile
=
tsDaysPerFile
;
if
(
pCreate
->
daysToKeep
<
0
)
pCreate
->
daysToKeep
=
tsDaysToKeep
;
if
(
pCreate
->
daysToKeep1
<
0
)
pCreate
->
daysToKeep1
=
pCreate
->
daysToKeep
;
if
(
pCreate
->
daysToKeep2
<
0
)
pCreate
->
daysToKeep2
=
pCreate
->
daysToKeep
;
if
(
pCreate
->
commitTime
<
0
)
pCreate
->
commitTime
=
tsCommitTime
;
if
(
pCreate
->
compression
<
0
)
pCreate
->
compression
=
tsCompression
;
if
(
pCreate
->
commitLog
<
0
)
pCreate
->
commitLog
=
tsCommitLog
;
if
(
pCreate
->
replications
<
0
)
pCreate
->
replications
=
tsReplications
;
//
if
(
pCreate
->
rowsInFileBlock
<
0
)
pCreate
->
rowsInFileBlock
=
tsRowsInFileBlock
;
//
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
0
)
pCreate
->
cacheNumOfBlocks
.
fraction
=
tsAverageCacheBlocks
;
//
if
(
mgmtCheckDBParams
(
pCreate
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
pCfg
->
commitLog
<
0
||
pCfg
->
commitLog
>
2
)
{
mError
(
"invalid db option commitLog:%d, only 0-2 allowed"
,
pCfg
->
commitLog
);
return
TSDB_CODE_INVALID_OPTION
;
}
pCreate
->
cacheNumOfBlocks
.
totalBlocks
=
(
int32_t
)(
pCreate
->
cacheNumOfBlocks
.
fraction
*
pCreate
->
maxSessions
);
if
(
pCreate
->
cacheNumOfBlocks
.
totalBlocks
>
TSDB_MAX_CACHE_BLOCKS
)
{
mTrace
(
"invalid db option cacheNumOfBlocks: %d valid range: [%d, %d]"
,
pCreate
->
cacheNumOfBlocks
.
totalBlocks
,
TSDB_MIN_CACHE_BLOCKS
,
TSDB_MAX_CACHE_BLOCKS
);
if
(
pCfg
->
replications
<
TSDB_REPLICA_MIN_NUM
||
pCfg
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mError
(
"invalid db option replications:%d valid range: [%d, %d]"
,
pCfg
->
replications
,
TSDB_REPLICA_MIN_NUM
,
TSDB_REPLICA_MAX_NUM
);
return
TSDB_CODE_INVALID_OPTION
;
}
// calculate the blocks per table
if
(
pCreate
->
blocksPerTable
<
0
)
{
pCreate
->
blocksPerTable
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
/
4
;
}
if
(
pCreate
->
blocksPerTable
>
pCreate
->
cacheNumOfBlocks
.
totalBlocks
*
3
/
4
)
{
pCreate
->
blocksPerTable
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
*
3
/
4
;
}
if
(
pCreate
->
blocksPerTable
<
TSDB_MIN_AVG_BLOCKS
)
{
pCreate
->
blocksPerTable
=
TSDB_MIN_AVG_BLOCKS
;
}
return
TSDB_CODE_SUCCESS
;
}
static
void
mgmtSetDefaultDbCfg
(
SDbCfg
*
pCfg
)
{
if
(
pCfg
->
maxCacheSize
<
0
)
pCfg
->
maxCacheSize
=
tsMaxCacheSize
;
if
(
pCfg
->
maxTables
<
0
)
pCfg
->
maxTables
=
tsSessionsPerVnode
;
if
(
pCfg
->
daysPerFile
<
0
)
pCfg
->
daysPerFile
=
tsDaysPerFile
;
if
(
pCfg
->
daysToKeep
<
0
)
pCfg
->
daysToKeep
=
tsDaysToKeep
;
if
(
pCfg
->
daysToKeep1
<
0
)
pCfg
->
daysToKeep1
=
pCfg
->
daysToKeep
;
if
(
pCfg
->
daysToKeep2
<
0
)
pCfg
->
daysToKeep2
=
pCfg
->
daysToKeep
;
if
(
pCfg
->
minRowsPerFileBlock
<
0
)
pCfg
->
minRowsPerFileBlock
=
tsRowsInFileBlock
;
if
(
pCfg
->
maxRowsPerFileBlock
<
0
)
pCfg
->
maxRowsPerFileBlock
=
pCfg
->
minRowsPerFileBlock
*
2
;
if
(
pCfg
->
commitTime
<
0
)
pCfg
->
commitTime
=
tsCommitTime
;
if
(
pCfg
->
precision
<
0
)
pCfg
->
precision
=
tsTimePrecision
;
if
(
pCfg
->
compression
<
0
)
pCfg
->
compression
=
tsCompression
;
if
(
pCfg
->
commitLog
<
0
)
pCfg
->
commitLog
=
tsCommitLog
;
if
(
pCfg
->
replications
<
0
)
pCfg
->
replications
=
tsReplications
;
}
static
int32_t
mgmtCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
)
{
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRANT_DB
);
if
(
code
!=
0
)
{
return
code
;
}
if
(
code
!=
0
)
return
code
;
SDbObj
*
pDb
=
mgmtGetDb
(
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
mgmtDecDbRef
(
pDb
);
if
(
pCreate
->
ignoreExist
)
{
return
TSDB_CODE_SUCCESS
;
}
else
{
...
...
@@ -309,45 +285,36 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
}
}
code
=
mgmtCheckDbParams
(
pCreate
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
code
;
assert
(
pCreate
->
daysToKeep1
<=
pCreate
->
daysToKeep2
&&
pCreate
->
daysToKeep2
<=
pCreate
->
daysToKeep
);
code
=
grantCheck
(
TSDB_GRANT_DB
);
if
(
code
!=
0
)
{
return
code
;
}
if
(
code
!=
0
)
return
code
;
pDb
=
calloc
(
1
,
sizeof
(
SDbObj
));
strncpy
(
pDb
->
name
,
pCreate
->
db
,
TSDB_DB_NAME_LEN
);
strncpy
(
pCreate
->
acct
,
pAcct
->
user
,
TSDB_USER_LEN
);
strncpy
(
pDb
->
acct
,
pAcct
->
user
,
TSDB_USER_LEN
);
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
cfg
=
(
SDbCfg
)
{
.
vgId
=
pCreate
->
vgId
,
.
precision
=
pCreate
->
precision
,
.
maxSessions
=
pCreate
->
maxSessions
,
.
cacheNumOfBlocks
.
totalBlocks
=
pCreate
->
cacheNumOfBlocks
.
totalBlocks
,
.
rowsInFileBlock
=
pCreate
->
rowsInFileBlock
,
.
commitLog
=
pCreate
->
commitLog
,
.
replications
=
pCreate
->
replications
,
.
maxCacheSize
=
64
,
//(int64_t)pCreate->cacheBlockSize * pCreate->cacheNumOfBlocks.totalBlocks,
.
maxTables
=
pCreate
->
maxSessions
,
.
daysPerFile
=
pCreate
->
daysPerFile
,
.
cacheBlockSize
=
pCreate
->
cacheBlockSize
,
.
commitTime
=
pCreate
->
commitTime
,
.
blocksPerTable
=
pCreate
->
blocksPerTable
,
.
compression
=
pCreate
->
compression
,
.
daysToKeep
=
pCreate
->
daysToKeep
,
.
daysToKeep1
=
pCreate
->
daysToKeep1
,
.
daysToKeep2
=
pCreate
->
daysToKeep2
,
.
loadLatest
=
pCreate
->
loadLatest
,
.
repStrategy
=
pCreate
->
repStrategy
,
.
minRowsPerFileBlock
=
pCreate
->
rowsInFileBlock
*
1
,
.
maxRowsPerFileBlock
=
pCreate
->
rowsInFileBlock
*
2
,
.
commitTime
=
pCreate
->
commitTime
,
.
precision
=
pCreate
->
precision
,
.
compression
=
pCreate
->
compression
,
.
commitLog
=
pCreate
->
commitLog
,
.
replications
=
pCreate
->
replications
};
strncpy
(
pDb
->
cfg
.
db
,
pCreate
->
db
,
TSDB_DB_NAME_LEN
);
strncpy
(
pDb
->
cfg
.
acct
,
pCreate
->
acct
,
TSDB_USER_LEN
);
mgmtSetDefaultDbCfg
(
&
pDb
->
cfg
);
code
=
mgmtCheckDbCfg
(
&
pDb
->
cfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pDb
);
return
code
;
}
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
...
...
@@ -498,19 +465,7 @@ static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn)
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"cache(b)"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_FLOAT
;
strcpy
(
pSchema
[
cols
].
name
,
"ablocks"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"tblocks"
);
strcpy
(
pSchema
[
cols
].
name
,
"cache(Mb)"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
@@ -625,27 +580,15 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *
if
(
strcmp
(
pUser
->
user
,
"root"
)
==
0
)
{
#endif
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
maxSessions
;
// table num can be created should minus 1
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
rowsInFileBlock
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
cacheBlockSize
;
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
maxTables
;
// table num can be created should minus 1
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
#ifdef _TD_ARM_32_
*
(
int32_t
*
)
pWrite
=
(
pDb
->
cfg
.
cacheNumOfBlocks
.
totalBlocks
*
1
.
0
/
(
pDb
->
cfg
.
maxSessions
));
#else
*
(
float
*
)
pWrite
=
(
pDb
->
cfg
.
cacheNumOfBlocks
.
totalBlocks
*
1
.
0
/
(
pDb
->
cfg
.
maxSessions
));
#endif
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
minRowsPerFileBlock
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int
16_t
*
)
pWrite
=
pDb
->
cfg
.
blocksPerTabl
e
;
*
(
int
32_t
*
)
pWrite
=
pDb
->
cfg
.
maxCacheSiz
e
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
...
...
@@ -747,7 +690,7 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) {
static
SDbCfg
mgmtGetAlterDbOption
(
SDbObj
*
pDb
,
SCMAlterDbMsg
*
pAlter
)
{
SDbCfg
newCfg
=
pDb
->
cfg
;
int32_t
daysToKeep
=
htonl
(
pAlter
->
daysToKeep
);
int32_t
max
Session
s
=
htonl
(
pAlter
->
maxSessions
);
int32_t
max
Table
s
=
htonl
(
pAlter
->
maxSessions
);
int8_t
replications
=
pAlter
->
replications
;
terrno
=
TSDB_CODE_SUCCESS
;
...
...
@@ -755,25 +698,28 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
if
(
daysToKeep
>
0
&&
daysToKeep
!=
pDb
->
cfg
.
daysToKeep
)
{
mTrace
(
"db:%s, daysToKeep:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
daysToKeep
,
daysToKeep
);
newCfg
.
daysToKeep
=
daysToKeep
;
}
else
if
(
replications
>
0
&&
replications
!=
pDb
->
cfg
.
replications
)
{
}
if
(
replications
>
0
&&
replications
!=
pDb
->
cfg
.
replications
)
{
mTrace
(
"db:%s, replica:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
replications
,
replications
);
if
(
replications
<
TSDB_REPLICA_MIN_NUM
||
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mError
(
"invalid db option replica: %d valid range: %d--%d"
,
replications
,
TSDB_REPLICA_MIN_NUM
,
TSDB_REPLICA_MAX_NUM
);
terrno
=
TSDB_CODE_INVALID_OPTION
;
}
newCfg
.
replications
=
replications
;
}
else
if
(
maxSessions
>
0
&&
maxSessions
!=
pDb
->
cfg
.
maxSessions
)
{
mTrace
(
"db:%s, tables:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
maxSessions
,
maxSessions
);
if
(
maxSessions
<
TSDB_MIN_TABLES_PER_VNODE
||
maxSessions
>
TSDB_MAX_TABLES_PER_VNODE
)
{
mError
(
"invalid db option tables: %d valid range: %d--%d"
,
maxSessions
,
TSDB_MIN_TABLES_PER_VNODE
,
TSDB_MAX_TABLES_PER_VNODE
);
}
if
(
maxTables
>
0
&&
maxTables
!=
pDb
->
cfg
.
maxTables
)
{
mTrace
(
"db:%s, tables:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
maxTables
,
maxTables
);
if
(
maxTables
<
TSDB_MIN_TABLES_PER_VNODE
||
maxTables
>
TSDB_MAX_TABLES_PER_VNODE
)
{
mError
(
"invalid db option tables: %d valid range: %d--%d"
,
maxTables
,
TSDB_MIN_TABLES_PER_VNODE
,
TSDB_MAX_TABLES_PER_VNODE
);
terrno
=
TSDB_CODE_INVALID_OPTION
;
}
if
(
max
Sessions
<
pDb
->
cfg
.
maxSession
s
)
{
mError
(
"invalid db option tables: %d should larger than original:%d"
,
max
Sessions
,
pDb
->
cfg
.
maxSession
s
);
if
(
max
Tables
<
pDb
->
cfg
.
maxTable
s
)
{
mError
(
"invalid db option tables: %d should larger than original:%d"
,
max
Tables
,
pDb
->
cfg
.
maxTable
s
);
terrno
=
TSDB_CODE_INVALID_OPTION
;
}
newCfg
.
maxSessions
=
maxSessions
;
}
else
{
newCfg
.
maxTables
=
maxTables
;
}
return
newCfg
;
...
...
@@ -913,6 +859,8 @@ void mgmtDropAllDbs(SAcctObj *pAcct) {
SDbObj
*
pDb
=
NULL
;
void
*
pNode
=
NULL
;
mPrint
(
"acct:%s, all dbs will be dropped from sdb"
,
pAcct
->
user
);
while
(
1
)
{
pNode
=
sdbFetchRow
(
tsDbSdb
,
pNode
,
(
void
**
)
&
pDb
);
if
(
pDb
==
NULL
)
break
;
...
...
@@ -931,5 +879,5 @@ void mgmtDropAllDbs(SAcctObj *pAcct) {
mgmtDecDbRef
(
pDb
);
}
m
Trace
(
"acct:%s, all dbs is
is dropped from sdb"
,
pAcct
->
user
,
numOfDbs
);
m
Print
(
"acct:%s, all dbs:%d
is dropped from sdb"
,
pAcct
->
user
,
numOfDbs
);
}
src/mnode/src/mgmtDnode.c
浏览文件 @
b2f17cb5
...
...
@@ -260,7 +260,7 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) {
}
uint32_t
dnodeIp
=
inet_addr
(
pCmCfgDnode
->
ip
);
if
(
strcmp
(
pMsg
->
pUser
->
pAcct
->
user
,
"root"
)
!=
0
)
{
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
rpcRsp
.
code
=
TSDB_CODE_NO_RIGHTS
;
}
else
{
SRpcIpSet
ipSet
=
mgmtGetIpSetFromIp
(
dnodeIp
);
...
...
@@ -469,7 +469,7 @@ static void mgmtProcessCreateDnodeMsg(SQueuedMsg *pMsg) {
SCMCreateDnodeMsg
*
pCreate
=
pMsg
->
pCont
;
if
(
strcmp
(
pMsg
->
pUser
->
pAcct
->
user
,
"root"
)
!=
0
)
{
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
rpcRsp
.
code
=
TSDB_CODE_NO_RIGHTS
;
}
else
{
uint32_t
ip
=
inet_addr
(
pCreate
->
ip
);
...
...
@@ -489,7 +489,7 @@ static void mgmtProcessDropDnodeMsg(SQueuedMsg *pMsg) {
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SCMDropDnodeMsg
*
pDrop
=
pMsg
->
pCont
;
if
(
strcmp
(
pMsg
->
pUser
->
pAcct
->
user
,
"root"
)
!=
0
)
{
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
rpcRsp
.
code
=
TSDB_CODE_NO_RIGHTS
;
}
else
{
uint32_t
ip
=
inet_addr
(
pDrop
->
ip
);
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
b2f17cb5
...
...
@@ -400,6 +400,8 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
if
(
pTable
->
keyType
==
SDB_KEY_AUTO
)
{
pTable
->
autoIndex
=
MAX
(
pTable
->
autoIndex
,
*
((
uint32_t
*
)
pOper
->
pObj
));
}
else
{
pTable
->
autoIndex
++
;
}
pthread_mutex_unlock
(
&
pTable
->
mutex
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
b2f17cb5
...
...
@@ -151,8 +151,13 @@ static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
bool
usePublicIp
=
(
connInfo
.
serverIp
==
tsPublicIpInt
);
SRpcIpSet
ipSet
=
{
0
};
mgmtGetMnodeIpSet
(
&
ipSet
,
usePublicIp
);
mTrace
(
"conn from ip:%s user:%s redirect msg"
,
taosIpStr
(
connInfo
.
clientIp
),
connInfo
.
user
);
ipSet
.
port
=
tsMnodeShellPort
;
dnodeGetMnodeIpSet
(
&
ipSet
,
usePublicIp
);
mTrace
(
"conn from shell ip:%s user:%s redirect msg, inUse:%d"
,
taosIpStr
(
connInfo
.
clientIp
),
connInfo
.
user
,
ipSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
ipSet
.
numOfIps
;
++
i
)
{
mTrace
(
"index:%d ip:%s"
,
i
,
taosIpStr
(
ipSet
.
ip
[
i
]));
}
rpcSendRedirectRsp
(
rpcMsg
->
handle
,
&
ipSet
);
return
;
}
...
...
@@ -359,7 +364,7 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
}
static
int
mgmtShellRetriveAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
*
spi
=
0
;
*
spi
=
1
;
*
encrypt
=
0
;
*
ckey
=
0
;
...
...
@@ -429,9 +434,9 @@ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
connect_over:
rpcRsp
.
code
=
code
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mLError
(
"user:%s login from %s,
code:%d"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
code
);
mLError
(
"user:%s login from %s,
result:%s"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
tstrerror
(
code
)
);
}
else
{
mLPrint
(
"user:%s login from %s,
code:%d"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
code
);
mLPrint
(
"user:%s login from %s,
result:%s"
,
connInfo
.
user
,
taosIpStr
(
connInfo
.
clientIp
),
tstrerror
(
code
)
);
rpcRsp
.
pCont
=
pConnectRsp
;
rpcRsp
.
contLen
=
sizeof
(
SCMConnectRsp
);
}
...
...
@@ -488,7 +493,7 @@ static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg) {
}
static
void
mgmtProcessUnSupportMsg
(
SRpcMsg
*
rpcMsg
)
{
mError
(
"%s is not processed in shell"
,
taosMsg
[
rpcMsg
->
msgType
]);
mError
(
"%s is not processed in
mnode
shell"
,
taosMsg
[
rpcMsg
->
msgType
]);
SRpcMsg
rpcRsp
=
{
.
msgType
=
0
,
.
pCont
=
0
,
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
b2f17cb5
...
...
@@ -106,9 +106,9 @@ static int32_t mgmtChildTableActionInsert(SSdbOper *pOper) {
}
mgmtDecDbRef
(
pDb
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
if
(
pAcct
==
NULL
)
{
mError
(
"ctable:%s, acct:%s not exists"
,
pTable
->
info
.
tableId
,
pDb
->
cfg
.
acct
);
mError
(
"ctable:%s, acct:%s not exists"
,
pTable
->
info
.
tableId
,
pDb
->
acct
);
return
TSDB_CODE_INVALID_ACCT
;
}
mgmtDecAcctRef
(
pAcct
);
...
...
@@ -148,9 +148,9 @@ static int32_t mgmtChildTableActionDelete(SSdbOper *pOper) {
}
mgmtDecDbRef
(
pDb
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
if
(
pAcct
==
NULL
)
{
mError
(
"ctable:%s, acct:%s not exists"
,
pTable
->
info
.
tableId
,
pDb
->
cfg
.
acct
);
mError
(
"ctable:%s, acct:%s not exists"
,
pTable
->
info
.
tableId
,
pDb
->
acct
);
return
TSDB_CODE_INVALID_ACCT
;
}
mgmtDecAcctRef
(
pAcct
);
...
...
@@ -929,7 +929,7 @@ static int32_t mgmtAddSuperTableColumn(SDbObj *pDb, SSuperTableObj *pStable, SSc
pStable
->
numOfColumns
+=
ncols
;
pStable
->
sversion
++
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
ncols
*
pStable
->
numOfTables
);
mgmtDecAcctRef
(
pAcct
);
...
...
@@ -966,7 +966,7 @@ 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
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
-=
pStable
->
numOfTables
;
mgmtDecAcctRef
(
pAcct
);
...
...
@@ -1112,12 +1112,11 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
int32_t
dbNameLen
=
strlen
(
pDropDb
->
name
);
SSuperTableObj
*
pTable
=
NULL
;
mPrint
(
"db:%s, all super tables will be dropped from sdb"
,
pDropDb
->
name
);
while
(
1
)
{
mgmtDecTableRef
(
pTable
);
pNode
=
sdbFetchRow
(
tsSuperTableSdb
,
pNode
,
(
void
**
)
&
pTable
);
if
(
pTable
==
NULL
)
{
break
;
}
if
(
pTable
==
NULL
)
break
;
if
(
strncmp
(
pDropDb
->
name
,
pTable
->
info
.
tableId
,
dbNameLen
)
==
0
)
{
SSdbOper
oper
=
{
...
...
@@ -1128,10 +1127,12 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) {
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
continue
;
}
mgmtDecTableRef
(
pTable
);
}
mTrace
(
"db:%s, all super tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
mPrint
(
"db:%s, all super tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
}
static
int32_t
mgmtSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSuperTableObj
*
pTable
)
{
...
...
@@ -1217,7 +1218,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
}
static
void
mgmtProcessDropSuperTableRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"drop stable rsp received, handle:%p code:%
d"
,
rpcMsg
->
handle
,
rpcMsg
->
code
);
mTrace
(
"drop stable rsp received, handle:%p code:%
s"
,
rpcMsg
->
handle
,
tstrerror
(
rpcMsg
->
code
)
);
}
static
void
*
mgmtBuildCreateChildTableMsg
(
SCMCreateTableMsg
*
pMsg
,
SChildTableObj
*
pTable
)
{
...
...
@@ -1241,7 +1242,7 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb
return
NULL
;
}
m
emcpy
(
pCreate
->
tableId
,
pTable
->
info
.
tableId
,
TSDB_TABLE_ID_LEN
);
m
gmtExtractTableName
(
pTable
->
info
.
tableId
,
pCreate
->
tableId
);
pCreate
->
contLen
=
htonl
(
contLen
);
pCreate
->
vgId
=
htonl
(
pTable
->
vgId
);
pCreate
->
tableType
=
pTable
->
info
.
type
;
...
...
@@ -1251,7 +1252,7 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb
pCreate
->
uid
=
htobe64
(
pTable
->
uid
);
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
m
emcpy
(
pCreate
->
superTableId
,
pTable
->
superTable
->
info
.
tableId
,
TSDB_TABLE_ID_LEN
+
1
);
m
gmtExtractTableName
(
pTable
->
superTable
->
info
.
tableId
,
pCreate
->
superTableId
);
pCreate
->
numOfColumns
=
htons
(
pTable
->
superTable
->
numOfColumns
);
pCreate
->
numOfTags
=
htons
(
pTable
->
superTable
->
numOfTags
);
pCreate
->
sversion
=
htonl
(
pTable
->
superTable
->
sversion
);
...
...
@@ -1504,7 +1505,7 @@ static int32_t mgmtAddNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, SSc
pTable
->
numOfColumns
+=
ncols
;
pTable
->
sversion
++
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
+=
ncols
;
mgmtDecAcctRef
(
pAcct
);
...
...
@@ -1538,7 +1539,7 @@ static int32_t mgmtDropNormalTableColumn(SDbObj *pDb, SChildTableObj *pTable, ch
pTable
->
numOfColumns
--
;
pTable
->
sversion
++
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
cfg
.
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pDb
->
acct
);
if
(
pAcct
!=
NULL
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
--
;
mgmtDecAcctRef
(
pAcct
);
...
...
@@ -1681,12 +1682,11 @@ void mgmtDropAllChildTables(SDbObj *pDropDb) {
int32_t
dbNameLen
=
strlen
(
pDropDb
->
name
);
SChildTableObj
*
pTable
=
NULL
;
mPrint
(
"db:%s, all child tables will be dropped from sdb"
,
pDropDb
->
name
);
while
(
1
)
{
mgmtDecTableRef
(
pTable
);
pNode
=
sdbFetchRow
(
tsChildTableSdb
,
pNode
,
(
void
**
)
&
pTable
);
if
(
pTable
==
NULL
)
{
break
;
}
if
(
pTable
==
NULL
)
break
;
if
(
strncmp
(
pDropDb
->
name
,
pTable
->
info
.
tableId
,
dbNameLen
)
==
0
)
{
SSdbOper
oper
=
{
...
...
@@ -1697,11 +1697,11 @@ void mgmtDropAllChildTables(SDbObj *pDropDb) {
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
continue
;
}
mgmtDecTableRef
(
pTable
);
}
m
Trace
(
"db:%s, all child tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
m
Print
(
"db:%s, all child tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
}
static
void
mgmtDropAllChildTablesInStable
(
SSuperTableObj
*
pStable
)
{
...
...
@@ -1710,12 +1710,11 @@ static void mgmtDropAllChildTablesInStable(SSuperTableObj *pStable) {
int32_t
numOfTables
=
0
;
SChildTableObj
*
pTable
=
NULL
;
mPrint
(
"stable:%s, all child tables will dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
while
(
1
)
{
mgmtDecTableRef
(
pTable
);
pNode
=
sdbFetchRow
(
tsChildTableSdb
,
pNode
,
(
void
**
)
&
pTable
);
if
(
pTable
==
NULL
)
{
break
;
}
if
(
pTable
==
NULL
)
break
;
if
(
pTable
->
superTable
==
pStable
)
{
SSdbOper
oper
=
{
...
...
@@ -1726,11 +1725,12 @@ static void mgmtDropAllChildTablesInStable(SSuperTableObj *pStable) {
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
continue
;
}
mgmtDecTableRef
(
pTable
);
}
m
Trace
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
m
Print
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
}
static
SChildTableObj
*
mgmtGetTableByPos
(
uint32_t
dnodeId
,
int32_t
vnode
,
int32_t
sid
)
{
...
...
@@ -1876,7 +1876,7 @@ static void mgmtProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
// not implemented yet
static
void
mgmtProcessAlterTableRsp
(
SRpcMsg
*
rpcMsg
)
{
mTrace
(
"alter table rsp received, handle:%p code:%
d"
,
rpcMsg
->
handle
,
rpcMsg
->
code
);
mTrace
(
"alter table rsp received, handle:%p code:%
s"
,
rpcMsg
->
handle
,
tstrerror
(
rpcMsg
->
code
)
);
}
static
void
mgmtProcessMultiTableMetaMsg
(
SQueuedMsg
*
pMsg
)
{
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
b2f17cb5
...
...
@@ -353,6 +353,7 @@ static void mgmtProcessCreateUserMsg(SQueuedMsg *pMsg) {
mLPrint
(
"user:%s, is created by %s"
,
pCreate
->
user
,
pOperUser
->
user
);
}
}
else
{
mError
(
"user:%s, no rights to create user"
,
pOperUser
->
user
);
code
=
TSDB_CODE_NO_RIGHTS
;
}
...
...
@@ -398,6 +399,7 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
code
=
mgmtUpdateUser
(
pUser
);
mLPrint
(
"user:%s, password is altered by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
else
{
mError
(
"user:%s, no rights to ater user"
,
pOperUser
->
user
);
code
=
TSDB_CODE_NO_RIGHTS
;
}
...
...
@@ -440,11 +442,13 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
code
=
mgmtUpdateUser
(
pUser
);
mLPrint
(
"user:%s, privilege is altered by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
else
{
mError
(
"user:%s, no rights to ater user"
,
pOperUser
->
user
);
code
=
TSDB_CODE_NO_RIGHTS
;
}
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
}
else
{
mError
(
"user:%s, no rights to ater user"
,
pOperUser
->
user
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_NO_RIGHTS
);
}
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
b2f17cb5
...
...
@@ -71,14 +71,14 @@ static int32_t mgmtVgroupActionInsert(SSdbOper *pOper) {
pVgroup
->
prev
=
NULL
;
pVgroup
->
next
=
NULL
;
int32_t
size
=
sizeof
(
SChildTableObj
*
)
*
pDb
->
cfg
.
max
Session
s
;
pVgroup
->
tableList
=
calloc
(
pDb
->
cfg
.
max
Session
s
,
sizeof
(
SChildTableObj
*
));
int32_t
size
=
sizeof
(
SChildTableObj
*
)
*
pDb
->
cfg
.
max
Table
s
;
pVgroup
->
tableList
=
calloc
(
pDb
->
cfg
.
max
Table
s
,
sizeof
(
SChildTableObj
*
));
if
(
pVgroup
->
tableList
==
NULL
)
{
mError
(
"vgroup:%d, failed to malloc(size:%d) for the tableList of vgroups"
,
pVgroup
->
vgId
,
size
);
return
-
1
;
}
pVgroup
->
idPool
=
taosInitIdPool
(
pDb
->
cfg
.
max
Session
s
);
pVgroup
->
idPool
=
taosInitIdPool
(
pDb
->
cfg
.
max
Table
s
);
if
(
pVgroup
->
idPool
==
NULL
)
{
mError
(
"vgroup:%d, failed to taosInitIdPool for vgroups"
,
pVgroup
->
vgId
);
tfree
(
pVgroup
->
tableList
);
...
...
@@ -146,15 +146,15 @@ static int32_t mgmtVgroupActionUpdate(SSdbOper *pOper) {
int32_t
oldTables
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
SDbObj
*
pDb
=
pVgroup
->
pDb
;
if
(
pDb
!=
NULL
)
{
if
(
pDb
->
cfg
.
max
Session
s
!=
oldTables
)
{
mPrint
(
"vgroup:%d tables change from %d to %d"
,
pVgroup
->
vgId
,
oldTables
,
pDb
->
cfg
.
max
Session
s
);
taosUpdateIdPool
(
pVgroup
->
idPool
,
pDb
->
cfg
.
max
Session
s
);
int32_t
size
=
sizeof
(
SChildTableObj
*
)
*
pDb
->
cfg
.
max
Session
s
;
if
(
pDb
->
cfg
.
max
Table
s
!=
oldTables
)
{
mPrint
(
"vgroup:%d tables change from %d to %d"
,
pVgroup
->
vgId
,
oldTables
,
pDb
->
cfg
.
max
Table
s
);
taosUpdateIdPool
(
pVgroup
->
idPool
,
pDb
->
cfg
.
max
Table
s
);
int32_t
size
=
sizeof
(
SChildTableObj
*
)
*
pDb
->
cfg
.
max
Table
s
;
pVgroup
->
tableList
=
(
SChildTableObj
**
)
realloc
(
pVgroup
->
tableList
,
size
);
}
}
mTrace
(
"vgroup:%d, is updated, tables:%d numOfVnode:%d"
,
pVgroup
->
vgId
,
pDb
->
cfg
.
max
Session
s
,
pVgroup
->
numOfVnodes
);
mTrace
(
"vgroup:%d, is updated, tables:%d numOfVnode:%d"
,
pVgroup
->
vgId
,
pDb
->
cfg
.
max
Table
s
,
pVgroup
->
numOfVnodes
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -511,7 +511,7 @@ void mgmtAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
pVgroup
->
numOfTables
++
;
}
if
(
pVgroup
->
numOfTables
>=
pVgroup
->
pDb
->
cfg
.
max
Session
s
)
if
(
pVgroup
->
numOfTables
>=
pVgroup
->
pDb
->
cfg
.
max
Table
s
)
mgmtAddVgroupIntoDbTail
(
pVgroup
);
}
...
...
@@ -522,7 +522,7 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
pVgroup
->
numOfTables
--
;
}
if
(
pVgroup
->
numOfTables
>=
pVgroup
->
pDb
->
cfg
.
max
Session
s
)
if
(
pVgroup
->
numOfTables
>=
pVgroup
->
pDb
->
cfg
.
max
Table
s
)
mgmtAddVgroupIntoDbTail
(
pVgroup
);
}
...
...
@@ -535,16 +535,16 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup) {
SMDVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCfg
->
maxTables
=
htonl
(
pDb
->
cfg
.
max
Session
s
);
pCfg
->
maxCacheSize
=
htobe64
(
(
int64_t
)
pDb
->
cfg
.
cacheBlockSize
*
pDb
->
cfg
.
cacheNumOfBlocks
.
totalBlocks
);
pCfg
->
maxCacheSize
=
htobe64
(
-
1
);
pCfg
->
minRowsPerFileBlock
=
htonl
(
-
1
);
pCfg
->
maxRowsPerFileBlock
=
htonl
(
-
1
);
pCfg
->
maxTables
=
htonl
(
pDb
->
cfg
.
max
Table
s
);
pCfg
->
maxCacheSize
=
htobe64
(
pDb
->
cfg
.
maxCacheSize
);
pCfg
->
maxCacheSize
=
htobe64
(
-
1
);
//TODO
pCfg
->
minRowsPerFileBlock
=
htonl
(
-
1
);
//TODO
pCfg
->
maxRowsPerFileBlock
=
htonl
(
-
1
);
//TODO
pCfg
->
daysPerFile
=
htonl
(
pDb
->
cfg
.
daysPerFile
);
pCfg
->
daysToKeep1
=
htonl
(
pDb
->
cfg
.
daysToKeep1
);
pCfg
->
daysToKeep2
=
htonl
(
pDb
->
cfg
.
daysToKeep2
);
pCfg
->
daysToKeep
=
htonl
(
pDb
->
cfg
.
daysToKeep
);
pCfg
->
daysToKeep
=
htonl
(
-
1
);
pCfg
->
daysToKeep
=
htonl
(
-
1
);
//TODO
pCfg
->
commitTime
=
htonl
(
pDb
->
cfg
.
commitTime
);
pCfg
->
precision
=
pDb
->
cfg
.
precision
;
pCfg
->
compression
=
pDb
->
cfg
.
compression
;
...
...
@@ -744,12 +744,13 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) {
void
mgmtDropAllVgroups
(
SDbObj
*
pDropDb
)
{
void
*
pNode
=
NULL
;
void
*
pLastNode
=
NULL
;
int32_t
numOf
Table
s
=
0
;
int32_t
numOf
Vgroup
s
=
0
;
int32_t
dbNameLen
=
strlen
(
pDropDb
->
name
);
SVgObj
*
pVgroup
=
NULL
;
mPrint
(
"db:%s, all vgroups will be dropped from sdb"
,
pDropDb
->
name
);
while
(
1
)
{
mgmtDecVgroupRef
(
pVgroup
);
pNode
=
sdbFetchRow
(
tsVgroupSdb
,
pNode
,
(
void
**
)
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
...
...
@@ -761,12 +762,14 @@ void mgmtDropAllVgroups(SDbObj *pDropDb) {
};
sdbDeleteRow
(
&
oper
);
pNode
=
pLastNode
;
numOfTables
++
;
continue
;
numOfVgroups
++
;
}
mgmtSendDropVgroupMsg
(
pVgroup
,
NULL
);
mgmtDecVgroupRef
(
pVgroup
);
}
m
Trace
(
"db:%s, all vgroups is dropped from sdb"
,
pDropDb
->
name
,
numOfTable
s
);
m
Print
(
"db:%s, all vgroups:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfVgroup
s
);
}
void
mgmtAlterVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
...
...
src/plugins/http/inc/httpLog.h
浏览文件 @
b2f17cb5
...
...
@@ -39,9 +39,4 @@ extern int32_t httpDebugFlag;
#define httpPrint(...) \
{ taosPrintLog("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/gcHandle.c
浏览文件 @
b2f17cb5
...
...
@@ -13,11 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gcHandle.h"
#define _DEFAULT_SOURCE
#include "os.h"
#include "cJSON.h"
#include "httpLog.h"
#include "gcHandle.h"
#include "gcJson.h"
#include "taosdef.h"
#include "httpLog.h"
static
HttpDecodeMethod
gcDecodeMethod
=
{
"grafana"
,
gcProcessRequest
};
static
HttpEncodeMethod
gcHeartBeatMethod
=
{
NULL
,
gcSendHeartBeatResp
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
};
...
...
src/plugins/http/src/gcJson.c
浏览文件 @
b2f17cb5
...
...
@@ -13,10 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#define _DEFAULT_SOURCE
#include "os.h"
#include "gcHandle.h"
#include "gcJson.h"
#include "httpJson.h"
...
...
src/plugins/http/src/httpAuth.c
浏览文件 @
b2f17cb5
...
...
@@ -13,12 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tkey.h"
#include "tutil.h"
#include "http.h"
#include "httpLog.h"
#include "httpHandle.h"
#include "tkey.h"
#define KEY_DES_4 4971256377704625728L
bool
httpParseBasicAuthToken
(
HttpContext
*
pContext
,
char
*
token
,
int
len
)
{
...
...
src/plugins/http/src/httpCode.c
浏览文件 @
b2f17cb5
...
...
@@ -13,6 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
char
*
httpMsg
[]
=
{
"success"
,
// 0
"http server is not online"
,
// 1
...
...
src/plugins/http/src/httpHandle.c
浏览文件 @
b2f17cb5
...
...
@@ -13,21 +13,18 @@
* 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>
#include "http.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#include "shash.h"
#define _DEFAULT_SOURCE
#include "os.h"
#include "taos.h"
#include "tglobal.h"
#include "tsocket.h"
#include "ttimer.h"
#include "shash.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
void
httpToLowerUrl
(
char
*
url
)
{
/*ignore case */
...
...
src/plugins/http/src/httpJson.c
浏览文件 @
b2f17cb5
...
...
@@ -13,20 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpJson.h"
#include "httpResp.h"
#include "taosmsg.h"
#include "httpLog.h"
#include "taoserror.h"
#define MAX_NUM_STR_SZ 25
...
...
src/plugins/http/src/httpResp.c
浏览文件 @
b2f17cb5
...
...
@@ -13,14 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "httpLog.h"
#include "httpResp.h"
#include <stdio.h>
#include <string.h>
#include "httpCode.h"
#include "httpJson.h"
#include "taosmsg.h"
#include "httpLog.h"
#include "taoserror.h"
const
char
*
httpKeepAliveStr
[]
=
{
""
,
"Connection: Keep-Alive
\r\n
"
,
"Connection: Close
\r\n
"
};
...
...
@@ -44,9 +44,8 @@ const char *httpRespTemplate[] = {
"%s 200 OK
\r\n
Access-Control-Allow-Origin:*
\r\n
%sAccess-Control-Allow-Methods:POST, GET, OPTIONS, DELETE, PUT
\r\n
Access-Control-Allow-Headers:Accept, Content-Type
\r\n
Content-Type: application/json;charset=utf-8
\r\n
Content-Length: %d
\r\n\r\n
"
};
void
httpSendErrorRespImp
(
HttpContext
*
pContext
,
int
httpCode
,
char
*
httpCodeStr
,
int
errNo
,
char
*
desc
)
{
httpError
(
"context:%p, fd:%d, ip:%s, code:%d, error:%d:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
httpCode
,
errNo
,
desc
);
static
void
httpSendErrorRespImp
(
HttpContext
*
pContext
,
int
httpCode
,
char
*
httpCodeStr
,
int
errNo
,
char
*
desc
)
{
httpError
(
"context:%p, fd:%d, ip:%s, code:%d, error:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
httpCode
,
desc
);
char
head
[
512
]
=
{
0
};
char
body
[
512
]
=
{
0
};
...
...
@@ -184,7 +183,7 @@ void httpSendErrorResp(HttpContext *pContext, int errNo) { httpSendErrorRespWith
void
httpSendTaosdErrorResp
(
HttpContext
*
pContext
,
int
errCode
)
{
int
httpCode
=
400
;
httpSendErrorRespImp
(
pContext
,
httpCode
,
"Bad Request"
,
errCode
,
(
char
*
)
tstrerror
(
errCode
));
httpSendErrorRespImp
(
pContext
,
httpCode
,
"Bad Request"
,
1000
,
(
char
*
)
tstrerror
(
errCode
));
}
void
httpSendTaosdInvalidSqlErrorResp
(
HttpContext
*
pContext
,
char
*
errMsg
)
{
...
...
src/plugins/http/src/httpServer.c
浏览文件 @
b2f17cb5
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "tsocket.h"
...
...
src/plugins/http/src/httpSession.c
浏览文件 @
b2f17cb5
...
...
@@ -13,20 +13,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "http.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#define _DEFAULT_SOURCE
#include "os.h"
#include "shash.h"
#include "taos.h"
#include "ttime.h"
#include "ttimer.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
void
httpAccessSession
(
HttpContext
*
pContext
)
{
HttpServer
*
server
=
pContext
->
pThread
->
pServer
;
...
...
src/plugins/http/src/httpSql.c
浏览文件 @
b2f17cb5
...
...
@@ -13,15 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tnote.h"
#include "taos.h"
#include "tsclient.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#include "taos.h"
#include "tsclient.h"
#include "tnote.h"
#include "httpLog.h"
void
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
...
...
@@ -55,8 +56,8 @@ void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numO
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
numOfRows
,
sql
);
if
(
numOfRows
<
0
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, process pos:%d, retrieve failed code:%
d
, sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
-
numOfRows
,
sql
);
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, process pos:%d, retrieve failed code:%
s
, sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
tstrerror
(
numOfRows
)
,
sql
);
}
else
{
taos_free_result
(
result
);
}
...
...
@@ -79,21 +80,21 @@ void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int code) {
HttpSqlCmd
*
singleCmd
=
multiCmds
->
cmds
+
multiCmds
->
pos
;
char
*
sql
=
httpGetCmdsString
(
pContext
,
singleCmd
->
sql
);
if
(
-
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
httpWarn
(
"context:%p, fd:%d, ip:%s, user:%s, process pos:%d, code:%
d
:inprogress, sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
-
code
,
sql
);
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
httpWarn
(
"context:%p, fd:%d, ip:%s, user:%s, process pos:%d, code:%
s
:inprogress, sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
tstrerror
(
code
)
,
sql
);
return
;
}
if
(
code
<
0
)
{
if
(
encode
->
checkFinishedFp
!=
NULL
&&
!
encode
->
checkFinishedFp
(
pContext
,
singleCmd
,
code
>=
0
?
0
:
-
code
))
{
singleCmd
->
code
=
-
code
;
httpTrace
(
"context:%p, fd:%d, ip:%s, user:%s, process pos jump to:%d, last code:%
d
, last sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
+
1
,
-
code
,
sql
);
if
(
encode
->
checkFinishedFp
!=
NULL
&&
!
encode
->
checkFinishedFp
(
pContext
,
singleCmd
,
code
>=
0
?
0
:
code
))
{
singleCmd
->
code
=
code
;
httpTrace
(
"context:%p, fd:%d, ip:%s, user:%s, process pos jump to:%d, last code:%
s
, last sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
+
1
,
tstrerror
(
code
)
,
sql
);
}
else
{
singleCmd
->
code
=
-
code
;
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, process pos:%d, error code:%
d
, sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
-
code
,
sql
);
singleCmd
->
code
=
code
;
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, process pos:%d, error code:%
s
, sql:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
multiCmds
->
pos
,
tstrerror
(
code
)
,
sql
);
if
(
singleCmd
->
cmdReturnType
==
HTTP_CMD_RETURN_TYPE_WITH_RETURN
)
{
if
(
encode
->
startJsonFp
)
(
encode
->
startJsonFp
)(
pContext
,
singleCmd
,
result
);
...
...
@@ -209,8 +210,8 @@ void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int num
pContext
->
user
,
numOfRows
);
if
(
numOfRows
<
0
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, retrieve failed, code:%
d
"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
-
numOfRows
);
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, retrieve failed, code:%
s
"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
tstrerror
(
numOfRows
)
);
}
else
{
taos_free_result
(
result
);
}
...
...
@@ -229,22 +230,22 @@ void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int code) {
HttpEncodeMethod
*
encode
=
pContext
->
encodeMethod
;
if
(
-
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%
d
:inprogress, sqlObj:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
pContext
->
session
->
taos
,
-
code
,
(
SSqlObj
*
)
result
);
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%
s
:inprogress, sqlObj:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
pContext
->
session
->
taos
,
tstrerror
(
code
)
,
(
SSqlObj
*
)
result
);
return
;
}
if
(
code
<
0
)
{
SSqlObj
*
pObj
=
(
SSqlObj
*
)
result
;
if
(
-
code
==
TSDB_CODE_INVALID_SQL
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%
d
:invalidsql, sqlObj:%p, error:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
pContext
->
session
->
taos
,
-
code
,
pObj
,
pObj
->
cmd
.
payload
);
if
(
code
==
TSDB_CODE_INVALID_SQL
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%
s
:invalidsql, sqlObj:%p, error:%s"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
pContext
->
session
->
taos
,
tstrerror
(
code
)
,
pObj
,
pObj
->
cmd
.
payload
);
httpSendTaosdInvalidSqlErrorResp
(
pContext
,
pObj
->
cmd
.
payload
);
}
else
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%
d
, sqlObj:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
pContext
->
session
->
taos
,
-
code
,
pObj
);
httpSendTaosdErrorResp
(
pContext
,
-
code
);
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%
s
, sqlObj:%p"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
pContext
->
session
->
taos
,
tstrerror
(
code
)
,
pObj
);
httpSendTaosdErrorResp
(
pContext
,
code
);
}
return
;
}
...
...
@@ -349,9 +350,9 @@ void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
if
(
pContext
==
NULL
||
pContext
->
signature
!=
pContext
)
return
;
if
(
code
<
0
)
{
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, login error, code:%
d
"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
-
code
);
httpSendTaosdErrorResp
(
pContext
,
-
code
);
httpError
(
"context:%p, fd:%d, ip:%s, user:%s, login error, code:%
s
"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
pContext
->
user
,
tstrerror
(
code
)
);
httpSendTaosdErrorResp
(
pContext
,
code
);
return
;
}
...
...
src/plugins/http/src/httpSystem.c
浏览文件 @
b2f17cb5
...
...
@@ -15,17 +15,17 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "shash.h"
#include "taos.h"
#include "tglobal.h"
#include "tsocket.h"
#include "ttimer.h"
#include "tadmin.h"
#include "http.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#include "httpLog.h"
#include "shash.h"
#include "taos.h"
#include "tglobal.h"
#include "tsocket.h"
#include "ttimer.h"
#include "gcHandle.h"
#include "httpHandle.h"
#include "restHandle.h"
...
...
src/plugins/http/src/httpUtil.c
浏览文件 @
b2f17cb5
...
...
@@ -13,15 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tmd5.h"
#include "shash.h"
#include "taos.h"
#include "http.h"
#include "httpLog.h"
#include "httpCode.h"
#include "httpHandle.h"
#include "httpResp.h"
#include "shash.h"
#include "taos.h"
#include "httpLog.h"
bool
httpCheckUsedbSql
(
char
*
sql
)
{
if
(
strstr
(
sql
,
"use "
)
!=
NULL
)
{
...
...
src/plugins/http/src/restHandle.c
浏览文件 @
b2f17cb5
...
...
@@ -13,9 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "httpLog.h"
#include "restHandle.h"
#include "restJson.h"
#include "httpLog.h"
static
HttpDecodeMethod
restDecodeMethod
=
{
"rest"
,
restProcessRequest
};
static
HttpDecodeMethod
restDecodeMethod2
=
{
"restful"
,
restProcessRequest
};
...
...
src/plugins/http/src/restJson.c
浏览文件 @
b2f17cb5
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "httpLog.h"
...
...
src/plugins/http/src/tgHandle.c
浏览文件 @
b2f17cb5
...
...
@@ -13,14 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tg
Handle
.h"
#include "tg
lobal
.h"
#include "shash.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tgHandle.h"
#include "tgJson.h"
#include "taosdef.h"
#include "httpLog.h"
#include "tglobal.h"
/*
* taos.telegraf.cfg formats like
...
...
src/plugins/http/src/tgJson.c
浏览文件 @
b2f17cb5
...
...
@@ -13,13 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosmsg.h"
#include "httpLog.h"
#include "httpJson.h"
#include "httpResp.h"
#include "taosmsg.h"
#include "tgHandle.h"
#include "tgJson.h"
#include "httpLog.h"
void
tgInitQueryJson
(
HttpContext
*
pContext
)
{
JsonBuf
*
jsonBuf
=
httpMallocJsonBuf
(
pContext
);
...
...
@@ -97,8 +98,8 @@ void tgBuildSqlAffectRowsJson(HttpContext *pContext, HttpSqlCmd *cmd, int affect
bool
tgCheckFinished
(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
int
code
)
{
HttpSqlCmds
*
multiCmds
=
pContext
->
multiCmds
;
httpTrace
(
"context:%p, fd:%d, ip:%s, check telegraf command, code:%
d
, state:%d, type:%d, rettype:%d, tags:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
code
,
cmd
->
cmdState
,
cmd
->
cmdType
,
cmd
->
cmdReturnType
,
cmd
->
tagNum
);
httpTrace
(
"context:%p, fd:%d, ip:%s, check telegraf command, code:%
s
, state:%d, type:%d, rettype:%d, tags:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
tstrerror
(
code
)
,
cmd
->
cmdState
,
cmd
->
cmdType
,
cmd
->
cmdReturnType
,
cmd
->
tagNum
);
if
(
cmd
->
cmdType
==
HTTP_CMD_TYPE_INSERT
)
{
if
(
cmd
->
cmdState
==
HTTP_CMD_STATE_NOT_RUN_YET
)
{
...
...
@@ -124,11 +125,11 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
}
}
else
if
(
cmd
->
cmdType
==
HTTP_CMD_TYPE_CREATE_DB
)
{
cmd
->
cmdState
=
HTTP_CMD_STATE_RUN_FINISHED
;
httpTrace
(
"context:%p, fd:%d, ip:%s, code:%
d
, create database failed"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
code
);
httpTrace
(
"context:%p, fd:%d, ip:%s, code:%
s
, create database failed"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
tstrerror
(
code
)
);
}
else
if
(
cmd
->
cmdType
==
HTTP_CMD_TYPE_CREATE_STBALE
)
{
cmd
->
cmdState
=
HTTP_CMD_STATE_RUN_FINISHED
;
httpTrace
(
"context:%p, fd:%d, ip:%s, code:%
d, create stable failed"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
code
);
httpTrace
(
"context:%p, fd:%d, ip:%s, code:%
s, create stable failed"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
tstrerror
(
code
)
);
}
else
{
}
...
...
@@ -137,8 +138,8 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
void
tgSetNextCmd
(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
int
code
)
{
HttpSqlCmds
*
multiCmds
=
pContext
->
multiCmds
;
httpTrace
(
"context:%p, fd:%d, ip:%s, get telegraf next command, pos:%d, code:%
d
, state:%d, type:%d, rettype:%d, tags:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
multiCmds
->
pos
,
code
,
cmd
->
cmdState
,
cmd
->
cmdType
,
httpTrace
(
"context:%p, fd:%d, ip:%s, get telegraf next command, pos:%d, code:%
s
, state:%d, type:%d, rettype:%d, tags:%d"
,
pContext
,
pContext
->
fd
,
pContext
->
ipstr
,
multiCmds
->
pos
,
tstrerror
(
code
)
,
cmd
->
cmdState
,
cmd
->
cmdType
,
cmd
->
cmdReturnType
,
cmd
->
tagNum
);
if
(
cmd
->
cmdType
==
HTTP_CMD_TYPE_INSERT
)
{
...
...
src/plugins/monitor/inc/monitorSystem.h
已删除
100644 → 0
浏览文件 @
25e13520
/*
* 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_MONITOR_SYSTEM_H
#define TDENGINE_MONITOR_SYSTEM_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdbool.h>
#include <stdint.h>
int32_t
monitorInitSystem
();
int32_t
monitorStartSystem
();
void
monitorStopSystem
();
void
monitorCleanUpSystem
();
void
monitorSaveAcctLog
(
char
*
acctId
,
int64_t
currentPointsPerSecond
,
int64_t
maxPointsPerSecond
,
int64_t
totalTimeSeries
,
int64_t
maxTimeSeries
,
int64_t
totalStorage
,
int64_t
maxStorage
,
int64_t
totalQueryTime
,
int64_t
maxQueryTime
,
int64_t
totalInbound
,
int64_t
maxInbound
,
int64_t
totalOutbound
,
int64_t
maxOutbound
,
int64_t
totalDbs
,
int64_t
maxDbs
,
int64_t
totalUsers
,
int64_t
maxUsers
,
int64_t
totalStreams
,
int64_t
maxStreams
,
int64_t
totalConns
,
int64_t
maxConns
,
int8_t
accessState
);
void
monitorSaveLog
(
int
level
,
const
char
*
const
format
,
...);
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
src/plugins/monitor/src/monitor
System
.c
→
src/plugins/monitor/src/monitor
Main
.c
浏览文件 @
b2f17cb5
...
...
@@ -15,16 +15,17 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tlog.h"
#include "monitor.h"
#include "dnode.h"
#include "tsclient.h"
#include "taosdef.h"
#include "tsystem.h"
#include "taoserror.h"
#include "tlog.h"
#include "ttime.h"
#include "ttimer.h"
#include "tutil.h"
#include "monitorSystem.h"
#include "tsystem.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "dnode.h"
#include "monitor.h"
#define monitorError(...) \
if (monitorDebugFlag & DEBUG_ERROR) { \
...
...
@@ -41,10 +42,6 @@
#define monitorPrint(...) \
{ taosPrintLog("MON ", 255, __VA_ARGS__); }
#define monitorLError(...) monitorError(__VA_ARGS__)
#define monitorLWarn(...) monitorWarn(__VA_ARGS__)
#define monitorLPrint(...) monitorPrint(__VA_ARGS__)
#define SQL_LENGTH 1024
#define LOG_LEN_STR 80
#define IP_LEN_STR 15
...
...
@@ -59,14 +56,14 @@ typedef enum {
MONITOR_CMD_CREATE_TB_ACCT_ROOT
,
MONITOR_CMD_CREATE_TB_SLOWQUERY
,
MONITOR_CMD_MAX
}
MonitorCommand
;
}
E
MonitorCommand
;
typedef
enum
{
MONITOR_STATE_UN_INIT
,
MONITOR_STATE_INITIALIZING
,
MONITOR_STATE_INITIALIZED
,
MONITOR_STATE_STOPPED
}
MonitorState
;
}
E
MonitorState
;
typedef
struct
{
void
*
conn
;
...
...
@@ -77,89 +74,75 @@ typedef struct {
char
sql
[
SQL_LENGTH
];
void
*
initTimer
;
void
*
diskTimer
;
}
MonitorConn
;
MonitorConn
*
monitor
=
NULL
;
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
void
monitorInitConn
(
void
*
para
,
void
*
unused
);
void
monitorInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
int
code
);
void
monitorInitDatabase
();
void
monitorInitDatabaseCb
(
void
*
param
,
TAOS_RES
*
result
,
int
code
);
void
monitorStartTimer
();
void
monitorSaveSystemInfo
();
void
monitorSaveLog
(
int
level
,
const
char
*
const
format
,
...);
void
monitorSaveAcctLog
(
char
*
acctId
,
int64_t
currentPointsPerSecond
,
int64_t
maxPointsPerSecond
,
int64_t
totalTimeSeries
,
int64_t
maxTimeSeries
,
int64_t
totalStorage
,
int64_t
maxStorage
,
int64_t
totalQueryTime
,
int64_t
maxQueryTime
,
int64_t
totalInbound
,
int64_t
maxInbound
,
int64_t
totalOutbound
,
int64_t
maxOutbound
,
int64_t
totalDbs
,
int64_t
maxDbs
,
int64_t
totalUsers
,
int64_t
maxUsers
,
int64_t
totalStreams
,
int64_t
maxStreams
,
int64_t
totalConns
,
int64_t
maxConns
,
int8_t
accessState
);
void
(
*
mnodeCountRequestFp
)(
SDnodeStatisInfo
*
info
)
=
NULL
;
void
monitorExecuteSQL
(
char
*
sql
);
void
monitorCheckDiskUsage
(
void
*
para
,
void
*
unused
)
{
}
SMonitorConn
;
static
SMonitorConn
tsMonitorConn
;
static
void
monitorInitConn
(
void
*
para
,
void
*
unused
);
static
void
monitorInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
);
static
void
monitorInitDatabase
();
static
void
monitorInitDatabaseCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
);
static
void
monitorStartTimer
();
static
void
monitorSaveSystemInfo
();
static
void
monitorCheckDiskUsage
(
void
*
para
,
void
*
unused
)
{
taosGetDisk
();
taosTmrReset
(
monitorCheckDiskUsage
,
CHECK_INTERVAL
,
NULL
,
tscTmr
,
&
monitor
->
diskTimer
);
taosTmrReset
(
monitorCheckDiskUsage
,
CHECK_INTERVAL
,
NULL
,
tscTmr
,
&
tsMonitorConn
.
diskTimer
);
}
int
monitorInitSystem
()
{
monitor
=
(
MonitorConn
*
)
malloc
(
sizeof
(
MonitorConn
));
memset
(
monitor
,
0
,
sizeof
(
MonitorConn
));
taosTmrReset
(
monitorCheckDiskUsage
,
CHECK_INTERVAL
,
NULL
,
tscTmr
,
&
monitor
->
diskTimer
);
int32_t
monitorInitSystem
()
{
taos_init
();
taosTmrReset
(
monitorCheckDiskUsage
,
CHECK_INTERVAL
,
NULL
,
tscTmr
,
&
tsMonitorConn
.
diskTimer
);
return
0
;
}
int
monitorStartSystem
()
{
if
(
monitor
==
NULL
)
{
int
32_t
monitorStartSystem
()
{
monitorPrint
(
"start monitor module"
);
monitorInitSystem
();
}
taosTmrReset
(
monitorInitConn
,
10
,
NULL
,
tscTmr
,
&
monitor
->
initTimer
);
taosTmrReset
(
monitorInitConn
,
10
,
NULL
,
tscTmr
,
&
tsMonitorConn
.
initTimer
);
return
0
;
}
void
monitorStartSystemRetry
()
{
if
(
monitor
->
initTimer
!=
NULL
)
{
taosTmrReset
(
monitorInitConn
,
3000
,
NULL
,
tscTmr
,
&
monitor
->
initTimer
);
static
void
monitorStartSystemRetry
()
{
if
(
tsMonitorConn
.
initTimer
!=
NULL
)
{
taosTmrReset
(
monitorInitConn
,
3000
,
NULL
,
tscTmr
,
&
tsMonitorConn
.
initTimer
);
}
}
void
monitorInitConn
(
void
*
para
,
void
*
unused
)
{
static
void
monitorInitConn
(
void
*
para
,
void
*
unused
)
{
monitorPrint
(
"starting to initialize monitor service .."
);
monitor
->
state
=
MONITOR_STATE_INITIALIZING
;
tsMonitorConn
.
state
=
MONITOR_STATE_INITIALIZING
;
if
(
monitor
->
privateIpStr
[
0
]
==
0
)
{
strcpy
(
monitor
->
privateIpStr
,
tsPrivateIp
);
for
(
int
i
=
0
;
i
<
TSDB_IPv4ADDR_LEN
;
++
i
)
{
if
(
monitor
->
privateIpStr
[
i
]
==
'.'
)
{
monitor
->
privateIpStr
[
i
]
=
'_'
;
if
(
tsMonitorConn
.
privateIpStr
[
0
]
==
0
)
{
strcpy
(
tsMonitorConn
.
privateIpStr
,
tsPrivateIp
);
for
(
int
32_t
i
=
0
;
i
<
TSDB_IPv4ADDR_LEN
;
++
i
)
{
if
(
tsMonitorConn
.
privateIpStr
[
i
]
==
'.'
)
{
tsMonitorConn
.
privateIpStr
[
i
]
=
'_'
;
}
}
}
if
(
monitor
->
conn
==
NULL
)
{
taos_connect_a
(
NULL
,
"monitor"
,
tsInternalPass
,
""
,
0
,
monitorInitConnCb
,
monitor
,
&
(
monitor
->
conn
));
if
(
tsMonitorConn
.
conn
==
NULL
)
{
taos_connect_a
(
NULL
,
"monitor"
,
tsInternalPass
,
""
,
0
,
monitorInitConnCb
,
&
tsMonitorConn
,
&
(
tsMonitorConn
.
conn
));
}
else
{
monitorInitDatabase
();
}
}
void
monitorInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
in
t
code
)
{
static
void
monitorInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_
t
code
)
{
if
(
code
<
0
)
{
monitorError
(
"monitor:%p, connect to database failed,
code:%d"
,
monitor
->
conn
,
code
);
taos_close
(
monitor
->
conn
);
monitor
->
conn
=
NULL
;
monitor
->
state
=
MONITOR_STATE_UN_INIT
;
monitorError
(
"monitor:%p, connect to database failed,
reason:%s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
)
);
taos_close
(
tsMonitorConn
.
conn
);
tsMonitorConn
.
conn
=
NULL
;
tsMonitorConn
.
state
=
MONITOR_STATE_UN_INIT
;
monitorStartSystemRetry
();
return
;
}
monitorTrace
(
"monitor:%p, connect to database success,
code:%d"
,
monitor
->
conn
,
code
);
monitorTrace
(
"monitor:%p, connect to database success,
reason:%s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
)
);
monitorInitDatabase
();
}
void
dnodeBuildMonitorSql
(
char
*
sql
,
in
t
cmd
)
{
static
void
dnodeBuildMonitorSql
(
char
*
sql
,
int32_
t
cmd
)
{
memset
(
sql
,
0
,
SQL_LENGTH
);
if
(
cmd
==
MONITOR_CMD_CREATE_DB
)
{
...
...
@@ -180,7 +163,7 @@ void dnodeBuildMonitorSql(char *sql, int cmd) {
tsMonitorDbName
,
IP_LEN_STR
+
1
);
}
else
if
(
cmd
==
MONITOR_CMD_CREATE_TB_DN
)
{
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists %s.dn_%s using %s.dn tags('%s')"
,
tsMonitorDbName
,
monitor
->
privateIpStr
,
tsMonitorDbName
,
tsPrivateIp
);
tsMonitorConn
.
privateIpStr
,
tsMonitorDbName
,
tsPrivateIp
);
}
else
if
(
cmd
==
MONITOR_CMD_CREATE_MT_ACCT
)
{
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists %s.acct(ts timestamp "
...
...
@@ -215,111 +198,106 @@ void dnodeBuildMonitorSql(char *sql, int cmd) {
sql
[
SQL_LENGTH
]
=
0
;
}
void
monitorInitDatabase
()
{
if
(
monitor
->
cmdIndex
<
MONITOR_CMD_MAX
)
{
dnodeBuildMonitorSql
(
monitor
->
sql
,
monitor
->
cmdIndex
);
taos_query_a
(
monitor
->
conn
,
monitor
->
sql
,
monitorInitDatabaseCb
,
NULL
);
static
void
monitorInitDatabase
()
{
if
(
tsMonitorConn
.
cmdIndex
<
MONITOR_CMD_MAX
)
{
dnodeBuildMonitorSql
(
tsMonitorConn
.
sql
,
tsMonitorConn
.
cmdIndex
);
taos_query_a
(
tsMonitorConn
.
conn
,
tsMonitorConn
.
sql
,
monitorInitDatabaseCb
,
NULL
);
}
else
{
monitor
->
state
=
MONITOR_STATE_INITIALIZED
;
tsMonitorConn
.
state
=
MONITOR_STATE_INITIALIZED
;
monitorPrint
(
"monitor service init success"
);
monitorStartTimer
();
}
}
void
monitorInitDatabaseCb
(
void
*
param
,
TAOS_RES
*
result
,
in
t
code
)
{
static
void
monitorInitDatabaseCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_
t
code
)
{
if
(
-
code
==
TSDB_CODE_TABLE_ALREADY_EXIST
||
-
code
==
TSDB_CODE_DB_ALREADY_EXIST
||
code
>=
0
)
{
monitorTrace
(
"monitor:%p, sql success,
code:%d, %s"
,
monitor
->
conn
,
code
,
monitor
->
sql
);
if
(
monitor
->
cmdIndex
==
MONITOR_CMD_CREATE_TB_LOG
)
{
monitor
L
Print
(
"dnode:%s is started"
,
tsPrivateIp
);
monitorTrace
(
"monitor:%p, sql success,
reason:%d, %s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
),
tsMonitorConn
.
sql
);
if
(
tsMonitorConn
.
cmdIndex
==
MONITOR_CMD_CREATE_TB_LOG
)
{
monitorPrint
(
"dnode:%s is started"
,
tsPrivateIp
);
}
monitor
->
cmdIndex
++
;
tsMonitorConn
.
cmdIndex
++
;
monitorInitDatabase
();
}
else
{
monitorError
(
"monitor:%p, sql failed,
code:%d, %s"
,
monitor
->
conn
,
code
,
monitor
->
sql
);
monitor
->
state
=
MONITOR_STATE_UN_INIT
;
monitorError
(
"monitor:%p, sql failed,
reason:%s, %s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
),
tsMonitorConn
.
sql
);
tsMonitorConn
.
state
=
MONITOR_STATE_UN_INIT
;
monitorStartSystemRetry
();
}
}
void
monitorStopSystem
()
{
if
(
monitor
==
NULL
)
{
return
;
}
monitorLPrint
(
"dnode:%s monitor module is stopped"
,
tsPrivateIp
);
monitor
->
state
=
MONITOR_STATE_STOPPED
;
// taosLogFp = NULL;
if
(
monitor
->
initTimer
!=
NULL
)
{
taosTmrStopA
(
&
(
monitor
->
initTimer
));
monitorPrint
(
"monitor module is stopped"
);
tsMonitorConn
.
state
=
MONITOR_STATE_STOPPED
;
if
(
tsMonitorConn
.
initTimer
!=
NULL
)
{
taosTmrStopA
(
&
(
tsMonitorConn
.
initTimer
));
}
if
(
monitor
->
timer
!=
NULL
)
{
taosTmrStopA
(
&
(
monitor
->
timer
));
if
(
tsMonitorConn
.
timer
!=
NULL
)
{
taosTmrStopA
(
&
(
tsMonitorConn
.
timer
));
}
}
void
monitorCleanUpSystem
()
{
monitorPrint
(
"monitor service cleanup"
);
monitorStopSystem
();
monitorPrint
(
"monitor module cleanup"
);
}
void
monitorStartTimer
()
{
taosTmrReset
(
monitorSaveSystemInfo
,
tsMonitorInterval
*
1000
,
NULL
,
tscTmr
,
&
monitor
->
timer
);
static
void
monitorStartTimer
()
{
taosTmrReset
(
monitorSaveSystemInfo
,
tsMonitorInterval
*
1000
,
NULL
,
tscTmr
,
&
tsMonitorConn
.
timer
);
}
void
dnodeMontiorInsertAcctCallback
(
void
*
param
,
TAOS_RES
*
result
,
in
t
code
)
{
static
void
dnodeMontiorInsertAcctCallback
(
void
*
param
,
TAOS_RES
*
result
,
int32_
t
code
)
{
if
(
code
<
0
)
{
monitorError
(
"monitor:%p, save account info failed, code:%
d"
,
monitor
->
conn
,
code
);
monitorError
(
"monitor:%p, save account info failed, code:%
s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
)
);
}
else
if
(
code
==
0
)
{
monitorError
(
"monitor:%p, save account info failed, affect rows:%d"
,
monitor
->
conn
,
code
);
monitorError
(
"monitor:%p, save account info failed, affect rows:%d"
,
tsMonitorConn
.
conn
,
code
);
}
else
{
monitorTrace
(
"monitor:%p, save account info success, code:%
d"
,
monitor
->
conn
,
code
);
monitorTrace
(
"monitor:%p, save account info success, code:%
s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
)
);
}
}
void
dnodeMontiorInsertSysCallback
(
void
*
param
,
TAOS_RES
*
result
,
in
t
code
)
{
static
void
dnodeMontiorInsertSysCallback
(
void
*
param
,
TAOS_RES
*
result
,
int32_
t
code
)
{
if
(
code
<
0
)
{
monitorError
(
"monitor:%p, save system info failed, code:%
d %s"
,
monitor
->
conn
,
code
,
monitor
->
sql
);
monitorError
(
"monitor:%p, save system info failed, code:%
s %s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
),
tsMonitorConn
.
sql
);
}
else
if
(
code
==
0
)
{
monitorError
(
"monitor:%p, save system info failed, affect rows:%d %s"
,
monitor
->
conn
,
code
,
monitor
->
sql
);
monitorError
(
"monitor:%p, save system info failed, affect rows:%d %s"
,
tsMonitorConn
.
conn
,
code
,
tsMonitorConn
.
sql
);
}
else
{
monitorTrace
(
"monitor:%p, save system info success, code:%
d %s"
,
monitor
->
conn
,
code
,
monitor
->
sql
);
monitorTrace
(
"monitor:%p, save system info success, code:%
s %s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
),
tsMonitorConn
.
sql
);
}
}
void
dnodeMontiorInsertLogCallback
(
void
*
param
,
TAOS_RES
*
result
,
in
t
code
)
{
static
void
dnodeMontiorInsertLogCallback
(
void
*
param
,
TAOS_RES
*
result
,
int32_
t
code
)
{
if
(
code
<
0
)
{
monitorError
(
"monitor:%p, save log failed, code:%
d"
,
monitor
->
conn
,
code
);
monitorError
(
"monitor:%p, save log failed, code:%
s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
)
);
}
else
if
(
code
==
0
)
{
monitorError
(
"monitor:%p, save log failed, affect rows:%d"
,
monitor
->
conn
,
code
);
monitorError
(
"monitor:%p, save log failed, affect rows:%d"
,
tsMonitorConn
.
conn
,
code
);
}
else
{
monitorTrace
(
"monitor:%p, save log info success, code:%
d"
,
monitor
->
conn
,
code
);
monitorTrace
(
"monitor:%p, save log info success, code:%
s"
,
tsMonitorConn
.
conn
,
tstrerror
(
code
)
);
}
}
// unit is MB
in
t
monitorBuildMemorySql
(
char
*
sql
)
{
static
int32_
t
monitorBuildMemorySql
(
char
*
sql
)
{
float
sysMemoryUsedMB
=
0
;
bool
suc
=
taosGetSysMemory
(
&
sysMemoryUsedMB
);
if
(
!
suc
)
{
monitorError
(
"monitor:%p, get sys memory info failed."
,
monitor
->
conn
);
monitorError
(
"monitor:%p, get sys memory info failed."
,
tsMonitorConn
.
conn
);
}
float
procMemoryUsedMB
=
0
;
suc
=
taosGetProcMemory
(
&
procMemoryUsedMB
);
if
(
!
suc
)
{
monitorError
(
"monitor:%p, get proc memory info failed."
,
monitor
->
conn
);
monitorError
(
"monitor:%p, get proc memory info failed."
,
tsMonitorConn
.
conn
);
}
return
sprintf
(
sql
,
", %f, %f, %d"
,
procMemoryUsedMB
,
sysMemoryUsedMB
,
tsTotalMemoryMB
);
}
// unit is %
in
t
monitorBuildCpuSql
(
char
*
sql
)
{
static
int32_
t
monitorBuildCpuSql
(
char
*
sql
)
{
float
sysCpuUsage
=
0
,
procCpuUsage
=
0
;
bool
suc
=
taosGetCpuUsage
(
&
sysCpuUsage
,
&
procCpuUsage
);
if
(
!
suc
)
{
monitorError
(
"monitor:%p, get cpu usage failed."
,
monitor
->
conn
);
monitorError
(
"monitor:%p, get cpu usage failed."
,
tsMonitorConn
.
conn
);
}
if
(
sysCpuUsage
<=
procCpuUsage
)
{
...
...
@@ -330,51 +308,45 @@ int monitorBuildCpuSql(char *sql) {
}
// unit is GB
in
t
monitorBuildDiskSql
(
char
*
sql
)
{
static
int32_
t
monitorBuildDiskSql
(
char
*
sql
)
{
return
sprintf
(
sql
,
", %f, %d"
,
(
tsTotalDataDirGB
-
tsAvailDataDirGB
),
(
int32_t
)
tsTotalDataDirGB
);
}
// unit is Kb
in
t
monitorBuildBandSql
(
char
*
sql
)
{
static
int32_
t
monitorBuildBandSql
(
char
*
sql
)
{
float
bandSpeedKb
=
0
;
bool
suc
=
taosGetBandSpeed
(
&
bandSpeedKb
);
if
(
!
suc
)
{
monitorError
(
"monitor:%p, get bandwidth speed failed."
,
monitor
->
conn
);
monitorError
(
"monitor:%p, get bandwidth speed failed."
,
tsMonitorConn
.
conn
);
}
return
sprintf
(
sql
,
", %f"
,
bandSpeedKb
);
}
int
monitorBuildReqSql
(
char
*
sql
)
{
SDnodeStatisInfo
info
;
info
.
httpReqNum
=
info
.
submitReqNum
=
info
.
queryReqNum
=
0
;
(
*
mnodeCountRequestFp
)(
&
info
);
static
int32_t
monitorBuildReqSql
(
char
*
sql
)
{
SDnodeStatisInfo
info
=
dnodeGetStatisInfo
();
return
sprintf
(
sql
,
", %d, %d, %d)"
,
info
.
httpReqNum
,
info
.
queryReqNum
,
info
.
submitReqNum
);
}
in
t
monitorBuildIoSql
(
char
*
sql
)
{
static
int32_
t
monitorBuildIoSql
(
char
*
sql
)
{
float
readKB
=
0
,
writeKB
=
0
;
bool
suc
=
taosGetProcIO
(
&
readKB
,
&
writeKB
);
if
(
!
suc
)
{
monitorError
(
"monitor:%p, get io info failed."
,
monitor
->
conn
);
monitorError
(
"monitor:%p, get io info failed."
,
tsMonitorConn
.
conn
);
}
return
sprintf
(
sql
,
", %f, %f"
,
readKB
,
writeKB
);
}
void
monitorSaveSystemInfo
()
{
if
(
monitor
->
state
!=
MONITOR_STATE_INITIALIZED
)
{
return
;
}
if
(
mnodeCountRequestFp
==
NULL
)
{
static
void
monitorSaveSystemInfo
()
{
if
(
tsMonitorConn
.
state
!=
MONITOR_STATE_INITIALIZED
)
{
monitorStartTimer
();
return
;
}
int64_t
ts
=
taosGetTimestampUs
();
char
*
sql
=
monitor
->
sql
;
int
pos
=
snprintf
(
sql
,
SQL_LENGTH
,
"insert into %s.dn_%s values(%"
PRId64
,
tsMonitorDbName
,
monitor
->
privateIpStr
,
ts
);
char
*
sql
=
tsMonitorConn
.
sql
;
int
32_t
pos
=
snprintf
(
sql
,
SQL_LENGTH
,
"insert into %s.dn_%s values(%"
PRId64
,
tsMonitorDbName
,
tsMonitorConn
.
privateIpStr
,
ts
);
pos
+=
monitorBuildCpuSql
(
sql
+
pos
);
pos
+=
monitorBuildMemorySql
(
sql
+
pos
);
...
...
@@ -383,22 +355,16 @@ void monitorSaveSystemInfo() {
pos
+=
monitorBuildIoSql
(
sql
+
pos
);
pos
+=
monitorBuildReqSql
(
sql
+
pos
);
monitorTrace
(
"monitor:%p, save system info, sql:%s"
,
monitor
->
conn
,
sql
);
taos_query_a
(
monitor
->
conn
,
sql
,
dnodeMontiorInsertSysCallback
,
"log"
);
monitorTrace
(
"monitor:%p, save system info, sql:%s"
,
tsMonitorConn
.
conn
,
sql
);
taos_query_a
(
tsMonitorConn
.
conn
,
sql
,
dnodeMontiorInsertSysCallback
,
"log"
);
if
(
monitor
->
timer
!=
NULL
&&
monitor
->
state
!=
MONITOR_STATE_STOPPED
)
{
if
(
tsMonitorConn
.
timer
!=
NULL
&&
tsMonitorConn
.
state
!=
MONITOR_STATE_STOPPED
)
{
monitorStartTimer
();
}
}
void
monitorSaveAcctLog
(
char
*
acctId
,
int64_t
currentPointsPerSecond
,
int64_t
maxPointsPerSecond
,
int64_t
totalTimeSeries
,
int64_t
maxTimeSeries
,
int64_t
totalStorage
,
int64_t
maxStorage
,
int64_t
totalQueryTime
,
int64_t
maxQueryTime
,
int64_t
totalInbound
,
int64_t
maxInbound
,
int64_t
totalOutbound
,
int64_t
maxOutbound
,
int64_t
totalDbs
,
int64_t
maxDbs
,
int64_t
totalUsers
,
int64_t
maxUsers
,
int64_t
totalStreams
,
int64_t
maxStreams
,
int64_t
totalConns
,
int64_t
maxConns
,
int8_t
accessState
)
{
if
(
monitor
==
NULL
)
return
;
if
(
monitor
->
state
!=
MONITOR_STATE_INITIALIZED
)
return
;
void
monitorSaveAcctLog
(
SAcctMonitorObj
*
pMon
)
{
if
(
tsMonitorConn
.
state
!=
MONITOR_STATE_INITIALIZED
)
return
;
char
sql
[
1024
]
=
{
0
};
sprintf
(
sql
,
...
...
@@ -414,33 +380,33 @@ void monitorSaveAcctLog(char *acctId, int64_t currentPointsPerSecond, int64_t ma
", %"
PRId64
", %"
PRId64
", %"
PRId64
", %"
PRId64
", %d)"
,
tsMonitorDbName
,
acctId
,
tsMonitorDbName
,
acctId
,
currentPointsPerSecond
,
maxPointsPerSecond
,
totalTimeSeries
,
maxTimeSeries
,
totalStorage
,
maxStorage
,
totalQueryTime
,
maxQueryTime
,
totalInbound
,
maxInbound
,
totalOutbound
,
maxOutbound
,
totalDbs
,
maxDbs
,
totalUsers
,
maxUsers
,
totalStreams
,
maxStreams
,
totalConns
,
maxConns
,
accessState
);
monitorTrace
(
"monitor:%p, save account info, sql %s"
,
monitor
->
conn
,
sql
);
taos_query_a
(
monitor
->
conn
,
sql
,
dnodeMontiorInsertAcctCallback
,
"account"
);
tsMonitorDbName
,
pMon
->
acctId
,
tsMonitorDbName
,
pMon
->
acctId
,
pMon
->
currentPointsPerSecond
,
pMon
->
maxPointsPerSecond
,
pMon
->
totalTimeSeries
,
pMon
->
maxTimeSeries
,
pMon
->
totalStorage
,
pMon
->
maxStorage
,
pMon
->
totalQueryTime
,
pMon
->
maxQueryTime
,
pMon
->
totalInbound
,
pMon
->
maxInbound
,
pMon
->
totalOutbound
,
pMon
->
maxOutbound
,
pMon
->
totalDbs
,
pMon
->
maxDbs
,
pMon
->
totalUsers
,
pMon
->
maxUsers
,
pMon
->
totalStreams
,
pMon
->
maxStreams
,
pMon
->
totalConns
,
pMon
->
maxConns
,
pMon
->
accessState
);
monitorTrace
(
"monitor:%p, save account info, sql %s"
,
tsMonitorConn
.
conn
,
sql
);
taos_query_a
(
tsMonitorConn
.
conn
,
sql
,
dnodeMontiorInsertAcctCallback
,
"account"
);
}
void
monitorSaveLog
(
int
level
,
const
char
*
const
format
,
...)
{
void
monitorSaveLog
(
int32_t
level
,
const
char
*
const
format
,
...)
{
if
(
tsMonitorConn
.
state
!=
MONITOR_STATE_INITIALIZED
)
return
;
va_list
argpointer
;
char
sql
[
SQL_LENGTH
]
=
{
0
};
int
max_length
=
SQL_LENGTH
-
30
;
int
32_t
max_length
=
SQL_LENGTH
-
30
;
if
(
monitor
->
state
!=
MONITOR_STATE_INITIALIZED
)
{
return
;
}
if
(
tsMonitorConn
.
state
!=
MONITOR_STATE_INITIALIZED
)
return
;
int
len
=
snprintf
(
sql
,
(
size_t
)
max_length
,
"import into %s.log values(%"
PRId64
", %d,'"
,
tsMonitorDbName
,
int
32_t
len
=
snprintf
(
sql
,
(
size_t
)
max_length
,
"import into %s.log values(%"
PRId64
", %d,'"
,
tsMonitorDbName
,
taosGetTimestampUs
(),
level
);
va_start
(
argpointer
,
format
);
...
...
@@ -451,11 +417,15 @@ void monitorSaveLog(int level, const char *const format, ...) {
len
+=
sprintf
(
sql
+
len
,
"', '%s')"
,
tsPrivateIp
);
sql
[
len
++
]
=
0
;
monitorTrace
(
"monitor:%p, save log, sql: %s"
,
monitor
->
conn
,
sql
);
taos_query_a
(
monitor
->
conn
,
sql
,
dnodeMontiorInsertLogCallback
,
"log"
);
monitorTrace
(
"monitor:%p, save log, sql: %s"
,
tsMonitorConn
.
conn
,
sql
);
taos_query_a
(
tsMonitorConn
.
conn
,
sql
,
dnodeMontiorInsertLogCallback
,
"log"
);
}
void
monitorExecuteSQL
(
char
*
sql
)
{
monitorTrace
(
"monitor:%p, execute sql: %s"
,
monitor
->
conn
,
sql
);
taos_query_a
(
monitor
->
conn
,
sql
,
NULL
,
NULL
);
if
(
tsMonitorConn
.
state
!=
MONITOR_STATE_INITIALIZED
)
return
;
monitorTrace
(
"monitor:%p, execute sql: %s"
,
tsMonitorConn
.
conn
,
sql
);
// bug while insert binary
// taos_query_a(tsMonitorConn.conn, sql, NULL, NULL);
}
src/tsdb/inc/tsdbMain.h
浏览文件 @
b2f17cb5
...
...
@@ -245,7 +245,7 @@ typedef struct {
int32_t
len
;
int32_t
offset
;
int32_t
hasLast
:
1
;
int32_t
numOf
Super
Blocks
:
31
;
int32_t
numOfBlocks
:
31
;
int32_t
checksum
;
TSKEY
maxKey
;
}
SCompIdx
;
/* sizeof(SCompIdx) = 24 */
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
b2f17cb5
...
...
@@ -322,12 +322,12 @@ int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols) {
if
(
tsdbWriteBlockToFile
(
pHelper
,
pWFile
,
pDataCols
,
rowsToWrite
,
&
compBlock
,
isLast
,
true
)
<
0
)
goto
_err
;
if
(
tsdbInsertSuperBlock
(
pHelper
,
&
compBlock
,
pIdx
->
numOf
Super
Blocks
)
<
0
)
goto
_err
;
if
(
tsdbInsertSuperBlock
(
pHelper
,
&
compBlock
,
pIdx
->
numOfBlocks
)
<
0
)
goto
_err
;
}
else
{
// (Has old data) AND ((has last block) OR (key overlap)), need to merge the block
SCompBlock
*
pCompBlock
=
taosbsearch
((
void
*
)(
&
keyFirst
),
(
void
*
)(
pHelper
->
pCompInfo
->
blocks
),
pIdx
->
numOf
Super
Blocks
,
sizeof
(
SCompBlock
),
compareKeyBlock
,
TD_GE
);
pIdx
->
numOfBlocks
,
sizeof
(
SCompBlock
),
compareKeyBlock
,
TD_GE
);
int
blkIdx
=
(
pCompBlock
==
NULL
)
?
(
pIdx
->
numOf
Super
Blocks
-
1
)
:
(
pCompBlock
-
pHelper
->
pCompInfo
->
blocks
);
int
blkIdx
=
(
pCompBlock
==
NULL
)
?
(
pIdx
->
numOfBlocks
-
1
)
:
(
pCompBlock
-
pHelper
->
pCompInfo
->
blocks
);
if
(
pCompBlock
==
NULL
)
{
// No key overlap, must has last block, just merge with the last block
ASSERT
(
pIdx
->
hasLast
&&
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfSuperBlocks
-
1
].
last
);
...
...
@@ -362,18 +362,18 @@ int tsdbMoveLastBlockIfNeccessary(SRWHelper *pHelper) {
if
((
pHelper
->
files
.
nLastF
.
fd
>
0
)
&&
(
pHelper
->
hasOldLastBlock
))
{
if
(
tsdbLoadCompInfo
(
pHelper
,
NULL
)
<
0
)
return
-
1
;
SCompBlock
*
pCompBlock
=
pHelper
->
pCompInfo
->
blocks
+
pIdx
->
numOf
Super
Blocks
-
1
;
SCompBlock
*
pCompBlock
=
pHelper
->
pCompInfo
->
blocks
+
pIdx
->
numOfBlocks
-
1
;
ASSERT
(
pCompBlock
->
last
);
if
(
pCompBlock
->
numOfSubBlocks
>
1
)
{
if
(
tsdbLoadBlockData
(
pHelper
,
blockAtIdx
(
pHelper
,
pIdx
->
numOf
Super
Blocks
-
1
),
NULL
)
<
0
)
return
-
1
;
if
(
tsdbLoadBlockData
(
pHelper
,
blockAtIdx
(
pHelper
,
pIdx
->
numOfBlocks
-
1
),
NULL
)
<
0
)
return
-
1
;
ASSERT
(
pHelper
->
pDataCols
[
0
]
->
numOfPoints
>
0
&&
pHelper
->
pDataCols
[
0
]
->
numOfPoints
<
pHelper
->
config
.
minRowsPerFileBlock
);
if
(
tsdbWriteBlockToFile
(
pHelper
,
&
(
pHelper
->
files
.
nLastF
),
pHelper
->
pDataCols
[
0
],
pHelper
->
pDataCols
[
0
]
->
numOfPoints
,
&
compBlock
,
true
,
true
)
<
0
)
return
-
1
;
if
(
tsdbUpdateSuperBlock
(
pHelper
,
&
compBlock
,
pIdx
->
numOf
Super
Blocks
-
1
)
<
0
)
return
-
1
;
if
(
tsdbUpdateSuperBlock
(
pHelper
,
&
compBlock
,
pIdx
->
numOfBlocks
-
1
)
<
0
)
return
-
1
;
}
else
{
if
(
lseek
(
pHelper
->
files
.
lastF
.
fd
,
pCompBlock
->
offset
,
SEEK_SET
)
<
0
)
return
-
1
;
...
...
@@ -827,7 +827,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
ASSERT
(
keyFirst
<=
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyLast
);
TSKEY
keyLimit
=
(
blkIdx
==
pIdx
->
numOf
Super
Blocks
-
1
)
?
INT64_MAX
:
pHelper
->
pCompInfo
->
blocks
[
blkIdx
+
1
].
keyFirst
-
1
;
(
blkIdx
==
pIdx
->
numOfBlocks
-
1
)
?
INT64_MAX
:
pHelper
->
pCompInfo
->
blocks
[
blkIdx
+
1
].
keyFirst
-
1
;
// rows1: number of rows must merge in this block
int
rows1
=
tsdbGetRowsInRange
(
pDataCols
,
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyFirst
,
blockAtIdx
(
pHelper
,
blkIdx
)
->
keyLast
);
...
...
@@ -969,7 +969,7 @@ static int tsdbInsertSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
if
(
tsdbAdjustInfoSizeIfNeeded
(
pHelper
,
pIdx
->
len
+
sizeof
(
SCompInfo
))
<
0
)
goto
_err
;
// Change the offset
for
(
int
i
=
0
;
i
<
pIdx
->
numOf
Super
Blocks
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pIdx
->
numOfBlocks
;
i
++
)
{
SCompBlock
*
pTCompBlock
=
&
pHelper
->
pCompInfo
->
blocks
[
i
];
if
(
pTCompBlock
->
numOfSubBlocks
>
1
)
pTCompBlock
->
offset
+=
sizeof
(
SCompBlock
);
}
...
...
@@ -984,13 +984,13 @@ static int tsdbInsertSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
}
pHelper
->
pCompInfo
->
blocks
[
blkIdx
]
=
*
pCompBlock
;
pIdx
->
numOf
Super
Blocks
++
;
pIdx
->
numOfBlocks
++
;
pIdx
->
len
+=
sizeof
(
SCompBlock
);
ASSERT
(
pIdx
->
len
<=
tsizeof
(
pHelper
->
pCompInfo
));
pIdx
->
maxKey
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOf
Super
Blocks
-
1
].
keyLast
;
pIdx
->
hasLast
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOf
Super
Blocks
-
1
].
last
;
pIdx
->
maxKey
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfBlocks
-
1
].
keyLast
;
pIdx
->
hasLast
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfBlocks
-
1
].
last
;
if
(
pIdx
->
numOf
Super
Blocks
>
1
)
{
if
(
pIdx
->
numOfBlocks
>
1
)
{
ASSERT
(
pHelper
->
pCompInfo
->
blocks
[
0
].
keyLast
<
pHelper
->
pCompInfo
->
blocks
[
1
].
keyFirst
);
}
...
...
@@ -1022,7 +1022,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
memmove
((
void
*
)((
char
*
)(
pHelper
->
pCompInfo
)
+
pSCompBlock
->
offset
+
pSCompBlock
->
len
+
sizeof
(
SCompBlock
)),
(
void
*
)((
char
*
)(
pHelper
->
pCompInfo
)
+
pSCompBlock
->
offset
+
pSCompBlock
->
len
),
tsize
);
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOf
Super
Blocks
;
i
++
)
{
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOfBlocks
;
i
++
)
{
SCompBlock
*
pTCompBlock
=
&
pHelper
->
pCompInfo
->
blocks
[
i
];
if
(
pTCompBlock
->
numOfSubBlocks
>
1
)
pTCompBlock
->
offset
+=
sizeof
(
SCompBlock
);
}
...
...
@@ -1040,7 +1040,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
pIdx
->
len
+=
sizeof
(
SCompBlock
);
}
else
{
// Need to create two sub-blocks
void
*
ptr
=
NULL
;
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOf
Super
Blocks
;
i
++
)
{
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOfBlocks
;
i
++
)
{
SCompBlock
*
pTCompBlock
=
pHelper
->
pCompInfo
->
blocks
+
i
;
if
(
pTCompBlock
->
numOfSubBlocks
>
1
)
{
ptr
=
(
void
*
)((
char
*
)(
pHelper
->
pCompInfo
)
+
pTCompBlock
->
offset
+
pTCompBlock
->
len
);
...
...
@@ -1053,7 +1053,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
size_t
tsize
=
pIdx
->
len
-
((
char
*
)
ptr
-
(
char
*
)(
pHelper
->
pCompInfo
));
if
(
tsize
>
0
)
{
memmove
((
void
*
)((
char
*
)
ptr
+
sizeof
(
SCompBlock
)
*
2
),
ptr
,
tsize
);
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOf
Super
Blocks
;
i
++
)
{
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOfBlocks
;
i
++
)
{
SCompBlock
*
pTCompBlock
=
pHelper
->
pCompInfo
->
blocks
+
i
;
if
(
pTCompBlock
->
numOfSubBlocks
>
1
)
pTCompBlock
->
offset
+=
(
sizeof
(
SCompBlock
)
*
2
);
}
...
...
@@ -1074,8 +1074,8 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
pIdx
->
len
+=
(
sizeof
(
SCompBlock
)
*
2
);
}
pIdx
->
maxKey
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOf
Super
Blocks
-
1
].
keyLast
;
pIdx
->
hasLast
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOf
Super
Blocks
-
1
].
last
;
pIdx
->
maxKey
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfBlocks
-
1
].
keyLast
;
pIdx
->
hasLast
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfBlocks
-
1
].
last
;
return
0
;
...
...
@@ -1102,7 +1102,7 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
(
void
*
)((
char
*
)(
pHelper
->
pCompInfo
)
+
pSCompBlock
->
offset
+
pSCompBlock
->
len
),
tsize
);
}
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOf
Super
Blocks
;
i
++
)
{
for
(
int
i
=
blkIdx
+
1
;
i
<
pIdx
->
numOfBlocks
;
i
++
)
{
SCompBlock
*
pTCompBlock
=
&
pHelper
->
pCompInfo
->
blocks
[
i
];
if
(
pTCompBlock
->
numOfSubBlocks
>
1
)
pTCompBlock
->
offset
-=
(
sizeof
(
SCompBlock
)
*
pSCompBlock
->
numOfSubBlocks
);
}
...
...
@@ -1112,8 +1112,8 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
*
pSCompBlock
=
*
pCompBlock
;
pIdx
->
maxKey
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOf
Super
Blocks
-
1
].
keyLast
;
pIdx
->
hasLast
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOf
Super
Blocks
-
1
].
last
;
pIdx
->
maxKey
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfBlocks
-
1
].
keyLast
;
pIdx
->
hasLast
=
pHelper
->
pCompInfo
->
blocks
[
pIdx
->
numOfBlocks
-
1
].
last
;
return
0
;
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
b2f17cb5
...
...
@@ -301,7 +301,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pQueryHandle
->
pTableCheckInfo
,
i
);
SCompIdx
*
compIndex
=
&
pQueryHandle
->
rhelper
.
pCompIdx
[
pCheckInfo
->
tableId
.
tid
];
if
(
compIndex
->
len
==
0
||
compIndex
->
numOf
Super
Blocks
==
0
)
{
// no data block in this file, try next file
if
(
compIndex
->
len
==
0
||
compIndex
->
numOfBlocks
==
0
)
{
// no data block in this file, try next file
continue
;
//no data blocks in the file belongs to pCheckInfo->pTable
}
else
{
if
(
pCheckInfo
->
compSize
<
compIndex
->
len
)
{
...
...
@@ -327,7 +327,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
TSKEY
e
=
MAX
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
// discard the unqualified data block based on the query time window
int32_t
start
=
binarySearchForBlockImpl
(
pCompInfo
->
blocks
,
compIndex
->
numOf
Super
Blocks
,
s
,
TSDB_ORDER_ASC
);
int32_t
start
=
binarySearchForBlockImpl
(
pCompInfo
->
blocks
,
compIndex
->
numOfBlocks
,
s
,
TSDB_ORDER_ASC
);
int32_t
end
=
start
;
if
(
s
>
pCompInfo
->
blocks
[
start
].
keyLast
)
{
...
...
@@ -335,7 +335,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
}
// todo speedup the procedure of located end block
while
(
end
<
compIndex
->
numOf
Super
Blocks
&&
(
pCompInfo
->
blocks
[
end
].
keyFirst
<=
e
))
{
while
(
end
<
compIndex
->
numOfBlocks
&&
(
pCompInfo
->
blocks
[
end
].
keyFirst
<=
e
))
{
end
+=
1
;
}
...
...
src/vnode/inc/vnodeLog.h
浏览文件 @
b2f17cb5
...
...
@@ -39,10 +39,6 @@ extern int32_t ddebugFlag;
#define dPrint(...) \
{ taosPrintLog("DND ", 255, __VA_ARGS__); }
#define dLError(...) taosLogError(__VA_ARGS__) dError(__VA_ARGS__)
#define dLWarn(...) taosLogWarn(__VA_ARGS__) dWarn(__VA_ARGS__)
#define dLPrint(...) taosLogPrint(__VA_ARGS__) dPrint(__VA_ARGS__)
#ifdef __cplusplus
}
#endif
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
b2f17cb5
...
...
@@ -332,6 +332,9 @@ static void vnodeBuildVloadMsg(char *pNode, void * param) {
SVnodeLoad
*
pLoad
=
&
pStatus
->
load
[
pStatus
->
openVnodes
++
];
pLoad
->
vgId
=
htonl
(
pVnode
->
vgId
);
pLoad
->
totalStorage
=
htobe64
(
pLoad
->
totalStorage
);
pLoad
->
compStorage
=
htobe64
(
pLoad
->
compStorage
);
pLoad
->
pointsWritten
=
htobe64
(
pLoad
->
pointsWritten
);
pLoad
->
status
=
pVnode
->
status
;
pLoad
->
role
=
pVnode
->
role
;
pLoad
->
replica
=
pVnode
->
syncCfg
.
replica
;
...
...
tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
浏览文件 @
b2f17cb5
...
...
@@ -118,7 +118,7 @@
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.9.10.
3
</version>
<version>
2.9.10.
4
</version>
</dependency>
<dependency>
...
...
tests/script/general/http/restful.sim
浏览文件 @
b2f17cb5
...
...
@@ -77,8 +77,8 @@ if $system_content != @{"status":"succ","code":0,"desc":"jIlItaLFFIPa8qdtNZmtONr
return -1
endi
system_content curl 127.0.0.1:6020/rest/login/u2/abcd_1234
system_content curl 127.0.0.1:6020/rest/login/u2/a
a
bcd_1234
print curl 127.0.0.1:6020/rest/login/u2/abcd_1234 -----> $system_content
if $system_content != @{"status":"
succ","code":0,"desc":"AZH3lNvWZiLa8qdtNZmtONryp201ma04QExCHYkbFFQB/46k1gwnPNryp201ma04
"}@ then
if $system_content != @{"status":"
error","code":1000,"desc":"auth failure
"}@ then
return -1
endi
tests/script/general/http/restful_full.sim
浏览文件 @
b2f17cb5
system sh/stop_dnodes.sh
sleep 5000
#
sleep 5000
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec.sh -n dnode1 -s start
sleep 3000
#
sleep 3000
sql connect
print ============================ dnode1 start
...
...
@@ -41,19 +41,19 @@ endi
system_content curl 192.168.0.1:6020/rest/login/root/123
print 5-> $system_content
if $system_content != @{"status":"error","code":10
,"desc":"authentication
failure"}@ then
if $system_content != @{"status":"error","code":10
00,"desc":"auth
failure"}@ then
return -1
endi
system_content curl 192.168.0.1:6020/rest/login/root/123/1/1/3
print 6-> $system_content
if $system_content != @{"status":"error","code":10
,"desc":"authentication
failure"}@ then
if $system_content != @{"status":"error","code":10
00,"desc":"auth
failure"}@ then
return -1
endi
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 192.168.0.1:6020/rest/login/root/1
print 7-> $system_content
if $system_content != @{"status":"error","code":10
,"desc":"authentication
failure"}@ then
if $system_content != @{"status":"error","code":10
00,"desc":"auth
failure"}@ then
return -1
endi
...
...
tests/script/general/http/testSuite.sim
浏览文件 @
b2f17cb5
run general/http/grafana.sim
run general/http/restful.sim
run general/http/restful_full.sim
run general/http/telegraf.sim
run general/http/prepare.sim
run general/http/grafana_bug.sim
#run general/http/opentsdb
.sim
run general/http/grafana
.sim
tests/script/sh/deploy.sh
浏览文件 @
b2f17cb5
...
...
@@ -93,10 +93,10 @@ echo "privateIp $NODE_IP" >> $TAOS_CFG
echo
"dDebugFlag 199"
>>
$TAOS_CFG
echo
"mDebugFlag 199"
>>
$TAOS_CFG
echo
"sdbDebugFlag 199"
>>
$TAOS_CFG
echo
"rpcDebugFlag 13
5
"
>>
$TAOS_CFG
echo
"rpcDebugFlag 13
1
"
>>
$TAOS_CFG
echo
"tmrDebugFlag 131"
>>
$TAOS_CFG
echo
"cDebugFlag 135"
>>
$TAOS_CFG
echo
"httpDebugFlag 13
1
"
>>
$TAOS_CFG
echo
"httpDebugFlag 13
5
"
>>
$TAOS_CFG
echo
"monitorDebugFlag 131"
>>
$TAOS_CFG
echo
"udebugFlag 131"
>>
$TAOS_CFG
echo
"jnidebugFlag 131"
>>
$TAOS_CFG
...
...
tests/script/unique/account/account_delete.sim
浏览文件 @
b2f17cb5
...
...
@@ -59,10 +59,17 @@ endi
sql drop account oroot
print ============= step4
sleep 2000
sql show dnodes
if $data02 != 0 then
$x = 0
show4:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
if $data03 != 0 then
goto show4
endi
print ============= step5
...
...
tests/script/unique/account/basic.sim
浏览文件 @
b2f17cb5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/exec_up
_up
.sh -n dnode1 -s start
system sh/exec_up.sh -n dnode1 -s start
sql connect
print =============== show accounts
...
...
tests/script/unique/account/monitor.sim
已删除
100644 → 0
浏览文件 @
25e13520
system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c monitor -v 0
print ========== step1
system sh/cfg.sh -n dnode1 -c monitor -v 1
system sh/cfg.sh -n dnode1 -c monitorInterval -v 1
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
print ========== step2
sql drop database log -x step21
return -1
step21:
sql drop table log.cpu -x step22
return -1
step22:
sql drop user log -x step23
return -1
step23:
print ========== step3
sleep 3000
sql select * from log.dn
if $rows == 0 then
return -1
endi
tests/script/unique/account/paras.sim
浏览文件 @
b2f17cb5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/exec_up
_up
.sh -n dnode1 -s start
system sh/exec_up.sh -n dnode1 -s start
sql connect
print =============== show accounts
...
...
tests/script/unique/account/testSuite.sim
浏览文件 @
b2f17cb5
...
...
@@ -6,4 +6,7 @@ run unique/account/pass_len.sim
run unique/account/user_create.sim
run unique/account/user_len.sim
run unique/account/authority.sim
run unique/account/basic.sim
run unique/account/paras.sim
run unique/account/usage.sim
run unique/account/monitor.sim
tests/script/unique/account/usage.sim
浏览文件 @
b2f17cb5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/exec_up
_up
.sh -n dnode1 -s start
system sh/exec_up.sh -n dnode1 -s start
sql connect
print =============== show accounts
...
...
tests/script/
general
/http/opentsdb.sim
→
tests/script/
unique
/http/opentsdb.sim
浏览文件 @
b2f17cb5
文件已移动
tests/script/unique/http/testSuite.sim
浏览文件 @
b2f17cb5
run unique/http/admin.sim
#run general/http/opentsdb.sim
\ No newline at end of file
tests/script/unique/mnode/mgmt33.sim
浏览文件 @
b2f17cb5
...
...
@@ -116,7 +116,7 @@ sleep 8000
sql show mnodes
$dnode1Role = $data3_1
$dnode2Role = $data3_
2
$dnode2Role = $data3_
4
$dnode3Role = $data3_3
print 192.168.0.1 ==> $dnode1Role
print 192.168.0.2 ==> $dnode2Role
...
...
@@ -138,13 +138,13 @@ sleep 10000
sql show mnodes
$dnode1Role = $data3_1
$dnode2Role = $data3_
2
$dnode2Role = $data3_
4
$dnode3Role = $data3_3
print 192.168.0.1 ==> $dnode1Role
print 192.168.0.2 ==> $dnode2Role
print 192.168.0.3 ==> $dnode3Role
if $dnode1Role !=
undecided
then
if $dnode1Role !=
offline
then
return -1
endi
#if $dnode2Role != master then
...
...
tests/script/unique/mnode/mgmt34.sim
浏览文件 @
b2f17cb5
...
...
@@ -183,7 +183,7 @@ endi
print ============== step7
system sh/exec_up.sh -n dnode1 -s stop
sleep
10
000
sleep
4
000
sql show mnodes
$dnode1Role = $data3_1
...
...
@@ -195,7 +195,7 @@ print 192.168.0.2 ==> $dnode2Role
print 192.168.0.3 ==> $dnode3Role
print 192.168.0.4 ==> $dnode4Role
if $dnode1Role !=
undecided
then
if $dnode1Role !=
offline
then
return -1
endi
...
...
@@ -205,7 +205,7 @@ sleep 8000
sql show mnodes
$dnode1Role = $data3_1
$dnode2Role = $data3_
2
$dnode2Role = $data3_
5
$dnode3Role = $data3_3
$dnode4Role = $data3_4
print 192.168.0.1 ==> $dnode1Role
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录