Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f0b8386b
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
f0b8386b
编写于
7月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: adjust the name of stream automatically created by sma
上级
c0639d3d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
11 deletion
+29
-11
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-1
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+1
-1
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+27
-9
未找到文件。
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
f0b8386b
...
@@ -125,7 +125,7 @@ typedef struct SMnode {
...
@@ -125,7 +125,7 @@ typedef struct SMnode {
}
SMnode
;
}
SMnode
;
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
int64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
int64_t
mndGenerateUid
(
c
onst
c
har
*
name
,
int32_t
len
);
int32_t
mndAcquireRpcRef
(
SMnode
*
pMnode
);
int32_t
mndAcquireRpcRef
(
SMnode
*
pMnode
);
void
mndReleaseRpcRef
(
SMnode
*
pMnode
);
void
mndReleaseRpcRef
(
SMnode
*
pMnode
);
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
f0b8386b
...
@@ -624,7 +624,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
...
@@ -624,7 +624,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
}
}
// Note: uid 0 is reserved
// Note: uid 0 is reserved
int64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
{
int64_t
mndGenerateUid
(
c
onst
c
har
*
name
,
int32_t
len
)
{
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
do
{
do
{
int64_t
us
=
taosGetTimestampUs
();
int64_t
us
=
taosGetTimestampUs
();
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
f0b8386b
...
@@ -479,7 +479,8 @@ static void mndDestroySmaObj(SSmaObj *pSmaObj) {
...
@@ -479,7 +479,8 @@ static void mndDestroySmaObj(SSmaObj *pSmaObj) {
}
}
}
}
static
int32_t
mndCreateSma
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SMCreateSmaReq
*
pCreate
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
static
int32_t
mndCreateSma
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SMCreateSmaReq
*
pCreate
,
SDbObj
*
pDb
,
SStbObj
*
pStb
,
const
char
*
streamName
)
{
SSmaObj
smaObj
=
{
0
};
SSmaObj
smaObj
=
{
0
};
memcpy
(
smaObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
smaObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
smaObj
.
stb
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
smaObj
.
stb
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
...
@@ -520,12 +521,12 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
...
@@ -520,12 +521,12 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
}
}
SStreamObj
streamObj
=
{
0
};
SStreamObj
streamObj
=
{
0
};
tstrncpy
(
streamObj
.
name
,
pCreate
->
n
ame
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
name
,
streamN
ame
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
sourceDb
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
streamObj
.
sourceDb
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
streamObj
.
targetDb
,
streamObj
.
sourceDb
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
streamObj
.
targetDb
,
streamObj
.
sourceDb
,
TSDB_DB_FNAME_LEN
);
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
n
ame
));
streamObj
.
uid
=
mndGenerateUid
(
streamName
,
strlen
(
streamN
ame
));
streamObj
.
sourceDbUid
=
pDb
->
uid
;
streamObj
.
sourceDbUid
=
pDb
->
uid
;
streamObj
.
targetDbUid
=
pDb
->
uid
;
streamObj
.
targetDbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
version
=
1
;
...
@@ -590,7 +591,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
...
@@ -590,7 +591,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
mndTransSetSerial
(
pTrans
);
mndTransSetSerial
(
pTrans
);
mDebug
(
"trans:%d, used to create sma:%s
"
,
pTrans
->
id
,
pCreate
->
name
);
mDebug
(
"trans:%d, used to create sma:%s
stream:%s"
,
pTrans
->
id
,
pCreate
->
name
,
streamObj
.
name
);
if
(
mndSetCreateSmaRedoLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaRedoLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaVgroupRedoLogs
(
pMnode
,
pTrans
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaVgroupRedoLogs
(
pMnode
,
pTrans
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
goto
_OVER
;
...
@@ -638,6 +639,14 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) {
...
@@ -638,6 +639,14 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) {
return
0
;
return
0
;
}
}
static
void
mndGetStreamNameFromSmaName
(
char
*
streamName
,
char
*
smaName
)
{
SName
n
;
tNameFromString
(
&
n
,
smaName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
streamName
[
0
]
=
'1'
;
streamName
[
1
]
=
'.'
;
strcpy
(
streamName
+
2
,
tNameGetTableName
(
&
n
));
}
static
int32_t
mndProcessCreateSmaReq
(
SRpcMsg
*
pReq
)
{
static
int32_t
mndProcessCreateSmaReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -663,9 +672,12 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
...
@@ -663,9 +672,12 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
pStream
=
mndAcquireStream
(
pMnode
,
createReq
.
name
);
char
streamName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
mndGetStreamNameFromSmaName
(
streamName
,
createReq
.
name
);
pStream
=
mndAcquireStream
(
pMnode
,
streamName
);
if
(
pStream
!=
NULL
)
{
if
(
pStream
!=
NULL
)
{
mError
(
"sma:%s, failed to create since stream:%s already exist"
,
createReq
.
name
,
createReq
.
n
ame
);
mError
(
"sma:%s, failed to create since stream:%s already exist"
,
createReq
.
name
,
streamN
ame
);
terrno
=
TSDB_CODE_MND_STREAM_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_STREAM_ALREADY_EXIST
;
goto
_OVER
;
goto
_OVER
;
}
}
...
@@ -692,7 +704,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
...
@@ -692,7 +704,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
code
=
mndCreateSma
(
pMnode
,
pReq
,
&
createReq
,
pDb
,
pStb
);
code
=
mndCreateSma
(
pMnode
,
pReq
,
&
createReq
,
pDb
,
pStb
,
streamName
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
_OVER:
_OVER:
...
@@ -789,7 +801,10 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
...
@@ -789,7 +801,10 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
mDebug
(
"trans:%d, used to drop sma:%s"
,
pTrans
->
id
,
pSma
->
name
);
mDebug
(
"trans:%d, used to drop sma:%s"
,
pTrans
->
id
,
pSma
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
SStreamObj
*
pStream
=
mndAcquireStream
(
pMnode
,
pSma
->
name
);
char
streamName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
mndGetStreamNameFromSmaName
(
streamName
,
pSma
->
name
);
SStreamObj
*
pStream
=
mndAcquireStream
(
pMnode
,
streamName
);
if
(
pStream
==
NULL
||
pStream
->
smaId
!=
pSma
->
uid
)
{
if
(
pStream
==
NULL
||
pStream
->
smaId
!=
pSma
->
uid
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
goto
_OVER
;
goto
_OVER
;
...
@@ -838,7 +853,10 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
...
@@ -838,7 +853,10 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
pVgroup
=
mndAcquireVgroup
(
pMnode
,
pSma
->
dstVgId
);
pVgroup
=
mndAcquireVgroup
(
pMnode
,
pSma
->
dstVgId
);
if
(
pVgroup
==
NULL
)
goto
_OVER
;
if
(
pVgroup
==
NULL
)
goto
_OVER
;
SStreamObj
*
pStream
=
mndAcquireStream
(
pMnode
,
pSma
->
name
);
char
streamName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
mndGetStreamNameFromSmaName
(
streamName
,
pSma
->
name
);
SStreamObj
*
pStream
=
mndAcquireStream
(
pMnode
,
streamName
);
if
(
pStream
!=
NULL
&&
pStream
->
smaId
==
pSma
->
uid
)
{
if
(
pStream
!=
NULL
&&
pStream
->
smaId
==
pSma
->
uid
)
{
if
(
mndDropStreamTasks
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
if
(
mndDropStreamTasks
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
mError
(
"stream:%s, failed to drop task since %s"
,
pStream
->
name
,
terrstr
());
mError
(
"stream:%s, failed to drop task since %s"
,
pStream
->
name
,
terrstr
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录