Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7d658025
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,发现更多精彩内容 >>
提交
7d658025
编写于
4月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: refact shell arguments
上级
cf433ec9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
68 deletion
+70
-68
source/dnode/mgmt/implement/src/dmTransport.c
source/dnode/mgmt/implement/src/dmTransport.c
+1
-0
source/dnode/mgmt/interface/src/dmInt.c
source/dnode/mgmt/interface/src/dmInt.c
+6
-4
tools/shell/src/shellMain.c
tools/shell/src/shellMain.c
+63
-64
未找到文件。
source/dnode/mgmt/implement/src/dmTransport.c
浏览文件 @
7d658025
...
@@ -505,6 +505,7 @@ static void dmCleanupServer(SDnode *pDnode) {
...
@@ -505,6 +505,7 @@ static void dmCleanupServer(SDnode *pDnode) {
int32_t
dmInitTrans
(
SDnode
*
pDnode
)
{
int32_t
dmInitTrans
(
SDnode
*
pDnode
)
{
if
(
dmInitServer
(
pDnode
)
!=
0
)
return
-
1
;
if
(
dmInitServer
(
pDnode
)
!=
0
)
return
-
1
;
if
(
dmInitClient
(
pDnode
)
!=
0
)
return
-
1
;
if
(
dmInitClient
(
pDnode
)
!=
0
)
return
-
1
;
dmReportStartup
(
pDnode
,
"transport"
,
"initialized"
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/interface/src/dmInt.c
浏览文件 @
7d658025
...
@@ -154,10 +154,12 @@ static void dmGetServerStatus(SDnode *pDnode, SServerStatusRsp *pStatus) {
...
@@ -154,10 +154,12 @@ static void dmGetServerStatus(SDnode *pDnode, SServerStatusRsp *pStatus) {
if
(
pStatus
->
statusCode
==
TSDB_SRV_STATUS_NETWORK_OK
)
{
if
(
pStatus
->
statusCode
==
TSDB_SRV_STATUS_NETWORK_OK
)
{
SStartupInfo
*
pStartup
=
&
pDnode
->
startup
;
SStartupInfo
*
pStartup
=
&
pDnode
->
startup
;
int32_t
len
=
strlen
(
pStartup
->
name
)
+
strlen
(
pStartup
->
desc
)
+
24
;
int32_t
len
=
strlen
(
pStartup
->
name
)
+
strlen
(
pStartup
->
desc
);
pStatus
->
details
=
taosMemoryCalloc
(
1
,
len
);
if
(
len
>
0
)
{
if
(
pStatus
->
details
!=
NULL
)
{
pStatus
->
details
=
taosMemoryCalloc
(
1
,
len
+
24
);
pStatus
->
detailLen
=
snprintf
(
pStatus
->
details
,
len
-
1
,
"%s: %s"
,
pStartup
->
name
,
pStartup
->
desc
)
+
1
;
if
(
pStatus
->
details
!=
NULL
)
{
pStatus
->
detailLen
=
snprintf
(
pStatus
->
details
,
len
+
20
,
"%s: %s"
,
pStartup
->
name
,
pStartup
->
desc
)
+
1
;
}
}
}
}
}
...
...
tools/shell/src/shellMain.c
浏览文件 @
7d658025
...
@@ -531,10 +531,10 @@ void showOnScreen(Command *cmd) {
...
@@ -531,10 +531,10 @@ void showOnScreen(Command *cmd) {
void
cleanup_handler
(
void
*
arg
)
{
resetTerminalMode
();
}
void
cleanup_handler
(
void
*
arg
)
{
resetTerminalMode
();
}
void
exitShell
()
{
void
exitShell
()
{
/*int32_t ret =*/
resetTerminalMode
();
taos_cleanup
();
taos_cleanup
();
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
void
shellQueryInterruptHandler
(
int32_t
signum
,
void
*
sigInfo
,
void
*
context
)
{
tsem_post
(
&
cancelSem
);
}
void
shellQueryInterruptHandler
(
int32_t
signum
,
void
*
sigInfo
,
void
*
context
)
{
tsem_post
(
&
cancelSem
);
}
void
*
cancelHandler
(
void
*
arg
)
{
void
*
cancelHandler
(
void
*
arg
)
{
...
@@ -546,21 +546,9 @@ void *cancelHandler(void *arg) {
...
@@ -546,21 +546,9 @@ void *cancelHandler(void *arg) {
continue
;
continue
;
}
}
#ifdef LINUX
#if 0
int64_t rid = atomic_val_compare_exchange_64(&result, result, 0);
SSqlObj* pSql = taosAcquireRef(tscObjRef, rid);
taos_stop_query(pSql);
taosReleaseRef(tscObjRef, rid);
#endif
#else
resetTerminalMode
();
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
exit
(
0
);
#endif
resetTerminalMode
();
resetTerminalMode
();
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
exit
(
0
);
exit
Shell
(
);
}
}
return
NULL
;
return
NULL
;
...
@@ -587,52 +575,53 @@ int checkVersion() {
...
@@ -587,52 +575,53 @@ int checkVersion() {
}
}
// Global configurations
// Global configurations
SShellArguments
args
=
{.
host
=
NULL
,
SShellArguments
args
=
{
.
host
=
NULL
,
.
user
=
NULL
,
.
database
=
NULL
,
.
timezone
=
NULL
,
.
is_raw_time
=
false
,
.
is_use_passwd
=
false
,
.
dump_config
=
false
,
.
file
=
"
\0
"
,
.
dir
=
"
\0
"
,
.
threadNum
=
5
,
.
commands
=
NULL
,
.
pktLen
=
1000
,
.
pktNum
=
100
,
.
pktType
=
"TCP"
,
.
netTestRole
=
NULL
,
#ifndef TD_WINDOWS
#ifndef TD_WINDOWS
.
password
=
NULL
,
.
password
=
NULL
,
#endif
#endif
.
user
=
NULL
,
};
.
database
=
NULL
,
.
timezone
=
NULL
,
.
is_raw_time
=
false
,
.
is_use_passwd
=
false
,
.
dump_config
=
false
,
.
file
=
"
\0
"
,
.
dir
=
"
\0
"
,
.
threadNum
=
5
,
.
commands
=
NULL
,
.
pktLen
=
1000
,
.
pktNum
=
100
,
.
pktType
=
"TCP"
,
.
netTestRole
=
NULL
};
/*
void
shellDumpConfig
()
{
* Main function.
if
(
!
args
.
dump_config
)
return
;
*/
int
main
(
int
argc
,
char
*
argv
[])
{
/*setlocale(LC_ALL, "en_US.UTF-8"); */
if
(
!
checkVersion
())
{
SConfig
*
pCfg
=
taosGetCfg
();
if
(
NULL
==
pCfg
)
{
printf
(
"TDengine read global config failed!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
cfgDumpCfg
(
pCfg
,
0
,
1
);
exitShell
();
}
shellParseArgument
(
argc
,
argv
,
&
args
);
void
shellTestNetWork
()
{
taos_init
();
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
,
args
.
pktNum
,
args
.
pktType
);
if
(
args
.
dump_config
)
{
exitShell
();
SConfig
*
pCfg
=
taosGetCfg
();
if
(
NULL
==
pCfg
)
{
printf
(
"TDengine read global config failed!
\n
"
);
exit
(
EXIT_FAILURE
);
}
cfgDumpCfg
(
pCfg
,
0
,
1
);
exit
(
0
);
}
}
}
if
(
args
.
status
||
args
.
verbose
)
{
void
shellCheckServerStatus
()
{
char
details
[
1024
]
=
{
0
};
if
(
!
args
.
status
&&
!
args
.
verbose
)
return
;
char
details
[
1024
]
=
{
0
};
TSDB_SERVER_STATUS
code
=
taos_check_server_status
(
args
.
host
,
args
.
port
,
details
,
args
.
verbose
?
1024
:
0
);
TSDB_SERVER_STATUS
code
;
do
{
code
=
taos_check_server_status
(
args
.
host
,
args
.
port
,
details
,
args
.
verbose
?
1024
:
0
);
switch
(
code
)
{
switch
(
code
)
{
case
TSDB_SRV_STATUS_UNAVAILABLE
:
case
TSDB_SRV_STATUS_UNAVAILABLE
:
printf
(
"0: unavailable
\n
"
);
printf
(
"0: unavailable
\n
"
);
...
@@ -650,44 +639,54 @@ int main(int argc, char *argv[]) {
...
@@ -650,44 +639,54 @@ int main(int argc, char *argv[]) {
printf
(
"4: exiting
\n
"
);
printf
(
"4: exiting
\n
"
);
break
;
break
;
}
}
if
(
strlen
(
details
)
!=
0
)
{
if
(
strlen
(
details
)
!=
0
)
{
printf
(
"
detail info:
\n
%s
\n
"
,
details
);
printf
(
"
%s
\n
\n
"
,
details
);
}
}
exit
(
0
);
if
(
code
==
TSDB_SRV_STATUS_NETWORK_OK
)
{
}
taosMsleep
(
1000
);
}
}
while
(
code
==
TSDB_SRV_STATUS_NETWORK_OK
);
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
exitShell
();
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
,
args
.
pktNum
,
args
.
pktType
);
}
exit
(
0
);
}
/* Initialize the shell */
void
shellExecute
()
{
TAOS
*
con
=
shellInit
(
&
args
);
TAOS
*
con
=
shellInit
(
&
args
);
if
(
con
==
NULL
)
{
if
(
con
==
NULL
)
{
exit
(
EXIT_FAILURE
);
exit
Shell
(
);
}
}
if
(
tsem_init
(
&
cancelSem
,
0
,
0
)
!=
0
)
{
if
(
tsem_init
(
&
cancelSem
,
0
,
0
)
!=
0
)
{
printf
(
"failed to create cancel semphore
\n
"
);
printf
(
"failed to create cancel semphore
\n
"
);
exit
(
EXIT_FAILURE
);
exit
Shell
(
);
}
}
TdThread
spid
;
TdThread
spid
;
taosThreadCreate
(
&
spid
,
NULL
,
cancelHandler
,
NULL
);
taosThreadCreate
(
&
spid
,
NULL
,
cancelHandler
,
NULL
);
/* Interrupt handler. */
taosSetSignal
(
SIGTERM
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGTERM
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGINT
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGINT
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGHUP
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGHUP
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGABRT
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGABRT
,
shellQueryInterruptHandler
);
/* Get grant information */
shellGetGrantInfo
(
con
);
shellGetGrantInfo
(
con
);
/* Loop to query the input. */
while
(
1
)
{
while
(
1
)
{
taosThreadCreate
(
&
pid
,
NULL
,
shellLoopQuery
,
con
);
taosThreadCreate
(
&
pid
,
NULL
,
shellLoopQuery
,
con
);
taosThreadJoin
(
pid
,
NULL
);
taosThreadJoin
(
pid
,
NULL
);
}
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
!
checkVersion
())
exitShell
();
shellParseArgument
(
argc
,
argv
,
&
args
);
taos_init
();
shellDumpConfig
();
shellCheckServerStatus
();
shellTestNetWork
();
shellExecute
();
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录