Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
de09879d
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
de09879d
编写于
1月 15, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1207
上级
8a9ed8e2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
159 addition
and
123 deletion
+159
-123
src/dnode/src/dnodeSystem.c
src/dnode/src/dnodeSystem.c
+31
-42
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+1
-1
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+11
-1
src/os/src/linux/linuxEnv.c
src/os/src/linux/linuxEnv.c
+6
-9
src/os/src/windows/wSysinfo.c
src/os/src/windows/wSysinfo.c
+97
-57
src/sync/src/syncArbitrator.c
src/sync/src/syncArbitrator.c
+13
-13
未找到文件。
src/dnode/src/dnodeSystem.c
浏览文件 @
de09879d
...
...
@@ -19,43 +19,9 @@
#include "tconfig.h"
#include "dnodeMain.h"
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
tsem_t
exitSem
;
#ifdef WINDOWS
static
void
signal_handler
(
int32_t
signum
)
{
dInfo
(
"shut down signal is %d"
,
signum
);
#else
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
if
(
signum
==
SIGUSR1
)
{
taosCfgDynamicOptions
(
"debugFlag 143"
);
return
;
}
if
(
signum
==
SIGUSR2
)
{
taosCfgDynamicOptions
(
"resetlog"
);
return
;
}
dInfo
(
"shut down signal is %d, sender PID:%d cmdline:%s"
,
signum
,
sigInfo
->
si_pid
,
taosGetCmdlineByPID
(
sigInfo
->
si_pid
));
#endif
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
// protect the application from receive another signal
struct
sigaction
act
=
{{
0
}};
act
.
sa_handler
=
SIG_IGN
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
#ifndef WINDOWS
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR2
,
&
act
,
NULL
);
#endif
// inform main thread to exit
tsem_post
(
&
exitSem
);
}
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
int
dump_config
=
0
;
...
...
@@ -147,8 +113,6 @@ int32_t main(int32_t argc, char *argv[]) {
/* Set termination handler. */
struct
sigaction
act
=
{{
0
}};
#ifndef WINDOWS
act
.
sa_flags
=
SA_SIGINFO
;
act
.
sa_sigaction
=
signal_handler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
...
...
@@ -156,11 +120,6 @@ int32_t main(int32_t argc, char *argv[]) {
sigaction
(
SIGINT
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR2
,
&
act
,
NULL
);
#else
act
.
sa_handler
=
signal_handler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
#endif
// Open /var/log/syslog file to record information.
openlog
(
"TDengine:"
,
LOG_PID
|
LOG_CONS
|
LOG_NDELAY
,
LOG_LOCAL1
);
...
...
@@ -187,3 +146,33 @@ int32_t main(int32_t argc, char *argv[]) {
closelog
();
return
EXIT_SUCCESS
;
}
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
if
(
signum
==
SIGUSR1
)
{
taosCfgDynamicOptions
(
"debugFlag 143"
);
return
;
}
if
(
signum
==
SIGUSR2
)
{
taosCfgDynamicOptions
(
"resetlog"
);
return
;
}
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
// clean the system.
dInfo
(
"shut down signal is %d, sender PID:%d cmdline:%s"
,
signum
,
sigInfo
->
si_pid
,
taosGetCmdlineByPID
(
sigInfo
->
si_pid
));
// protect the application from receive another signal
struct
sigaction
act
=
{{
0
}};
#ifndef WINDOWS
act
.
sa_handler
=
SIG_IGN
;
#endif
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR2
,
&
act
,
NULL
);
// inform main thread to exit
tsem_post
(
&
exitSem
);
}
\ No newline at end of file
src/kit/shell/src/shellMain.c
浏览文件 @
de09879d
...
...
@@ -21,7 +21,7 @@
pthread_t
pid
;
static
tsem_t
cancelSem
;
void
shellQueryInterruptHandler
(
int32_t
signum
)
{
void
shellQueryInterruptHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
tsem_post
(
&
cancelSem
);
}
...
...
src/os/inc/osWindows.h
浏览文件 @
de09879d
...
...
@@ -193,9 +193,19 @@ int gettimeofday(struct timeval *ptv, void *pTimeZone);
//for signal, not dispose
#define SIGALRM 1234
#define SIGHUP 1234
#define SIGUSR1 1234
#define SIGUSR2 1234
#define SA_SIGINFO 1234
typedef
int
sigset_t
;
typedef
struct
siginfo_t
{
int
si_pid
;
}
siginfo_t
;
struct
sigaction
{
void
(
*
sa_handler
)(
int
);
int
sa_flags
;
void
(
*
sa_handler
)(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
void
(
*
sa_sigaction
)(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
};
int
sigaction
(
int
,
struct
sigaction
*
,
void
*
);
...
...
src/os/src/linux/linuxEnv.c
浏览文件 @
de09879d
...
...
@@ -18,7 +18,6 @@
#include "tglobal.h"
void
osInit
()
{
#ifdef _TD_POWER_
if
(
configDir
[
0
]
==
0
)
{
strcpy
(
configDir
,
"/etc/power"
);
...
...
@@ -43,16 +42,14 @@ void osInit() {
char
cmdline
[
1024
];
char
*
taosGetCmdlineByPID
(
int
pid
)
{
sprintf
(
cmdline
,
"/proc/%d/cmdline"
,
pid
);
FILE
*
f
=
fopen
(
cmdline
,
"r"
);
if
(
f
){
char
*
taosGetCmdlineByPID
(
int
pid
)
{
sprintf
(
cmdline
,
"/proc/%d/cmdline"
,
pid
);
FILE
*
f
=
fopen
(
cmdline
,
"r"
);
if
(
f
)
{
size_t
size
;
size
=
fread
(
cmdline
,
sizeof
(
char
),
1024
,
f
);
if
(
size
>
0
){
if
(
'\n'
==
cmdline
[
size
-
1
])
cmdline
[
size
-
1
]
=
'\0'
;
if
(
size
>
0
)
{
if
(
'\n'
==
cmdline
[
size
-
1
])
cmdline
[
size
-
1
]
=
'\0'
;
}
fclose
(
f
);
}
...
...
src/os/src/windows/wSysinfo.c
浏览文件 @
de09879d
...
...
@@ -32,10 +32,51 @@
#endif
#pragma warning(push)
#pragma warning(disable
:
4091)
#pragma warning(disable
:
4091)
#include <DbgHelp.h>
#pragma warning(pop)
static
int32_t
taosGetTotalMemory
()
{
MEMORYSTATUSEX
memsStat
;
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
0
;
}
float
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
return
(
int32_t
)
nMemTotal
;
}
bool
taosGetSysMemory
(
float
*
memoryUsedMB
)
{
MEMORYSTATUSEX
memsStat
;
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
false
;
}
float
nMemFree
=
memsStat
.
ullAvailPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
float
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
*
memoryUsedMB
=
nMemTotal
-
nMemFree
;
return
true
;
}
bool
taosGetProcMemory
(
float
*
memoryUsedMB
)
{
unsigned
bytes_used
=
0
;
#if defined(_WIN32) && defined(_MSC_VER)
PROCESS_MEMORY_COUNTERS
pmc
;
HANDLE
cur_proc
=
GetCurrentProcess
();
if
(
GetProcessMemoryInfo
(
cur_proc
,
&
pmc
,
sizeof
(
pmc
)))
{
bytes_used
=
(
unsigned
)(
pmc
.
WorkingSetSize
+
pmc
.
PagefileUsage
);
}
#endif
*
memoryUsedMB
=
(
float
)
bytes_used
/
1024
/
1024
;
return
true
;
}
static
void
taosGetSystemTimezone
()
{
// get and set default timezone
SGlobalCfg
*
cfg_timezone
=
taosGetConfigOption
(
"timezone"
);
...
...
@@ -71,16 +112,16 @@ static void taosGetSystemLocale() {
}
}
void
taosPrintOsInfo
()
{}
void
taosKillSystem
()
{
uError
(
"function taosKillSystem, exit!"
);
exit
(
0
);
static
int32_t
taosGetCpuCores
()
{
SYSTEM_INFO
info
;
GetSystemInfo
(
&
info
);
return
(
int32_t
)
info
.
dwNumberOfProcessors
;
}
void
taosGetSystemInfo
()
{
taosGetSystemTimezone
();
taosGetSystemLocale
();
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
*
sysCpuUsage
=
0
;
*
procCpuUsage
=
0
;
return
true
;
}
bool
taosGetDisk
()
{
...
...
@@ -89,20 +130,35 @@ bool taosGetDisk() {
unsigned
_int64
i64FreeBytesToCaller
;
unsigned
_int64
i64TotalBytes
;
unsigned
_int64
i64FreeBytes
;
char
dir
[
4
]
=
{
'C'
,
':'
,
'\\'
,
'\0'
};
int
drive_type
;
if
(
tscEmbedded
)
{
drive_type
=
GetDriveTypeA
(
dir
);
if
(
drive_type
==
DRIVE_FIXED
)
{
fResult
=
GetDiskFreeSpaceExA
(
dir
,
(
PULARGE_INTEGER
)
&
i64FreeBytesToCaller
,
(
PULARGE_INTEGER
)
&
i64TotalBytes
,
(
PULARGE_INTEGER
)
&
i64FreeBytes
);
if
(
fResult
)
{
tsTotalDataDirGB
=
tsTotalLogDirGB
=
tsTotalTmpDirGB
=
(
float
)(
i64TotalBytes
/
unit
);
tsAvailDataDirGB
=
tsAvailLogDirGB
=
tsAvailTmpDirectorySpace
=
(
float
)(
i64FreeBytes
/
unit
);
}
fResult
=
GetDiskFreeSpaceExA
(
tsDataDir
,
(
PULARGE_INTEGER
)
&
i64FreeBytesToCaller
,
(
PULARGE_INTEGER
)
&
i64TotalBytes
,
(
PULARGE_INTEGER
)
&
i64FreeBytes
);
if
(
fResult
)
{
tsTotalDataDirGB
=
(
float
)(
i64TotalBytes
/
unit
);
tsAvailDataDirGB
=
(
float
)(
i64FreeBytes
/
unit
);
}
}
fResult
=
GetDiskFreeSpaceExA
(
tsLogDir
,
(
PULARGE_INTEGER
)
&
i64FreeBytesToCaller
,
(
PULARGE_INTEGER
)
&
i64TotalBytes
,
(
PULARGE_INTEGER
)
&
i64FreeBytes
);
if
(
fResult
)
{
tsTotalLogDirGB
=
(
float
)(
i64TotalBytes
/
unit
);
tsAvailLogDirGB
=
(
float
)(
i64FreeBytes
/
unit
);
}
fResult
=
GetDiskFreeSpaceExA
(
tsTempDir
,
(
PULARGE_INTEGER
)
&
i64FreeBytesToCaller
,
(
PULARGE_INTEGER
)
&
i64TotalBytes
,
(
PULARGE_INTEGER
)
&
i64FreeBytes
);
if
(
fResult
)
{
tsTotalTmpDirGB
=
(
float
)(
i64TotalBytes
/
unit
);
tsAvailTmpDirectorySpace
=
(
float
)(
i64FreeBytes
/
unit
);
}
return
true
;
}
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
*
bandSpeedKb
=
0
;
return
true
;
}
...
...
@@ -144,48 +200,30 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
return
true
;
}
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
*
bandSpeedKb
=
0
;
return
true
;
}
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
*
sysCpuUsage
=
0
;
*
procCpuUsage
=
0
;
return
true
;
}
bool
taosGetProcMemory
(
float
*
memoryUsedMB
)
{
unsigned
bytes_used
=
0
;
#if 0
#if defined(_WIN32) && defined(_MSC_VER)
PROCESS_MEMORY_COUNTERS pmc;
HANDLE cur_proc = GetCurrentProcess();
if (GetProcessMemoryInfo(cur_proc, &pmc, sizeof(pmc))) {
bytes_used = (unsigned)(pmc.WorkingSetSize + pmc.PagefileUsage);
}
#endif
#endif
void
taosGetSystemInfo
()
{
tsNumOfCores
=
taosGetCpuCores
();
tsTotalMemoryMB
=
taosGetTotalMemory
();
*
memoryUsedMB
=
(
float
)
bytes_used
/
1024
/
1024
;
float
tmp1
,
tmp2
;
taosGetDisk
();
taosGetBandSpeed
(
&
tmp1
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
return
true
;
taosGetSystemTimezone
();
taosGetSystemLocale
();
}
bool
taosGetSysMemory
(
float
*
memoryUsedMB
)
{
MEMORYSTATUSEX
memsStat
;
float
nMemFree
;
float
nMemTotal
;
void
taosPrintOsInfo
()
{
uInfo
(
" os numOfCores: %d"
,
tsNumOfCores
);
uInfo
(
" os totalDisk: %f(GB)"
,
tsTotalDataDirGB
);
uInfo
(
" os totalMemory: %d(MB)"
,
tsTotalMemoryMB
);
uInfo
(
"=================================="
);
}
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
false
;
}
nMemFree
=
memsStat
.
ullAvailPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
*
memoryUsedMB
=
nMemTotal
-
nMemFree
;
return
true
;
void
taosKillSystem
()
{
uError
(
"function taosKillSystem, exit!"
);
exit
(
0
);
}
int
taosSystem
(
const
char
*
cmd
)
{
...
...
@@ -240,4 +278,6 @@ void taosSetCoreDump() { SetUnhandledExceptionFilter(&FlCrashDump); }
bool
taosGetSystemUid
(
char
*
uid
)
{
sprintf
(
uid
,
"uid_not_implemented_yet"
);
return
true
;
}
\ No newline at end of file
}
char
*
taosGetCmdlineByPID
(
int
pid
)
{
return
""
;
}
src/sync/src/syncArbitrator.c
浏览文件 @
de09879d
...
...
@@ -27,7 +27,7 @@
#include "syncInt.h"
#include "syncTcp.h"
static
void
arbSignalHandler
(
int32_t
signum
);
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
arbProcessIncommingConnection
(
SOCKET
connFd
,
uint32_t
sourceIp
);
static
void
arbProcessBrokenLink
(
int64_t
rid
);
static
int32_t
arbProcessPeerMsg
(
int64_t
rid
,
void
*
buffer
);
...
...
@@ -35,9 +35,9 @@ static tsem_t tsArbSem;
static
void
*
tsArbTcpPool
;
typedef
struct
{
char
id
[
TSDB_EP_LEN
+
24
];
SOCKET
nodeFd
;
void
*
pConn
;
char
id
[
TSDB_EP_LEN
+
24
];
SOCKET
nodeFd
;
void
*
pConn
;
}
SNodeConn
;
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
...
...
@@ -70,14 +70,13 @@ int32_t main(int32_t argc, char *argv[]) {
/* Set termination handler. */
struct
sigaction
act
=
{{
0
}};
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
act
.
sa_flags
=
SA_SIGINFO
;
act
.
sa_sigaction
=
arbSignalHandler
;
act
.
sa_handler
=
arbSignalHandler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
#ifndef WINDOWS
sigaction
(
SIGHUP
,
&
act
,
NULL
);
#endif
sigaction
(
SIGINT
,
&
act
,
NULL
);
tsAsyncLog
=
0
;
strcat
(
arbLogPath
,
"/arbitrator.log"
);
...
...
@@ -107,6 +106,7 @@ int32_t main(int32_t argc, char *argv[]) {
syncCloseTcpThreadPool
(
tsArbTcpPool
);
sInfo
(
"TAOS arbitrator is shut down"
);
closelog
();
return
0
;
}
...
...
@@ -174,16 +174,16 @@ static int32_t arbProcessPeerMsg(int64_t rid, void *buffer) {
return
0
;
}
static
void
arbSignalHandler
(
int32_t
signum
)
{
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
struct
sigaction
act
=
{{
0
}};
#ifndef WINDOWS
act
.
sa_handler
=
SIG_IGN
;
#endif
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
#ifndef WINDOWS
sigaction
(
SIGHUP
,
&
act
,
NULL
);
#endif
sigaction
(
SIGINT
,
&
act
,
NULL
);
sInfo
(
"shut down signal is %d
"
,
signum
);
sInfo
(
"shut down signal is %d
, sender PID:%d"
,
signum
,
sigInfo
->
si_pid
);
// inform main thread to exit
tsem_post
(
&
tsArbSem
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录