Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c73c3977
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,发现更多精彩内容 >>
提交
c73c3977
编写于
9月 29, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10430] add dnode check for dnode module
上级
9c29039a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
237 addition
and
0 deletion
+237
-0
source/server/dnode/inc/dnodeCheck.h
source/server/dnode/inc/dnodeCheck.h
+35
-0
source/server/dnode/src/dnodeCheck.c
source/server/dnode/src/dnodeCheck.c
+202
-0
未找到文件。
source/server/dnode/inc/dnodeCheck.h
0 → 100644
浏览文件 @
c73c3977
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_DNODE_CHECK_H_
#define _TD_DNODE_CHECK_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#include "dnodeInt.h"
typedef
struct
DnCheck
{
Dnode
*
dnode
;
}
DnCheck
;
int32_t
dnodeInitCheck
(
Dnode
*
dnode
,
DnCheck
**
check
);
void
dnodeCleanupCheck
(
Dnode
*
dnode
,
DnCheck
**
check
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_DNODE_CHECK_H_*/
source/server/dnode/src/dnodeCheck.c
0 → 100644
浏览文件 @
c73c3977
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tglobal.h"
#include "dnodeCheck.h"
#define MIN_AVAIL_MEMORY_MB 32
static
int32_t
dnodeBindTcpPort
(
uint16_t
port
)
{
#if 0
SOCKET serverSocket;
struct sockaddr_in server_addr;
if ((serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
dError("failed to create tcp socket since %s", strerror(errno));
return -1;
}
bzero(&server_addr, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(serverSocket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
dError("failed to bind tcp port:%d since %s", port, strerror(errno));
taosCloseSocket(serverSocket);
return -1;
}
if (listen(serverSocket, 5) < 0) {
dError("failed to listen tcp port:%d since %s", port, strerror(errno));
taosCloseSocket(serverSocket);
return -1;
}
taosCloseSocket(serverSocket);
#endif
return
0
;
}
static
int32_t
dnodeBindUdpPort
(
int16_t
port
)
{
#if 0
SOCKET serverSocket;
struct sockaddr_in server_addr;
if ((serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
dError("failed to create udp socket since %s", strerror(errno));
return -1;
}
bzero(&server_addr, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(serverSocket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
dError("failed to bind udp port:%d since %s", port, strerror(errno));
taosCloseSocket(serverSocket);
return -1;
}
taosCloseSocket(serverSocket);
#endif
return
0
;
}
static
int32_t
dnodeCheckNetwork
()
{
int32_t
ret
;
uint16_t
startPort
=
tsServerPort
;
for
(
uint16_t
port
=
startPort
;
port
<
startPort
+
12
;
port
++
)
{
ret
=
dnodeBindTcpPort
(
port
);
if
(
0
!=
ret
)
{
dError
(
"failed to bind tcp port:%d"
,
port
);
return
-
1
;
}
ret
=
dnodeBindUdpPort
(
port
);
if
(
0
!=
ret
)
{
dError
(
"failed to bind udp port:%d"
,
port
);
return
-
1
;
}
}
return
0
;
}
static
int32_t
dnodeCheckMem
()
{
float
memoryUsedMB
;
float
memoryAvailMB
;
if
(
true
!=
taosGetSysMemory
(
&
memoryUsedMB
))
{
dError
(
"failed to get system memory since %s, errno:%u,"
,
strerror
(
errno
),
errno
);
return
-
1
;
}
memoryAvailMB
=
(
float
)
tsTotalMemoryMB
-
memoryUsedMB
;
if
(
memoryAvailMB
<
MIN_AVAIL_MEMORY_MB
)
{
dError
(
"available memory %fMB less than the threshold %dMB"
,
memoryAvailMB
,
MIN_AVAIL_MEMORY_MB
);
return
-
1
;
}
return
0
;
}
static
int32_t
dnodeCheckDisk
()
{
taosGetDisk
();
if
(
tsAvailDataDirGB
<
tsMinimalDataDirGB
)
{
dError
(
"dataDir disk size:%fGB less than threshold %fGB "
,
tsAvailDataDirGB
,
tsMinimalDataDirGB
);
return
-
1
;
}
if
(
tsAvailLogDirGB
<
tsMinimalLogDirGB
)
{
dError
(
"logDir disk size:%fGB less than threshold %fGB"
,
tsAvailLogDirGB
,
tsMinimalLogDirGB
);
return
-
1
;
}
if
(
tsAvailTmpDirectorySpace
<
tsReservedTmpDirectorySpace
)
{
dError
(
"tmpDir disk size:%fGB less than threshold %fGB"
,
tsAvailTmpDirectorySpace
,
tsReservedTmpDirectorySpace
);
return
-
1
;
}
return
0
;
}
static
int32_t
dnodeCheckCpu
()
{
return
0
;
}
static
int32_t
dnodeCheckOs
()
{
return
0
;
}
static
int32_t
dnodeCheckAccess
()
{
return
0
;
}
static
int32_t
dnodeCheckVersion
()
{
return
0
;
}
static
int32_t
dnodeCheckDatafile
()
{
return
0
;
}
int32_t
dnodeInitCheck
(
Dnode
*
dnode
,
DnCheck
**
out
)
{
DnCheck
*
check
=
calloc
(
1
,
sizeof
(
DnCheck
));
if
(
check
==
NULL
)
return
-
1
;
check
->
dnode
=
dnode
;
*
out
=
check
;
if
(
dnodeCheckNetwork
()
!=
0
)
{
dError
(
"failed to check network"
);
return
-
1
;
}
if
(
dnodeCheckMem
()
!=
0
)
{
dError
(
"failed to check memory"
);
return
-
1
;
}
if
(
dnodeCheckCpu
()
!=
0
)
{
dError
(
"failed to check cpu"
);
return
-
1
;
}
if
(
dnodeCheckDisk
()
!=
0
)
{
dError
(
"failed to check disk"
);
return
-
1
;
}
if
(
dnodeCheckOs
()
!=
0
)
{
dError
(
"failed to check os"
);
return
-
1
;
}
if
(
dnodeCheckAccess
()
!=
0
)
{
dError
(
"failed to check access"
);
return
-
1
;
}
if
(
dnodeCheckVersion
()
!=
0
)
{
dError
(
"failed to check version"
);
return
-
1
;
}
if
(
dnodeCheckDatafile
()
!=
0
)
{
dError
(
"failed to check datafile"
);
return
-
1
;
}
dInfo
(
"dnode check is finished"
);
return
0
;
}
void
dnodeCleanupCheck
(
Dnode
*
dnode
,
DnCheck
**
out
)
{
DnCheck
*
check
=
*
out
;
*
out
=
NULL
;
free
(
check
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录