Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6afebf9a
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
6afebf9a
编写于
2月 28, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
[td-13039] merge 3.0
上级
40da10fa
f5cf2ca3
变更
50
隐藏空白更改
内联
并排
Showing
50 changed file
with
489 addition
and
425 deletion
+489
-425
include/common/tglobal.h
include/common/tglobal.h
+3
-2
include/dnode/mgmt/dnode.h
include/dnode/mgmt/dnode.h
+10
-7
include/os/osDef.h
include/os/osDef.h
+4
-0
include/os/osEnv.h
include/os/osEnv.h
+19
-21
include/os/osFile.h
include/os/osFile.h
+1
-1
include/os/osSysinfo.h
include/os/osSysinfo.h
+1
-14
include/util/tconfig.h
include/util/tconfig.h
+8
-1
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+2
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+155
-115
source/common/src/ttszip.c
source/common/src/ttszip.c
+1
-1
source/dnode/mgmt/daemon/src/dmnCfg.c
source/dnode/mgmt/daemon/src/dmnCfg.c
+2
-0
source/dnode/mgmt/daemon/src/dmnMain.c
source/dnode/mgmt/daemon/src/dmnMain.c
+2
-2
source/dnode/mgmt/impl/src/dndEnv.c
source/dnode/mgmt/impl/src/dndEnv.c
+10
-3
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+3
-3
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+28
-25
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+4
-2
source/dnode/vnode/src/inc/tsdbFile.h
source/dnode/vnode/src/inc/tsdbFile.h
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+4
-2
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+4
-2
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+6
-4
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+2
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+1
-1
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+1
-1
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+1
-1
source/libs/index/test/fstUT.cc
source/libs/index/test/fstUT.cc
+1
-1
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+1
-1
source/libs/parser/src/parserImpl.c
source/libs/parser/src/parserImpl.c
+1
-1
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+1
-1
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+1
-1
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+1
-1
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+1
-1
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+1
-1
source/libs/tdb/src/db/tdbEnv.c
source/libs/tdb/src/db/tdbEnv.c
+1
-1
source/libs/tdb/src/db/tdbPgFile.c
source/libs/tdb/src/db/tdbPgFile.c
+1
-1
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+1
-1
source/libs/transport/test/rserver.c
source/libs/transport/test/rserver.c
+1
-1
source/libs/transport/test/transUT.cc
source/libs/transport/test/transUT.cc
+1
-1
source/libs/wal/src/walSeek.c
source/libs/wal/src/walSeek.c
+4
-4
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+3
-3
source/os/src/osEnv.c
source/os/src/osEnv.c
+51
-72
source/os/src/osFile.c
source/os/src/osFile.c
+66
-76
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+2
-7
source/util/src/tconfig.c
source/util/src/tconfig.c
+66
-11
source/util/src/tlog.c
source/util/src/tlog.c
+4
-19
source/util/test/cfgTest.cpp
source/util/test/cfgTest.cpp
+0
-1
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+3
-3
tools/shell/src/shellLinux.c
tools/shell/src/shellLinux.c
+1
-1
未找到文件。
include/common/tglobal.h
浏览文件 @
6afebf9a
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "tcfg.h"
#include "tdef.h"
#include "tarray.h"
// cluster
extern
char
tsFirst
[];
...
...
@@ -94,8 +95,8 @@ extern SDiskCfg tsDiskCfg[];
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
);
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
);
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
void
taosCleanupCfg
();
void
taosCfgDynamicOptions
(
const
char
*
option
,
const
char
*
value
);
...
...
include/dnode/mgmt/dnode.h
浏览文件 @
6afebf9a
...
...
@@ -17,6 +17,7 @@
#define _TD_DNODE_H_
#include "tdef.h"
#include "tcfg.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -40,13 +41,15 @@ void dndCleanup();
/* ------------------------ SDnode ----------------------- */
typedef
struct
{
int32_t
numOfSupportVnodes
;
uint16_t
serverPort
;
char
dataDir
[
TSDB_FILENAME_LEN
];
char
localEp
[
TSDB_EP_LEN
];
char
localFqdn
[
TSDB_FQDN_LEN
];
char
firstEp
[
TSDB_EP_LEN
];
char
secondEp
[
TSDB_EP_LEN
];
int32_t
numOfSupportVnodes
;
uint16_t
serverPort
;
char
dataDir
[
TSDB_FILENAME_LEN
];
char
localEp
[
TSDB_EP_LEN
];
char
localFqdn
[
TSDB_FQDN_LEN
];
char
firstEp
[
TSDB_EP_LEN
];
char
secondEp
[
TSDB_EP_LEN
];
SDiskCfg
*
pDisks
;
int32_t
numOfDisks
;
}
SDnodeObjCfg
;
/**
...
...
include/os/osDef.h
浏览文件 @
6afebf9a
...
...
@@ -191,6 +191,10 @@ extern "C" {
#define TD_DIRSEP "/"
#endif
#define TD_LOCALE_LEN 64
#define TD_CHARSET_LEN 64
#define TD_TIMEZONE_LEN 96
#ifdef __cplusplus
}
#endif
...
...
include/os/osEnv.h
浏览文件 @
6afebf9a
...
...
@@ -22,33 +22,31 @@
extern
"C"
{
#endif
typedef
struct
SOsEnv
SOsEnv
;
extern
char
tsOsName
[];
extern
char
tsTimezone
[];
extern
char
tsCharset
[];
extern
char
tsLocale
[];
extern
int8_t
tsDaylight
;
extern
bool
tsEnableCoreFile
;
extern
int64_t
tsPageSize
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsStreamMax
;
extern
int32_t
tsNumOfCores
;
extern
int32_t
tsTotalMemoryMB
;
extern
char
configDir
[];
extern
char
tsDataDir
[];
extern
char
tsLogDir
[];
extern
char
tsTempDir
[];
extern
SDiskSpace
tsDataSpace
;
extern
SDiskSpace
tsLogSpace
;
extern
SDiskSpace
tsTempSpace
;
void
osInit
();
void
osUpdate
();
bool
osLogSpaceAvailable
();
int8_t
osDaylight
();
const
char
*
osLogDir
();
const
char
*
osTempDir
();
const
char
*
osDataDir
();
const
char
*
osName
();
const
char
*
osTimezone
();
const
char
*
osLocale
();
const
char
*
osCharset
();
void
osSetLogDir
(
const
char
*
logDir
);
void
osSetTempDir
(
const
char
*
tempDir
);
void
osSetDataDir
(
const
char
*
dataDir
);
void
osSetLogReservedSpace
(
float
sizeInGB
);
void
osSetTempReservedSpace
(
float
sizeInGB
);
void
osSetDataReservedSpace
(
float
sizeInGB
);
bool
osLogSpaceAvailable
();
void
osSetTimezone
(
const
char
*
timezone
);
void
osSetLocale
(
const
char
*
locale
,
const
char
*
charset
);
bool
osSetEnableCore
(
bool
enable
);
#ifdef __cplusplus
}
...
...
include/os/osFile.h
浏览文件 @
6afebf9a
...
...
@@ -62,7 +62,7 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
int64_t
taosPReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
,
int64_t
offset
);
int64_t
taosWriteFile
(
TdFilePtr
pFile
,
const
void
*
buf
,
int64_t
count
);
void
taosFprintfFile
(
TdFilePtr
pFile
,
const
char
*
format
,
...);
size
_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
);
int64
_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
);
int32_t
taosEOFFile
(
TdFilePtr
pFile
);
int64_t
taosCloseFile
(
TdFilePtr
*
ppFile
);
...
...
include/os/osSysinfo.h
浏览文件 @
6afebf9a
...
...
@@ -22,29 +22,17 @@ extern "C" {
#include "os.h"
#define TD_LOCALE_LEN 64
#define TD_CHARSET_LEN 64
#define TD_TIMEZONE_LEN 96
typedef
struct
{
int64_t
total
;
int64_t
used
;
int64_t
avail
;
}
SDiskSize
;
typedef
struct
SDiskSpace
{
typedef
struct
{
int64_t
reserved
;
SDiskSize
size
;
}
SDiskSpace
;
extern
int64_t
tsPageSize
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsStreamMax
;
extern
int32_t
tsNumOfCores
;
extern
int32_t
tsTotalMemoryMB
;
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
);
int32_t
taosGetCpuCores
();
void
taosGetSystemInfo
();
...
...
@@ -56,7 +44,6 @@ void taosGetDisk();
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsage
);
bool
taosGetProcMemory
(
float
*
memoryUsedMB
);
bool
taosGetSysMemory
(
float
*
memoryUsedMB
);
void
taosPrintOsInfo
();
int
taosSystem
(
const
char
*
cmd
);
void
taosKillSystem
();
int32_t
taosGetSystemUUID
(
char
*
uid
,
int32_t
uidlen
);
...
...
include/util/tconfig.h
浏览文件 @
6afebf9a
...
...
@@ -18,6 +18,7 @@
#define _TD_CONFIG_H_
#include "os.h"
#include "tarray.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -32,7 +33,6 @@ typedef enum {
CFG_STYPE_ENV_VAR
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_API_OPTION
}
ECfgSrcType
;
typedef
enum
{
...
...
@@ -68,12 +68,19 @@ typedef struct SConfigItem {
int64_t
imax
;
double
fmax
;
};
SArray
*
array
;
// SDiskCfg
}
SConfigItem
;
typedef
struct
{
const
char
*
name
;
const
char
*
value
;
}
SConfigPair
;
typedef
struct
SConfig
SConfig
;
SConfig
*
cfgInit
();
int32_t
cfgLoad
(
SConfig
*
pCfg
,
ECfgSrcType
cfgType
,
const
char
*
sourceStr
);
int32_t
cfgLoadArray
(
SConfig
*
pCfg
,
SArray
*
pArgs
);
// SConfigPair
void
cfgCleanup
(
SConfig
*
pCfg
);
int32_t
cfgGetSize
(
SConfig
*
pCfg
);
...
...
source/client/src/clientEnv.c
浏览文件 @
6afebf9a
...
...
@@ -212,12 +212,12 @@ void taos_init_imp(void) {
deltaToUtcInitOnce
();
if
(
taosCreateLog
(
"taoslog"
,
10
,
configDir
,
NULL
,
NULL
,
1
)
!=
0
)
{
if
(
taosCreateLog
(
"taoslog"
,
10
,
configDir
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
tscInitRes
=
-
1
;
return
;
}
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
1
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
tscInitRes
=
-
1
;
return
;
}
...
...
source/common/src/tglobal.c
浏览文件 @
6afebf9a
...
...
@@ -154,19 +154,20 @@ 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
);
}
static
void
taosReadDataDirCfg
(
char
*
v1
,
char
*
v2
,
char
*
v3
)
{
if
(
tsDiskCfgNum
==
1
)
{
SDiskCfg
*
cfg
=
&
tsDiskCfg
[
0
];
uInfo
(
"dataDir:%s, level:%d primary:%d is replaced by %s"
,
cfg
->
dir
,
cfg
->
level
,
cfg
->
primary
,
v1
);
}
taosAddDataDir
(
0
,
v1
,
0
,
1
);
tsDiskCfgNum
=
1
;
}
static
void
taosPrintDataDirCfg
()
{
for
(
int32_t
i
=
0
;
i
<
tsDiskCfgNum
;
++
i
)
{
SDiskCfg
*
cfg
=
&
tsDiskCfg
[
i
];
uInfo
(
" dataDir: %s"
,
cfg
->
dir
);
static
void
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
if
(
pItem
==
NULL
)
return
;
int32_t
size
=
taosArrayGetSize
(
pItem
->
array
);
if
(
size
<=
0
)
{
tsDiskCfgNum
=
1
;
taosAddDataDir
(
0
,
pItem
->
str
,
0
,
1
);
}
else
{
tsDiskCfgNum
=
size
<
TFS_MAX_DISKS
?
size
:
TFS_MAX_DISKS
;
for
(
int32_t
index
=
0
;
index
<
tsDiskCfgNum
;
++
index
)
{
SDiskCfg
*
pCfg
=
taosArrayGet
(
pItem
->
array
,
index
);
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
}
}
}
...
...
@@ -206,103 +207,126 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
return
0
;
}
static
void
taosAddClientLogCfg
(
SConfig
*
pCfg
)
{
cfgAddDir
(
pCfg
,
"logDir"
,
osLogDir
(),
1
);
cfgAddFloat
(
pCfg
,
"minimalLogDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
);
cfgAddInt32
(
pCfg
,
"numOfLogLines"
,
tsNumOfLogLines
,
1000
,
2000000000
,
1
);
cfgAddBool
(
pCfg
,
"asyncLog"
,
tsAsyncLog
,
1
);
cfgAddInt32
(
pCfg
,
"logKeepDays"
,
0
,
-
365000
,
365000
,
1
);
cfgAddInt32
(
pCfg
,
"cDebugFlag"
,
cDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"uDebugFlag"
,
uDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"rpcDebugFlag"
,
rpcDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"tmrDebugFlag"
,
tmrDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"jniDebugFlag"
,
jniDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"simDebugFlag"
,
143
,
0
,
255
,
1
);
cfgAddDir
(
pCfg
,
"configDir"
,
configDir
,
1
);
cfgAddDir
(
pCfg
,
"scriptDir"
,
configDir
,
1
);
cfgAddInt32
(
pCfg
,
"debugFlag"
,
0
,
0
,
255
,
1
);
static
int32_t
taosAddClientLogCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddDir
(
pCfg
,
"logDir"
,
tsLogDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalLogDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfLogLines"
,
tsNumOfLogLines
,
1000
,
2000000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"asyncLog"
,
tsAsyncLog
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"logKeepDays"
,
0
,
-
365000
,
365000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"cDebugFlag"
,
cDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"uDebugFlag"
,
uDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcDebugFlag"
,
rpcDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tmrDebugFlag"
,
tmrDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"jniDebugFlag"
,
jniDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"simDebugFlag"
,
143
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"configDir"
,
configDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"scriptDir"
,
configDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"debugFlag"
,
0
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddServerLogCfg
(
SConfig
*
pCfg
)
{
cfgAddInt32
(
pCfg
,
"dDebugFlag"
,
dDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"vDebugFlag"
,
vDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"mDebugFlag"
,
mDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"qDebugFlag"
,
qDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"wDebugFlag"
,
wDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"sDebugFlag"
,
sDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"tsdbDebugFlag"
,
tsdbDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"tqDebugFlag"
,
tqDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"fsDebugFlag"
,
fsDebugFlag
,
0
,
255
,
0
);
static
int32_t
taosAddServerLogCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddInt32
(
pCfg
,
"dDebugFlag"
,
dDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"vDebugFlag"
,
vDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"mDebugFlag"
,
mDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"qDebugFlag"
,
qDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"wDebugFlag"
,
wDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"sDebugFlag"
,
sDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tsdbDebugFlag"
,
tsdbDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tqDebugFlag"
,
tqDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"fsDebugFlag"
,
fsDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddClientCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosAddClientCfg
(
SConfig
*
pCfg
)
{
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
int32_t
defaultServerPort
=
6030
;
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
char
defaultSecondEp
[
TSDB_EP_LEN
]
=
{
0
};
taosGetFqdn
(
defaultFqdn
);
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
return
-
1
;
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
snprintf
(
defaultSecondEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
,
1
);
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
,
1
);
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
);
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
);
cfgAddDir
(
pCfg
,
"tempDir"
,
osTempDir
(),
1
);
cfgAddFloat
(
pCfg
,
"minimalTempDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
);
cfgAddFloat
(
pCfg
,
"numOfThreadsPerCore"
,
tsNumOfThreadsPerCore
,
0
,
10
,
1
);
cfgAddInt32
(
pCfg
,
"maxTmrCtrl"
,
tsMaxTmrCtrl
,
8
,
2048
,
1
);
cfgAddInt32
(
pCfg
,
"rpcTimer"
,
tsRpcTimer
,
100
,
3000
,
1
);
cfgAddInt32
(
pCfg
,
"rpcMaxTime"
,
tsRpcMaxTime
,
100
,
7200
,
1
);
cfgAddBool
(
pCfg
,
"rpcForceTcp"
,
tsRpcForceTcp
,
1
);
cfgAddInt32
(
pCfg
,
"shellActivityTimer"
,
tsShellActivityTimer
,
1
,
120
,
1
);
cfgAddInt32
(
pCfg
,
"compressMsgSize"
,
tsCompressMsgSize
,
-
1
,
100000000
,
1
);
cfgAddInt32
(
pCfg
,
"compressColData"
,
tsCompressColData
,
-
1
,
100000000
,
1
);
cfgAddInt32
(
pCfg
,
"maxWildCardsLength"
,
tsMaxWildCardsLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
);
cfgAddInt32
(
pCfg
,
"maxRegexStringLen"
,
tsMaxRegexStringLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
);
cfgAddInt32
(
pCfg
,
"maxNumOfOrderedRes"
,
tsMaxNumOfOrderedResults
,
128
,
TSDB_MAX_ALLOWED_SQL_LEN
,
1
);
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
);
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
);
cfgAddTimezone
(
pCfg
,
"timezone"
,
osTimezone
());
cfgAddLocale
(
pCfg
,
"locale"
,
osLocale
());
cfgAddCharset
(
pCfg
,
"charset"
,
osCharset
());
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
0
,
1
);
cfgAddInt32
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
1
,
100000
,
1
);
cfgAddString
(
pCfg
,
"version"
,
version
,
1
);
cfgAddString
(
pCfg
,
"compatible_version"
,
compatible_version
,
1
);
cfgAddString
(
pCfg
,
"gitinfo"
,
gitinfo
,
1
);
cfgAddString
(
pCfg
,
"gitinfoOfInternal"
,
gitinfoOfInternal
,
1
);
cfgAddString
(
pCfg
,
"buildinfo"
,
buildinfo
,
1
);
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalTempDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"numOfThreadsPerCore"
,
tsNumOfThreadsPerCore
,
0
,
10
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxTmrCtrl"
,
tsMaxTmrCtrl
,
8
,
2048
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcTimer"
,
tsRpcTimer
,
100
,
3000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcMaxTime"
,
tsRpcMaxTime
,
100
,
7200
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"rpcForceTcp"
,
tsRpcForceTcp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"shellActivityTimer"
,
tsShellActivityTimer
,
1
,
120
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"compressMsgSize"
,
tsCompressMsgSize
,
-
1
,
100000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"compressColData"
,
tsCompressColData
,
-
1
,
100000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxWildCardsLength"
,
tsMaxWildCardsLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxRegexStringLen"
,
tsMaxRegexStringLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfOrderedRes"
,
tsMaxNumOfOrderedResults
,
128
,
TSDB_MAX_ALLOWED_SQL_LEN
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddServerCfg
(
SConfig
*
pCfg
)
{
cfgAddInt32
(
pCfg
,
"supportVnodes"
,
256
,
0
,
65536
,
0
);
cfgAddDir
(
pCfg
,
"dataDir"
,
osDataDir
(),
0
);
cfgAddFloat
(
pCfg
,
"minimalDataDirGB"
,
2
.
0
f
,
0
.
001
f
,
10000000
,
0
);
cfgAddInt32
(
pCfg
,
"numOfCommitThreads"
,
tsNumOfCommitThreads
,
1
,
100
,
0
);
cfgAddFloat
(
pCfg
,
"ratioOfQueryCores"
,
tsRatioOfQueryCores
,
0
,
2
,
0
);
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
);
cfgAddBool
(
pCfg
,
"telemetryReporting"
,
tsEnableTelemetryReporting
,
0
);
cfgAddInt32
(
pCfg
,
"maxConnections"
,
tsMaxConnections
,
1
,
100000
,
0
);
cfgAddInt32
(
pCfg
,
"maxShellConns"
,
tsMaxShellConns
,
10
,
50000000
,
0
);
cfgAddInt32
(
pCfg
,
"statusInterval"
,
tsStatusInterval
,
1
,
30
,
0
);
cfgAddInt32
(
pCfg
,
"minSlidingTime"
,
tsMinSlidingTime
,
10
,
1000000
,
0
);
cfgAddInt32
(
pCfg
,
"minIntervalTime"
,
tsMinIntervalTime
,
1
,
1000000
,
0
);
cfgAddInt32
(
pCfg
,
"maxStreamCompDelay"
,
tsMaxStreamComputDelay
,
10
,
1000000000
,
0
);
cfgAddInt32
(
pCfg
,
"maxFirstStreamCompDelay"
,
tsStreamCompStartDelay
,
1000
,
1000000000
,
0
);
cfgAddInt32
(
pCfg
,
"retryStreamCompDelay"
,
tsRetryStreamCompDelay
,
10
,
1000000000
,
0
);
cfgAddFloat
(
pCfg
,
"streamCompDelayRatio"
,
tsStreamComputDelayRatio
,
0
.
1
,
0
.
9
,
0
);
cfgAddInt32
(
pCfg
,
"queryBufferSize"
,
tsQueryBufferSize
,
-
1
,
500000000000
,
0
);
cfgAddBool
(
pCfg
,
"retrieveBlockingModel"
,
tsRetrieveBlockingModel
,
0
);
cfgAddBool
(
pCfg
,
"printAuth"
,
tsPrintAuth
,
0
);
cfgAddBool
(
pCfg
,
"slaveQuery"
,
tsEnableSlaveQuery
,
0
);
cfgAddBool
(
pCfg
,
"deadLockKillQuery"
,
tsDeadLockKillQuery
,
0
);
static
int32_t
taosAddSystemCfg
(
SConfig
*
pCfg
)
{
SysNameInfo
info
=
taosGetSysNameInfo
();
if
(
cfgAddTimezone
(
pCfg
,
"timezone"
,
tsTimezone
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
0
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
1
,
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
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"totalMemory(MB)"
,
tsTotalMemoryMB
,
0
,
INT32_MAX
,
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 release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os version"
,
info
.
version
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os machine"
,
info
.
machine
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"version"
,
version
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"compatible_version"
,
compatible_version
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"gitinfo"
,
gitinfo
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"gitinfoOfInternal"
,
gitinfoOfInternal
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"buildinfo"
,
buildinfo
,
1
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
taosAddServerCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddInt32
(
pCfg
,
"supportVnodes"
,
256
,
0
,
65536
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"dataDir"
,
tsDataDir
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalDataDirGB"
,
2
.
0
f
,
0
.
001
f
,
10000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCommitThreads"
,
tsNumOfCommitThreads
,
1
,
100
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"ratioOfQueryCores"
,
tsRatioOfQueryCores
,
0
,
2
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"telemetryReporting"
,
tsEnableTelemetryReporting
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxConnections"
,
tsMaxConnections
,
1
,
100000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxShellConns"
,
tsMaxShellConns
,
10
,
50000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"statusInterval"
,
tsStatusInterval
,
1
,
30
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minSlidingTime"
,
tsMinSlidingTime
,
10
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minIntervalTime"
,
tsMinIntervalTime
,
1
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxStreamCompDelay"
,
tsMaxStreamComputDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxFirstStreamCompDelay"
,
tsStreamCompStartDelay
,
1000
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"retryStreamCompDelay"
,
tsRetryStreamCompDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"streamCompDelayRatio"
,
tsStreamComputDelayRatio
,
0
.
1
,
0
.
9
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryBufferSize"
,
tsQueryBufferSize
,
-
1
,
500000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"retrieveBlockingModel"
,
tsRetrieveBlockingModel
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"printAuth"
,
tsPrintAuth
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"slaveQuery"
,
tsEnableSlaveQuery
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"deadLockKillQuery"
,
tsDeadLockKillQuery
,
0
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosSetClientLogCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"logDir"
);
osSetLogDir
(
cfgGetItem
(
pCfg
,
"logDir"
)
->
str
);
osSetDataReservedSpace
(
cfgGetItem
(
pCfg
,
"minimalLogDirGB"
)
->
fval
)
;
tstrncpy
(
tsLogDir
,
cfgGetItem
(
pCfg
,
"logDir"
)
->
str
,
PATH_MAX
);
tsLogSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalLogDirGB"
)
->
fval
;
tsNumOfLogLines
=
cfgGetItem
(
pCfg
,
"numOfLogLines"
)
->
i32
;
tsAsyncLog
=
cfgGetItem
(
pCfg
,
"asyncLog"
)
->
bval
;
tsLogKeepDays
=
cfgGetItem
(
pCfg
,
"logKeepDays"
)
->
i32
;
...
...
@@ -331,8 +355,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_EP_LEN
);
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
osSetTempDir
(
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
);
osSetDataReservedSpace
(
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
)
;
tstrncpy
(
tsLogDir
,
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
,
PATH_MAX
);
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
;
tsNumOfThreadsPerCore
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
fval
;
tsMaxTmrCtrl
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
i32
;
...
...
@@ -347,31 +371,32 @@ static void taosSetClientCfg(SConfig *pCfg) {
tsMaxNumOfOrderedResults
=
cfgGetItem
(
pCfg
,
"maxNumOfOrderedRes"
)
->
i32
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
}
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"timezone"
);
osSetTimezone
(
pItem
->
str
);
uDebug
(
"timezone format changed from %s to %s"
,
pItem
->
str
,
osTimezone
()
);
cfgSetItem
(
pCfg
,
"timezone"
,
osTimezone
()
,
pItem
->
stype
);
uDebug
(
"timezone format changed from %s to %s"
,
pItem
->
str
,
tsTimezone
);
cfgSetItem
(
pCfg
,
"timezone"
,
tsTimezone
,
pItem
->
stype
);
const
char
*
locale
=
cfgGetItem
(
pCfg
,
"locale"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
osSet
Locale
(
locale
,
charset
);
taosSetSystem
Locale
(
locale
,
charset
);
if
(
tsNumOfCores
<=
1
)
{
tsNumOfCores
=
2
;
}
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
taosSetCo
reDump
(
enableCore
);
taosSetCo
nsoleEcho
(
enableCore
);
// todo
tsVersion
=
30000000
;
}
static
void
taosSetServerCfg
(
SConfig
*
pCfg
)
{
osSetDataDir
(
cfgGetItem
(
pCfg
,
"dataDir"
)
->
str
);
osSetTempReservedSpace
(
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
);
tstrncpy
(
tsDataDir
,
cfgGetItem
(
pCfg
,
"dataDir"
)
->
str
,
PATH_MAX
);
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
;
tsNumOfCommitThreads
=
cfgGetItem
(
pCfg
,
"numOfCommitThreads"
)
->
i32
;
tsRatioOfQueryCores
=
cfgGetItem
(
pCfg
,
"ratioOfQueryCores"
)
->
fval
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
...
...
@@ -397,17 +422,17 @@ static void taosSetServerCfg(SConfig *pCfg) {
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
)
{
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osInit
();
SConfig
*
pCfg
=
cfgInit
();
if
(
pCfg
==
NULL
)
return
-
1
;
if
(
tsc
)
{
taosAddClientLogCfg
(
pCfg
)
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
else
{
taosAddClientLogCfg
(
pCfg
)
;
taosAddServerLogCfg
(
pCfg
)
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
if
(
taosLoadCfg
(
pCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
...
...
@@ -416,15 +441,21 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
-
1
;
}
if
(
cfgLoadArray
(
pCfg
,
pArgs
)
!=
0
)
{
uError
(
"failed to load cfg from array since %s"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
-
1
;
}
if
(
tsc
)
{
taosSetClientLogCfg
(
pCfg
);
taosSetAllDebugFlag
(
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
);
}
else
{
taosSetClientLogCfg
(
pCfg
);
taosSetServerLogCfg
(
pCfg
);
taosSetAllDebugFlag
(
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
);
}
taosSetAllDebugFlag
(
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
);
if
(
taosInitLog
(
logname
,
logFileNum
)
!=
0
)
{
printf
(
"failed to init log file since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
...
...
@@ -435,19 +466,20 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
0
;
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
)
{
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
if
(
tsCfg
!=
NULL
)
return
0
;
tsCfg
=
cfgInit
();
if
(
tsc
)
{
taosAddClientLogCfg
(
tsCfg
)
;
taosAddClientCfg
(
tsCfg
)
;
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
else
{
taosAddClientLogCfg
(
tsCfg
)
;
taosAddServerLogCfg
(
tsCfg
)
;
taosAddClientCfg
(
tsCfg
)
;
taosAddServerCfg
(
tsCfg
)
;
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
taosAddSystemCfg
(
tsCfg
);
if
(
taosLoadCfg
(
tsCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
uError
(
"failed to load cfg since %s"
,
terrstr
());
...
...
@@ -456,12 +488,20 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
return
-
1
;
}
if
(
cfgLoadArray
(
tsCfg
,
pArgs
)
!=
0
)
{
uError
(
"failed to load cfg from array since %s"
,
terrstr
());
cfgCleanup
(
tsCfg
);
return
-
1
;
}
if
(
tsc
)
{
taosSetClientCfg
(
tsCfg
);
}
else
{
taosSetClientCfg
(
tsCfg
);
taosSetServerCfg
(
tsCfg
);
taosSetTfsCfg
(
tsCfg
);
}
taosSetSystemCfg
(
tsCfg
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
return
0
;
...
...
source/common/src/ttszip.c
浏览文件 @
6afebf9a
...
...
@@ -23,7 +23,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
pTSBuf
->
autoDelete
=
autoDelete
;
taosGetTmpfilePath
(
osTempDir
()
,
"join"
,
pTSBuf
->
path
);
taosGetTmpfilePath
(
tsTempDir
,
"join"
,
pTSBuf
->
path
);
// pTSBuf->pFile = fopen(pTSBuf->path, "wb+");
pTSBuf
->
pFile
=
taosOpenFile
(
pTSBuf
->
path
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
);
if
(
pTSBuf
->
pFile
==
NULL
)
{
...
...
source/dnode/mgmt/daemon/src/dmnCfg.c
浏览文件 @
6afebf9a
...
...
@@ -28,6 +28,8 @@ SDnodeObjCfg dmnGetObjCfg() {
objCfg
.
serverPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
tstrncpy
(
objCfg
.
localFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
sizeof
(
objCfg
.
localFqdn
));
snprintf
(
objCfg
.
localEp
,
sizeof
(
objCfg
.
localEp
),
"%s:%u"
,
objCfg
.
localFqdn
,
objCfg
.
serverPort
);
objCfg
.
pDisks
=
tsDiskCfg
;
objCfg
.
numOfDisks
=
tsDiskCfgNum
;
return
objCfg
;
}
...
...
source/dnode/mgmt/daemon/src/dmnMain.c
浏览文件 @
6afebf9a
...
...
@@ -111,12 +111,12 @@ int main(int argc, char const *argv[]) {
return
0
;
}
if
(
taosCreateLog
(
"taosdlog"
,
1
,
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
0
)
!=
0
)
{
if
(
taosCreateLog
(
"taosdlog"
,
1
,
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
NULL
,
0
)
!=
0
)
{
uInfo
(
"Failed to start TDengine since read config error"
);
return
-
1
;
}
if
(
taosInitCfg
(
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
0
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
NULL
,
0
)
!=
0
)
{
uInfo
(
"Failed to start TDengine since read config error"
);
return
-
1
;
}
...
...
source/dnode/mgmt/impl/src/dndEnv.c
浏览文件 @
6afebf9a
...
...
@@ -81,7 +81,7 @@ static TdFilePtr dndCheckRunning(char *dataDir) {
return
pFile
;
}
static
int32_t
dnd
CreateImp
(
SDnode
*
pDnode
,
SDnodeObjCfg
*
pCfg
)
{
static
int32_t
dnd
InitDir
(
SDnode
*
pDnode
,
SDnodeObjCfg
*
pCfg
)
{
pDnode
->
pLockFile
=
dndCheckRunning
(
pCfg
->
dataDir
);
if
(
pDnode
->
pLockFile
==
NULL
)
{
return
-
1
;
...
...
@@ -166,7 +166,7 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) {
dndSetStat
(
pDnode
,
DND_STAT_INIT
);
if
(
dnd
CreateImp
(
pDnode
,
pCfg
)
!=
0
)
{
if
(
dnd
InitDir
(
pDnode
,
pCfg
)
!=
0
)
{
dError
(
"failed to init dnode dir since %s"
,
terrstr
());
dndClose
(
pDnode
);
return
NULL
;
...
...
@@ -176,7 +176,14 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) {
tstrncpy
(
dCfg
.
dir
,
pDnode
->
cfg
.
dataDir
,
TSDB_FILENAME_LEN
);
dCfg
.
level
=
0
;
dCfg
.
primary
=
1
;
pDnode
->
pTfs
=
tfsOpen
(
&
dCfg
,
1
);
SDiskCfg
*
pDisks
=
pDnode
->
cfg
.
pDisks
;
int32_t
numOfDisks
=
pDnode
->
cfg
.
numOfDisks
;
if
(
numOfDisks
<=
0
||
pDisks
==
NULL
)
{
pDisks
=
&
dCfg
;
numOfDisks
=
1
;
}
pDnode
->
pTfs
=
tfsOpen
(
pDisks
,
numOfDisks
);
if
(
pDnode
->
pTfs
==
NULL
)
{
dError
(
"failed to init tfs since %s"
,
terrstr
());
dndClose
(
pDnode
);
...
...
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
6afebf9a
...
...
@@ -372,9 +372,9 @@ void dndSendStatusReq(SDnode *pDnode) {
req
.
clusterCfg
.
checkTime
=
0
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
req
.
clusterCfg
.
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
memcpy
(
req
.
clusterCfg
.
timezone
,
osTimezone
()
,
TD_TIMEZONE_LEN
);
memcpy
(
req
.
clusterCfg
.
locale
,
osLocale
()
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
charset
,
osCharset
()
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
timezone
,
tsTimezone
,
TD_TIMEZONE_LEN
);
memcpy
(
req
.
clusterCfg
.
locale
,
tsLocale
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
req
.
pVloads
=
taosArrayInit
(
TSDB_MAX_VNODES
,
sizeof
(
SVnodeLoad
));
...
...
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
6afebf9a
...
...
@@ -33,7 +33,7 @@ void Testbase::InitLog(const char* path) {
taosRemoveDir
(
path
);
taosMkDir
(
path
);
osSetLogDir
(
path
);
tstrncpy
(
tsLogDir
,
path
,
PATH_MAX
);
if
(
taosInitLog
(
"taosdlog"
,
1
)
!=
0
)
{
printf
(
"failed to init log file
\n
"
);
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
6afebf9a
...
...
@@ -22,11 +22,11 @@
#include "mndUser.h"
#include "mndVgroup.h"
#define TSDB_DNODE_VER_NUMBER 1
#define TSDB_DNODE_VER_NUMBER
1
#define TSDB_DNODE_RESERVE_SIZE 64
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN 48
#define TSDB_CONFIG_NUMBER 8
#define TSDB_CONFIG_OPTION_LEN
16
#define TSDB_CONIIG_VALUE_LEN
48
#define TSDB_CONFIG_NUMBER
8
static
const
char
*
offlineReason
[]
=
{
""
,
...
...
@@ -277,19 +277,19 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
return
DND_REASON_STATUS_INTERVAL_NOT_MATCH
;
}
if
((
0
!=
strcasecmp
(
pCfg
->
timezone
,
osTimezone
()
))
&&
(
pMnode
->
checkTime
!=
pCfg
->
checkTime
))
{
mError
(
"timezone [%s - %s] [%"
PRId64
" - %"
PRId64
"] cfg inconsistent"
,
pCfg
->
timezone
,
osTimezone
()
,
if
((
0
!=
strcasecmp
(
pCfg
->
timezone
,
tsTimezone
))
&&
(
pMnode
->
checkTime
!=
pCfg
->
checkTime
))
{
mError
(
"timezone [%s - %s] [%"
PRId64
" - %"
PRId64
"] cfg inconsistent"
,
pCfg
->
timezone
,
tsTimezone
,
pCfg
->
checkTime
,
pMnode
->
checkTime
);
return
DND_REASON_TIME_ZONE_NOT_MATCH
;
}
if
(
0
!=
strcasecmp
(
pCfg
->
locale
,
osLocale
()
))
{
mError
(
"locale [%s - %s] cfg inconsistent"
,
pCfg
->
locale
,
osLocale
()
);
if
(
0
!=
strcasecmp
(
pCfg
->
locale
,
tsLocale
))
{
mError
(
"locale [%s - %s] cfg inconsistent"
,
pCfg
->
locale
,
tsLocale
);
return
DND_REASON_LOCALE_NOT_MATCH
;
}
if
(
0
!=
strcasecmp
(
pCfg
->
charset
,
osCharset
()
))
{
mError
(
"charset [%s - %s] cfg inconsistent."
,
pCfg
->
charset
,
osCharset
()
);
if
(
0
!=
strcasecmp
(
pCfg
->
charset
,
tsCharset
))
{
mError
(
"charset [%s - %s] cfg inconsistent."
,
pCfg
->
charset
,
tsCharset
);
return
DND_REASON_CHARSET_NOT_MATCH
;
}
...
...
@@ -631,13 +631,13 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
pShow
->
bytes
[
cols
]
=
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
tstrncpy
(
pSchema
[
cols
].
name
,
"name"
,
sizeof
(
pSchema
[
cols
].
name
)
);
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_CONIIG_VALUE_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
tstrncpy
(
pSchema
[
cols
].
name
,
"value"
,
sizeof
(
pSchema
[
cols
].
name
)
);
strcpy
(
pSchema
[
cols
].
name
,
"value"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
...
...
@@ -658,29 +658,30 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
int32_t
totalRows
=
0
;
int32_t
numOfRows
=
0
;
char
*
cfgOpts
[
TSDB_CONFIG_NUMBER
]
=
{
0
};
char
cfgVals
[
TSDB_CONFIG_NUMBER
][
TSDB_CONIIG_VALUE_LEN
+
1
]
=
{
0
};
char
*
pWrite
;
int32_t
cols
=
0
;
cfgOpts
[
numOf
Rows
]
=
"statusInterval"
;
snprintf
(
cfgVals
[
numOf
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%d"
,
tsStatusInterval
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"statusInterval"
;
snprintf
(
cfgVals
[
total
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%d"
,
tsStatusInterval
);
total
Rows
++
;
cfgOpts
[
numOf
Rows
]
=
"timezone"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
osTimezone
()
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"timezone"
;
snprintf
(
cfgVals
[
totalRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsTimezone
);
total
Rows
++
;
cfgOpts
[
numOf
Rows
]
=
"locale"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
osLocale
()
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"locale"
;
snprintf
(
cfgVals
[
totalRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsLocale
);
total
Rows
++
;
cfgOpts
[
numOf
Rows
]
=
"charset"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
osCharset
()
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"charset"
;
snprintf
(
cfgVals
[
totalRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsCharset
);
total
Rows
++
;
for
(
int32_t
i
=
0
;
i
<
numOf
Rows
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
total
Rows
;
i
++
)
{
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
...
...
@@ -690,6 +691,8 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data,
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
cfgVals
[
i
],
TSDB_CONIIG_VALUE_LEN
);
cols
++
;
numOfRows
++
;
}
mndVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
6afebf9a
...
...
@@ -422,12 +422,14 @@ SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg) {
pMsg
->
rpcMsg
=
*
pRpcMsg
;
pMsg
->
createdTime
=
taosGetTimestampSec
();
mTrace
(
"msg:%p, is created, app:%p RPC:%p user:%s"
,
pMsg
,
pRpcMsg
->
ahandle
,
pRpcMsg
->
handle
,
pMsg
->
user
);
if
(
pRpcMsg
!=
NULL
)
{
mTrace
(
"msg:%p, is created, app:%p RPC:%p user:%s"
,
pMsg
,
pRpcMsg
->
ahandle
,
pRpcMsg
->
handle
,
pMsg
->
user
);
}
return
pMsg
;
}
void
mndCleanupMsg
(
SMnodeMsg
*
pMsg
)
{
mTrace
(
"msg:%p, is destroyed
, app:%p RPC:%p"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
->
rpcMsg
.
handle
);
mTrace
(
"msg:%p, is destroyed
"
,
pMsg
);
rpcFreeCont
(
pMsg
->
rpcMsg
.
pCont
);
pMsg
->
rpcMsg
.
pCont
=
NULL
;
taosFreeQitem
(
pMsg
);
...
...
source/dnode/vnode/src/inc/tsdbFile.h
浏览文件 @
6afebf9a
...
...
@@ -215,7 +215,7 @@ static FORCE_INLINE void tsdbCloseDFile(SDFile* pDFile) {
}
static
FORCE_INLINE
int64_t
tsdbSeekDFile
(
SDFile
*
pDFile
,
int64_t
offset
,
int
whence
)
{
ASSERT
(
TSDB_FILE_OPENED
(
pDFile
));
//
ASSERT(TSDB_FILE_OPENED(pDFile));
int64_t
loffset
=
taosLSeekFile
(
TSDB_FILE_PFILE
(
pDFile
),
offset
,
whence
);
if
(
loffset
<
0
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
6afebf9a
...
...
@@ -523,7 +523,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRDataf
=
TSDB_READ_DATA_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWDataf
=
TSDB_COMMIT_DATA_FILE
(
pCommith
);
tsdbInitDFileEx
(
pWDataf
,
pRDataf
);
if
(
tsdbOpenDFile
(
pWDataf
,
O_WRONLY
)
<
0
)
{
// if (tsdbOpenDFile(pWDataf, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
pWDataf
,
TD_FILE_WRITE
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWDataf
),
tstrerror
(
terrno
));
...
...
@@ -543,7 +544,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
tsdbInitDFileEx
(
pWLastf
,
pRLastf
);
pCommith
->
isLFileSame
=
true
;
if
(
tsdbOpenDFile
(
pWLastf
,
O_WRONLY
)
<
0
)
{
// if (tsdbOpenDFile(pWLastf, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
pWLastf
,
TD_FILE_WRITE
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWLastf
),
tstrerror
(
terrno
));
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
6afebf9a
...
...
@@ -1229,7 +1229,8 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
pDFile
->
f
=
*
pf
;
if
(
tsdbOpenDFile
(
pDFile
,
O_RDONLY
)
<
0
)
{
// if (tsdbOpenDFile(pDFile, O_RDONLY) < 0) {
if
(
tsdbOpenDFile
(
pDFile
,
TD_FILE_READ
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open DFile %s since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
));
taosArrayDestroy
(
fArray
);
...
...
@@ -1338,7 +1339,8 @@ static void tsdbScanAndTryFixDFilesHeader(STsdb *pRepo, int32_t *nExpired) {
}
tsdbDebug
(
"vgId:%d scan DFileSet %d header"
,
REPO_ID
(
pRepo
),
fset
.
fid
);
if
(
tsdbOpenDFileSet
(
&
fset
,
O_RDWR
)
<
0
)
{
// if (tsdbOpenDFileSet(&fset, O_RDWR) < 0) {
if
(
tsdbOpenDFileSet
(
&
fset
,
TD_FILE_WRITE
|
TD_FILE_READ
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open DFileSet %d since %s, continue"
,
REPO_ID
(
pRepo
),
fset
.
fid
,
tstrerror
(
terrno
));
continue
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
6afebf9a
...
...
@@ -356,7 +356,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader) {
ASSERT
(
pDFile
->
info
.
size
==
0
&&
pDFile
->
info
.
magic
==
TSDB_FILE_INIT_MAGIC
);
pDFile
->
pFile
=
taosOpenFile
(
TSDB_FILE_FULL_NAME
(
pDFile
),
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pDFile
->
pFile
<
0
)
{
if
(
pDFile
->
pFile
==
NULL
)
{
if
(
errno
==
ENOENT
)
{
// Try to create directory recursively
char
*
s
=
strdup
(
TSDB_FILE_REL_NAME
(
pDFile
));
...
...
@@ -367,7 +367,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader) {
tfree
(
s
);
pDFile
->
pFile
=
taosOpenFile
(
TSDB_FILE_FULL_NAME
(
pDFile
),
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pDFile
->
pFile
<
0
)
{
if
(
pDFile
->
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
...
...
@@ -456,7 +456,8 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
}
if
(
pDFile
->
info
.
size
<
dfstat
.
st_size
)
{
if
(
tsdbOpenDFile
(
&
df
,
O_WRONLY
)
<
0
)
{
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
return
-
1
;
}
...
...
@@ -537,7 +538,8 @@ static int tsdbApplyDFileChange(SDFile *from, SDFile *to) {
static
int
tsdbRollBackDFile
(
SDFile
*
pDFile
)
{
SDFile
df
=
*
pDFile
;
if
(
tsdbOpenDFile
(
&
df
,
O_WRONLY
)
<
0
)
{
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
return
-
1
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
6afebf9a
...
...
@@ -88,7 +88,7 @@ typedef struct STableCheckInfo {
int32_t
compSize
;
int32_t
numOfBlocks
:
29
;
// number of qualified data blocks not the original blocks
uint8_t
chosen
:
2
;
// indicate which iterator should move forward
bool
initBuf
;
// whether to initialize the in-memory skip list iterator or not
bool
initBuf
:
1
;
// whether to initialize the in-memory skip list iterator or not
SSkipListIterator
*
iter
;
// mem buffer skip list iterator
SSkipListIterator
*
iiter
;
// imem buffer skip list iterator
}
STableCheckInfo
;
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
6afebf9a
...
...
@@ -83,7 +83,8 @@ int tsdbSetAndOpenReadFSet(SReadH *pReadh, SDFileSet *pSet) {
pReadh
->
rSet
=
*
pSet
;
TSDB_FSET_SET_CLOSED
(
TSDB_READ_FSET
(
pReadh
));
if
(
tsdbOpenDFileSet
(
TSDB_READ_FSET
(
pReadh
),
O_RDONLY
)
<
0
)
{
// if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), O_RDONLY) < 0) {
if
(
tsdbOpenDFileSet
(
TSDB_READ_FSET
(
pReadh
),
TD_FILE_READ
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file set %d since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FSET_FID
(
pSet
),
tstrerror
(
terrno
));
return
-
1
;
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
6afebf9a
...
...
@@ -132,7 +132,7 @@ void ctgTestInitLogFile() {
ctgDbgEnableDebug
(
"api"
);
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
osLogDir
()
);
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
6afebf9a
...
...
@@ -4619,7 +4619,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr
getIntermediateBufInfo
(
pRuntimeEnv
,
&
ps
,
&
pQueryAttr
->
intermediateResultRowSize
);
int32_t
TENMB
=
1024
*
1024
*
10
;
int32_t
code
=
createDiskbasedBuf
(
&
pRuntimeEnv
->
pResultBuf
,
ps
,
TENMB
,
pQInfo
->
qId
,
osTempDir
()
);
int32_t
code
=
createDiskbasedBuf
(
&
pRuntimeEnv
->
pResultBuf
,
ps
,
TENMB
,
pQInfo
->
qId
,
"/tmp"
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
source/libs/function/src/tudf.c
浏览文件 @
6afebf9a
...
...
@@ -55,7 +55,7 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
} else {
char path[PATH_MAX] = {0};
taosGetTmpfilePath("script", path,
osTempDir()
);
taosGetTmpfilePath("script", path,
tsTempDir
);
FILE* file = fopen(path, "w+");
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
6afebf9a
...
...
@@ -105,7 +105,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
#endif
}
memcpy
(
ctx
->
file
.
buf
,
path
,
strlen
(
path
));
if
(
ctx
->
file
.
pFile
<
0
)
{
if
(
ctx
->
file
.
pFile
==
NULL
)
{
indexError
(
"failed to open file, error %d"
,
errno
);
goto
END
;
}
...
...
source/libs/index/test/fstUT.cc
浏览文件 @
6afebf9a
...
...
@@ -30,7 +30,7 @@ static void EnvInit() {
taosRemoveDir
(
path
.
c_str
());
taosMkDir
(
path
.
c_str
());
// init log file
osSetLogDir
(
path
.
c_str
()
);
tstrncpy
(
tsLogDir
,
path
.
c_str
(),
PATH_MAX
);
if
(
taosInitLog
(
"tindex.idx"
,
1
)
!=
0
)
{
printf
(
"failed to init log"
);
}
...
...
source/libs/parser/src/insertParser.c
浏览文件 @
6afebf9a
...
...
@@ -204,7 +204,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
bool
isSigned
=
false
;
toInteger
(
pToken
->
z
,
pToken
->
n
,
10
,
&
ts
,
&
isSigned
);
}
else
{
// parse the RFC-3339/ISO-8601 timestamp format string
if
(
taosParseTime
(
pToken
->
z
,
time
,
pToken
->
n
,
timePrec
,
osDaylight
()
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pToken
->
z
,
time
,
pToken
->
n
,
timePrec
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid timestamp format"
,
pToken
->
z
);
}
...
...
source/libs/parser/src/parserImpl.c
浏览文件 @
6afebf9a
...
...
@@ -578,7 +578,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
return
DEAL_RES_ERROR
;
}
int32_t
len
=
trimStringCopy
(
pVal
->
literal
,
n
,
tmp
);
if
(
taosParseTime
(
tmp
,
&
pVal
->
datum
.
i
,
len
,
pVal
->
node
.
resType
.
precision
,
osDaylight
()
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
tmp
,
&
pVal
->
datum
.
i
,
len
,
pVal
->
node
.
resType
.
precision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
tmp
);
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
DEAL_RES_ERROR
;
...
...
source/libs/parser/src/parserUtil.c
浏览文件 @
6afebf9a
...
...
@@ -1639,7 +1639,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
bool
isSigned
=
false
;
toInteger
(
pToken
->
z
,
pToken
->
n
,
10
,
&
ts
,
&
isSigned
);
}
else
{
// parse the RFC-3339/ISO-8601 timestamp format string
if
(
taosParseTime
(
pToken
->
z
,
time
,
pToken
->
n
,
timePrec
,
osDaylight
()
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pToken
->
z
,
time
,
pToken
->
n
,
timePrec
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid timestamp format"
,
pToken
->
z
);
}
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
6afebf9a
...
...
@@ -102,7 +102,7 @@ void qwtInitLogFile() {
qDebugFlag
=
159
;
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
osLogDir
()
);
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
...
...
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
6afebf9a
...
...
@@ -53,7 +53,7 @@ void flttInitLogFile() {
qDebugFlag
=
159
;
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
osLogDir
()
);
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
6afebf9a
...
...
@@ -52,7 +52,7 @@ void scltInitLogFile() {
qDebugFlag
=
159
;
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
osLogDir
()
);
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
...
...
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
6afebf9a
...
...
@@ -67,7 +67,7 @@ void schtInitLogFile() {
qDebugFlag
=
159
;
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
osLogDir
()
);
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
...
...
source/libs/tdb/src/db/tdbEnv.c
浏览文件 @
6afebf9a
...
...
@@ -140,7 +140,7 @@ static int tdbEnvDestroy(TENV *pEnv) {
int
tdbEnvBeginTxn
(
TENV
*
pEnv
)
{
pEnv
->
jpFile
=
taosOpenFile
(
pEnv
->
jname
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_READ
);
if
(
pEnv
->
jpFile
<
0
)
{
if
(
pEnv
->
jpFile
==
NULL
)
{
return
-
1
;
}
...
...
source/libs/tdb/src/db/tdbPgFile.c
浏览文件 @
6afebf9a
...
...
@@ -95,7 +95,7 @@ int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv) {
int
pgFileClose
(
SPgFile
*
pPgFile
)
{
if
(
pPgFile
)
{
if
(
pPgFile
->
pFile
>=
0
)
{
if
(
pPgFile
->
pFile
!=
NULL
)
{
taosCloseFile
(
&
pPgFile
->
pFile
);
}
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
6afebf9a
...
...
@@ -25,7 +25,7 @@ static int32_t tfsOpendirImpl(STfs *pTfs, STfsDir *pDir);
static
STfsDisk
*
tfsNextDisk
(
STfs
*
pTfs
,
SDiskIter
*
pIter
);
STfs
*
tfsOpen
(
SDiskCfg
*
pCfg
,
int32_t
ndisk
)
{
if
(
ndisk
<
0
||
ndisk
>
TFS_MAX_DISKS
)
{
if
(
ndisk
<
=
0
||
ndisk
>
TFS_MAX_DISKS
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
}
...
...
source/libs/transport/test/rserver.c
浏览文件 @
6afebf9a
...
...
@@ -43,7 +43,7 @@ void processShellMsg() {
for
(
int
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
(
void
**
)
&
pRpcMsg
);
if
(
pDataFile
>=
0
)
{
if
(
pDataFile
!=
NULL
)
{
if
(
taosWriteFile
(
pDataFile
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
)
<
0
)
{
tInfo
(
"failed to write data file, reason:%s"
,
strerror
(
errno
));
}
...
...
source/libs/transport/test/transUT.cc
浏览文件 @
6afebf9a
...
...
@@ -155,7 +155,7 @@ class TransObj {
taosRemoveDir
(
path
.
c_str
());
taosMkDir
(
path
.
c_str
());
osSetLogDir
(
path
.
c_str
()
);
tstrncpy
(
tsLogDir
,
path
.
c_str
(),
PATH_MAX
);
if
(
taosInitLog
(
"taosdlog"
,
1
)
!=
0
)
{
printf
(
"failed to init log file
\n
"
);
}
...
...
source/libs/wal/src/walSeek.c
浏览文件 @
6afebf9a
...
...
@@ -58,13 +58,13 @@ int walSetWrite(SWal* pWal) {
char
fnameStr
[
WAL_FILE_LEN
];
walBuildIdxName
(
pWal
,
fileFirstVer
,
fnameStr
);
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdxTFile
<
0
)
{
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
walBuildLogName
(
pWal
,
fileFirstVer
,
fnameStr
);
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pLogTFile
<
0
)
{
if
(
pLogTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
...
...
@@ -104,14 +104,14 @@ int walChangeWrite(SWal* pWal, int64_t ver) {
int64_t
fileFirstVer
=
pFileInfo
->
firstVer
;
walBuildIdxName
(
pWal
,
fileFirstVer
,
fnameStr
);
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdxTFile
<
0
)
{
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
pWal
->
pWriteIdxTFile
=
NULL
;
return
-
1
;
}
walBuildLogName
(
pWal
,
fileFirstVer
,
fnameStr
);
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pLogTFile
<
0
)
{
if
(
pLogTFile
==
NULL
)
{
taosCloseFile
(
&
pIdxTFile
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
pWal
->
pWriteLogTFile
=
NULL
;
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
6afebf9a
...
...
@@ -89,7 +89,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
walBuildLogName
(
pWal
,
walGetCurFileFirstVer
(
pWal
),
fnameStr
);
TdFilePtr
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_WRITE
|
TD_FILE_READ
);
if
(
pLogTFile
<
0
)
{
if
(
pLogTFile
==
NULL
)
{
// TODO
pthread_mutex_unlock
(
&
pWal
->
mutex
);
return
-
1
;
...
...
@@ -221,13 +221,13 @@ int walRoll(SWal *pWal) {
char
fnameStr
[
WAL_FILE_LEN
];
walBuildIdxName
(
pWal
,
newFileFirstVersion
,
fnameStr
);
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdxTFile
<
0
)
{
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
walBuildLogName
(
pWal
,
newFileFirstVersion
,
fnameStr
);
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pLogTFile
<
0
)
{
if
(
pLogTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
...
...
source/os/src/osEnv.c
浏览文件 @
6afebf9a
...
...
@@ -17,68 +17,31 @@
#include "osEnv.h"
extern
void
taosWinSocketInit
();
char
configDir
[
PATH_MAX
]
=
{
0
};
typedef
struct
SOsEnv
{
char
dataDir
[
PATH_MAX
];
char
logDir
[
PATH_MAX
];
char
tempDir
[
PATH_MAX
];
SDiskSpace
dataSpace
;
SDiskSpace
logSpace
;
SDiskSpace
tempSpace
;
char
osName
[
16
];
char
timezone
[
TD_TIMEZONE_LEN
];
char
locale
[
TD_LOCALE_LEN
];
char
charset
[
TD_CHARSET_LEN
];
int8_t
daylight
;
bool
enableCoreFile
;
}
SOsEnv
;
static
SOsEnv
env
=
{
0
};
SOsEnv
*
osEnv
()
{
return
&
env
;
}
void
osInitImp
()
{
taosGetSystemLocale
(
env
.
locale
,
env
.
charset
);
taosGetSystemTimezone
(
env
.
timezone
);
osSetTimezone
(
env
.
timezone
);
}
void
osUpdate
()
{
if
(
env
.
logDir
[
0
]
!=
0
)
{
taosGetDiskSize
(
env
.
logDir
,
&
env
.
logSpace
.
size
);
}
if
(
env
.
dataDir
[
0
]
!=
0
)
{
taosGetDiskSize
(
env
.
dataDir
,
&
env
.
dataSpace
.
size
);
}
if
(
env
.
tempDir
[
0
]
!=
0
)
{
taosGetDiskSize
(
env
.
tempDir
,
&
env
.
tempSpace
.
size
);
}
}
bool
osLogSpaceAvailable
()
{
return
env
.
logSpace
.
reserved
<=
env
.
logSpace
.
size
.
avail
;
}
int8_t
osDaylight
()
{
return
env
.
daylight
;
}
const
char
*
osLogDir
()
{
return
env
.
logDir
;
}
const
char
*
osTempDir
()
{
return
env
.
tempDir
;
}
const
char
*
osDataDir
()
{
return
env
.
dataDir
;
}
const
char
*
osName
()
{
return
env
.
osName
;
}
const
char
*
osTimezone
()
{
return
env
.
timezone
;
}
const
char
*
osLocale
()
{
return
env
.
locale
;
}
const
char
*
osCharset
()
{
return
env
.
charset
;
}
void
osSetLogDir
(
const
char
*
logDir
)
{
tstrncpy
(
env
.
logDir
,
logDir
,
PATH_MAX
);
}
void
osSetTempDir
(
const
char
*
tempDir
)
{
tstrncpy
(
env
.
tempDir
,
tempDir
,
PATH_MAX
);
}
void
osSetDataDir
(
const
char
*
dataDir
)
{
tstrncpy
(
env
.
dataDir
,
dataDir
,
PATH_MAX
);
}
void
osSetLogReservedSpace
(
float
sizeInGB
)
{
env
.
logSpace
.
reserved
=
sizeInGB
;
}
void
osSetTempReservedSpace
(
float
sizeInGB
)
{
env
.
tempSpace
.
reserved
=
sizeInGB
;
}
void
osSetDataReservedSpace
(
float
sizeInGB
)
{
env
.
dataSpace
.
reserved
=
sizeInGB
;
}
void
osSetTimezone
(
const
char
*
timezone
)
{
taosSetSystemTimezone
(
timezone
,
env
.
timezone
,
&
env
.
daylight
);
}
void
osSetLocale
(
const
char
*
locale
,
const
char
*
charset
)
{
taosSetSystemLocale
(
locale
,
charset
);
}
bool
osSetEnableCore
(
bool
enable
)
{
env
.
enableCoreFile
=
enable
;
}
char
configDir
[
PATH_MAX
]
=
{
0
};
char
tsDataDir
[
PATH_MAX
]
=
{
0
};
char
tsLogDir
[
PATH_MAX
]
=
{
0
};
char
tsTempDir
[
PATH_MAX
]
=
{
0
};
SDiskSpace
tsDataSpace
=
{
0
};
SDiskSpace
tsLogSpace
=
{
0
};
SDiskSpace
tsTempSpace
=
{
0
};
char
tsOsName
[
16
]
=
{
0
};
char
tsTimezone
[
TD_TIMEZONE_LEN
]
=
{
0
};
char
tsLocale
[
TD_LOCALE_LEN
]
=
{
0
};
char
tsCharset
[
TD_CHARSET_LEN
]
=
{
0
};
int8_t
tsDaylight
=
0
;
bool
tsEnableCoreFile
=
0
;
int64_t
tsPageSize
=
0
;
int64_t
tsOpenMax
=
0
;
int64_t
tsStreamMax
=
0
;
int32_t
tsNumOfCores
=
0
;
int32_t
tsTotalMemoryMB
=
0
;
void
osInit
()
{
srand
(
taosSafeRand
());
taosGetSystemLocale
(
tsLocale
,
tsCharset
);
taosGetSystemTimezone
(
tsTimezone
);
taosSetSystemTimezone
(
tsTimezone
,
tsTimezone
,
&
tsDaylight
);
taosGetSystemInfo
();
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
...
...
@@ -89,34 +52,50 @@ void osInit() {
tmpDir
=
getenv
(
"temp"
);
}
if
(
tmpDir
!=
NULL
)
{
strcpy
(
env
.
t
empDir
,
tmpDir
);
strcpy
(
tsT
empDir
,
tmpDir
);
}
if
(
configDir
[
0
]
==
0
)
{
strcpy
(
configDir
,
"C:
\\
TDengine
\\
cfg"
);
}
strcpy
(
env
.
d
ataDir
,
"C:
\\
TDengine
\\
data"
);
strcpy
(
env
.
l
ogDir
,
"C:
\\
TDengine
\\
log"
);
strcpy
(
env
.
t
empDir
,
"C:
\\
Windows
\\
Temp"
);
strcpy
(
env
.
o
sName
,
"Windows"
);
strcpy
(
tsD
ataDir
,
"C:
\\
TDengine
\\
data"
);
strcpy
(
tsL
ogDir
,
"C:
\\
TDengine
\\
log"
);
strcpy
(
tsT
empDir
,
"C:
\\
Windows
\\
Temp"
);
strcpy
(
tsO
sName
,
"Windows"
);
#elif defined(_TD_DARWIN_64)
if
(
configDir
[
0
]
==
0
)
{
strcpy
(
configDir
,
"/tmp/taosd"
);
}
strcpy
(
env
.
d
ataDir
,
"/usr/local/var/lib/taos"
);
strcpy
(
env
.
l
ogDir
,
"/usr/local/var/log/taos"
);
strcpy
(
env
.
t
empDir
,
"/usr/local/etc/taos"
);
strcpy
(
env
.
o
sName
,
"Darwin"
);
strcpy
(
tsD
ataDir
,
"/usr/local/var/lib/taos"
);
strcpy
(
tsL
ogDir
,
"/usr/local/var/log/taos"
);
strcpy
(
tsT
empDir
,
"/usr/local/etc/taos"
);
strcpy
(
tsO
sName
,
"Darwin"
);
#else
if
(
configDir
[
0
]
==
0
)
{
strcpy
(
configDir
,
"/etc/taos"
);
}
strcpy
(
env
.
d
ataDir
,
"/var/lib/taos"
);
strcpy
(
env
.
l
ogDir
,
"/var/log/taos"
);
strcpy
(
env
.
t
empDir
,
"/tmp"
);
strcpy
(
env
.
o
sName
,
"Linux"
);
strcpy
(
tsD
ataDir
,
"/var/lib/taos"
);
strcpy
(
tsL
ogDir
,
"/var/log/taos"
);
strcpy
(
tsT
empDir
,
"/tmp"
);
strcpy
(
tsO
sName
,
"Linux"
);
#endif
}
\ No newline at end of file
}
void
osUpdate
()
{
if
(
tsLogDir
[
0
]
!=
0
)
{
taosGetDiskSize
(
tsLogDir
,
&
tsLogSpace
.
size
);
}
if
(
tsDataDir
[
0
]
!=
0
)
{
taosGetDiskSize
(
tsDataDir
,
&
tsDataSpace
.
size
);
}
if
(
tsTempDir
[
0
]
!=
0
)
{
taosGetDiskSize
(
tsTempDir
,
&
tsTempSpace
.
size
);
}
}
bool
osLogSpaceAvailable
()
{
return
tsLogSpace
.
reserved
<=
tsLogSpace
.
size
.
avail
;
}
void
osSetTimezone
(
const
char
*
timezone
)
{
taosSetSystemTimezone
(
tsTimezone
,
tsTimezone
,
&
tsDaylight
);
}
source/os/src/osFile.c
浏览文件 @
6afebf9a
...
...
@@ -15,44 +15,44 @@
#define ALLOW_FORBID_FUNC
#include "os.h"
#define MAX_FPRINTFLINE_BUFFER_SIZE (1000)
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#include <io.h>
#if defined(_MSDOS)
#define open _open
#endif
#if defined(_WIN32)
extern
int
openA
(
const
char
*
,
int
,
...);
/* MsvcLibX ANSI version of open */
extern
int
openU
(
const
char
*
,
int
,
...);
/* MsvcLibX UTF-8 version of open */
#if defined(_UTF8_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#define open openU
#else
/* _ANSI_SOURCE */
#define open openA
#endif
/* defined(_UTF8_SOURCE) */
#endif
/* defined(_WIN32) */
#include <io.h>
#if defined(_MSDOS)
#define open _open
#endif
#if defined(_WIN32)
extern
int
openA
(
const
char
*
,
int
,
...);
/* MsvcLibX ANSI version of open */
extern
int
openU
(
const
char
*
,
int
,
...);
/* MsvcLibX UTF-8 version of open */
#if defined(_UTF8_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#define open openU
#else
/* _ANSI_SOURCE */
#define open openA
#endif
/* defined(_UTF8_SOURCE) */
#endif
/* defined(_WIN32) */
#else
#include <fcntl.h>
#include <sys/file.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <unistd.h>
#define LINUX_FILE_NO_TEXT_OPTION 0
#define O_TEXT
LINUX_FILE_NO_TEXT_OPTION
#include <fcntl.h>
#include <sys/file.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <unistd.h>
#define LINUX_FILE_NO_TEXT_OPTION 0
#define O_TEXT
LINUX_FILE_NO_TEXT_OPTION
#endif
typedef
int32_t
FileFd
;
typedef
struct
TdFile
{
int
refId
;
FileFd
fd
;
FILE
*
fp
;
}
*
TdFilePtr
,
TdFile
;
int
refId
;
FileFd
fd
;
FILE
*
fp
;
}
*
TdFilePtr
,
TdFile
;
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
)
{
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
)
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
char
tmpPath
[
PATH_MAX
];
...
...
@@ -79,7 +79,7 @@ void taosGetTmpfilePath(const char * inputTmpDir, const char *fileNamePrefix, ch
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
char
tmpPath
[
PATH_MAX
];
char
tmpPath
[
PATH_MAX
];
int32_t
len
=
strlen
(
inputTmpDir
);
memcpy
(
tmpPath
,
inputTmpDir
,
len
);
static
uint64_t
seqId
=
0
;
...
...
@@ -112,11 +112,11 @@ int64_t taosCopyFile(const char *from, const char *to) {
int64_t
bytes
;
// fidfrom = open(from, O_RDONLY);
TdFilePtr
pFileFrom
=
taosOpenFile
(
from
,
TD_FILE_READ
);
TdFilePtr
pFileFrom
=
taosOpenFile
(
from
,
TD_FILE_READ
);
if
(
pFileFrom
==
NULL
)
goto
_err
;
// fidto = open(to, O_WRONLY | O_CREAT | O_EXCL, 0755);
TdFilePtr
pFileTo
=
taosOpenFile
(
to
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_EXCL
);
TdFilePtr
pFileTo
=
taosOpenFile
(
to
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_EXCL
);
if
(
pFileTo
==
NULL
)
goto
_err
;
while
(
true
)
{
...
...
@@ -148,14 +148,14 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
int32_t
code
=
MoveFileEx
(
oldName
,
newName
,
MOVEFILE_REPLACE_EXISTING
|
MOVEFILE_COPY_ALLOWED
);
if
(
code
<
0
)
{
//printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
//
printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
}
return
code
;
#else
int32_t
code
=
rename
(
oldName
,
newName
);
if
(
code
<
0
)
{
//printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
//
printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
}
return
code
;
...
...
@@ -167,7 +167,7 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
return
0
;
#else
struct
stat
fileStat
;
int32_t
code
=
stat
(
path
,
&
fileStat
);
int32_t
code
=
stat
(
path
,
&
fileStat
);
if
(
code
<
0
)
{
return
code
;
}
...
...
@@ -184,25 +184,22 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
#endif
}
void
autoDelFileListAdd
(
const
char
*
path
)
{
return
;
}
void
autoDelFileListAdd
(
const
char
*
path
)
{
return
;
}
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
)
{
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
)
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
return
NULL
;
#else
int
access
=
O_BINARY
;
char
*
mode
=
NULL
;
access
|=
(
tdFileOptions
&
TD_FILE_CTEATE
)
?
O_CREAT
:
0
;
if
((
tdFileOptions
&
TD_FILE_WRITE
)
&&
(
tdFileOptions
&
TD_FILE_READ
))
{
if
((
tdFileOptions
&
TD_FILE_WRITE
)
&&
(
tdFileOptions
&
TD_FILE_READ
))
{
access
|=
O_RDWR
;
mode
=
(
tdFileOptions
&
TD_FILE_TEXT
)
?
"rt+"
:
"rb+"
;
}
else
if
(
tdFileOptions
&
TD_FILE_WRITE
)
{
}
else
if
(
tdFileOptions
&
TD_FILE_WRITE
)
{
access
|=
O_WRONLY
;
mode
=
(
tdFileOptions
&
TD_FILE_TEXT
)
?
"wt"
:
"wb"
;
}
else
if
(
tdFileOptions
&
TD_FILE_READ
)
{
}
else
if
(
tdFileOptions
&
TD_FILE_READ
)
{
access
|=
O_RDONLY
;
mode
=
(
tdFileOptions
&
TD_FILE_TEXT
)
?
"rt"
:
"rb"
;
}
...
...
@@ -210,14 +207,14 @@ TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions) {
access
|=
(
tdFileOptions
&
TD_FILE_APPEND
)
?
O_APPEND
:
0
;
access
|=
(
tdFileOptions
&
TD_FILE_TEXT
)
?
O_TEXT
:
0
;
access
|=
(
tdFileOptions
&
TD_FILE_EXCL
)
?
O_EXCL
:
0
;
if
(
tdFileOptions
&
TD_FILE_AUTO_DEL
)
{
if
(
tdFileOptions
&
TD_FILE_AUTO_DEL
)
{
autoDelFileListAdd
(
path
);
}
int
fd
=
open
(
path
,
access
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
fd
==
-
1
)
{
if
(
fd
==
-
1
)
{
return
NULL
;
}
FILE
*
fp
=
fdopen
(
fd
,
mode
);
FILE
*
fp
=
fdopen
(
fd
,
mode
);
if
(
fp
==
NULL
)
{
close
(
fd
);
return
NULL
;
...
...
@@ -239,10 +236,10 @@ int64_t taosCloseFile(TdFilePtr *ppFile) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
return
0
;
#else
if
(
ppFile
==
NULL
||
*
ppFile
==
NULL
||
(
*
ppFile
)
->
fd
==
-
1
)
{
if
(
ppFile
==
NULL
||
*
ppFile
==
NULL
||
(
*
ppFile
)
->
fd
==
-
1
)
{
return
0
;
}
f
sync
((
*
ppFile
)
->
fd
);
f
flush
((
*
ppFile
)
->
fp
);
close
((
*
ppFile
)
->
fd
);
(
*
ppFile
)
->
fd
=
-
1
;
(
*
ppFile
)
->
fp
=
NULL
;
...
...
@@ -254,12 +251,12 @@ int64_t taosCloseFile(TdFilePtr *ppFile) {
}
int64_t
taosReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
)
{
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
return
0
;
}
int64_t
leftbytes
=
count
;
int64_t
readbytes
;
char
*
tbuf
=
(
char
*
)
buf
;
char
*
tbuf
=
(
char
*
)
buf
;
while
(
leftbytes
>
0
)
{
readbytes
=
read
(
pFile
->
fd
,
(
void
*
)
tbuf
,
(
uint32_t
)
leftbytes
);
...
...
@@ -281,7 +278,7 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
}
int64_t
taosPReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
,
int64_t
offset
)
{
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
return
0
;
}
return
pread
(
pFile
->
fd
,
buf
,
count
,
offset
);
...
...
@@ -290,7 +287,7 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
int64_t
taosWriteFile
(
TdFilePtr
pFile
,
const
void
*
buf
,
int64_t
count
)
{
int64_t
nleft
=
count
;
int64_t
nwritten
=
0
;
char
*
tbuf
=
(
char
*
)
buf
;
char
*
tbuf
=
(
char
*
)
buf
;
while
(
nleft
>
0
)
{
nwritten
=
write
(
pFile
->
fd
,
(
void
*
)
tbuf
,
(
uint32_t
)
nleft
);
...
...
@@ -307,8 +304,9 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
return
count
;
}
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
)
{
return
(
int64_t
)
lseek
(
pFile
->
fd
,
(
long
)
offset
,
whence
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
)
{
if
(
pFile
==
NULL
)
return
-
1
;
return
(
int64_t
)
lseek
(
pFile
->
fd
,
(
long
)
offset
,
whence
);
}
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
)
{
...
...
@@ -316,7 +314,7 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
return
0
;
#else
struct
stat
fileStat
;
int32_t
code
=
fstat
(
pFile
->
fd
,
&
fileStat
);
int32_t
code
=
fstat
(
pFile
->
fd
,
&
fileStat
);
if
(
code
<
0
)
{
return
code
;
}
...
...
@@ -416,7 +414,7 @@ int32_t taosFsyncFile(TdFilePtr pFile) {
return
FlushFileBuffers
(
h
);
#else
return
f
sync
(
pFile
->
fd
);
return
f
flush
(
pFile
->
fp
);
#endif
}
...
...
@@ -499,7 +497,7 @@ int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t co
}
off_t
len
=
count
;
while
(
len
>
0
)
{
char
buf
[
1024
*
16
];
char
buf
[
1024
*
16
];
off_t
n
=
sizeof
(
buf
);
if
(
len
<
n
)
n
=
len
;
size_t
m
=
fread
(
buf
,
1
,
n
,
in_file
);
...
...
@@ -524,7 +522,7 @@ int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t count) {
}
off_t
len
=
count
;
while
(
len
>
0
)
{
char
buf
[
1024
*
16
];
char
buf
[
1024
*
16
];
off_t
n
=
sizeof
(
buf
);
if
(
len
<
n
)
n
=
len
;
size_t
m
=
read
(
sfd
,
buf
,
n
);
...
...
@@ -539,7 +537,7 @@ int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t count) {
#else
int64_t
taosSendFile
(
SocketFd
fdDst
,
TdFilePtr
pFileSrc
,
int64_t
*
offset
,
int64_t
size
)
{
int64_t
taosSendFile
(
SocketFd
fdDst
,
TdFilePtr
pFileSrc
,
int64_t
*
offset
,
int64_t
size
)
{
int64_t
leftbytes
=
size
;
int64_t
sentbytes
;
...
...
@@ -567,14 +565,11 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
#endif
#ifdef __GNUC__
__attribute__
((
format
(
printf
,
2
,
3
)))
#endif
void
taosFprintfFile
(
TdFilePtr
pFile
,
const
char
*
format
,
...)
{
va_list
ap
;
char
buffer
[
MAX_FPRINTFLINE_BUFFER_SIZE
]
=
{
0
};
va_list
ap
;
va_start
(
ap
,
format
);
fprintf
(
pFile
->
fp
,
format
,
ap
);
v
fprintf
(
pFile
->
fp
,
format
,
ap
);
va_end
(
ap
);
fflush
(
pFile
->
fp
);
}
...
...
@@ -586,9 +581,7 @@ void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length) {
return
ptr
;
}
bool
taosValidFile
(
TdFilePtr
pFile
)
{
return
pFile
!=
NULL
;
}
bool
taosValidFile
(
TdFilePtr
pFile
)
{
return
pFile
!=
NULL
;
}
int32_t
taosUmaskFile
(
int32_t
maskVal
)
{
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
...
...
@@ -598,12 +591,9 @@ int32_t taosUmaskFile(int32_t maskVal) {
#endif
}
int
taosGetErrorFile
(
TdFilePtr
pFile
)
{
return
errno
;
}
size_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
)
{
return
getline
(
ptrBuf
,
NULL
,
pFile
->
fp
);
int32_t
taosGetErrorFile
(
TdFilePtr
pFile
)
{
return
errno
;
}
int64_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
)
{
size_t
len
=
0
;
return
getline
(
ptrBuf
,
&
len
,
pFile
->
fp
);
}
int32_t
taosEOFFile
(
TdFilePtr
pFile
)
{
return
feof
(
pFile
->
fp
);
}
\ No newline at end of file
int32_t
taosEOFFile
(
TdFilePtr
pFile
)
{
return
feof
(
pFile
->
fp
);
}
\ No newline at end of file
source/os/src/osSysinfo.c
浏览文件 @
6afebf9a
...
...
@@ -16,11 +16,6 @@
#define _DEFAULT_SOURCE
#include "os.h"
int32_t
tsTotalMemoryMB
=
0
;
int64_t
tsPageSize
=
0
;
int64_t
tsOpenMax
=
0
;
int64_t
tsStreamMax
=
0
;
int32_t
tsNumOfCores
=
2
;
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
/*
...
...
@@ -111,7 +106,7 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
diskSize
->
used
=
(
int64_t
)(
i64TotalBytes
-
i64FreeBytes
);
return
0
;
}
else
{
//printf("failed to get disk size, dataDir:%s errno:%s",
osDataDir()
, strerror(errno));
//printf("failed to get disk size, dataDir:%s errno:%s",
tsDataDir
, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
...
...
@@ -316,7 +311,7 @@ void taosSetCoreDump() {}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
)
{
struct
statvfs
info
;
if
(
statvfs
(
dataDir
,
&
info
))
{
//printf("failed to get disk size, dataDir:%s errno:%s",
osDataDir()
, strerror(errno));
//printf("failed to get disk size, dataDir:%s errno:%s",
tsDataDir
, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
else
{
...
...
source/util/src/tconfig.c
浏览文件 @
6afebf9a
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "tconfig.h"
#include "taoserror.h"
#include "tcfg.h"
#include "thash.h"
#include "tutil.h"
#include "ulog.h"
...
...
@@ -66,9 +67,37 @@ int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const char *sourceStr) {
}
}
int32_t
cfgLoadArray
(
SConfig
*
pCfg
,
SArray
*
pArgs
)
{
int32_t
size
=
taosArrayGetSize
(
pArgs
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SConfigPair
*
pPair
=
taosArrayGet
(
pArgs
,
i
);
if
(
cfgSetItem
(
pCfg
,
pPair
->
name
,
pPair
->
value
,
CFG_STYPE_ARG_LIST
)
!=
0
)
{
return
-
1
;
}
}
return
0
;
}
static
void
cfgFreeItem
(
SConfigItem
*
pItem
)
{
if
(
pItem
->
dtype
==
CFG_DTYPE_STRING
||
pItem
->
dtype
==
CFG_DTYPE_DIR
||
pItem
->
dtype
==
CFG_DTYPE_LOCALE
||
pItem
->
dtype
==
CFG_DTYPE_CHARSET
||
pItem
->
dtype
==
CFG_DTYPE_TIMEZONE
)
{
tfree
(
pItem
->
str
);
}
if
(
pItem
->
array
)
{
taosArrayDestroy
(
pItem
->
array
);
pItem
->
array
=
NULL
;
}
}
void
cfgCleanup
(
SConfig
*
pCfg
)
{
if
(
pCfg
!=
NULL
)
{
if
(
pCfg
->
hash
!=
NULL
)
{
SConfigItem
*
pItem
=
taosHashIterate
(
pCfg
->
hash
,
NULL
);
while
(
pItem
!=
NULL
)
{
cfgFreeItem
(
pItem
);
pItem
=
taosHashIterate
(
pCfg
->
hash
,
pItem
);
}
taosHashCleanup
(
pCfg
->
hash
);
pCfg
->
hash
==
NULL
;
}
...
...
@@ -83,7 +112,7 @@ SConfigItem *cfgIterate(SConfig *pCfg, SConfigItem *pIter) { return taosHashIter
void
cfgCancelIterate
(
SConfig
*
pCfg
,
SConfigItem
*
pIter
)
{
return
taosHashCancelIterate
(
pCfg
->
hash
,
pIter
);
}
static
int32_t
cfgCheckAndSetTimezone
(
SConfigItem
*
pItem
,
const
char
*
timezone
)
{
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
timezone
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -94,7 +123,7 @@ static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone)
}
static
int32_t
cfgCheckAndSetCharset
(
SConfigItem
*
pItem
,
const
char
*
charset
)
{
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
charset
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -105,7 +134,7 @@ static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
}
static
int32_t
cfgCheckAndSetLocale
(
SConfigItem
*
pItem
,
const
char
*
locale
)
{
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
locale
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -134,7 +163,7 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
return
-
1
;
}
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
fullDir
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -275,6 +304,33 @@ static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType
return
0
;
}
static
int32_t
cfgSetTfsItem
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
value
,
const
char
*
level
,
const
char
*
primary
,
ECfgSrcType
stype
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
name
);
if
(
pItem
==
NULL
)
return
-
1
;
if
(
pItem
->
array
==
NULL
)
{
pItem
->
array
=
taosArrayInit
(
16
,
sizeof
(
SDiskCfg
));
if
(
pItem
->
array
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
SDiskCfg
cfg
=
{
0
};
tstrncpy
(
cfg
.
dir
,
value
,
sizeof
(
cfg
.
dir
));
cfg
.
level
=
atoi
(
level
);
cfg
.
primary
=
atoi
(
primary
);
void
*
ret
=
taosArrayPush
(
pItem
->
array
,
&
cfg
);
if
(
ret
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pItem
->
stype
=
stype
;
return
0
;
}
int32_t
cfgSetItem
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
value
,
ECfgSrcType
stype
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
name
);
if
(
pItem
==
NULL
)
{
...
...
@@ -441,8 +497,6 @@ const char *cfgStypeStr(ECfgSrcType type) {
return
"apollo_url"
;
case
CFG_STYPE_ARG_LIST
:
return
"arg_list"
;
case
CFG_STYPE_API_OPTION
:
return
"api_option"
;
default:
return
"invalid"
;
}
...
...
@@ -477,12 +531,12 @@ const char *cfgDtypeStr(ECfgDataType type) {
void
cfgDumpCfg
(
SConfig
*
pCfg
,
bool
tsc
,
bool
dump
)
{
if
(
dump
)
{
printf
(
" global config"
);
printf
(
"
global config"
);
printf
(
"
\n
"
);
printf
(
"================================================================="
);
printf
(
"
\n
"
);
}
else
{
uInfo
(
" global config"
);
uInfo
(
"
global config"
);
uInfo
(
"================================================================="
);
}
...
...
@@ -583,7 +637,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
}
while
(
!
taosEOFFile
(
pFile
))
{
name
=
value
=
value2
=
value3
=
NULL
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
...
...
@@ -610,11 +663,13 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
}
cfgSetItem
(
pConfig
,
name
,
value
,
CFG_STYPE_CFG_FILE
);
// taosReadConfigOption(name, value, value2, value3);
if
(
value2
!=
NULL
&&
value3
!=
NULL
&&
value2
[
0
]
!=
0
&&
value3
[
0
]
!=
0
)
{
cfgSetTfsItem
(
pConfig
,
name
,
value
,
value2
,
value3
,
CFG_STYPE_CFG_FILE
);
}
}
taosCloseFile
(
&
pFile
);
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
uInfo
(
"load from cfg file %s success"
,
filepath
);
return
0
;
...
...
source/util/src/tlog.c
浏览文件 @
6afebf9a
...
...
@@ -121,7 +121,7 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
osUpdate
();
char
fullName
[
PATH_MAX
]
=
{
0
};
snprintf
(
fullName
,
PATH_MAX
,
"%s"
TD_DIRSEP
"%s"
,
osLogDir
()
,
logName
);
snprintf
(
fullName
,
PATH_MAX
,
"%s"
TD_DIRSEP
"%s"
,
tsLogDir
,
logName
);
tsLogObj
.
logHandle
=
taosLogBuffNew
(
TSDB_DEFAULT_LOG_BUF_SIZE
);
if
(
tsLogObj
.
logHandle
==
NULL
)
return
-
1
;
...
...
@@ -187,7 +187,7 @@ static void taosKeepOldLog(char *oldName) {
}
}
taosRemoveOldFiles
(
osLogDir
()
,
TABS
(
tsLogKeepDays
));
taosRemoveOldFiles
(
tsLogDir
,
TABS
(
tsLogKeepDays
));
}
static
void
*
taosThreadToOpenNewFile
(
void
*
param
)
{
...
...
@@ -416,7 +416,7 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
buffer
[
len
++
]
=
'\n'
;
buffer
[
len
]
=
0
;
if
((
dflag
&
DEBUG_FILE
)
&&
tsLogObj
.
logHandle
&&
tsLogObj
.
logHandle
->
pFile
>=
0
)
{
if
((
dflag
&
DEBUG_FILE
)
&&
tsLogObj
.
logHandle
&&
tsLogObj
.
logHandle
->
pFile
!=
NULL
)
{
if
(
tsAsyncLog
)
{
taosPushLogBuffer
(
tsLogObj
.
logHandle
,
buffer
,
len
);
}
else
{
...
...
@@ -483,7 +483,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
buffer
[
len
++
]
=
'\n'
;
buffer
[
len
]
=
0
;
if
((
dflag
&
DEBUG_FILE
)
&&
tsLogObj
.
logHandle
&&
tsLogObj
.
logHandle
->
pFile
>=
0
)
{
if
((
dflag
&
DEBUG_FILE
)
&&
tsLogObj
.
logHandle
&&
tsLogObj
.
logHandle
->
pFile
!=
NULL
)
{
if
(
tsAsyncLog
)
{
taosPushLogBuffer
(
tsLogObj
.
logHandle
,
buffer
,
len
);
}
else
{
...
...
@@ -746,21 +746,6 @@ cmp_end:
return
ret
;
}
void
taosPrintOsInfo
()
{
SysNameInfo
info
=
taosGetSysNameInfo
();
uInfo
(
" os pageSize: %"
PRId64
"(KB)"
,
tsPageSize
);
uInfo
(
" os openMax: %"
PRId64
,
tsOpenMax
);
uInfo
(
" os streamMax: %"
PRId64
,
tsStreamMax
);
uInfo
(
" os numOfCores: %d"
,
tsNumOfCores
);
uInfo
(
" os totalMemory: %d(MB)"
,
tsTotalMemoryMB
);
uInfo
(
" os sysname: %s"
,
info
.
sysname
);
uInfo
(
" os nodename: %s"
,
info
.
nodename
);
uInfo
(
" os release: %s"
,
info
.
release
);
uInfo
(
" os version: %s"
,
info
.
version
);
uInfo
(
" os machine: %s"
,
info
.
machine
);
}
void
taosSetAllDebugFlag
(
int32_t
flag
)
{
if
(
!
(
flag
&
DEBUG_TRACE
||
flag
&
DEBUG_DEBUG
||
flag
&
DEBUG_DUMP
))
return
;
...
...
source/util/test/cfgTest.cpp
浏览文件 @
6afebf9a
...
...
@@ -34,7 +34,6 @@ TEST_F(CfgTest, 01_Str) {
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_VAR
),
"env_var"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_APOLLO_URL
),
"apollo_url"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ARG_LIST
),
"arg_list"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_API_OPTION
),
"api_option"
);
EXPECT_STREQ
(
cfgStypeStr
(
ECfgSrcType
(
1024
)),
"invalid"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_NONE
),
"none"
);
...
...
tools/shell/src/shellEngine.c
浏览文件 @
6afebf9a
...
...
@@ -68,11 +68,11 @@ TAOS *shellInit(SShellArguments *_args) {
printf
(
"
\n
"
);
if
(
!
_args
->
is_use_passwd
)
{
#ifdef TD_WINDOWS
strcpy
(
osName
()
,
"Windows"
);
strcpy
(
tsOsName
,
"Windows"
);
#elif defined(TD_DARWIN)
strcpy
(
osName
()
,
"Darwin"
);
strcpy
(
tsOsName
,
"Darwin"
);
#endif
printf
(
CLIENT_VERSION
,
osName
()
,
taos_get_client_info
());
printf
(
CLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
}
fflush
(
stdout
);
...
...
tools/shell/src/shellLinux.c
浏览文件 @
6afebf9a
...
...
@@ -184,7 +184,7 @@ static void parse_args(
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
((
strncmp
(
argv
[
i
],
"-p"
,
2
)
==
0
)
||
(
strncmp
(
argv
[
i
],
"--password"
,
10
)
==
0
))
{
printf
(
LINUXCLIENT_VERSION
,
osName
()
,
taos_get_client_info
());
printf
(
LINUXCLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
if
((
strlen
(
argv
[
i
])
==
2
)
||
(
strncmp
(
argv
[
i
],
"--password"
,
10
)
==
0
))
{
printf
(
"Enter password: "
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录