Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cde3e970
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cde3e970
编写于
3月 04, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
[td-13039] merge 3.0.
上级
92da01a8
abc28ce5
变更
67
显示空白变更内容
内联
并排
Showing
67 changed file
with
779 addition
and
576 deletion
+779
-576
include/libs/executor/executor.h
include/libs/executor/executor.h
+0
-19
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+20
-13
include/libs/tfs/tfs.h
include/libs/tfs/tfs.h
+9
-0
include/os/osDir.h
include/os/osDir.h
+1
-1
include/os/osEnv.h
include/os/osEnv.h
+3
-3
include/os/osFile.h
include/os/osFile.h
+17
-7
include/os/osSysinfo.h
include/os/osSysinfo.h
+12
-12
source/common/src/tglobal.c
source/common/src/tglobal.c
+42
-32
source/common/test/commonTests.cpp
source/common/test/commonTests.cpp
+3
-2
source/common/test/tmsgTest.cpp
source/common/test/tmsgTest.cpp
+1
-1
source/dnode/mgmt/impl/inc/dndEnv.h
source/dnode/mgmt/impl/inc/dndEnv.h
+2
-3
source/dnode/mgmt/impl/inc/dndMnode.h
source/dnode/mgmt/impl/inc/dndMnode.h
+1
-0
source/dnode/mgmt/impl/src/dndEnv.c
source/dnode/mgmt/impl/src/dndEnv.c
+8
-1
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+38
-10
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+7
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+7
-1
source/dnode/mnode/impl/inc/mndProfile.h
source/dnode/mnode/impl/inc/mndProfile.h
+1
-0
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+4
-0
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+5
-0
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+8
-11
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+129
-20
source/dnode/vnode/src/tq/tqMetaStore.c
source/dnode/vnode/src/tq/tqMetaStore.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+7
-8
source/libs/CMakeLists.txt
source/libs/CMakeLists.txt
+0
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+3
-3
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+8
-1
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+1
-38
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+4
-4
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+8
-8
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+1
-1
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+10
-8
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+18
-3
source/libs/monitor/test/monTest.cpp
source/libs/monitor/test/monTest.cpp
+5
-5
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+2
-4
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+2
-2
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+1
-1
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+10
-9
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+8
-2
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+7
-7
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+14
-2
source/libs/sync/test/syncIOSendMsgClientTest.cpp
source/libs/sync/test/syncIOSendMsgClientTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgServerTest.cpp
source/libs/sync/test/syncIOSendMsgServerTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgTest.cpp
source/libs/sync/test/syncIOSendMsgTest.cpp
+1
-1
source/libs/sync/test/syncIOTickPingTest.cpp
source/libs/sync/test/syncIOTickPingTest.cpp
+1
-1
source/libs/sync/test/syncIOTickQTest.cpp
source/libs/sync/test/syncIOTickQTest.cpp
+1
-1
source/libs/sync/test/syncRaftStoreTest.cpp
source/libs/sync/test/syncRaftStoreTest.cpp
+2
-2
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+1
-1
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+1
-1
source/libs/tdb/src/db/tdbUtil.c
source/libs/tdb/src/db/tdbUtil.c
+21
-22
source/libs/tdb/src/inc/tdbUtil.h
source/libs/tdb/src/inc/tdbUtil.h
+4
-4
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+1
-1
source/libs/tfs/CMakeLists.txt
source/libs/tfs/CMakeLists.txt
+1
-1
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+23
-9
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+49
-49
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+11
-11
source/os/src/osDir.c
source/os/src/osDir.c
+1
-1
source/os/src/osEnv.c
source/os/src/osEnv.c
+8
-3
source/os/src/osFile.c
source/os/src/osFile.c
+39
-0
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+171
-200
source/util/src/tconfig.c
source/util/src/tconfig.c
+2
-9
source/util/test/cacheTest.cpp
source/util/test/cacheTest.cpp
+1
-1
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+1
-1
source/util/test/freelistTest.cpp
source/util/test/freelistTest.cpp
+1
-1
source/util/test/hashTest.cpp
source/util/test/hashTest.cpp
+2
-2
tools/shell/src/backup/shellImport.c
tools/shell/src/backup/shellImport.c
+3
-5
未找到文件。
include/libs/executor/executor.h
浏览文件 @
cde3e970
...
@@ -89,25 +89,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds);
...
@@ -89,25 +89,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds);
*/
*/
int32_t
qRetrieveQueryResultInfo
(
qTaskInfo_t
tinfo
,
bool
*
buildRes
,
void
*
pRspContext
);
int32_t
qRetrieveQueryResultInfo
(
qTaskInfo_t
tinfo
,
bool
*
buildRes
,
void
*
pRspContext
);
/**
*
* Retrieve the actual results to fill the response message payload.
* Note that this function must be executed after qRetrieveQueryResultInfo is invoked.
*
* @param tinfo tinfo object
* @param pRsp response message
* @param contLen payload length
* @return
*/
//int32_t qDumpRetrieveResult(qTaskInfo_t tinfo, SRetrieveTableRsp** pRsp, int32_t* contLen, bool* continueExec);
/**
* return the transporter context (RPC)
* @param tinfo
* @return
*/
void
*
qGetResultRetrieveMsg
(
qTaskInfo_t
tinfo
);
/**
/**
* kill the ongoing query and free the query handle and corresponding resources automatically
* kill the ongoing query and free the query handle and corresponding resources automatically
* @param tinfo qhandle
* @param tinfo qhandle
...
...
include/libs/monitor/monitor.h
浏览文件 @
cde3e970
...
@@ -88,18 +88,18 @@ typedef struct {
...
@@ -88,18 +88,18 @@ typedef struct {
float
cpu_engine
;
float
cpu_engine
;
float
cpu_system
;
float
cpu_system
;
float
cpu_cores
;
float
cpu_cores
;
float
mem_engine
;
// M
B
int64_t
mem_engine
;
// K
B
float
mem_system
;
// M
B
int64_t
mem_system
;
// K
B
float
mem_total
;
// M
B
int64_t
mem_total
;
// K
B
float
disk_engine
;
// GB
float
disk_engine
;
// GB
float
disk_used
;
// GB
float
disk_used
;
// GB
float
disk_total
;
// GB
float
disk_total
;
// GB
float
net_in
;
// Kb/s
int64_t
net_in
;
float
net_out
;
// Kb/s
int64_t
net_out
;
float
io_read
;
// Mb/s
float
io_read
;
float
io_write
;
// Mb/s
float
io_write
;
float
io_read_disk
;
// Mb/s
float
io_read_disk
;
float
io_write_disk
;
// Mb/s
float
io_write_disk
;
int32_t
req_select
;
int32_t
req_select
;
float
req_select_rate
;
float
req_select_rate
;
int32_t
req_insert
;
int32_t
req_insert
;
...
@@ -116,7 +116,7 @@ typedef struct {
...
@@ -116,7 +116,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_FILENAME_LEN
];
char
name
[
TSDB_FILENAME_LEN
];
int
32_t
level
;
int
8_t
level
;
SDiskSize
size
;
SDiskSize
size
;
}
SMonDiskDesc
;
}
SMonDiskDesc
;
...
@@ -126,9 +126,16 @@ typedef struct {
...
@@ -126,9 +126,16 @@ typedef struct {
SMonDiskDesc
tempdir
;
SMonDiskDesc
tempdir
;
}
SMonDiskInfo
;
}
SMonDiskInfo
;
typedef
enum
{
MON_LEVEL_ERROR
=
0
,
MON_LEVEL_INFO
=
1
,
MON_LEVEL_DEBUG
=
2
,
MON_LEVEL_TRACE
=
3
,
}
EMonLogLevel
;
typedef
struct
{
typedef
struct
{
int64_t
ts
;
int64_t
ts
;
int8_t
level
;
EMonLogLevel
level
;
char
content
[
MON_LOG_LEN
];
char
content
[
MON_LOG_LEN
];
}
SMonLogItem
;
}
SMonLogItem
;
...
...
include/libs/tfs/tfs.h
浏览文件 @
cde3e970
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#define _TD_TFS_H_
#define _TD_TFS_H_
#include "tdef.h"
#include "tdef.h"
#include "monitor.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -237,6 +238,14 @@ const STfsFile *tfsReaddir(STfsDir *pDir);
...
@@ -237,6 +238,14 @@ const STfsFile *tfsReaddir(STfsDir *pDir);
*/
*/
void
tfsClosedir
(
STfsDir
*
pDir
);
void
tfsClosedir
(
STfsDir
*
pDir
);
/**
* @brief Get disk info of tfs.
*
* @param pTfs The fs object.
* @param pInfo The info object.
*/
int32_t
tfsGetMonitorInfo
(
STfs
*
pTfs
,
SMonDiskInfo
*
pInfo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/os/osDir.h
浏览文件 @
cde3e970
...
@@ -21,7 +21,7 @@ extern "C" {
...
@@ -21,7 +21,7 @@ extern "C" {
#endif
#endif
void
taosRemoveDir
(
const
char
*
dirname
);
void
taosRemoveDir
(
const
char
*
dirname
);
int32_t
taosDirExist
(
char
*
dirname
);
bool
taosDirExist
(
char
*
dirname
);
int32_t
taosMkDir
(
const
char
*
dirname
);
int32_t
taosMkDir
(
const
char
*
dirname
);
void
taosRemoveOldFiles
(
const
char
*
dirname
,
int32_t
keepDays
);
void
taosRemoveOldFiles
(
const
char
*
dirname
,
int32_t
keepDays
);
int32_t
taosExpandDir
(
const
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
int32_t
taosExpandDir
(
const
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
...
...
include/os/osEnv.h
浏览文件 @
cde3e970
...
@@ -28,11 +28,11 @@ extern char tsCharset[];
...
@@ -28,11 +28,11 @@ extern char tsCharset[];
extern
char
tsLocale
[];
extern
char
tsLocale
[];
extern
int8_t
tsDaylight
;
extern
int8_t
tsDaylight
;
extern
bool
tsEnableCoreFile
;
extern
bool
tsEnableCoreFile
;
extern
int64_t
tsPageSize
;
extern
int64_t
tsPageSize
KB
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsStreamMax
;
extern
int64_t
tsStreamMax
;
extern
int32_t
tsNumOfCores
;
extern
float
tsNumOfCores
;
extern
int
32_t
tsTotalMemoryM
B
;
extern
int
64_t
tsTotalMemoryK
B
;
extern
char
configDir
[];
extern
char
configDir
[];
extern
char
tsDataDir
[];
extern
char
tsDataDir
[];
...
...
include/os/osFile.h
浏览文件 @
cde3e970
...
@@ -25,8 +25,12 @@ extern "C" {
...
@@ -25,8 +25,12 @@ extern "C" {
#ifndef ALLOW_FORBID_FUNC
#ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID
#define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
// #define close CLOSE_FUNC_TAOS_FORBID
#define access ACCESS_FUNC_TAOS_FORBID
// #define fclose FCLOSE_FUNC_TAOS_FORBID
#define stat STAT_FUNC_TAOS_FORBID
#define lstat LSTAT_FUNC_TAOS_FORBID
#define fstat FSTAT_FUNC_TAOS_FORBID
#define close CLOSE_FUNC_TAOS_FORBID
#define fclose FCLOSE_FUNC_TAOS_FORBID
#endif
#endif
#ifndef PATH_MAX
#ifndef PATH_MAX
...
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
...
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_EXCL 0x0080
#define TD_FILE_EXCL 0x0080
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
#define TD_FILE_ACCESS_EXIST_OK 0x1
#define TD_FILE_ACCESS_READ_OK 0x2
#define TD_FILE_ACCESS_WRITE_OK 0x4
bool
taosCheckAccessFile
(
const
char
*
pathname
,
int
mode
);
int32_t
taosLockFile
(
TdFilePtr
pFile
);
int32_t
taosLockFile
(
TdFilePtr
pFile
);
int32_t
taosUnLockFile
(
TdFilePtr
pFile
);
int32_t
taosUnLockFile
(
TdFilePtr
pFile
);
...
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
...
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosDevInoFile
(
const
char
*
path
,
int64_t
*
stDev
,
int64_t
*
stIno
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
bool
taosCheckExistFile
(
const
char
*
pathname
);
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
);
int32_t
taosFtruncateFile
(
TdFilePtr
pFile
,
int64_t
length
);
int32_t
taosFtruncateFile
(
TdFilePtr
pFile
,
int64_t
length
);
...
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
...
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
void
*
taosMmapReadOnlyFile
(
TdFilePtr
pFile
,
int64_t
length
);
void
*
taosMmapReadOnlyFile
(
TdFilePtr
pFile
,
int64_t
length
);
bool
taosValidFile
(
TdFilePtr
pFile
);
bool
taosValidFile
(
TdFilePtr
pFile
);
int
taosGetErrorFile
(
TdFilePtr
pFile
);
int
32_t
taosGetErrorFile
(
TdFilePtr
pFile
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/os/osSysinfo.h
浏览文件 @
cde3e970
...
@@ -34,19 +34,19 @@ typedef struct {
...
@@ -34,19 +34,19 @@ typedef struct {
}
SDiskSpace
;
}
SDiskSpace
;
void
taosGetSystemInfo
();
void
taosGetSystemInfo
();
bool
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
int32_t
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
bool
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
bool
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_
t
*
numOfCores
);
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
floa
t
*
numOfCores
);
int32_t
taosGetCpuCores
();
int32_t
taosGetCpuCores
(
float
*
numOfCores
);
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsag
e
);
int32_t
taosGetCpuUsage
(
float
*
cpu_system
,
float
*
cpu_engin
e
);
bool
taosGetTotalSysMemoryKB
(
uint64_t
*
kb
);
int32_t
taosGetTotalMemory
(
int64_t
*
totalKB
);
bool
taosGetProcMemory
(
float
*
memoryUsedMB
);
//
int32_t
taosGetProcMemory
(
int64_t
*
usedKB
);
bool
taosGetSysMemory
(
float
*
memoryUsedMB
);
//
int32_t
taosGetSysMemory
(
int64_t
*
usedKB
);
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
);
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
);
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
);
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
);
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
);
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
);
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
);
int32_t
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
);
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
);
int32_t
taosGetBandSpeed
(
float
*
bandSpeedKb
);
int32_t
taosSystem
(
const
char
*
cmd
);
int32_t
taosSystem
(
const
char
*
cmd
);
void
taosKillSystem
();
void
taosKillSystem
();
...
...
source/common/src/tglobal.c
浏览文件 @
cde3e970
...
@@ -155,21 +155,40 @@ static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t prima
...
@@ -155,21 +155,40 @@ static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t prima
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
}
}
static
void
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
if
(
pItem
==
NULL
)
return
;
memset
(
tsDataDir
,
0
,
PATH_MAX
)
;
int32_t
size
=
taosArrayGetSize
(
pItem
->
array
);
int32_t
size
=
taosArrayGetSize
(
pItem
->
array
);
if
(
size
<=
0
)
{
if
(
size
<=
0
)
{
tsDiskCfgNum
=
1
;
tsDiskCfgNum
=
1
;
taosAddDataDir
(
0
,
pItem
->
str
,
0
,
1
);
taosAddDataDir
(
0
,
pItem
->
str
,
0
,
1
);
tstrncpy
(
tsDataDir
,
pItem
->
str
,
PATH_MAX
);
if
(
taosMkDir
(
tsDataDir
)
!=
0
)
{
uError
(
"failed to create dataDir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
}
else
{
}
else
{
tsDiskCfgNum
=
size
<
TFS_MAX_DISKS
?
size
:
TFS_MAX_DISKS
;
tsDiskCfgNum
=
size
<
TFS_MAX_DISKS
?
size
:
TFS_MAX_DISKS
;
for
(
int32_t
index
=
0
;
index
<
tsDiskCfgNum
;
++
index
)
{
for
(
int32_t
index
=
0
;
index
<
tsDiskCfgNum
;
++
index
)
{
SDiskCfg
*
pCfg
=
taosArrayGet
(
pItem
->
array
,
index
);
SDiskCfg
*
pCfg
=
taosArrayGet
(
pItem
->
array
,
index
);
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
if
(
pCfg
->
level
==
0
&&
pCfg
->
primary
==
1
)
{
tstrncpy
(
tsDataDir
,
pCfg
->
dir
,
PATH_MAX
);
}
if
(
taosMkDir
(
pCfg
->
dir
)
!=
0
)
{
uError
(
"failed to create tfsDir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
}
}
}
}
if
(
tsDataDir
[
0
]
==
0
)
{
uError
(
"datadir not set"
);
return
-
1
;
}
return
0
;
}
}
struct
SConfig
*
taosGetCfg
()
{
struct
SConfig
*
taosGetCfg
()
{
...
@@ -279,11 +298,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
...
@@ -279,11 +298,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
1
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
1
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
1
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
0
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize(KB)"
,
tsPageSize
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"totalMemory(MB)"
,
tsTotalMemoryMB
,
0
,
INT32_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize(KB)"
,
tsPageSizeKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"totalMemory(KB)"
,
tsTotalMemoryKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
...
@@ -358,7 +377,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
...
@@ -358,7 +377,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
fsDebugFlag
=
cfgGetItem
(
pCfg
,
"fsDebugFlag"
)
->
i32
;
fsDebugFlag
=
cfgGetItem
(
pCfg
,
"fsDebugFlag"
)
->
i32
;
}
}
static
void
taosSetClientCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosSetClientCfg
(
SConfig
*
pCfg
)
{
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
...
@@ -375,9 +394,13 @@ static void taosSetClientCfg(SConfig *pCfg) {
...
@@ -375,9 +394,13 @@ static void taosSetClientCfg(SConfig *pCfg) {
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
tstrncpy
(
ts
Log
Dir
,
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
,
PATH_MAX
);
tstrncpy
(
ts
Temp
Dir
,
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
,
PATH_MAX
);
taosExpandDir
(
ts
LogDir
,
tsLog
Dir
,
PATH_MAX
);
taosExpandDir
(
ts
TempDir
,
tsTemp
Dir
,
PATH_MAX
);
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
;
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
;
if
(
taosMkDir
(
tsTempDir
)
!=
0
)
{
uError
(
"failed to create tempDir:%s since %s"
,
tsTempDir
,
terrstr
());
return
-
1
;
}
tsNumOfThreadsPerCore
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
fval
;
tsNumOfThreadsPerCore
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
fval
;
tsMaxTmrCtrl
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
i32
;
tsMaxTmrCtrl
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
i32
;
...
@@ -392,6 +415,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
...
@@ -392,6 +415,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
tsMaxNumOfOrderedResults
=
cfgGetItem
(
pCfg
,
"maxNumOfOrderedRes"
)
->
i32
;
tsMaxNumOfOrderedResults
=
cfgGetItem
(
pCfg
,
"maxNumOfOrderedRes"
)
->
i32
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
return
0
;
}
}
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
...
@@ -404,10 +429,6 @@ static void taosSetSystemCfg(SConfig *pCfg) {
...
@@ -404,10 +429,6 @@ static void taosSetSystemCfg(SConfig *pCfg) {
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
taosSetSystemLocale
(
locale
,
charset
);
taosSetSystemLocale
(
locale
,
charset
);
if
(
tsNumOfCores
<=
1
)
{
tsNumOfCores
=
2
;
}
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
taosSetConsoleEcho
(
enableCore
);
taosSetConsoleEcho
(
enableCore
);
...
@@ -415,11 +436,8 @@ static void taosSetSystemCfg(SConfig *pCfg) {
...
@@ -415,11 +436,8 @@ static void taosSetSystemCfg(SConfig *pCfg) {
tsVersion
=
30000000
;
tsVersion
=
30000000
;
}
}
static
void
taosSetServerCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosSetServerCfg
(
SConfig
*
pCfg
)
{
tstrncpy
(
tsDataDir
,
cfgGetItem
(
pCfg
,
"dataDir"
)
->
str
,
PATH_MAX
);
tsDataSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
;
taosExpandDir
(
tsDataDir
,
tsDataDir
,
PATH_MAX
);
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
;
tsNumOfCommitThreads
=
cfgGetItem
(
pCfg
,
"numOfCommitThreads"
)
->
i32
;
tsNumOfCommitThreads
=
cfgGetItem
(
pCfg
,
"numOfCommitThreads"
)
->
i32
;
tsRatioOfQueryCores
=
cfgGetItem
(
pCfg
,
"ratioOfQueryCores"
)
->
fval
;
tsRatioOfQueryCores
=
cfgGetItem
(
pCfg
,
"ratioOfQueryCores"
)
->
fval
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
...
@@ -448,6 +466,8 @@ static void taosSetServerCfg(SConfig *pCfg) {
...
@@ -448,6 +466,8 @@ static void taosSetServerCfg(SConfig *pCfg) {
if
(
tsQueryBufferSize
>=
0
)
{
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
}
}
return
0
;
}
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
...
@@ -508,8 +528,8 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
...
@@ -508,8 +528,8 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
tsCfg
=
cfgInit
();
tsCfg
=
cfgInit
();
if
(
tsc
)
{
if
(
tsc
)
{
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
else
{
}
else
{
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerCfg
(
tsCfg
)
!=
0
)
return
-
1
;
...
@@ -532,24 +552,14 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
...
@@ -532,24 +552,14 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
}
}
if
(
tsc
)
{
if
(
tsc
)
{
taosSetClientCfg
(
tsCfg
)
;
if
(
taosSetClientCfg
(
tsCfg
))
return
-
1
;
}
else
{
}
else
{
taosSetClientCfg
(
tsCfg
)
;
if
(
taosSetClientCfg
(
tsCfg
))
return
-
1
;
taosSetServerCfg
(
tsCfg
)
;
if
(
taosSetServerCfg
(
tsCfg
))
return
-
1
;
taosSetTfsCfg
(
tsCfg
)
;
if
(
taosSetTfsCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
}
taosSetSystemCfg
(
tsCfg
);
taosSetSystemCfg
(
tsCfg
);
if
(
taosMkDir
(
tsTempDir
)
!=
0
)
{
uError
(
"failed to create dir:%s since %s"
,
tsTempDir
,
terrstr
());
return
-
1
;
}
if
(
!
tsc
&&
taosMkDir
(
tsDataDir
)
!=
0
)
{
uError
(
"failed to create dir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
return
0
;
return
0
;
}
}
...
...
source/common/test/commonTests.cpp
浏览文件 @
cde3e970
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tdatablock.h>
#include <iostream>
#include <iostream>
#include "tcommon.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
@@ -10,6 +8,9 @@
...
@@ -10,6 +8,9 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "tcommon.h"
#include "tdatablock.h"
#include "tcommon.h"
#include "taos.h"
#include "taos.h"
#include "tvariant.h"
#include "tvariant.h"
#include "tdef.h"
#include "tdef.h"
...
...
source/common/test/tmsgTest.cpp
浏览文件 @
cde3e970
#include <iostream>
#include <iostream>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tmsg.h"
#include "tmsg.h"
...
...
source/dnode/mgmt/impl/inc/dndEnv.h
浏览文件 @
cde3e970
...
@@ -137,8 +137,7 @@ typedef struct SDnode {
...
@@ -137,8 +137,7 @@ typedef struct SDnode {
SStartupReq
startup
;
SStartupReq
startup
;
}
SDnode
;
}
SDnode
;
int32_t
dndGetMonitorDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
);
int32_t
dndGetDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/impl/inc/dndMnode.h
浏览文件 @
cde3e970
...
@@ -34,6 +34,7 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
...
@@ -34,6 +34,7 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
int32_t
dndGetMnodeMonitorInfo
(
SDnode
*
pDnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
int32_t
dndGetMnodeMonitorInfo
(
SDnode
*
pDnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
);
SMonGrantInfo
*
pGrantInfo
);
int8_t
dndIsMnode
(
SDnode
*
pDnode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/impl/src/dndEnv.c
浏览文件 @
cde3e970
...
@@ -324,4 +324,11 @@ void dndCleanup() {
...
@@ -324,4 +324,11 @@ void dndCleanup() {
dInfo
(
"dnode env is cleaned up"
);
dInfo
(
"dnode env is cleaned up"
);
}
}
int32_t
dndGetDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
)
{
return
0
;
}
int32_t
dndGetMonitorDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
)
{
\ No newline at end of file
tstrncpy
(
pInfo
->
logdir
.
name
,
tsLogDir
,
sizeof
(
pInfo
->
logdir
.
name
));
pInfo
->
logdir
.
size
=
tsLogSpace
.
size
;
tstrncpy
(
pInfo
->
tempdir
.
name
,
tsTempDir
,
sizeof
(
pInfo
->
tempdir
.
name
));
pInfo
->
tempdir
.
size
=
tsTempSpace
.
size
;
return
tfsGetMonitorInfo
(
pDnode
->
pTfs
,
pInfo
);
}
\ No newline at end of file
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
cde3e970
...
@@ -474,13 +474,38 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
...
@@ -474,13 +474,38 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
static
int32_t
dndGet
BasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
static
void
dndGetMonitor
BasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
pInfo
->
dnode_id
=
dndGetDnodeId
(
pDnode
);
pInfo
->
dnode_id
=
dndGetDnodeId
(
pDnode
);
tstrncpy
(
pInfo
->
dnode_ep
,
tsLocalEp
,
TSDB_EP_LEN
);
tstrncpy
(
pInfo
->
dnode_ep
,
tsLocalEp
,
TSDB_EP_LEN
);
return
0
;
}
}
static
int32_t
dndGetDnodeInfo
(
SDnode
*
pDnode
,
SMonDnodeInfo
*
pInfo
)
{
return
0
;
}
static
void
dndGetMonitorDnodeInfo
(
SDnode
*
pDnode
,
SMonDnodeInfo
*
pInfo
)
{
pInfo
->
uptime
=
(
taosGetTimestampMs
()
-
pDnode
->
dmgmt
.
rebootTime
)
/
(
86400000
.
0
f
);
taosGetCpuUsage
(
&
pInfo
->
cpu_engine
,
&
pInfo
->
cpu_system
);
pInfo
->
cpu_cores
=
tsNumOfCores
;
taosGetProcMemory
(
&
pInfo
->
mem_engine
);
taosGetSysMemory
(
&
pInfo
->
mem_system
);
pInfo
->
mem_total
=
tsTotalMemoryKB
;
pInfo
->
disk_engine
=
0
;
pInfo
->
disk_used
=
tsDataSpace
.
size
.
used
/
(
1024
*
1024
*
1024
.
0
);
pInfo
->
disk_total
=
tsDataSpace
.
size
.
avail
/
(
1024
*
1024
*
1024
.
0
);
taosGetCardInfo
(
NULL
,
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
);
pInfo
->
io_read_disk
=
0
;
pInfo
->
io_write_disk
=
0
;
pInfo
->
req_select
=
0
;
pInfo
->
req_select_rate
=
0
;
pInfo
->
req_insert
=
0
;
pInfo
->
req_insert_success
=
0
;
pInfo
->
req_insert_rate
=
0
;
pInfo
->
req_insert_batch
=
0
;
pInfo
->
req_insert_batch_success
=
0
;
pInfo
->
req_insert_batch_rate
=
0
;
pInfo
->
errors
=
0
;
pInfo
->
vnodes_num
=
0
;
pInfo
->
masters
=
0
;
pInfo
->
has_mnode
=
dndIsMnode
(
pDnode
);
}
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
||
tsMonitorPort
==
0
)
return
;
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
||
tsMonitorPort
==
0
)
return
;
...
@@ -490,9 +515,8 @@ static void dndSendMonitorReport(SDnode *pDnode) {
...
@@ -490,9 +515,8 @@ static void dndSendMonitorReport(SDnode *pDnode) {
if
(
pMonitor
==
NULL
)
return
;
if
(
pMonitor
==
NULL
)
return
;
SMonBasicInfo
basicInfo
=
{
0
};
SMonBasicInfo
basicInfo
=
{
0
};
if
(
dndGetBasicInfo
(
pDnode
,
&
basicInfo
)
==
0
)
{
dndGetMonitorBasicInfo
(
pDnode
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
}
SMonClusterInfo
clusterInfo
=
{
0
};
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
...
@@ -504,15 +528,19 @@ static void dndSendMonitorReport(SDnode *pDnode) {
...
@@ -504,15 +528,19 @@ static void dndSendMonitorReport(SDnode *pDnode) {
}
}
SMonDnodeInfo
dnodeInfo
=
{
0
};
SMonDnodeInfo
dnodeInfo
=
{
0
};
if
(
dndGetDnodeInfo
(
pDnode
,
&
dnodeInfo
)
==
0
)
{
dndGetMonitorDnodeInfo
(
pDnode
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
}
SMonDiskInfo
diskInfo
=
{
0
};
SMonDiskInfo
diskInfo
=
{
0
};
if
(
dndGetDiskInfo
(
pDnode
,
&
diskInfo
)
==
0
)
{
if
(
dndGet
Monitor
DiskInfo
(
pDnode
,
&
diskInfo
)
==
0
)
{
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
}
}
taosArrayDestroy
(
clusterInfo
.
dnodes
);
taosArrayDestroy
(
clusterInfo
.
mnodes
);
taosArrayDestroy
(
vgroupInfo
.
vgroups
);
taosArrayDestroy
(
diskInfo
.
datadirs
);
monSendReport
(
pMonitor
);
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
}
}
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
cde3e970
...
@@ -640,3 +640,10 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
...
@@ -640,3 +640,10 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
dndReleaseMnode
(
pDnode
,
pMnode
);
dndReleaseMnode
(
pDnode
,
pMnode
);
return
code
;
return
code
;
}
}
int8_t
dndIsMnode
(
SDnode
*
pDnode
)
{
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
)
return
0
;
dndReleaseMnode
(
pDnode
,
pMnode
);
return
1
;
}
\ No newline at end of file
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
cde3e970
...
@@ -85,6 +85,11 @@ typedef struct {
...
@@ -85,6 +85,11 @@ typedef struct {
ESyncState
state
;
ESyncState
state
;
}
SSyncMgmt
;
}
SSyncMgmt
;
typedef
struct
{
int64_t
expireTimeMS
;
int64_t
timeseriesAllowed
;
}
SGrantInfo
;
typedef
struct
SMnode
{
typedef
struct
SMnode
{
int32_t
dnodeId
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
clusterId
;
...
@@ -105,6 +110,7 @@ typedef struct SMnode {
...
@@ -105,6 +110,7 @@ typedef struct SMnode {
STelemMgmt
telemMgmt
;
STelemMgmt
telemMgmt
;
SSyncMgmt
syncMgmt
;
SSyncMgmt
syncMgmt
;
SHashObj
*
infosMeta
;
SHashObj
*
infosMeta
;
SGrantInfo
grant
;
MndMsgFp
msgFp
[
TDMT_MAX
];
MndMsgFp
msgFp
[
TDMT_MAX
];
SendReqToDnodeFp
sendReqToDnodeFp
;
SendReqToDnodeFp
sendReqToDnodeFp
;
SendReqToMnodeFp
sendReqToMnodeFp
;
SendReqToMnodeFp
sendReqToMnodeFp
;
...
@@ -120,7 +126,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
...
@@ -120,7 +126,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
int32_t
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
);
void
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndProfile.h
浏览文件 @
cde3e970
...
@@ -24,6 +24,7 @@ extern "C" {
...
@@ -24,6 +24,7 @@ extern "C" {
int32_t
mndInitProfile
(
SMnode
*
pMnode
);
int32_t
mndInitProfile
(
SMnode
*
pMnode
);
void
mndCleanupProfile
(
SMnode
*
pMnode
);
void
mndCleanupProfile
(
SMnode
*
pMnode
);
int32_t
mndGetNumOfConnections
(
SMnode
*
pMnode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
cde3e970
...
@@ -99,11 +99,15 @@ void mndUpdateMnodeRole(SMnode *pMnode) {
...
@@ -99,11 +99,15 @@ void mndUpdateMnodeRole(SMnode *pMnode) {
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
ESyncState
lastRole
=
pObj
->
role
;
if
(
pObj
->
id
==
1
)
{
if
(
pObj
->
id
==
1
)
{
pObj
->
role
=
TAOS_SYNC_STATE_LEADER
;
pObj
->
role
=
TAOS_SYNC_STATE_LEADER
;
}
else
{
}
else
{
pObj
->
role
=
TAOS_SYNC_STATE_CANDIDATE
;
pObj
->
role
=
TAOS_SYNC_STATE_CANDIDATE
;
}
}
if
(
pObj
->
role
!=
lastRole
)
{
pObj
->
roleTime
=
taosGetTimestampMs
();
}
sdbRelease
(
pSdb
,
pObj
);
sdbRelease
(
pSdb
,
pObj
);
}
}
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
cde3e970
...
@@ -923,3 +923,8 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter) {
...
@@ -923,3 +923,8 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter) {
taosCacheDestroyIter
(
pIter
);
taosCacheDestroyIter
(
pIter
);
}
}
}
}
int32_t
mndGetNumOfConnections
(
SMnode
*
pMnode
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
return
taosCacheGetNumOfObj
(
pMgmt
->
cache
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
cde3e970
...
@@ -18,15 +18,15 @@
...
@@ -18,15 +18,15 @@
#include "mndCluster.h"
#include "mndCluster.h"
#include "mndSync.h"
#include "mndSync.h"
#include "tbuffer.h"
#include "tbuffer.h"
#include "tjson.h"
#include "thttp.h"
#include "thttp.h"
#include "tjson.h"
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_PORT 80
#define TELEMETRY_PORT 80
static
void
mndBuildRuntimeInfo
(
SMnode
*
pMnode
,
SJson
*
pJson
)
{
static
void
mndBuildRuntimeInfo
(
SMnode
*
pMnode
,
SJson
*
pJson
)
{
SMnodeLoad
load
=
{
0
};
SMnodeLoad
load
=
{
0
};
if
(
mndGetLoad
(
pMnode
,
&
load
)
!=
0
)
return
;
mndGetLoad
(
pMnode
,
&
load
)
;
tjsonAddDoubleToObject
(
pJson
,
"numOfDnode"
,
load
.
numOfDnode
);
tjsonAddDoubleToObject
(
pJson
,
"numOfDnode"
,
load
.
numOfDnode
);
tjsonAddDoubleToObject
(
pJson
,
"numOfMnode"
,
load
.
numOfMnode
);
tjsonAddDoubleToObject
(
pJson
,
"numOfMnode"
,
load
.
numOfMnode
);
...
@@ -52,23 +52,20 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
...
@@ -52,23 +52,20 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
tjsonAddStringToObject
(
pJson
,
"instanceId"
,
clusterName
);
tjsonAddStringToObject
(
pJson
,
"instanceId"
,
clusterName
);
tjsonAddDoubleToObject
(
pJson
,
"reportVersion"
,
1
);
tjsonAddDoubleToObject
(
pJson
,
"reportVersion"
,
1
);
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
)))
{
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
))
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
}
}
int32_
t
numOfCores
=
0
;
floa
t
numOfCores
=
0
;
if
(
taosGetCpuInfo
(
tmp
,
sizeof
(
tmp
),
&
numOfCores
))
{
if
(
taosGetCpuInfo
(
tmp
,
sizeof
(
tmp
),
&
numOfCores
)
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"cpuModel"
,
tmp
);
tjsonAddStringToObject
(
pJson
,
"cpuModel"
,
tmp
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
numOfCores
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
numOfCores
);
}
else
{
}
else
{
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
t
aosGetCpuCores
()
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
t
sNumOfCores
);
}
}
uint64_t
memoryKB
=
0
;
snprintf
(
tmp
,
sizeof
(
tmp
),
"%"
PRId64
" kB"
,
tsTotalMemoryKB
);
if
(
taosGetTotalSysMemoryKB
(
&
memoryKB
))
{
snprintf
(
tmp
,
sizeof
(
tmp
),
"%"
PRIu64
" kB"
,
memoryKB
);
tjsonAddStringToObject
(
pJson
,
"memory"
,
tmp
);
tjsonAddStringToObject
(
pJson
,
"memory"
,
tmp
);
}
tjsonAddStringToObject
(
pJson
,
"version"
,
version
);
tjsonAddStringToObject
(
pJson
,
"version"
,
version
);
tjsonAddStringToObject
(
pJson
,
"buildInfo"
,
buildinfo
);
tjsonAddStringToObject
(
pJson
,
"buildInfo"
,
buildinfo
);
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
cde3e970
...
@@ -359,6 +359,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
...
@@ -359,6 +359,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
return
NULL
;
return
NULL
;
}
}
mndUpdateMnodeRole
(
pMnode
);
mDebug
(
"mnode open successfully "
);
mDebug
(
"mnode open successfully "
);
return
pMnode
;
return
pMnode
;
}
}
...
@@ -385,26 +386,6 @@ void mndDestroy(const char *path) {
...
@@ -385,26 +386,6 @@ void mndDestroy(const char *path) {
mDebug
(
"mnode is destroyed"
);
mDebug
(
"mnode is destroyed"
);
}
}
int32_t
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
)
{
pLoad
->
numOfDnode
=
0
;
pLoad
->
numOfMnode
=
0
;
pLoad
->
numOfVgroup
=
0
;
pLoad
->
numOfDatabase
=
0
;
pLoad
->
numOfSuperTable
=
0
;
pLoad
->
numOfChildTable
=
0
;
pLoad
->
numOfColumn
=
0
;
pLoad
->
totalPoints
=
0
;
pLoad
->
totalStorage
=
0
;
pLoad
->
compStorage
=
0
;
return
0
;
}
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
return
0
;
}
SMnodeMsg
*
mndInitMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pRpcMsg
)
{
SMnodeMsg
*
mndInitMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pRpcMsg
)
{
SMnodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
SMnodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
...
@@ -523,3 +504,131 @@ uint64_t mndGenerateUid(char *name, int32_t len) {
...
@@ -523,3 +504,131 @@ uint64_t mndGenerateUid(char *name, int32_t len) {
}
}
}
while
(
true
);
}
while
(
true
);
}
}
void
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
)
{
memset
(
pLoad
,
0
,
sizeof
(
SMnodeLoad
));
SSdb
*
pSdb
=
pMnode
->
pSdb
;
pLoad
->
numOfDnode
=
sdbGetSize
(
pSdb
,
SDB_DNODE
);
pLoad
->
numOfMnode
=
sdbGetSize
(
pSdb
,
SDB_MNODE
);
pLoad
->
numOfVgroup
=
sdbGetSize
(
pSdb
,
SDB_VGROUP
);
pLoad
->
numOfDatabase
=
sdbGetSize
(
pSdb
,
SDB_DB
);
pLoad
->
numOfSuperTable
=
sdbGetSize
(
pSdb
,
SDB_STB
);
void
*
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
pLoad
->
numOfChildTable
+=
pVgroup
->
numOfTables
;
pLoad
->
numOfColumn
+=
pVgroup
->
numOfTimeSeries
;
pLoad
->
totalPoints
+=
pVgroup
->
pointsWritten
;
pLoad
->
totalStorage
+=
pVgroup
->
totalStorage
;
pLoad
->
compStorage
+=
pVgroup
->
compStorage
;
sdbRelease
(
pSdb
,
pVgroup
);
}
}
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
if
(
!
mndIsMaster
(
pMnode
))
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
ms
=
taosGetTimestampMs
();
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
pClusterInfo
->
mnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_MNODE
),
sizeof
(
SMonMnodeDesc
));
pVgroupInfo
->
vgroups
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_VGROUP
),
sizeof
(
SMonVgroupDesc
));
if
(
pClusterInfo
->
dnodes
==
NULL
||
pClusterInfo
->
mnodes
==
NULL
||
pVgroupInfo
->
vgroups
==
NULL
)
{
return
-
1
;
}
// cluster info
tstrncpy
(
pClusterInfo
->
version
,
version
,
sizeof
(
pClusterInfo
->
version
));
pClusterInfo
->
monitor_interval
=
tsMonitorInterval
;
pClusterInfo
->
connections_total
=
mndGetNumOfConnections
(
pMnode
);
void
*
pIter
=
NULL
;
while
(
1
)
{
SDnodeObj
*
pObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
SMonDnodeDesc
desc
=
{
0
};
desc
.
dnode_id
=
pObj
->
id
;
tstrncpy
(
desc
.
dnode_ep
,
pObj
->
ep
,
sizeof
(
desc
.
dnode_ep
));
if
(
mndIsDnodeOnline
(
pMnode
,
pObj
,
ms
))
{
tstrncpy
(
desc
.
status
,
"ready"
,
sizeof
(
desc
.
status
));
}
else
{
tstrncpy
(
desc
.
status
,
"offline"
,
sizeof
(
desc
.
status
));
}
taosArrayPush
(
pClusterInfo
->
dnodes
,
&
desc
);
sdbRelease
(
pSdb
,
pObj
);
}
pIter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
SMonMnodeDesc
desc
=
{
0
};
desc
.
mnode_id
=
pObj
->
id
;
tstrncpy
(
desc
.
mnode_ep
,
pObj
->
pDnode
->
ep
,
sizeof
(
desc
.
mnode_ep
));
tstrncpy
(
desc
.
role
,
mndGetRoleStr
(
pObj
->
role
),
sizeof
(
desc
.
role
));
taosArrayPush
(
pClusterInfo
->
mnodes
,
&
desc
);
sdbRelease
(
pSdb
,
pObj
);
if
(
pObj
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
pClusterInfo
->
first_ep_dnode_id
=
pObj
->
id
;
tstrncpy
(
pClusterInfo
->
first_ep
,
pObj
->
pDnode
->
ep
,
sizeof
(
pClusterInfo
->
first_ep
));
pClusterInfo
->
master_uptime
=
(
ms
-
pObj
->
roleTime
)
/
(
86400000
.
0
f
);
}
}
// vgroup info
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
pClusterInfo
->
vgroups_total
++
;
SMonVgroupDesc
desc
=
{
0
};
desc
.
vgroup_id
=
pVgroup
->
vgId
;
strncpy
(
desc
.
database_name
,
pVgroup
->
dbName
,
sizeof
(
desc
.
database_name
));
desc
.
tables_num
=
pVgroup
->
numOfTables
;
pGrantInfo
->
timeseries_used
+=
pVgroup
->
numOfTimeSeries
;
tstrncpy
(
desc
.
status
,
"unsynced"
,
sizeof
(
desc
.
status
));
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SMonVnodeDesc
*
pVnDesc
=
&
desc
.
vnodes
[
i
];
pVnDesc
->
dnode_id
=
pVgid
->
dnodeId
;
tstrncpy
(
pVnDesc
->
vnode_role
,
mndGetRoleStr
(
pVgid
->
role
),
sizeof
(
pVnDesc
->
vnode_role
));
if
(
pVgid
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
tstrncpy
(
desc
.
status
,
"ready"
,
sizeof
(
desc
.
status
));
pClusterInfo
->
vgroups_alive
++
;
}
if
(
pVgid
->
role
==
TAOS_SYNC_STATE_LEADER
||
pVgid
->
role
==
TAOS_SYNC_STATE_CANDIDATE
)
{
pClusterInfo
->
vnodes_alive
++
;
}
pClusterInfo
->
vnodes_total
++
;
}
taosArrayPush
(
pVgroupInfo
->
vgroups
,
&
desc
);
sdbRelease
(
pSdb
,
pVgroup
);
}
// grant info
pGrantInfo
->
expire_time
=
(
pMnode
->
grant
.
expireTimeMS
-
ms
)
/
86400000
.
0
f
;
pGrantInfo
->
timeseries_total
=
pMnode
->
grant
.
timeseriesAllowed
;
if
(
pMnode
->
grant
.
expireTimeMS
==
0
)
{
pGrantInfo
->
expire_time
=
INT32_MAX
;
pGrantInfo
->
timeseries_total
=
INT32_MAX
;
}
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
cde3e970
...
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
...
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
char
name
[
pathLen
+
10
];
char
name
[
pathLen
+
10
];
strcpy
(
name
,
path
);
strcpy
(
name
,
path
);
if
(
taosDirExist
(
name
)
!=
0
&&
taosMkDir
(
name
)
!=
0
)
{
if
(
!
taosDirExist
(
name
)
&&
taosMkDir
(
name
)
!=
0
)
{
terrno
=
TSDB_CODE_TQ_FAILED_TO_CREATE_DIR
;
terrno
=
TSDB_CODE_TQ_FAILED_TO_CREATE_DIR
;
tqError
(
"failed to create dir:%s since %s "
,
name
,
terrstr
());
tqError
(
"failed to create dir:%s since %s "
,
name
,
terrstr
());
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
cde3e970
...
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pRSmadF
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmadF
))
)
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbInitDFile
(
pRepo
,
pWSmadF
,
did
,
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
tsdbInitDFile
(
pRepo
,
pWSmadF
,
did
,
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
...
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
if
((
pCommith
->
isLFileSame
)
&&
access
(
TSDB_FILE_FULL_NAME
(
pRSmalF
),
F_OK
)
==
0
)
{
if
((
pCommith
->
isLFileSame
)
&&
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmalF
))
)
{
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
cde3e970
...
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
...
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
if
(
access
(
current
,
F_OK
)
==
0
)
{
if
(
taosCheckExistFile
(
current
)
)
{
if
(
tsdbOpenFSFromCurrent
(
pRepo
)
<
0
)
{
if
(
tsdbOpenFSFromCurrent
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to open FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
cde3e970
...
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
...
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
}
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
struct
stat
dfstat
;
SDFile
df
;
SDFile
df
;
tsdbInitDFileEx
(
&
df
,
pDFile
);
tsdbInitDFileEx
(
&
df
,
pDFile
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pDFile
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pDFile
))
)
{
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
));
TSDB_FILE_FULL_NAME
(
pDFile
));
// pRepo->state |= TSDB_STATE_BAD_DATA;
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
return
0
;
return
0
;
}
}
int64_t
file_size
=
0
;
if
(
stat
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
dfstat
)
<
0
)
{
if
(
taosStatFile
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
file_size
,
NULL
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
if
(
pDFile
->
info
.
size
<
dfstat
.
st
_size
)
{
if
(
pDFile
->
info
.
size
<
file
_size
)
{
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
return
-
1
;
return
-
1
;
...
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
...
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
tsdbCloseDFile
(
&
df
);
tsdbCloseDFile
(
&
df
);
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
file
_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
>
dfstat
.
st
_size
)
{
}
else
if
(
pDFile
->
info
.
size
>
file
_size
)
{
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
file
_size
,
pDFile
->
info
.
size
);
// pRepo->state |= TSDB_STATE_BAD_DATA;
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
...
...
source/libs/CMakeLists.txt
浏览文件 @
cde3e970
add_definitions
(
"-D ALLOW_FORBID_FUNC"
)
add_subdirectory
(
transport
)
add_subdirectory
(
transport
)
add_subdirectory
(
sync
)
add_subdirectory
(
sync
)
add_subdirectory
(
tdb
)
add_subdirectory
(
tdb
)
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
cde3e970
...
@@ -14,9 +14,7 @@
...
@@ -14,9 +14,7 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#include "os.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
@@ -24,8 +22,10 @@
...
@@ -24,8 +22,10 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#include <addr_any.h>
#include "addr_any.h"
#include "os.h"
#include "tglobal.h"
#include "catalog.h"
#include "catalog.h"
#include "catalogInt.h"
#include "catalogInt.h"
#include "stub.h"
#include "stub.h"
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
cde3e970
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
#ifndef TDENGINE_EXECUTORIMPL_H
#ifndef TDENGINE_EXECUTORIMPL_H
#define TDENGINE_EXECUTORIMPL_H
#define TDENGINE_EXECUTORIMPL_H
#include "tsort.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "os.h"
#include "os.h"
#include "tsort.h"
#include "tcommon.h"
#include "tcommon.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "ttszip.h"
#include "ttszip.h"
...
@@ -157,6 +157,13 @@ typedef struct STaskCostInfo {
...
@@ -157,6 +157,13 @@ typedef struct STaskCostInfo {
SHashObj
*
operatorProfResults
;
// map<operator_type, SQueryProfEvent>
SHashObj
*
operatorProfResults
;
// map<operator_type, SQueryProfEvent>
}
STaskCostInfo
;
}
STaskCostInfo
;
typedef
struct
SOperatorCostInfo
{
uint64_t
openCost
;
uint64_t
execCost
;
uint64_t
totalRows
;
uint64_t
totalBytes
;
}
SOperatorCostInfo
;
typedef
struct
{
typedef
struct
{
int64_t
vgroupLimit
;
int64_t
vgroupLimit
;
int64_t
ts
;
int64_t
ts
;
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
cde3e970
...
@@ -179,13 +179,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
...
@@ -179,13 +179,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
return
pTaskInfo
->
code
;
return
pTaskInfo
->
code
;
}
}
void
*
qGetResultRetrieveMsg
(
qTaskInfo_t
qinfo
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
assert
(
pQInfo
!=
NULL
);
return
pQInfo
->
rspContext
;
}
int32_t
qKillTask
(
qTaskInfo_t
qinfo
)
{
int32_t
qKillTask
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
...
@@ -221,7 +214,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
...
@@ -221,7 +214,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
int32_t
qIsTaskCompleted
(
qTaskInfo_t
qinfo
)
{
int32_t
qIsTaskCompleted
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
if
(
pTaskInfo
==
NULL
/*|| !isValidQInfo(pTaskInfo)*/
)
{
if
(
pTaskInfo
==
NULL
)
{
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
}
}
...
@@ -235,33 +228,3 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) {
...
@@ -235,33 +228,3 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) {
queryCostStatis
(
pTaskInfo
);
// print the query cost summary
queryCostStatis
(
pTaskInfo
);
// print the query cost summary
doDestroyTask
(
pTaskInfo
);
doDestroyTask
(
pTaskInfo
);
}
}
#if 0
//kill by qid
int32_t qKillQueryByQId(void* pMgmt, int64_t qId, int32_t waitMs, int32_t waitCount) {
int32_t error = TSDB_CODE_SUCCESS;
void** handle = qAcquireTask(pMgmt, qId);
if(handle == NULL) return terrno;
SQInfo* pQInfo = (SQInfo*)(*handle);
if (pQInfo == NULL || !isValidQInfo(pQInfo)) {
return TSDB_CODE_QRY_INVALID_QHANDLE;
}
qWarn("%s be killed(no memory commit).", pQInfo->qId);
setTaskKilled(pQInfo);
// wait query stop
int32_t loop = 0;
while (pQInfo->owner != 0) {
taosMsleep(waitMs);
if(loop++ > waitCount){
error = TSDB_CODE_FAILED;
break;
}
}
qReleaseTask(pMgmt, (void **)&handle, true);
return error;
}
#endif
source/libs/executor/src/executorimpl.c
浏览文件 @
cde3e970
...
@@ -2215,10 +2215,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
...
@@ -2215,10 +2215,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
if
(
pQueryAttr
->
tsCompQuery
&&
pRuntimeEnv
->
outputBuf
&&
pRuntimeEnv
->
outputBuf
->
pDataBlock
&&
taosArrayGetSize
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
)
>
0
)
{
if
(
pQueryAttr
->
tsCompQuery
&&
pRuntimeEnv
->
outputBuf
&&
pRuntimeEnv
->
outputBuf
->
pDataBlock
&&
taosArrayGetSize
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
)
>
0
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
,
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
,
0
);
if
(
pColInfoData
)
{
if
(
pColInfoData
)
{
FILE
*
f
=
*
(
FILE
*
*
)
pColInfoData
->
pData
;
// TODO refactor
TdFilePtr
pFile
=
*
(
TdFilePtr
*
)
pColInfoData
->
pData
;
// TODO refactor
if
(
f
)
{
if
(
pFile
!=
NULL
)
{
fclose
(
f
);
taosCloseFile
(
&
pFile
);
*
(
FILE
*
*
)
pColInfoData
->
pData
=
NULL
;
*
(
TdFilePtr
*
)
pColInfoData
->
pData
=
NULL
;
}
}
}
}
}
}
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
cde3e970
...
@@ -13,10 +13,7 @@
...
@@ -13,10 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <executorimpl.h>
#include <function.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
@@ -26,15 +23,18 @@
...
@@ -26,15 +23,18 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "executor.h"
#include "tglobal.h"
#include "stub.h"
#include "executorimpl.h"
#include "function.h"
#include "taos.h"
#include "taos.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tvariant.h"
#include "tdatablock.h"
#include "trpc.h"
#include "stub.h"
#include "executor.h"
#include "tmsg.h"
#include "tmsg.h"
#include "tname.h"
#include "tname.h"
#include "trpc.h"
#include "tvariant.h"
namespace
{
namespace
{
...
...
source/libs/executor/test/sortTests.cpp
浏览文件 @
cde3e970
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <executorimpl.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <tglobal.h>
#include <tsort.h>
#include <tsort.h>
...
@@ -26,6 +25,7 @@
...
@@ -26,6 +25,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "executorimpl.h"
#include "executor.h"
#include "executor.h"
#include "stub.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
cde3e970
...
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
...
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
}
}
static
int
writeCtxGetSize
(
WriterCtx
*
ctx
)
{
static
int
writeCtxGetSize
(
WriterCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFile
)
{
if
(
ctx
->
type
==
TFile
)
{
struct
stat
fstat
;
int64_t
file_size
=
0
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
return
fstat
.
st
_size
;
return
(
int
)
file
_size
;
}
}
return
0
;
return
0
;
}
}
...
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
...
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
ctx
->
file
.
pFile
=
taosOpenFile
(
path
,
TD_FILE_READ
);
ctx
->
file
.
pFile
=
taosOpenFile
(
path
,
TD_FILE_READ
);
struct
stat
fstat
;
int64_t
file_size
=
0
;
stat
(
path
,
&
fstat
);
taosFStatFile
(
ctx
->
file
.
pFile
,
&
file_size
,
NULL
);
ctx
->
file
.
size
=
fstat
.
st
_size
;
ctx
->
file
.
size
=
(
int
)
file
_size
;
#ifdef USE_MMAP
#ifdef USE_MMAP
ctx
->
file
.
ptr
=
(
char
*
)
tfMmapReadOnly
(
ctx
->
file
.
pFile
,
ctx
->
file
.
size
);
ctx
->
file
.
ptr
=
(
char
*
)
tfMmapReadOnly
(
ctx
->
file
.
pFile
,
ctx
->
file
.
size
);
#endif
#endif
...
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
...
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
#endif
#endif
}
}
if
(
ctx
->
file
.
readOnly
==
false
)
{
if
(
ctx
->
file
.
readOnly
==
false
)
{
struct
stat
fstat
;
int64_t
file_size
=
0
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
// struct stat fstat;
// stat(ctx->file.buf, &fstat);
// indexError("write file size: %d", (int)(fstat.st_size));
// indexError("write file size: %d", (int)(fstat.st_size));
}
}
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
cde3e970
...
@@ -128,11 +128,11 @@ void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
...
@@ -128,11 +128,11 @@ void monSetClusterInfo(SMonInfo *pMonitor, SMonClusterInfo *pInfo) {
SJson
*
pMnodesJson
=
tjsonAddArrayToObject
(
pJson
,
"mnodes"
);
SJson
*
pMnodesJson
=
tjsonAddArrayToObject
(
pJson
,
"mnodes"
);
if
(
pMnodesJson
==
NULL
)
return
;
if
(
pMnodesJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
d
nodes
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
m
nodes
);
++
i
)
{
SJson
*
pMnodeJson
=
tjsonCreateObject
();
SJson
*
pMnodeJson
=
tjsonCreateObject
();
if
(
pMnodeJson
==
NULL
)
continue
;
if
(
pMnodeJson
==
NULL
)
continue
;
SMonMnodeDesc
*
pMnodeDesc
=
taosArrayGet
(
pInfo
->
d
nodes
,
i
);
SMonMnodeDesc
*
pMnodeDesc
=
taosArrayGet
(
pInfo
->
m
nodes
,
i
);
tjsonAddDoubleToObject
(
pMnodeJson
,
"mnode_id"
,
pMnodeDesc
->
mnode_id
);
tjsonAddDoubleToObject
(
pMnodeJson
,
"mnode_id"
,
pMnodeDesc
->
mnode_id
);
tjsonAddStringToObject
(
pMnodeJson
,
"mnode_ep"
,
pMnodeDesc
->
mnode_ep
);
tjsonAddStringToObject
(
pMnodeJson
,
"mnode_ep"
,
pMnodeDesc
->
mnode_ep
);
tjsonAddStringToObject
(
pMnodeJson
,
"role"
,
pMnodeDesc
->
role
);
tjsonAddStringToObject
(
pMnodeJson
,
"role"
,
pMnodeDesc
->
role
);
...
@@ -270,6 +270,21 @@ void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
...
@@ -270,6 +270,21 @@ void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
}
}
static
const
char
*
monLogLevelStr
(
EMonLogLevel
level
)
{
switch
(
level
)
{
case
MON_LEVEL_ERROR
:
return
"error"
;
case
MON_LEVEL_INFO
:
return
"info"
;
case
MON_LEVEL_DEBUG
:
return
"debug"
;
case
MON_LEVEL_TRACE
:
return
"trace"
;
default:
return
"undefine"
;
}
}
static
void
monSetLogInfo
(
SMonInfo
*
pMonitor
)
{
static
void
monSetLogInfo
(
SMonInfo
*
pMonitor
)
{
SJson
*
pJson
=
tjsonCreateObject
();
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
pJson
==
NULL
)
return
;
...
@@ -291,7 +306,7 @@ static void monSetLogInfo(SMonInfo *pMonitor) {
...
@@ -291,7 +306,7 @@ static void monSetLogInfo(SMonInfo *pMonitor) {
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pLogItem
->
ts
,
TSDB_TIME_PRECISION_MILLI
);
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pLogItem
->
ts
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pLogJson
,
"ts"
,
buf
);
tjsonAddStringToObject
(
pLogJson
,
"ts"
,
buf
);
tjsonAdd
DoubleToObject
(
pLogJson
,
"level"
,
pLogItem
->
level
);
tjsonAdd
StringToObject
(
pLogJson
,
"level"
,
monLogLevelStr
(
pLogItem
->
level
)
);
tjsonAddStringToObject
(
pLogJson
,
"content"
,
pLogItem
->
content
);
tjsonAddStringToObject
(
pLogJson
,
"content"
,
pLogItem
->
content
);
if
(
tjsonAddItemToArray
(
pLogsJson
,
pLogJson
)
!=
0
)
tjsonDelete
(
pLogJson
);
if
(
tjsonAddItemToArray
(
pLogsJson
,
pLogJson
)
!=
0
)
tjsonDelete
(
pLogJson
);
...
...
source/libs/monitor/test/monTest.cpp
浏览文件 @
cde3e970
...
@@ -195,19 +195,19 @@ void MonitorTest::GetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
...
@@ -195,19 +195,19 @@ void MonitorTest::GetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
void
MonitorTest
::
AddLogInfo1
()
{
void
MonitorTest
::
AddLogInfo1
()
{
SMonLogItem
log1
=
{
0
};
SMonLogItem
log1
=
{
0
};
log1
.
ts
=
taosGetTimestampMs
();
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
1
;
log1
.
level
=
MON_LEVEL_INFO
;
strcpy
(
log1
.
content
,
"1 -------------------------- a"
);
strcpy
(
log1
.
content
,
"1 -------------------------- a"
);
monAddLogItem
(
&
log1
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
=
{
0
};
SMonLogItem
log2
=
{
0
};
log2
.
ts
=
taosGetTimestampMs
();
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
1
;
log2
.
level
=
MON_LEVEL_ERROR
;
strcpy
(
log2
.
content
,
"1 ------------------------ b"
);
strcpy
(
log2
.
content
,
"1 ------------------------ b"
);
monAddLogItem
(
&
log2
);
monAddLogItem
(
&
log2
);
SMonLogItem
log3
=
{
0
};
SMonLogItem
log3
=
{
0
};
log3
.
ts
=
taosGetTimestampMs
();
log3
.
ts
=
taosGetTimestampMs
();
log3
.
level
=
1
;
log3
.
level
=
MON_LEVEL_DEBUG
;
strcpy
(
log3
.
content
,
"1 ------- c"
);
strcpy
(
log3
.
content
,
"1 ------- c"
);
monAddLogItem
(
&
log3
);
monAddLogItem
(
&
log3
);
}
}
...
@@ -215,13 +215,13 @@ void MonitorTest::AddLogInfo1() {
...
@@ -215,13 +215,13 @@ void MonitorTest::AddLogInfo1() {
void
MonitorTest
::
AddLogInfo2
()
{
void
MonitorTest
::
AddLogInfo2
()
{
SMonLogItem
log1
;
SMonLogItem
log1
;
log1
.
ts
=
taosGetTimestampMs
();
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
01
;
log1
.
level
=
MON_LEVEL_ERROR
;
strcpy
(
log1
.
content
,
"2 ------- a"
);
strcpy
(
log1
.
content
,
"2 ------- a"
);
monAddLogItem
(
&
log1
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
;
SMonLogItem
log2
;
log2
.
ts
=
taosGetTimestampMs
();
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
0
;
log2
.
level
=
MON_LEVEL_ERROR
;
strcpy
(
log2
.
content
,
"2 ------- b"
);
strcpy
(
log2
.
content
,
"2 ------- b"
);
monAddLogItem
(
&
log2
);
monAddLogItem
(
&
log2
);
}
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
cde3e970
...
@@ -13,19 +13,17 @@
...
@@ -13,19 +13,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "mockCatalog.h"
#include <iostream>
#include <iostream>
#include "stub.h"
#include "stub.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#include
"addr_any.h"
#include
<addr_any.h>
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#include "mockCatalog.h"
namespace
{
namespace
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
cde3e970
...
@@ -13,10 +13,8 @@
...
@@ -13,10 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <function.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <iostream>
#include <iostream>
#include "tglobal.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
@@ -25,6 +23,8 @@
...
@@ -25,6 +23,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "function.h"
#include "tglobal.h"
#include "astGenerator.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "parserInt.h"
#include "taos.h"
#include "taos.h"
...
...
source/libs/parser/test/plannerTest.cpp
浏览文件 @
cde3e970
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <function.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
...
@@ -25,6 +24,7 @@
...
@@ -25,6 +24,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "function.h"
#include "astGenerator.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "parserInt.h"
#include "taos.h"
#include "taos.h"
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
cde3e970
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
@@ -26,20 +25,22 @@
...
@@ -26,20 +25,22 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "os.h"
#include "addr_any.h"
#include "tglobal.h"
#include "dataSinkMgt.h"
#include "executor.h"
#include "planner.h"
#include "qworker.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "trpc.h"
#include "tvariant.h"
#include "tvariant.h"
#include "tdatablock.h"
#include "trpc.h"
#include "planner.h"
#include "qworker.h"
#include "stub.h"
#include "executor.h"
#include "dataSinkMgt.h"
namespace
{
namespace
{
...
...
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
cde3e970
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
@@ -26,10 +25,17 @@
...
@@ -26,10 +25,17 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "os.h"
#include "addr_any.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tdatablock.h"
#include "stub.h"
#include "scalar.h"
#include "filter.h"
#include "filter.h"
#include "nodes.h"
#include "nodes.h"
#include "scalar.h"
#include "scalar.h"
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
cde3e970
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
@@ -26,18 +25,19 @@
...
@@ -26,18 +25,19 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "os.h"
#include "addr_any.h"
#include "tglobal.h"
#include "nodes.h"
#include "scalar.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tlog.h"
#include "tvariant.h"
#include "tvariant.h"
#include "tdatablock.h"
#include "stub.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
namespace
{
namespace
{
...
...
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
cde3e970
...
@@ -14,11 +14,24 @@
...
@@ -14,11 +14,24 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
#include <addr_any.h>
#include "os.h"
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "catalog.h"
#include "catalog.h"
#include "scheduler.h"
#include "scheduler.h"
#include "taos.h"
#include "taos.h"
...
@@ -37,7 +50,6 @@
...
@@ -37,7 +50,6 @@
#include "schedulerInt.h"
#include "schedulerInt.h"
#include "stub.h"
#include "stub.h"
#include "addr_any.h"
#include "tref.h"
#include "tref.h"
namespace
{
namespace
{
...
...
source/libs/sync/test/syncIOSendMsgClientTest.cpp
浏览文件 @
cde3e970
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgServerTest.cpp
浏览文件 @
cde3e970
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
cde3e970
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOTickPingTest.cpp
浏览文件 @
cde3e970
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOTickQTest.cpp
浏览文件 @
cde3e970
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncRaftStoreTest.cpp
浏览文件 @
cde3e970
#include "syncRaftStore.h"
#include <stdio.h>
#include <stdio.h>
#include "gtest/gtest.h"
#include <gtest/gtest.h>
#include "syncRaftStore.h"
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
...
...
source/libs/sync/test/syncTest.cpp
浏览文件 @
cde3e970
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/tdb/src/db/tdb.c
浏览文件 @
cde3e970
...
@@ -90,7 +90,7 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
...
@@ -90,7 +90,7 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
// get page file from the env, if not opened yet, open it
// get page file from the env, if not opened yet, open it
pPgFile
=
NULL
;
pPgFile
=
NULL
;
snprintf
(
dbfname
,
128
,
"%s/%s"
,
tdbEnvGetRootDir
(
pEnv
),
fname
);
snprintf
(
dbfname
,
128
,
"%s/%s"
,
tdbEnvGetRootDir
(
pEnv
),
fname
);
fileExist
=
(
tdbCheckFileAccess
(
fname
,
TDB_F_OK
)
==
0
);
fileExist
=
taosCheckExistFile
(
fname
);
if
(
fileExist
)
{
if
(
fileExist
)
{
tdbGnrtFileID
(
dbfname
,
fileid
,
false
);
tdbGnrtFileID
(
dbfname
,
fileid
,
false
);
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
...
...
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
cde3e970
...
@@ -16,16 +16,16 @@
...
@@ -16,16 +16,16 @@
#include "tdbInt.h"
#include "tdbInt.h"
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
)
{
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
)
{
struct
stat
statbuf
;
int64_t
stDev
=
0
,
stIno
=
0
;
if
(
stat
(
fname
,
&
statbuf
)
<
0
)
{
if
(
taosDevInoFile
(
fname
,
&
stDev
,
&
stIno
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
memset
(
fileid
,
0
,
TDB_FILE_ID_LEN
);
memset
(
fileid
,
0
,
TDB_FILE_ID_LEN
);
((
uint64_t
*
)
fileid
)[
0
]
=
(
uint64_t
)
statbuf
.
st_ino
;
((
uint64_t
*
)
fileid
)[
0
]
=
stDev
;
((
uint64_t
*
)
fileid
)[
1
]
=
(
uint64_t
)
statbuf
.
st_dev
;
((
uint64_t
*
)
fileid
)[
1
]
=
stIno
;
if
(
unique
)
{
if
(
unique
)
{
((
uint64_t
*
)
fileid
)[
2
]
=
rand
();
((
uint64_t
*
)
fileid
)[
2
]
=
rand
();
}
}
...
@@ -33,35 +33,34 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
...
@@ -33,35 +33,34 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
return
0
;
return
0
;
}
}
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
)
{
//
int tdbCheckFileAccess(const char *pathname, int mode) {
int
flags
=
0
;
//
int flags = 0;
if
(
mode
&
TDB_F_OK
)
{
//
if (mode & TDB_F_OK) {
flags
|=
F_OK
;
//
flags |= F_OK;
}
//
}
if
(
mode
&
TDB_R_OK
)
{
//
if (mode & TDB_R_OK) {
flags
|=
R_OK
;
//
flags |= R_OK;
}
//
}
if
(
mode
&
TDB_W_OK
)
{
//
if (mode & TDB_W_OK) {
flags
|=
W_OK
;
//
flags |= W_OK;
}
//
}
return
access
(
pathname
,
flags
);
//
return access(pathname, flags);
}
//
}
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
)
{
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
)
{
struct
stat
st
;
int
ret
;
int
ret
;
int64_t
file_size
=
0
;
ret
=
stat
(
fname
,
&
st
);
ret
=
taosStatFile
(
fname
,
&
file_size
,
NULL
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
ASSERT
(
st
.
st
_size
%
pgSize
==
0
);
ASSERT
(
file
_size
%
pgSize
==
0
);
*
pSize
=
st
.
st
_size
/
pgSize
;
*
pSize
=
file
_size
/
pgSize
;
return
0
;
return
0
;
}
}
\ No newline at end of file
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
cde3e970
...
@@ -30,10 +30,10 @@ extern "C" {
...
@@ -30,10 +30,10 @@ extern "C" {
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
);
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
);
#define TDB_F_OK 0x1
//
#define TDB_F_OK 0x1
#define TDB_R_OK 0x2
//
#define TDB_R_OK 0x2
#define TDB_W_OK 0x4
//
#define TDB_W_OK 0x4
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
);
//
int tdbCheckFileAccess(const char *pathname, int mode);
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
);
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
);
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
cde3e970
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tdb.h"
#include "tdb.h"
...
...
source/libs/tfs/CMakeLists.txt
浏览文件 @
cde3e970
...
@@ -6,7 +6,7 @@ target_include_directories(
...
@@ -6,7 +6,7 @@ target_include_directories(
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
target_link_libraries
(
tfs os util common
)
target_link_libraries
(
tfs os util common
monitor
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
add_subdirectory
(
test
)
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
cde3e970
...
@@ -389,7 +389,6 @@ static int32_t tfsMount(STfs *pTfs, SDiskCfg *pCfg) {
...
@@ -389,7 +389,6 @@ static int32_t tfsMount(STfs *pTfs, SDiskCfg *pCfg) {
static
int32_t
tfsCheckAndFormatCfg
(
STfs
*
pTfs
,
SDiskCfg
*
pCfg
)
{
static
int32_t
tfsCheckAndFormatCfg
(
STfs
*
pTfs
,
SDiskCfg
*
pCfg
)
{
char
dirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
char
dirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
struct
stat
pstat
;
if
(
pCfg
->
level
<
0
||
pCfg
->
level
>=
TFS_MAX_TIERS
)
{
if
(
pCfg
->
level
<
0
||
pCfg
->
level
>=
TFS_MAX_TIERS
)
{
fError
(
"failed to mount %s to FS since invalid level %d"
,
pCfg
->
dir
,
pCfg
->
level
);
fError
(
"failed to mount %s to FS since invalid level %d"
,
pCfg
->
dir
,
pCfg
->
level
);
...
@@ -422,19 +421,13 @@ static int32_t tfsCheckAndFormatCfg(STfs *pTfs, SDiskCfg *pCfg) {
...
@@ -422,19 +421,13 @@ static int32_t tfsCheckAndFormatCfg(STfs *pTfs, SDiskCfg *pCfg) {
return
-
1
;
return
-
1
;
}
}
if
(
access
(
dirName
,
W_OK
|
R_OK
|
F_OK
)
!=
0
)
{
if
(
!
taosCheckAccessFile
(
dirName
,
TD_FILE_ACCESS_EXIST_OK
|
TD_FILE_ACCESS_READ_OK
|
TD_FILE_ACCESS_WRITE_OK
)
)
{
fError
(
"failed to mount %s to FS since no R/W access rights"
,
pCfg
->
dir
);
fError
(
"failed to mount %s to FS since no R/W access rights"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
return
-
1
;
}
}
if
(
stat
(
dirName
,
&
pstat
)
<
0
)
{
if
(
!
taosIsDir
(
dirName
))
{
fError
(
"failed to mount %s to FS since %s"
,
pCfg
->
dir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
!
S_ISDIR
(
pstat
.
st_mode
))
{
fError
(
"failed to mount %s to FS since not a directory"
,
pCfg
->
dir
);
fError
(
"failed to mount %s to FS since not a directory"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
return
-
1
;
...
@@ -544,3 +537,24 @@ static STfsDisk *tfsNextDisk(STfs *pTfs, SDiskIter *pIter) {
...
@@ -544,3 +537,24 @@ static STfsDisk *tfsNextDisk(STfs *pTfs, SDiskIter *pIter) {
return
pDisk
;
return
pDisk
;
}
}
int32_t
tfsGetMonitorInfo
(
STfs
*
pTfs
,
SMonDiskInfo
*
pInfo
)
{
pInfo
->
datadirs
=
taosArrayInit
(
32
,
sizeof
(
SMonDiskDesc
));
if
(
pInfo
->
datadirs
==
NULL
)
return
-
1
;
tfsUpdateSize
(
pTfs
);
tfsLock
(
pTfs
);
for
(
int32_t
level
=
0
;
level
<
pTfs
->
nlevel
;
level
++
)
{
STfsTier
*
pTier
=
&
pTfs
->
tiers
[
level
];
for
(
int32_t
disk
=
0
;
disk
<
pTier
->
ndisk
;
++
disk
)
{
STfsDisk
*
pDisk
=
pTier
->
disks
[
disk
];
SMonDiskDesc
dinfo
=
{
0
};
dinfo
.
size
=
pDisk
->
size
;
dinfo
.
level
=
pDisk
->
level
;
tstrncpy
(
dinfo
.
name
,
pDisk
->
path
,
sizeof
(
dinfo
.
name
));
taosArrayPush
(
pInfo
->
datadirs
,
&
dinfo
);
}
}
tfsUnLock
(
pTfs
);
}
\ No newline at end of file
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
cde3e970
...
@@ -119,29 +119,29 @@ TEST_F(TfsTest, 03_Dir) {
...
@@ -119,29 +119,29 @@ TEST_F(TfsTest, 03_Dir) {
char
p1
[]
=
"p1"
;
char
p1
[]
=
"p1"
;
char
ap1
[
128
]
=
{
0
};
char
ap1
[
128
]
=
{
0
};
snprintf
(
ap1
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p1
);
snprintf
(
ap1
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p1
);
EXPECT_NE
(
taosDirExist
(
ap1
),
0
);
EXPECT_NE
(
taosDirExist
(
ap1
),
1
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap1
),
1
);
char
p2
[]
=
"p2"
;
char
p2
[]
=
"p2"
;
char
ap2
[
128
]
=
{
0
};
char
ap2
[
128
]
=
{
0
};
snprintf
(
ap2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p2
);
snprintf
(
ap2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p2
);
SDiskID
did
=
{
0
};
SDiskID
did
=
{
0
};
EXPECT_NE
(
taosDirExist
(
ap2
),
0
);
EXPECT_NE
(
taosDirExist
(
ap2
),
1
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap2
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap2
),
1
);
char
p3
[]
=
"p3/p2/p1/p0"
;
char
p3
[]
=
"p3/p2/p1/p0"
;
char
ap3
[
128
]
=
{
0
};
char
ap3
[
128
]
=
{
0
};
snprintf
(
ap3
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p3
);
snprintf
(
ap3
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p3
);
EXPECT_NE
(
taosDirExist
(
ap3
),
0
);
EXPECT_NE
(
taosDirExist
(
ap3
),
1
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap3
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap3
),
1
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
taosDirExist
(
ap3
),
0
);
EXPECT_NE
(
taosDirExist
(
ap3
),
1
);
char
p45
[]
=
"p5"
;
char
p45
[]
=
"p5"
;
char
p44
[]
=
"p4"
;
char
p44
[]
=
"p4"
;
...
@@ -149,12 +149,12 @@ TEST_F(TfsTest, 03_Dir) {
...
@@ -149,12 +149,12 @@ TEST_F(TfsTest, 03_Dir) {
char
ap4
[
128
]
=
{
0
};
char
ap4
[
128
]
=
{
0
};
snprintf
(
ap4
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p4
);
snprintf
(
ap4
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
p4
);
EXPECT_NE
(
taosDirExist
(
ap4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
1
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap4
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap4
),
1
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
1
);
tfsClose
(
pTfs
);
tfsClose
(
pTfs
);
}
}
...
@@ -251,9 +251,9 @@ TEST_F(TfsTest, 04_File) {
...
@@ -251,9 +251,9 @@ TEST_F(TfsTest, 04_File) {
char
af2
[
128
]
=
{
0
};
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
n2
);
snprintf
(
af2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
EXPECT_EQ
(
taosDirExist
(
af2
),
1
);
tfsRemoveFile
(
&
f2
);
tfsRemoveFile
(
&
f2
);
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
taosDirExist
(
af2
),
1
);
{
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
...
@@ -529,35 +529,35 @@ TEST_F(TfsTest, 05_MultiDisk) {
...
@@ -529,35 +529,35 @@ TEST_F(TfsTest, 05_MultiDisk) {
snprintf
(
ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p1
);
snprintf
(
ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p1
);
char
ap23
[
128
]
=
{
0
};
char
ap23
[
128
]
=
{
0
};
snprintf
(
ap23
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
p1
);
snprintf
(
ap23
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
p1
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
1
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
1
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
1
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
1
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
1
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
1
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
1
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
1
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
1
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap00
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap00
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap01
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap01
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap10
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap10
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap11
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap11
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap12
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap12
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap20
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap20
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap21
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap21
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap22
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap22
),
1
);
EXPECT_EQ
(
taosDirExist
(
ap23
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap23
),
1
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p1
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
1
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
1
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
1
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
1
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
1
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
1
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
1
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
1
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
1
);
char
p2
[]
=
"p2"
;
char
p2
[]
=
"p2"
;
char
_ap21
[
128
]
=
{
0
};
char
_ap21
[
128
]
=
{
0
};
...
@@ -565,22 +565,22 @@ TEST_F(TfsTest, 05_MultiDisk) {
...
@@ -565,22 +565,22 @@ TEST_F(TfsTest, 05_MultiDisk) {
SDiskID
did
=
{
0
};
SDiskID
did
=
{
0
};
did
.
level
=
2
;
did
.
level
=
2
;
did
.
id
=
1
;
did
.
id
=
1
;
EXPECT_NE
(
taosDirExist
(
_ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap21
),
1
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap21
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap21
),
1
);
char
p3
[]
=
"p3/p2/p1/p0"
;
char
p3
[]
=
"p3/p2/p1/p0"
;
char
_ap12
[
128
]
=
{
0
};
char
_ap12
[
128
]
=
{
0
};
snprintf
(
_ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p3
);
snprintf
(
_ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p3
);
did
.
level
=
1
;
did
.
level
=
1
;
did
.
id
=
2
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
1
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap12
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap12
),
1
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
1
);
char
p45
[]
=
"p5"
;
char
p45
[]
=
"p5"
;
char
p44
[]
=
"p4"
;
char
p44
[]
=
"p4"
;
...
@@ -590,12 +590,12 @@ TEST_F(TfsTest, 05_MultiDisk) {
...
@@ -590,12 +590,12 @@ TEST_F(TfsTest, 05_MultiDisk) {
did
.
level
=
2
;
did
.
level
=
2
;
did
.
id
=
2
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
1
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
1
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
1
);
}
}
//------------- File -----------------//
//------------- File -----------------//
...
@@ -660,7 +660,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
...
@@ -660,7 +660,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
char
af2
[
128
]
=
{
0
};
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
n2
);
snprintf
(
af2
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
EXPECT_EQ
(
taosDirExist
(
af2
),
1
);
tfsRemoveFile
(
&
f2
);
tfsRemoveFile
(
&
f2
);
{
{
...
@@ -678,7 +678,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
...
@@ -678,7 +678,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
tfsClosedir
(
pDir
);
tfsClosedir
(
pDir
);
}
}
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
taosDirExist
(
af2
),
1
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
{
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
cde3e970
...
@@ -64,10 +64,10 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
...
@@ -64,10 +64,10 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
struct
stat
statbuf
;
int64_t
file_size
=
0
;
stat
(
fnameStr
,
&
statbuf
);
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
int
readSize
=
TMIN
(
WAL_MAX_SIZE
+
2
,
statbuf
.
st
_size
);
int
readSize
=
TMIN
(
WAL_MAX_SIZE
+
2
,
file
_size
);
pLastFileInfo
->
fileSize
=
statbuf
.
st
_size
;
pLastFileInfo
->
fileSize
=
file
_size
;
TdFilePtr
pFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
TdFilePtr
pFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
...
@@ -177,11 +177,11 @@ int walCheckAndRepairMeta(SWal* pWal) {
...
@@ -177,11 +177,11 @@ int walCheckAndRepairMeta(SWal* pWal) {
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
newSz
-
1
);
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
newSz
-
1
);
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
struct
stat
statbuf
;
int64_t
file_size
=
0
;
stat
(
fnameStr
,
&
statbuf
);
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
if
(
oldSz
!=
newSz
||
pLastFileInfo
->
fileSize
!=
statbuf
.
st
_size
)
{
if
(
oldSz
!=
newSz
||
pLastFileInfo
->
fileSize
!=
file
_size
)
{
pLastFileInfo
->
fileSize
=
statbuf
.
st
_size
;
pLastFileInfo
->
fileSize
=
file
_size
;
pWal
->
vers
.
lastVer
=
walScanLogGetLastVer
(
pWal
);
pWal
->
vers
.
lastVer
=
walScanLogGetLastVer
(
pWal
);
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
pWal
->
vers
.
lastVer
;
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
pWal
->
vers
.
lastVer
;
ASSERT
(
pWal
->
vers
.
lastVer
!=
-
1
);
ASSERT
(
pWal
->
vers
.
lastVer
!=
-
1
);
...
@@ -395,9 +395,9 @@ int walLoadMeta(SWal* pWal) {
...
@@ -395,9 +395,9 @@ int walLoadMeta(SWal* pWal) {
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
walBuildMetaName
(
pWal
,
metaVer
,
fnameStr
);
walBuildMetaName
(
pWal
,
metaVer
,
fnameStr
);
// read metafile
// read metafile
struct
stat
statbuf
;
int64_t
file_size
=
0
;
stat
(
fnameStr
,
&
statbuf
);
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
int
size
=
statbuf
.
st
_size
;
int
size
=
(
int
)
file
_size
;
char
*
buf
=
malloc
(
size
+
5
);
char
*
buf
=
malloc
(
size
+
5
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
...
...
source/os/src/osDir.c
浏览文件 @
cde3e970
...
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
...
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
//printf("dir:%s is removed\n", dirname);
//printf("dir:%s is removed\n", dirname);
}
}
int32_t
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
);
}
bool
taosDirExist
(
char
*
dirname
)
{
return
taosCheckExistFile
(
dirname
);
}
int32_t
taosMkDir
(
const
char
*
dirname
)
{
int32_t
taosMkDir
(
const
char
*
dirname
)
{
int32_t
code
=
mkdir
(
dirname
,
0755
);
int32_t
code
=
mkdir
(
dirname
,
0755
);
...
...
source/os/src/osEnv.c
浏览文件 @
cde3e970
...
@@ -31,11 +31,11 @@ char tsLocale[TD_LOCALE_LEN] = {0};
...
@@ -31,11 +31,11 @@ char tsLocale[TD_LOCALE_LEN] = {0};
char
tsCharset
[
TD_CHARSET_LEN
]
=
{
0
};
char
tsCharset
[
TD_CHARSET_LEN
]
=
{
0
};
int8_t
tsDaylight
=
0
;
int8_t
tsDaylight
=
0
;
bool
tsEnableCoreFile
=
0
;
bool
tsEnableCoreFile
=
0
;
int64_t
tsPageSize
=
0
;
int64_t
tsPageSize
KB
=
0
;
int64_t
tsOpenMax
=
0
;
int64_t
tsOpenMax
=
0
;
int64_t
tsStreamMax
=
0
;
int64_t
tsStreamMax
=
0
;
int32_t
tsNumOfCores
=
0
;
float
tsNumOfCores
=
0
;
int
32_t
tsTotalMemoryM
B
=
0
;
int
64_t
tsTotalMemoryK
B
=
0
;
void
osInit
()
{
void
osInit
()
{
srand
(
taosSafeRand
());
srand
(
taosSafeRand
());
...
@@ -44,6 +44,11 @@ void osInit() {
...
@@ -44,6 +44,11 @@ void osInit() {
taosSetSystemTimezone
(
tsTimezone
,
tsTimezone
,
&
tsDaylight
);
taosSetSystemTimezone
(
tsTimezone
,
tsTimezone
,
&
tsDaylight
);
taosGetSystemInfo
();
taosGetSystemInfo
();
// deadlock in query
if
(
tsNumOfCores
<
2
)
{
tsNumOfCores
=
2
;
}
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
taosWinSocketInit
();
taosWinSocketInit
();
...
...
source/os/src/osFile.c
浏览文件 @
cde3e970
...
@@ -186,6 +186,27 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
...
@@ -186,6 +186,27 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
return
0
;
return
0
;
#endif
#endif
}
}
int32_t
taosDevInoFile
(
const
char
*
path
,
int64_t
*
stDev
,
int64_t
*
stIno
)
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
return
0
;
#else
struct
stat
fileStat
;
int32_t
code
=
stat
(
path
,
&
fileStat
);
if
(
code
<
0
)
{
return
code
;
}
if
(
stDev
!=
NULL
)
{
*
stDev
=
fileStat
.
st_dev
;
}
if
(
stIno
!=
NULL
)
{
*
stIno
=
fileStat
.
st_ino
;
}
return
0
;
#endif
}
void
autoDelFileListAdd
(
const
char
*
path
)
{
return
;
}
void
autoDelFileListAdd
(
const
char
*
path
)
{
return
;
}
...
@@ -733,3 +754,21 @@ int32_t taosEOFFile(TdFilePtr pFile) {
...
@@ -733,3 +754,21 @@ int32_t taosEOFFile(TdFilePtr pFile) {
return
feof
(
pFile
->
fp
);
return
feof
(
pFile
->
fp
);
}
}
bool
taosCheckAccessFile
(
const
char
*
pathname
,
int32_t
tdFileAccessOptions
)
{
int
flags
=
0
;
if
(
tdFileAccessOptions
&
TD_FILE_ACCESS_EXIST_OK
)
{
flags
|=
F_OK
;
}
if
(
tdFileAccessOptions
&
TD_FILE_ACCESS_READ_OK
)
{
flags
|=
R_OK
;
}
if
(
tdFileAccessOptions
&
TD_FILE_ACCESS_WRITE_OK
)
{
flags
|=
W_OK
;
}
return
access
(
pathname
,
flags
)
==
0
;
}
bool
taosCheckExistFile
(
const
char
*
pathname
)
{
return
taosCheckAccessFile
(
pathname
,
TD_FILE_ACCESS_EXIST_OK
);
};
\ No newline at end of file
source/os/src/osSysinfo.c
浏览文件 @
cde3e970
...
@@ -39,32 +39,32 @@
...
@@ -39,32 +39,32 @@
#include <DbgHelp.h>
#include <DbgHelp.h>
#pragma warning(pop)
#pragma warning(pop)
static
int32_t
taosGetTotalMemory
(
)
{
int32_t
taosGetTotalMemory
(
int64_t
*
totalKB
)
{
MEMORYSTATUSEX
memsStat
;
MEMORYSTATUSEX
memsStat
;
memsStat
.
dwLength
=
sizeof
(
memsStat
);
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
0
;
return
-
1
;
}
}
float
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
)
;
*
totalKB
=
memsStat
.
ullTotalPhys
/
1024
;
return
(
int32_t
)
nMemTotal
;
return
0
;
}
}
bool
taosGetSysMemory
(
float
*
memoryUsedM
B
)
{
int32_t
taosGetSysMemory
(
int64_t
*
usedK
B
)
{
MEMORYSTATUSEX
memsStat
;
MEMORYSTATUSEX
memsStat
;
memsStat
.
dwLength
=
sizeof
(
memsStat
);
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
false
;
return
-
1
;
}
}
float
nMemFree
=
memsStat
.
ullAvailPhys
/
(
1024
.
0
f
*
1024
.
0
f
)
;
int64_t
nMemFree
=
memsStat
.
ullAvailPhys
/
1024
;
float
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
)
;
int64_t
nMemTotal
=
memsStat
.
ullTotalPhys
/
1024
.
0
;
*
memoryUsedM
B
=
nMemTotal
-
nMemFree
;
*
usedK
B
=
nMemTotal
-
nMemFree
;
return
true
;
return
0
;
}
}
bool
taosGetProcMemory
(
float
*
memoryUsedM
B
)
{
int32_t
taosGetProcMemory
(
int64_t
*
usedK
B
)
{
unsigned
bytes_used
=
0
;
unsigned
bytes_used
=
0
;
#if defined(_WIN64) && defined(_MSC_VER)
#if defined(_WIN64) && defined(_MSC_VER)
...
@@ -76,21 +76,21 @@ bool taosGetProcMemory(float *memoryUsedMB) {
...
@@ -76,21 +76,21 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
}
#endif
#endif
*
memoryUsedMB
=
(
float
)
bytes_used
/
1024
/
1024
;
*
usedKB
=
bytes_used
/
1024
;
return
true
;
return
0
;
}
}
int32_t
taosGetCpuCores
(
float
*
numOfCores
)
{
int32_t
taosGetCpuCores
()
{
SYSTEM_INFO
info
;
SYSTEM_INFO
info
;
GetSystemInfo
(
&
info
);
GetSystemInfo
(
&
info
);
return
(
int32_t
)
info
.
dwNumberOfProcessors
;
*
numOfCores
=
info
.
dwNumberOfProcessors
;
return
0
;
}
}
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
int32_t
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
*
sysCpuUsage
=
0
;
*
sysCpuUsage
=
0
;
*
procCpuUsage
=
0
;
*
procCpuUsage
=
0
;
return
true
;
return
0
;
}
}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
...
@@ -106,49 +106,49 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
...
@@ -106,49 +106,49 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
diskSize
->
used
=
(
int64_t
)(
i64TotalBytes
-
i64FreeBytes
);
diskSize
->
used
=
(
int64_t
)(
i64TotalBytes
-
i64FreeBytes
);
return
0
;
return
0
;
}
else
{
}
else
{
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
//
printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
}
}
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
)
{
int32_t
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
)
{
if
(
bytes
)
*
bytes
=
0
;
if
(
bytes
)
*
bytes
=
0
;
if
(
rbytes
)
*
rbytes
=
0
;
if
(
rbytes
)
*
rbytes
=
0
;
if
(
tbytes
)
*
tbytes
=
0
;
if
(
tbytes
)
*
tbytes
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
int32_t
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
*
bandSpeedKb
=
0
;
*
bandSpeedKb
=
0
;
return
true
;
return
0
;
}
}
bool
taosReadProcIO
(
int64_t
*
readbyte
,
int64_t
*
writebyte
)
{
int32_t
taosReadProcIO
(
int64_t
*
readbyte
,
int64_t
*
writebyte
)
{
IO_COUNTERS
io_counter
;
IO_COUNTERS
io_counter
;
if
(
GetProcessIoCounters
(
GetCurrentProcess
(),
&
io_counter
))
{
if
(
GetProcessIoCounters
(
GetCurrentProcess
(),
&
io_counter
))
{
if
(
readbyte
)
*
readbyte
=
io_counter
.
ReadTransferCount
;
if
(
readbyte
)
*
readbyte
=
io_counter
.
ReadTransferCount
;
if
(
writebyte
)
*
writebyte
=
io_counter
.
WriteTransferCount
;
if
(
writebyte
)
*
writebyte
=
io_counter
.
WriteTransferCount
;
return
true
;
return
0
;
}
}
return
false
;
return
-
1
;
}
}
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
int64_t
curWritebyte
=
0
;
if
(
!
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
)
)
{
if
(
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
)
!=
0
)
{
return
false
;
return
-
1
;
}
}
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
lastReadbyte
=
curReadbyte
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
lastWritebyte
=
curWritebyte
;
return
false
;
return
-
1
;
}
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
...
@@ -159,12 +159,12 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
...
@@ -159,12 +159,12 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
lastReadbyte
=
curReadbyte
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
lastWritebyte
=
curWritebyte
;
return
true
;
return
0
;
}
}
void
taosGetSystemInfo
()
{
void
taosGetSystemInfo
()
{
t
sNumOfCores
=
taosGetCpuCores
(
);
t
aosGetCpuCores
(
&
tsNumOfCores
);
t
sTotalMemoryMB
=
taosGetTotalMemory
(
);
t
aosGetTotalMemory
(
&
tsTotalMemoryKB
);
float
tmp1
,
tmp2
;
float
tmp1
,
tmp2
;
taosGetBandSpeed
(
&
tmp1
);
taosGetBandSpeed
(
&
tmp1
);
...
@@ -173,12 +173,12 @@ void taosGetSystemInfo() {
...
@@ -173,12 +173,12 @@ void taosGetSystemInfo() {
}
}
void
taosKillSystem
()
{
void
taosKillSystem
()
{
//printf("function taosKillSystem, exit!");
//
printf("function taosKillSystem, exit!");
exit
(
0
);
exit
(
0
);
}
}
int
taosSystem
(
const
char
*
cmd
)
{
int
taosSystem
(
const
char
*
cmd
)
{
//printf("taosSystem not support");
//
printf("taosSystem not support");
return
-
1
;
return
-
1
;
}
}
...
@@ -241,66 +241,66 @@ char *taosGetCmdlineByPID(int pid) { return ""; }
...
@@ -241,66 +241,66 @@ char *taosGetCmdlineByPID(int pid) { return ""; }
#include <errno.h>
#include <errno.h>
#include <libproc.h>
#include <libproc.h>
void
taosKillSystem
()
{
void
taosKillSystem
()
{
//printf("function taosKillSystem, exit!");
//
printf("function taosKillSystem, exit!");
exit
(
0
);
exit
(
0
);
}
}
int32_t
taosGetCpuCores
()
{
return
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
int32_t
taosGetCpuCores
(
float
*
numOfCores
)
{
*
numOfCores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
return
0
;
}
void
taosGetSystemInfo
()
{
void
taosGetSystemInfo
()
{
// taosGetProcInfos();
tsNumOfCores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
long
physical_pages
=
sysconf
(
_SC_PHYS_PAGES
);
long
physical_pages
=
sysconf
(
_SC_PHYS_PAGES
);
long
page_size
=
sysconf
(
_SC_PAGESIZE
);
long
page_size
=
sysconf
(
_SC_PAGESIZE
);
tsTotalMemoryMB
=
physical_pages
*
page_size
/
(
1024
*
1024
);
tsTotalMemoryKB
=
physical_pages
*
page_size
/
1024
;
tsPageSize
=
page_size
;
tsPageSizeKB
=
page_size
/
1024
;
tsNumOfCores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
}
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
if
(
rchars
)
*
rchars
=
0
;
if
(
rchars
)
*
rchars
=
0
;
if
(
wchars
)
*
wchars
=
0
;
if
(
wchars
)
*
wchars
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
*
readKB
=
0
;
*
readKB
=
0
;
*
writeKB
=
0
;
*
writeKB
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
)
{
int32_t
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
)
{
if
(
bytes
)
*
bytes
=
0
;
if
(
bytes
)
*
bytes
=
0
;
if
(
rbytes
)
*
rbytes
=
0
;
if
(
rbytes
)
*
rbytes
=
0
;
if
(
tbytes
)
*
tbytes
=
0
;
if
(
tbytes
)
*
tbytes
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
int32_t
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
*
bandSpeedKb
=
0
;
*
bandSpeedKb
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
int32_t
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
*
sysCpuUsage
=
0
;
*
sysCpuUsage
=
0
;
*
procCpuUsage
=
0
;
*
procCpuUsage
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetProcMemory
(
float
*
memoryUsedM
B
)
{
int32_t
taosGetProcMemory
(
int64_t
*
usedK
B
)
{
*
memoryUsedM
B
=
0
;
*
usedK
B
=
0
;
return
true
;
return
0
;
}
}
bool
taosGetSysMemory
(
float
*
memoryUsedM
B
)
{
int32_t
taosGetSysMemory
(
int64_t
*
usedK
B
)
{
*
memoryUsedM
B
=
0
;
*
usedK
B
=
0
;
return
true
;
return
0
;
}
}
int
taosSystem
(
const
char
*
cmd
)
{
int
taosSystem
(
const
char
*
cmd
)
{
//printf("un support funtion");
//
printf("un support funtion");
return
-
1
;
return
-
1
;
}
}
...
@@ -309,7 +309,7 @@ void taosSetCoreDump() {}
...
@@ -309,7 +309,7 @@ void taosSetCoreDump() {}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
struct
statvfs
info
;
struct
statvfs
info
;
if
(
statvfs
(
dataDir
,
&
info
))
{
if
(
statvfs
(
dataDir
,
&
info
))
{
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
//
printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -377,39 +377,38 @@ static char tsSysCpuFile[] = "/proc/stat";
...
@@ -377,39 +377,38 @@ static char tsSysCpuFile[] = "/proc/stat";
static
char
tsProcCpuFile
[
25
]
=
{
0
};
static
char
tsProcCpuFile
[
25
]
=
{
0
};
static
char
tsProcMemFile
[
25
]
=
{
0
};
static
char
tsProcMemFile
[
25
]
=
{
0
};
static
char
tsProcIOFile
[
25
]
=
{
0
};
static
char
tsProcIOFile
[
25
]
=
{
0
};
static
float
tsPageSizeKB
=
0
;
static
void
taosGetProcInfos
()
{
static
void
taosGetProcInfos
()
{
tsPageSize
=
sysconf
(
_SC_PAGESIZE
)
;
tsPageSize
KB
=
sysconf
(
_SC_PAGESIZE
)
/
1024
;
tsOpenMax
=
sysconf
(
_SC_OPEN_MAX
);
tsOpenMax
=
sysconf
(
_SC_OPEN_MAX
);
tsStreamMax
=
sysconf
(
_SC_STREAM_MAX
);
tsStreamMax
=
sysconf
(
_SC_STREAM_MAX
);
tsProcId
=
(
pid_t
)
syscall
(
SYS_gettid
);
tsProcId
=
(
pid_t
)
syscall
(
SYS_gettid
);
tsPageSizeKB
=
(
float
)(
sysconf
(
_SC_PAGESIZE
))
/
1024
;
snprintf
(
tsProcMemFile
,
25
,
"/proc/%d/status"
,
tsProcId
);
snprintf
(
tsProcMemFile
,
sizeof
(
tsProcMemFile
)
,
"/proc/%d/status"
,
tsProcId
);
snprintf
(
tsProcCpuFile
,
25
,
"/proc/%d/stat"
,
tsProcId
);
snprintf
(
tsProcCpuFile
,
sizeof
(
tsProcCpuFile
)
,
"/proc/%d/stat"
,
tsProcId
);
snprintf
(
tsProcIOFile
,
25
,
"/proc/%d/io"
,
tsProcId
);
snprintf
(
tsProcIOFile
,
sizeof
(
tsProcIOFile
)
,
"/proc/%d/io"
,
tsProcId
);
}
}
static
int32_t
taosGetTotalMemory
()
{
return
(
int32_t
)((
float
)
sysconf
(
_SC_PHYS_PAGES
)
*
tsPageSizeKB
/
1024
);
}
int32_t
taosGetTotalMemory
(
int64_t
*
totalKB
)
{
*
totalKB
=
(
int64_t
)(
sysconf
(
_SC_PHYS_PAGES
)
*
tsPageSizeKB
);
return
0
;
}
bool
taosGetSysMemory
(
float
*
memoryUsedMB
)
{
int32_t
taosGetSysMemory
(
int64_t
*
usedKB
)
{
float
memoryAvailMB
=
(
float
)
sysconf
(
_SC_AVPHYS_PAGES
)
*
tsPageSizeKB
/
1024
;
*
usedKB
=
sysconf
(
_SC_AVPHYS_PAGES
)
*
tsPageSizeKB
;
*
memoryUsedMB
=
(
float
)
tsTotalMemoryMB
-
memoryAvailMB
;
return
0
;
return
true
;
}
}
bool
taosGetProcMemory
(
float
*
memoryUsedM
B
)
{
int32_t
taosGetProcMemory
(
int64_t
*
usedK
B
)
{
// FILE *fp = fopen(tsProcMemFile, "r");
// FILE *fp = fopen(tsProcMemFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsProcMemFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
tsProcMemFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsProcMemFile);
//
printf("open file:%s failed", tsProcMemFile);
return
false
;
return
-
1
;
}
}
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
while
(
!
taosEOFFile
(
pFile
))
{
while
(
!
taosEOFFile
(
pFile
))
{
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
...
@@ -421,60 +420,58 @@ bool taosGetProcMemory(float *memoryUsedMB) {
...
@@ -421,60 +420,58 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
}
if
(
line
==
NULL
)
{
if
(
line
==
NULL
)
{
//printf("read file:%s failed", tsProcMemFile);
//
printf("read file:%s failed", tsProcMemFile);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
false
;
return
-
1
;
}
}
int64_t
memKB
=
0
;
char
tmp
[
10
];
char
tmp
[
10
];
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
&
memKB
);
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
usedKB
);
*
memoryUsedMB
=
(
float
)((
double
)
memKB
/
1024
);
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
true
;
return
0
;
}
}
static
bool
taosGetSysCpuInfo
(
SysCpuInfo
*
cpuInfo
)
{
static
int32_t
taosGetSysCpuInfo
(
SysCpuInfo
*
cpuInfo
)
{
// FILE *fp = fopen(tsSysCpuFile, "r");
// FILE *fp = fopen(tsSysCpuFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsSysCpuFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
tsSysCpuFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsSysCpuFile);
//
printf("open file:%s failed", tsSysCpuFile);
return
false
;
return
-
1
;
}
}
char
*
line
=
NULL
;
char
*
line
=
NULL
;
ssize_t
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
ssize_t
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
//printf("read file:%s failed", tsSysCpuFile);
//
printf("read file:%s failed", tsSysCpuFile);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
false
;
return
-
1
;
}
}
char
cpu
[
10
]
=
{
0
};
char
cpu
[
10
]
=
{
0
};
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
&
cpuInfo
->
idle
);
&
cpuInfo
->
idle
);
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
true
;
return
0
;
}
}
static
bool
taosGetProcCpuInfo
(
ProcCpuInfo
*
cpuInfo
)
{
static
int32_t
taosGetProcCpuInfo
(
ProcCpuInfo
*
cpuInfo
)
{
// FILE *fp = fopen(tsProcCpuFile, "r");
// FILE *fp = fopen(tsProcCpuFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsProcCpuFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
tsProcCpuFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsProcCpuFile);
//
printf("open file:%s failed", tsProcCpuFile);
return
false
;
return
-
1
;
}
}
char
*
line
=
NULL
;
char
*
line
=
NULL
;
ssize_t
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
ssize_t
_bytes
=
taosGetLineFile
(
pFile
,
&
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
//printf("read file:%s failed", tsProcCpuFile);
//
printf("read file:%s failed", tsProcCpuFile);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
false
;
return
-
1
;
}
}
for
(
int
i
=
0
,
blank
=
0
;
line
[
i
]
!=
0
;
++
i
)
{
for
(
int
i
=
0
,
blank
=
0
;
line
[
i
]
!=
0
;
++
i
)
{
...
@@ -486,26 +483,28 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
...
@@ -486,26 +483,28 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
}
}
}
}
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
true
;
return
0
;
}
}
int32_t
taosGetCpuCores
(
float
*
numOfCores
)
{
*
numOfCores
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
return
0
;
}
int32_t
taosGetCpuCores
()
{
return
(
int32_t
)
sysconf
(
_SC_NPROCESSORS_ONLN
);
}
int32_t
taosGetCpuUsage
(
float
*
cpu_system
,
float
*
cpu_engine
)
{
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
)
{
static
uint64_t
lastSysUsed
=
0
;
static
uint64_t
lastSysUsed
=
0
;
static
uint64_t
lastSysTotal
=
0
;
static
uint64_t
lastSysTotal
=
0
;
static
uint64_t
lastProcTotal
=
0
;
static
uint64_t
lastProcTotal
=
0
;
SysCpuInfo
sysCpu
;
SysCpuInfo
sysCpu
;
ProcCpuInfo
procCpu
;
ProcCpuInfo
procCpu
;
if
(
!
taosGetSysCpuInfo
(
&
sysCpu
)
)
{
if
(
taosGetSysCpuInfo
(
&
sysCpu
)
!=
0
)
{
return
false
;
return
-
1
;
}
}
if
(
!
taosGetProcCpuInfo
(
&
procCpu
)
)
{
if
(
taosGetProcCpuInfo
(
&
procCpu
)
!=
0
)
{
return
false
;
return
-
1
;
}
}
uint64_t
curSysUsed
=
sysCpu
.
user
+
sysCpu
.
nice
+
sysCpu
.
system
;
uint64_t
curSysUsed
=
sysCpu
.
user
+
sysCpu
.
nice
+
sysCpu
.
system
;
...
@@ -516,21 +515,21 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
...
@@ -516,21 +515,21 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
lastSysUsed
=
curSysUsed
>
1
?
curSysUsed
:
1
;
lastSysUsed
=
curSysUsed
>
1
?
curSysUsed
:
1
;
lastSysTotal
=
curSysTotal
>
1
?
curSysTotal
:
1
;
lastSysTotal
=
curSysTotal
>
1
?
curSysTotal
:
1
;
lastProcTotal
=
curProcTotal
>
1
?
curProcTotal
:
1
;
lastProcTotal
=
curProcTotal
>
1
?
curProcTotal
:
1
;
return
false
;
return
-
1
;
}
}
if
(
curSysTotal
==
lastSysTotal
)
{
if
(
curSysTotal
==
lastSysTotal
)
{
return
false
;
return
-
1
;
}
}
*
sysCpuUsag
e
=
(
float
)((
double
)(
curSysUsed
-
lastSysUsed
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
);
*
cpu_engin
e
=
(
float
)((
double
)(
curSysUsed
-
lastSysUsed
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
);
*
procCpuUsage
=
(
float
)((
double
)(
curProcTotal
-
lastProcTotal
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
);
*
cpu_system
=
(
float
)((
double
)(
curProcTotal
-
lastProcTotal
)
/
(
double
)(
curSysTotal
-
lastSysTotal
)
*
100
);
lastSysUsed
=
curSysUsed
;
lastSysUsed
=
curSysUsed
;
lastSysTotal
=
curSysTotal
;
lastSysTotal
=
curSysTotal
;
lastProcTotal
=
curProcTotal
;
lastProcTotal
=
curProcTotal
;
return
true
;
return
0
;
}
}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
...
@@ -540,22 +539,22 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
...
@@ -540,22 +539,22 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
}
else
{
}
else
{
diskSize
->
total
=
info
.
f_blocks
*
info
.
f_frsize
;
diskSize
->
total
=
info
.
f_blocks
*
info
.
f_frsize
;
diskSize
->
avail
=
info
.
f_bavail
*
info
.
f_frsize
;
diskSize
->
avail
=
info
.
f_bavail
*
info
.
f_frsize
;
diskSize
->
used
=
(
info
.
f_blocks
-
info
.
f_bfree
)
*
info
.
f_frsize
;
diskSize
->
used
=
diskSize
->
total
-
diskSize
->
avail
;
return
0
;
return
0
;
}
}
}
}
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
)
{
int32_t
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
)
{
*
bytes
=
0
;
if
(
bytes
)
*
bytes
=
0
;
// FILE *fp = fopen(tsSysNetFile, "r");
// FILE *fp = fopen(tsSysNetFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsSysNetFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
tsSysNetFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsSysNetFile);
//
printf("open file:%s failed", tsSysNetFile);
return
false
;
return
-
1
;
}
}
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
while
(
!
taosEOFFile
(
pFile
))
{
while
(
!
taosEOFFile
(
pFile
))
{
int64_t
o_rbytes
=
0
;
int64_t
o_rbytes
=
0
;
...
@@ -587,37 +586,37 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
...
@@ -587,37 +586,37 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
nouse0
,
&
o_rbytes
,
&
rpackts
,
&
nouse1
,
&
nouse2
,
&
nouse3
,
&
nouse4
,
&
nouse5
,
&
nouse6
,
&
o_tbytes
,
&
tpackets
);
nouse0
,
&
o_rbytes
,
&
rpackts
,
&
nouse1
,
&
nouse2
,
&
nouse3
,
&
nouse4
,
&
nouse5
,
&
nouse6
,
&
o_tbytes
,
&
tpackets
);
if
(
rbytes
)
*
rbytes
=
o_rbytes
;
if
(
rbytes
)
*
rbytes
=
o_rbytes
;
if
(
tbytes
)
*
tbytes
=
o_tbytes
;
if
(
tbytes
)
*
tbytes
=
o_tbytes
;
*
bytes
+=
(
o_rbytes
+
o_tbytes
);
if
(
bytes
)
*
bytes
+=
(
o_rbytes
+
o_tbytes
);
}
}
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
true
;
return
0
;
}
}
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
int32_t
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
static
int64_t
lastBytes
=
0
;
static
int64_t
lastBytes
=
0
;
static
time_t
lastTime
=
0
;
static
time_t
lastTime
=
0
;
int64_t
curBytes
=
0
;
int64_t
curBytes
=
0
;
time_t
curTime
=
time
(
NULL
);
time_t
curTime
=
time
(
NULL
);
if
(
!
taosGetCardInfo
(
&
curBytes
,
NULL
,
NULL
)
)
{
if
(
taosGetCardInfo
(
&
curBytes
,
NULL
,
NULL
)
!=
0
)
{
return
false
;
return
-
1
;
}
}
if
(
lastTime
==
0
||
lastBytes
==
0
)
{
if
(
lastTime
==
0
||
lastBytes
==
0
)
{
lastTime
=
curTime
;
lastTime
=
curTime
;
lastBytes
=
curBytes
;
lastBytes
=
curBytes
;
*
bandSpeedKb
=
0
;
*
bandSpeedKb
=
0
;
return
true
;
return
0
;
}
}
if
(
lastTime
>=
curTime
||
lastBytes
>
curBytes
)
{
if
(
lastTime
>=
curTime
||
lastBytes
>
curBytes
)
{
lastTime
=
curTime
;
lastTime
=
curTime
;
lastBytes
=
curBytes
;
lastBytes
=
curBytes
;
*
bandSpeedKb
=
0
;
*
bandSpeedKb
=
0
;
return
true
;
return
0
;
}
}
double
totalBytes
=
(
double
)(
curBytes
-
lastBytes
)
/
1024
*
8
;
// Kb
double
totalBytes
=
(
double
)(
curBytes
-
lastBytes
)
/
1024
*
8
;
// Kb
...
@@ -629,19 +628,19 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
...
@@ -629,19 +628,19 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
lastTime
=
curTime
;
lastTime
=
curTime
;
lastBytes
=
curBytes
;
lastBytes
=
curBytes
;
return
true
;
return
0
;
}
}
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
// FILE *fp = fopen(tsProcIOFile, "r");
// FILE *fp = fopen(tsProcIOFile, "r");
TdFilePtr
pFile
=
taosOpenFile
(
tsProcIOFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
tsProcIOFile
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
//printf("open file:%s failed", tsProcIOFile);
//
printf("open file:%s failed", tsProcIOFile);
return
false
;
return
-
1
;
}
}
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
char
tmp
[
10
];
char
tmp
[
10
];
int
readIndex
=
0
;
int
readIndex
=
0
;
...
@@ -662,32 +661,32 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
...
@@ -662,32 +661,32 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
if
(
readIndex
>=
2
)
break
;
if
(
readIndex
>=
2
)
break
;
}
}
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
if
(
readIndex
<
2
)
{
if
(
readIndex
<
2
)
{
//printf("read file:%s failed", tsProcIOFile);
//
printf("read file:%s failed", tsProcIOFile);
return
false
;
return
-
1
;
}
}
return
true
;
return
0
;
}
}
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
int64_t
curWritebyte
=
0
;
if
(
!
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
)
)
{
if
(
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
)
!=
0
)
{
return
false
;
return
-
1
;
}
}
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
lastReadbyte
=
curReadbyte
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
lastWritebyte
=
curWritebyte
;
return
false
;
return
-
1
;
}
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
...
@@ -698,27 +697,23 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
...
@@ -698,27 +697,23 @@ bool taosGetProcIO(float *readKB, float *writeKB) {
lastReadbyte
=
curReadbyte
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
lastWritebyte
=
curWritebyte
;
return
true
;
return
0
;
}
}
void
taosGetSystemInfo
()
{
void
taosGetSystemInfo
()
{
taosGetProcInfos
();
taosGetProcInfos
();
taosGetCpuCores
(
&
tsNumOfCores
);
tsNumOfCores
=
taosGetCpuCores
();
taosGetTotalMemory
(
&
tsTotalMemoryKB
);
tsTotalMemoryMB
=
taosGetTotalMemory
();
float
tmp1
,
tmp2
;
float
tmp1
,
tmp2
;
taosGetSysMemory
(
&
tmp1
);
taosGetProcMemory
(
&
tmp2
);
taosGetBandSpeed
(
&
tmp1
);
taosGetBandSpeed
(
&
tmp1
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetCpuUsage
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
taosGetProcIO
(
&
tmp1
,
&
tmp2
);
}
}
void
taosKillSystem
()
{
void
taosKillSystem
()
{
// SIGINT
// SIGINT
//printf("taosd will shut down soon");
//
printf("taosd will shut down soon");
kill
(
tsProcId
,
2
);
kill
(
tsProcId
,
2
);
}
}
...
@@ -727,22 +722,22 @@ int taosSystem(const char *cmd) {
...
@@ -727,22 +722,22 @@ int taosSystem(const char *cmd) {
int
res
;
int
res
;
char
buf
[
1024
];
char
buf
[
1024
];
if
(
cmd
==
NULL
)
{
if
(
cmd
==
NULL
)
{
//printf("taosSystem cmd is NULL!");
//
printf("taosSystem cmd is NULL!");
return
-
1
;
return
-
1
;
}
}
if
((
fp
=
popen
(
cmd
,
"r"
))
==
NULL
)
{
if
((
fp
=
popen
(
cmd
,
"r"
))
==
NULL
)
{
//printf("popen cmd:%s error: %s", cmd, strerror(errno));
//
printf("popen cmd:%s error: %s", cmd, strerror(errno));
return
-
1
;
return
-
1
;
}
else
{
}
else
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
//printf("popen result:%s", buf);
//
printf("popen result:%s", buf);
}
}
if
((
res
=
pclose
(
fp
))
==
-
1
)
{
if
((
res
=
pclose
(
fp
))
==
-
1
)
{
//printf("close popen file pointer fp error!");
//
printf("close popen file pointer fp error!");
}
else
{
}
else
{
//printf("popen res is :%d", res);
//
printf("popen res is :%d", res);
}
}
return
res
;
return
res
;
...
@@ -757,14 +752,14 @@ void taosSetCoreDump(bool enable) {
...
@@ -757,14 +752,14 @@ void taosSetCoreDump(bool enable) {
struct
rlimit
rlim_new
;
struct
rlimit
rlim_new
;
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
#ifndef _ALPINE
//printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
//
printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
#else
//printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
//
printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
#endif
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
//printf("set unlimited fail, error: %s", strerror(errno));
//
printf("set unlimited fail, error: %s", strerror(errno));
rlim_new
.
rlim_cur
=
rlim
.
rlim_max
;
rlim_new
.
rlim_cur
=
rlim
.
rlim_max
;
rlim_new
.
rlim_max
=
rlim
.
rlim_max
;
rlim_new
.
rlim_max
=
rlim
.
rlim_max
;
(
void
)
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
);
(
void
)
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
);
...
@@ -773,9 +768,9 @@ void taosSetCoreDump(bool enable) {
...
@@ -773,9 +768,9 @@ void taosSetCoreDump(bool enable) {
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
#ifndef _ALPINE
//printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
//
printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
#else
//printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
//
printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
#endif
}
}
...
@@ -801,10 +796,10 @@ void taosSetCoreDump(bool enable) {
...
@@ -801,10 +796,10 @@ void taosSetCoreDump(bool enable) {
old_len
=
sizeof
(
old_usespid
);
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
//printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
//
printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
}
//printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
//
printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
old_usespid
=
0
;
old_usespid
=
0
;
old_len
=
0
;
old_len
=
0
;
...
@@ -817,10 +812,10 @@ void taosSetCoreDump(bool enable) {
...
@@ -817,10 +812,10 @@ void taosSetCoreDump(bool enable) {
old_len
=
sizeof
(
old_usespid
);
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
//printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
//
printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
}
//printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
//
printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
#endif
#endif
}
}
...
@@ -885,7 +880,7 @@ SysNameInfo taosGetSysNameInfo() {
...
@@ -885,7 +880,7 @@ SysNameInfo taosGetSysNameInfo() {
return
info
;
return
info
;
}
}
bool
taosGetEmail
(
char
*
email
,
int32_t
maxLen
)
{
int32_t
taosGetEmail
(
char
*
email
,
int32_t
maxLen
)
{
const
char
*
filepath
=
"/usr/local/taos/email"
;
const
char
*
filepath
=
"/usr/local/taos/email"
;
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_READ
);
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_READ
);
...
@@ -893,17 +888,17 @@ bool taosGetEmail(char *email, int32_t maxLen) {
...
@@ -893,17 +888,17 @@ bool taosGetEmail(char *email, int32_t maxLen) {
if
(
taosReadFile
(
pFile
,
(
void
*
)
email
,
maxLen
)
<
0
)
{
if
(
taosReadFile
(
pFile
,
(
void
*
)
email
,
maxLen
)
<
0
)
{
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
false
;
return
-
1
;
}
}
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
true
;
return
0
;
}
}
bool
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
)
{
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
)
{
char
*
line
=
NULL
;
char
*
line
=
NULL
;
size_t
size
=
0
;
size_t
size
=
0
;
bool
ret
=
false
;
int32_t
code
=
-
1
;
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
if
(
pFile
==
NULL
)
return
false
;
...
@@ -917,21 +912,21 @@ bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
...
@@ -917,21 +912,21 @@ bool taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
line
[
size
-
2
]
=
0
;
line
[
size
-
2
]
=
0
;
}
}
tstrncpy
(
releaseName
,
p
,
maxLen
);
tstrncpy
(
releaseName
,
p
,
maxLen
);
ret
=
true
;
code
=
0
;
break
;
break
;
}
}
}
}
if
(
line
!=
NULL
)
free
(
line
);
if
(
line
!=
NULL
)
free
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
ret
;
return
code
;
}
}
bool
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_
t
*
numOfCores
)
{
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
floa
t
*
numOfCores
)
{
char
*
line
=
NULL
;
char
*
line
=
NULL
;
size_t
size
=
0
;
size_t
size
=
0
;
int32_t
done
=
0
;
int32_t
done
=
0
;
bool
ret
=
false
;
int32_t
code
=
-
1
;
TdFilePtr
pFile
=
taosOpenFile
(
"/proc/cpuinfo"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
"/proc/cpuinfo"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
if
(
pFile
==
NULL
)
return
false
;
...
@@ -941,11 +936,11 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
...
@@ -941,11 +936,11 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
tstrncpy
(
cpuModel
,
v
,
maxLen
);
tstrncpy
(
cpuModel
,
v
,
maxLen
);
ret
=
true
;
code
=
0
;
done
|=
1
;
done
|=
1
;
}
else
if
(((
done
&
2
)
==
0
)
&&
strncmp
(
line
,
"cpu cores"
,
9
)
==
0
)
{
}
else
if
(((
done
&
2
)
==
0
)
&&
strncmp
(
line
,
"cpu cores"
,
9
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
*
numOfCores
=
ato
i
(
v
);
*
numOfCores
=
ato
f
(
v
);
done
|=
2
;
done
|=
2
;
}
}
}
}
...
@@ -953,31 +948,7 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
...
@@ -953,31 +948,7 @@ bool taosGetCpuInfo(char *cpuModel, int32_t maxLen, int32_t *numOfCores) {
if
(
line
!=
NULL
)
free
(
line
);
if
(
line
!=
NULL
)
free
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
ret
;
return
code
;
}
bool
taosGetTotalSysMemoryKB
(
uint64_t
*
kb
)
{
char
*
line
=
NULL
;
size_t
size
=
0
;
bool
ret
=
false
;
TdFilePtr
pFile
=
taosOpenFile
(
"/proc/meminfo"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
while
((
size
=
taosGetLineFile
(
pFile
,
&
line
))
!=
-
1
)
{
line
[
size
-
1
]
=
'\0'
;
if
(
strncmp
(
line
,
"MemTotal"
,
8
)
==
0
)
{
const
char
*
p
=
strchr
(
line
,
':'
)
+
1
;
while
(
*
p
==
' '
)
p
++
;
ret
=
true
;
*
kb
=
atoll
(
p
);
break
;
}
}
if
(
line
!=
NULL
)
free
(
line
);
taosCloseFile
(
&
pFile
);
return
ret
;
}
}
#endif
#endif
source/util/src/tconfig.c
浏览文件 @
cde3e970
...
@@ -145,14 +145,7 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
...
@@ -145,14 +145,7 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
return
-
1
;
return
-
1
;
}
}
#if 0
tfree
(
pItem
->
str
);
if (taosMkDir(fullDir) != 0) {
uError("failed to create dir:%s realpath:%s since %s", inputDir, fullDir, terrstr());
return -1;
}
#endif
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
fullDir
);
pItem
->
str
=
strdup
(
fullDir
);
if
(
pItem
->
str
==
NULL
)
{
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -647,7 +640,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
...
@@ -647,7 +640,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
}
}
cfgSetItem
(
pConfig
,
name
,
value
,
CFG_STYPE_CFG_FILE
);
cfgSetItem
(
pConfig
,
name
,
value
,
CFG_STYPE_CFG_FILE
);
if
(
value2
!=
NULL
&&
value3
!=
NULL
&&
value2
[
0
]
!=
0
&&
value3
[
0
]
!=
0
)
{
if
(
value2
!=
NULL
&&
value3
!=
NULL
&&
value2
[
0
]
!=
0
&&
value3
[
0
]
!=
0
&&
strcasecmp
(
name
,
"dataDir"
)
==
0
)
{
cfgSetTfsItem
(
pConfig
,
name
,
value
,
value2
,
value3
,
CFG_STYPE_CFG_FILE
);
cfgSetTfsItem
(
pConfig
,
name
,
value
,
value2
,
value3
,
CFG_STYPE_CFG_FILE
);
}
}
}
}
...
...
source/util/test/cacheTest.cpp
浏览文件 @
cde3e970
#include "os.h"
#include <iostream>
#include <iostream>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include "os.h"
#include "taos.h"
#include "taos.h"
#include "tcache.h"
#include "tcache.h"
...
...
source/util/test/encodeTest.cpp
浏览文件 @
cde3e970
#include <iostream>
#include <iostream>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tencode.h"
#include "tencode.h"
...
...
source/util/test/freelistTest.cpp
浏览文件 @
cde3e970
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tfreelist.h"
#include "tfreelist.h"
...
...
source/util/test/hashTest.cpp
浏览文件 @
cde3e970
#include "os.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <limits.h>
#include <limits.h>
#include <taosdef.h>
#include <iostream>
#include <iostream>
#include "os.h"
#include "taosdef.h"
#include "thash.h"
#include "thash.h"
#include "taos.h"
#include "taos.h"
...
...
tools/shell/src/backup/shellImport.c
浏览文件 @
cde3e970
...
@@ -93,8 +93,7 @@ static void shellCheckTablesSQLFile(const char *directoryName)
...
@@ -93,8 +93,7 @@ static void shellCheckTablesSQLFile(const char *directoryName)
{
{
sprintf
(
shellTablesSQLFile
,
"%s/tables.sql"
,
directoryName
);
sprintf
(
shellTablesSQLFile
,
"%s/tables.sql"
,
directoryName
);
struct
stat
fstat
;
if
(
taosFStatFile
(
shellTablesSQLFile
,
NULL
,
NULL
)
<
0
)
{
if
(
stat
(
shellTablesSQLFile
,
&
fstat
)
<
0
)
{
shellTablesSQLFile
[
0
]
=
0
;
shellTablesSQLFile
[
0
]
=
0
;
}
}
}
}
...
@@ -109,13 +108,12 @@ static void shellMallocSQLFiles()
...
@@ -109,13 +108,12 @@ static void shellMallocSQLFiles()
static
void
shellGetDirectoryFileList
(
char
*
inputDir
)
static
void
shellGetDirectoryFileList
(
char
*
inputDir
)
{
{
struct
stat
fileStat
;
if
(
!
taosDirExist
(
inputDir
))
{
if
(
stat
(
inputDir
,
&
fileStat
)
<
0
)
{
fprintf
(
stderr
,
"ERROR: %s not exist
\n
"
,
inputDir
);
fprintf
(
stderr
,
"ERROR: %s not exist
\n
"
,
inputDir
);
exit
(
0
);
exit
(
0
);
}
}
if
(
fileStat
.
st_mode
&
S_IFDIR
)
{
if
(
taosIsDir
(
inputDir
)
)
{
shellCheckTablesSQLFile
(
inputDir
);
shellCheckTablesSQLFile
(
inputDir
);
shellSQLFileNum
=
shellGetFilesNum
(
inputDir
,
"sql"
);
shellSQLFileNum
=
shellGetFilesNum
(
inputDir
,
"sql"
);
int
totalSQLFileNum
=
shellSQLFileNum
;
int
totalSQLFileNum
=
shellSQLFileNum
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录