Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
18c871a9
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
18c871a9
编写于
11月 29, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 add global variables in sdb
上级
35b0c693
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
164 addition
and
113 deletion
+164
-113
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+9
-5
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-0
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+1
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+1
-1
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-1
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+86
-46
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+41
-35
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+24
-24
未找到文件。
include/dnode/mnode/sdb/sdb.h
浏览文件 @
18c871a9
...
...
@@ -126,6 +126,10 @@ typedef enum {
SDB_MAX
=
12
}
ESdbType
;
typedef
struct
SSdbOpt
{
const
char
*
path
;
}
SSdbOpt
;
typedef
int32_t
(
*
SdbInsertFp
)(
void
*
pObj
);
typedef
int32_t
(
*
SdbUpdateFp
)(
void
*
pSrcObj
,
void
*
pDstObj
);
typedef
int32_t
(
*
SdbDeleteFp
)(
void
*
pObj
);
...
...
@@ -146,12 +150,12 @@ typedef struct {
typedef
struct
SSdb
SSdb
;
int32_t
sdbInit
(
);
void
sdbCleanup
(
);
void
sdbSetTable
(
SSdbTable
table
);
SSdb
*
sdbOpen
(
SSdbOpt
*
pOption
);
void
sdbClose
(
SSdb
*
pSdb
);
void
sdbSetTable
(
SSdb
*
pSdb
,
SSdbTable
table
);
int32_t
sdbOpen
();
void
sdbClose
();
//
int32_t sdbOpen();
//
void sdbClose();
int32_t
sdbWrite
(
SSdbRaw
*
pRaw
);
int32_t
sdbDeploy
();
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
18c871a9
...
...
@@ -43,6 +43,7 @@ typedef struct SMnode {
tmr_h
timer
;
SSdb
*
pSdb
;
SDnode
*
pDnode
;
char
*
path
;
SArray
steps
;
MndMsgFp
msgFp
[
TSDB_MSG_TYPE_MAX
];
SendMsgToDnodeFp
sendMsgToDnodeFp
;
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
18c871a9
...
...
@@ -110,8 +110,8 @@ int32_t mndInitAcct(SMnode *pMnode) {
.
insertFp
=
(
SdbInsertFp
)
mnodeAcctActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mnodeAcctActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mnodeAcctActionDelete
};
sdbSetTable
(
table
);
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
18c871a9
...
...
@@ -320,7 +320,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
.
insertFp
=
(
SdbInsertFp
)
trnActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
trnActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
trnActionDelete
};
sdbSetTable
(
table
);
sdbSetTable
(
pMnode
->
pSdb
,
table
);
mInfo
(
"trn module is initialized"
);
return
0
;
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
18c871a9
...
...
@@ -223,7 +223,7 @@ int32_t mndInitUser(SMnode *pMnode) {
.
insertFp
=
(
SdbInsertFp
)
mndUserActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndUserActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndUserActionDelete
};
sdbSetTable
(
table
);
sdbSetTable
(
pMnode
->
pSdb
,
table
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_USER
,
mndProcessCreateUserMsg
);
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
18c871a9
...
...
@@ -46,6 +46,12 @@ int64_t mndGetClusterId(SMnode *pMnode) {
return
-
1
;
}
tmr_h
mndGetTimer
(
SMnode
*
pMnode
)
{
if
(
pMnode
!=
NULL
)
{
return
pMnode
->
timer
;
}
}
void
mndSendMsgToDnode
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
!=
NULL
&&
pMnode
->
sendMsgToDnodeFp
!=
NULL
)
{
(
*
pMnode
->
sendMsgToDnodeFp
)(
pMnode
->
pDnode
,
pEpSet
,
pMsg
);
...
...
@@ -83,33 +89,42 @@ static void mndCleanupTimer(SMnode *pMnode) {
}
}
tmr_h
mndGetTimer
(
SMnode
*
pMnode
)
{
if
(
pMnode
!=
NULL
)
{
return
pMnode
->
timer
;
static
int32_t
mnodeCreateDir
(
SMnode
*
pMnode
,
const
char
*
path
)
{
pMnode
->
path
=
strdup
(
path
);
if
(
pMnode
->
path
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
terrno
;
}
if
(
taosMkDir
(
pMnode
->
path
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
terrno
;
}
return
0
;
}
static
int32_t
mndSetOptions
(
SMnode
*
pMnode
,
const
SMnodeOpt
*
pOption
)
{
pMnode
->
dnodeId
=
pOption
->
dnodeId
;
pMnode
->
clusterId
=
pOption
->
clusterId
;
pMnode
->
replica
=
pOption
->
replica
;
pMnode
->
selfIndex
=
pOption
->
selfIndex
;
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
pDnode
=
pOption
->
pDnode
;
pMnode
->
putMsgToApplyMsgFp
=
pOption
->
putMsgToApplyMsgFp
;
pMnode
->
sendMsgToDnodeFp
=
pOption
->
sendMsgToDnodeFp
;
pMnode
->
sendMsgToMnodeFp
=
pOption
->
sendMsgToMnodeFp
;
pMnode
->
sendRedirectMsgFp
=
pOption
->
sendRedirectMsgFp
;
static
int32_t
mndInitSdb
(
SMnode
*
pMnode
)
{
SSdbOpt
opt
=
{
0
};
opt
.
path
=
pMnode
->
path
;
if
(
pMnode
->
sendMsgToDnodeFp
==
NULL
||
pMnode
->
sendMsgToMnodeFp
==
NULL
||
pMnode
->
sendRedirectMsgFp
==
NULL
||
pMnode
->
putMsgToApplyMsgFp
==
NULL
||
pMnode
->
dnodeId
<
0
||
pMnode
->
clusterId
<
0
)
{
terrno
=
TSDB_CODE_MND_APP_ERROR
;
pMnode
->
pSdb
=
sdbOpen
(
&
opt
);
if
(
pMnode
->
pSdb
==
NULL
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
mndDeploySdb
(
SMnode
*
pMnode
)
{
return
sdbDeploy
(
pMnode
->
pSdb
);
}
static
void
mndCleanupSdb
(
SMnode
*
pMnode
)
{
if
(
pMnode
->
pSdb
)
{
sdbClose
(
pMnode
->
pSdb
);
pMnode
->
pSdb
=
NULL
;
}
}
static
int32_t
mndAllocStep
(
SMnode
*
pMnode
,
char
*
name
,
MndInitFp
initFp
,
MndCleanupFp
cleanupFp
)
{
SMnodeStep
step
=
{
0
};
step
.
name
=
name
;
...
...
@@ -125,33 +140,28 @@ static int32_t mndAllocStep(SMnode *pMnode, char *name, MndInitFp initFp, MndCle
}
static
int32_t
mndInitSteps
(
SMnode
*
pMnode
)
{
if
(
mndAllocStep
(
pMnode
,
"mnode-trans"
,
mndInitTrans
,
mndCleanupTrans
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-cluster"
,
mndInitCluster
,
mndCleanupCluster
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-mnode"
,
mndInitMnode
,
mndCleanupMnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-db"
,
mndInitDb
,
mndCleanupDb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-vgroup"
,
mndInitVgroup
,
mndCleanupVgroup
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stable"
,
mndInitStable
,
mndCleanupStable
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-func"
,
mndInitFunc
,
mndCleanupFunc
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb"
,
sdbInit
,
sdbCleanup
)
!=
0
)
return
-
1
;
if
(
pMnode
->
replica
==
1
)
{
if
(
mndAllocStep
(
pMnode
,
"mnode-deploy-sdb"
,
sdbDeploy
,
sdbClose
)
!=
0
)
return
-
1
;
}
else
{
if
(
mndAllocStep
(
pMnode
,
"mnode-open-sdb"
,
sdbOpen
,
sdbClose
)
!=
0
)
return
-
1
;
}
if
(
mndAllocStep
(
pMnode
,
"mnode-timer"
,
mndInitTimer
,
NULL
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb-file"
,
sdbOpen
,
sdbClose
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-balance"
,
mndInitBalance
,
mndCleanupBalance
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-profile"
,
mndInitProfile
,
mndCleanupProfile
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-show"
,
mndInitShow
,
mndCleanupShow
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sync"
,
mndInitSync
,
mndCleanupSync
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-telem"
,
mndInitTelem
,
mndCleanupTelem
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-timer"
,
NULL
,
mndCleanupTimer
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-trans"
,
mndInitTrans
,
mndCleanupTrans
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-cluster"
,
mndInitCluster
,
mndCleanupCluster
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-mnode"
,
mndInitMnode
,
mndCleanupMnode
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-db"
,
mndInitDb
,
mndCleanupDb
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-vgroup"
,
mndInitVgroup
,
mndCleanupVgroup
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stable"
,
mndInitStable
,
mndCleanupStable
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-func"
,
mndInitFunc
,
mndCleanupFunc
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb"
,
mndInitSdb
,
mndCleanupSdb
)
!=
0
)
return
terrno
;
if
(
pMnode
->
clusterId
<=
0
)
{
if
(
mndAllocStep
(
pMnode
,
"mnode-deploy"
,
mndDeploySdb
,
NULL
)
!=
0
)
return
terrno
;
}
if
(
mndAllocStep
(
pMnode
,
"mnode-timer"
,
mndInitTimer
,
NULL
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-balance"
,
mndInitBalance
,
mndCleanupBalance
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-profile"
,
mndInitProfile
,
mndCleanupProfile
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-show"
,
mndInitShow
,
mndCleanupShow
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sync"
,
mndInitSync
,
mndCleanupSync
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-telem"
,
mndInitTelem
,
mndCleanupTelem
)
!=
0
)
return
terrno
;
if
(
mndAllocStep
(
pMnode
,
"mnode-timer"
,
NULL
,
mndCleanupTimer
)
!=
0
)
return
terrno
;
return
0
;
}
...
...
@@ -194,10 +204,39 @@ static int32_t mndExecSteps(SMnode *pMnode) {
}
}
static
int32_t
mndSetOptions
(
SMnode
*
pMnode
,
const
SMnodeOpt
*
pOption
)
{
pMnode
->
dnodeId
=
pOption
->
dnodeId
;
pMnode
->
clusterId
=
pOption
->
clusterId
;
pMnode
->
replica
=
pOption
->
replica
;
pMnode
->
selfIndex
=
pOption
->
selfIndex
;
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
pDnode
=
pOption
->
pDnode
;
pMnode
->
putMsgToApplyMsgFp
=
pOption
->
putMsgToApplyMsgFp
;
pMnode
->
sendMsgToDnodeFp
=
pOption
->
sendMsgToDnodeFp
;
pMnode
->
sendMsgToMnodeFp
=
pOption
->
sendMsgToMnodeFp
;
pMnode
->
sendRedirectMsgFp
=
pOption
->
sendRedirectMsgFp
;
if
(
pMnode
->
sendMsgToDnodeFp
==
NULL
||
pMnode
->
sendMsgToMnodeFp
==
NULL
||
pMnode
->
sendRedirectMsgFp
==
NULL
||
pMnode
->
putMsgToApplyMsgFp
==
NULL
||
pMnode
->
dnodeId
<
0
||
pMnode
->
clusterId
<
0
)
{
terrno
=
TSDB_CODE_MND_APP_ERROR
;
return
terrno
;
}
return
0
;
}
SMnode
*
mndOpen
(
const
char
*
path
,
const
SMnodeOpt
*
pOption
)
{
SMnode
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnode
));
int32_t
code
=
mndSetOptions
(
pMnode
,
pOption
);
int32_t
code
=
mnodeCreateDir
(
pMnode
,
path
);
if
(
code
!=
0
)
{
mError
(
"failed to set mnode options since %s"
,
terrstr
());
mndClose
(
pMnode
);
terrno
=
code
;
return
NULL
;
}
code
=
mndSetOptions
(
pMnode
,
pOption
);
if
(
code
!=
0
)
{
mndClose
(
pMnode
);
terrno
=
code
;
...
...
@@ -227,7 +266,8 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
void
mndClose
(
SMnode
*
pMnode
)
{
mndCleanupSteps
(
pMnode
,
-
1
);
free
(
pMnode
);
tfree
(
pMnode
->
path
);
tfree
(
pMnode
);
mDebug
(
"mnode:%p object is cleaned up"
,
pMnode
);
}
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
18c871a9
...
...
@@ -19,27 +19,31 @@
SSdb
tsSdb
=
{
0
};
int32_t
sdbInit
()
{
char
path
[
PATH_MAX
+
100
];
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%scur%s"
,
tsMnodeDir
,
TD_DIRSEP
,
TD_DIRSEP
);
tsSdb
.
currDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%ssync%s"
,
tsMnodeDir
,
TD_DIRSEP
,
TD_DIRSEP
);
tsSdb
.
syncDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%stmp%s"
,
tsMnodeDir
,
TD_DIRSEP
,
TD_DIRSEP
);
tsSdb
.
tmpDir
=
strdup
(
path
);
SSdb
*
sdbOpen
(
SSdbOpt
*
pOption
)
{
SSdb
*
pSdb
=
calloc
(
1
,
sizeof
(
SSdb
));
if
(
pSdb
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
if
(
tsSdb
.
currDir
==
NULL
||
tsSdb
.
currDir
==
NULL
||
tsSdb
.
currDir
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
char
path
[
PATH_MAX
+
100
];
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%scur%s"
,
pOption
->
path
,
TD_DIRSEP
,
TD_DIRSEP
);
pSdb
->
currDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%ssync%s"
,
pOption
->
path
,
TD_DIRSEP
,
TD_DIRSEP
);
pSdb
->
syncDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%stmp%s"
,
pOption
->
path
,
TD_DIRSEP
,
TD_DIRSEP
);
pSdb
->
tmpDir
=
strdup
(
path
);
if
(
pSdb
->
currDir
==
NULL
||
pSdb
->
currDir
==
NULL
||
pSdb
->
currDir
==
NULL
)
{
sdbClose
(
pSdb
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
SDB_MAX
;
++
i
)
{
int32_t
type
;
if
(
tsSdb
.
keyTypes
[
i
]
==
SDB_KEY_INT32
)
{
if
(
pSdb
->
keyTypes
[
i
]
==
SDB_KEY_INT32
)
{
type
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
tsSdb
.
keyTypes
[
i
]
==
SDB_KEY_INT64
)
{
}
else
if
(
pSdb
->
keyTypes
[
i
]
==
SDB_KEY_INT64
)
{
type
=
TSDB_DATA_TYPE_BIGINT
;
}
else
{
type
=
TSDB_DATA_TYPE_BINARY
;
...
...
@@ -47,45 +51,47 @@ int32_t sdbInit() {
SHashObj
*
hash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
type
),
true
,
HASH_NO_LOCK
);
if
(
hash
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
sdbClose
(
pSdb
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
tsSdb
.
hashObjs
[
i
]
=
hash
;
taosInitRWLatch
(
&
tsSdb
.
locks
[
i
]);
pSdb
->
hashObjs
[
i
]
=
hash
;
taosInitRWLatch
(
&
pSdb
->
locks
[
i
]);
}
return
0
;
}
void
sdbCl
eanup
(
)
{
if
(
tsSdb
.
currDir
!=
NULL
)
{
tfree
(
tsSdb
.
currDir
);
void
sdbCl
ose
(
SSdb
*
pSdb
)
{
if
(
pSdb
->
currDir
!=
NULL
)
{
tfree
(
pSdb
->
currDir
);
}
if
(
tsSdb
.
syncDir
!=
NULL
)
{
tfree
(
tsSdb
.
syncDir
);
if
(
pSdb
->
syncDir
!=
NULL
)
{
tfree
(
pSdb
->
syncDir
);
}
if
(
tsSdb
.
tmpDir
!=
NULL
)
{
tfree
(
tsSdb
.
tmpDir
);
if
(
pSdb
->
tmpDir
!=
NULL
)
{
tfree
(
pSdb
->
tmpDir
);
}
for
(
int32_t
i
=
0
;
i
<
SDB_MAX
;
++
i
)
{
SHashObj
*
hash
=
tsSdb
.
hashObjs
[
i
];
SHashObj
*
hash
=
pSdb
->
hashObjs
[
i
];
if
(
hash
!=
NULL
)
{
taosHashCleanup
(
hash
);
}
tsSdb
.
hashObjs
[
i
]
=
NULL
;
pSdb
->
hashObjs
[
i
]
=
NULL
;
}
}
void
sdbSetTable
(
SSdbTable
table
)
{
void
sdbSetTable
(
SSdb
*
pSdb
,
SSdb
Table
table
)
{
ESdbType
sdb
=
table
.
sdbType
;
tsSdb
.
keyTypes
[
sdb
]
=
table
.
keyType
;
tsSdb
.
insertFps
[
sdb
]
=
table
.
insertFp
;
tsSdb
.
updateFps
[
sdb
]
=
table
.
updateFp
;
tsSdb
.
deleteFps
[
sdb
]
=
table
.
deleteFp
;
tsSdb
.
deployFps
[
sdb
]
=
table
.
deployFp
;
tsSdb
.
encodeFps
[
sdb
]
=
table
.
encodeFp
;
tsSdb
.
decodeFps
[
sdb
]
=
table
.
decodeFp
;
pSdb
->
keyTypes
[
sdb
]
=
table
.
keyType
;
pSdb
->
insertFps
[
sdb
]
=
table
.
insertFp
;
pSdb
->
updateFps
[
sdb
]
=
table
.
updateFp
;
pSdb
->
deleteFps
[
sdb
]
=
table
.
deleteFp
;
pSdb
->
deployFps
[
sdb
]
=
table
.
deployFp
;
pSdb
->
encodeFps
[
sdb
]
=
table
.
encodeFp
;
pSdb
->
decodeFps
[
sdb
]
=
table
.
decodeFp
;
}
\ No newline at end of file
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
18c871a9
...
...
@@ -212,29 +212,29 @@ static int32_t sdbWriteDataFile() {
return
code
;
}
int32_t
sdbOpen
()
{
mDebug
(
"start to read mnode file"
);
if
(
sdbReadDataFile
()
!=
0
)
{
return
-
1
;
}
return
0
;
}
void
sdbClose
()
{
if
(
tsSdb
.
curVer
!=
tsSdb
.
lastCommitVer
)
{
mDebug
(
"start to write mnode file"
);
sdbWriteDataFile
();
}
for
(
int32_t
i
=
0
;
i
<
SDB_MAX
;
++
i
)
{
SHashObj
*
hash
=
tsSdb
.
hashObjs
[
i
];
if
(
hash
!=
NULL
)
{
taosHashClear
(
hash
);
}
}
}
//
int32_t sdbOpen() {
//
mDebug("start to read mnode file");
//
if (sdbReadDataFile() != 0) {
//
return -1;
//
}
//
return 0;
//
}
//
void sdbClose() {
//
if (tsSdb.curVer != tsSdb.lastCommitVer) {
//
mDebug("start to write mnode file");
//
sdbWriteDataFile();
//
}
//
for (int32_t i = 0; i < SDB_MAX; ++i) {
//
SHashObj *hash = tsSdb.hashObjs[i];
//
if (hash != NULL) {
//
taosHashClear(hash);
//
}
//
}
//
}
int32_t
sdbDeploy
()
{
if
(
sdbCreateDir
()
!=
0
)
{
...
...
@@ -249,7 +249,7 @@ int32_t sdbDeploy() {
return
-
1
;
}
sdbClose
();
//
sdbClose();
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录