Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
23da7d42
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
23da7d42
编写于
12月 08, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 create dnode
上级
47e1d695
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
589 addition
and
81 deletion
+589
-81
include/common/taosmsg.h
include/common/taosmsg.h
+10
-6
include/common/tglobal.h
include/common/tglobal.h
+0
-1
include/util/tutil.h
include/util/tutil.h
+12
-11
source/common/src/tglobal.c
source/common/src/tglobal.c
+0
-18
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+15
-17
source/dnode/mnode/impl/inc/mndDnode.h
source/dnode/mnode/impl/inc/mndDnode.h
+1
-0
source/dnode/mnode/impl/inc/mndShow.h
source/dnode/mnode/impl/inc/mndShow.h
+1
-0
source/dnode/mnode/impl/inc/mndVgroup.h
source/dnode/mnode/impl/inc/mndVgroup.h
+1
-0
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+417
-11
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+1
-6
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+4
-3
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+110
-4
source/util/src/tutil.c
source/util/src/tutil.c
+17
-4
未找到文件。
include/common/taosmsg.h
浏览文件 @
23da7d42
...
@@ -829,7 +829,16 @@ typedef struct SShowRsp {
...
@@ -829,7 +829,16 @@ typedef struct SShowRsp {
typedef
struct
{
typedef
struct
{
char
ep
[
TSDB_EP_LEN
];
// end point, hostname:port
char
ep
[
TSDB_EP_LEN
];
// end point, hostname:port
}
SCreateDnodeMsg
,
SDropDnodeMsg
;
}
SCreateDnodeMsg
;
typedef
struct
{
int32_t
dnodeId
;
}
SDropDnodeMsg
;
typedef
struct
{
int32_t
dnodeId
;
char
config
[
128
];
}
SCfgDnodeMsg
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
...
@@ -849,11 +858,6 @@ typedef struct {
...
@@ -849,11 +858,6 @@ typedef struct {
int32_t
vgId
;
int32_t
vgId
;
}
SConfigVnodeMsg
;
}
SConfigVnodeMsg
;
typedef
struct
{
char
ep
[
TSDB_EP_LEN
];
// end point, hostname:port
char
config
[
64
];
}
SCfgDnodeMsg
;
typedef
struct
{
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
char
sql
[
TSDB_SHOW_SQL_LEN
];
int32_t
queryId
;
int32_t
queryId
;
...
...
include/common/tglobal.h
浏览文件 @
23da7d42
...
@@ -196,7 +196,6 @@ extern SDiskCfg tsDiskCfg[];
...
@@ -196,7 +196,6 @@ extern SDiskCfg tsDiskCfg[];
void
taosInitGlobalCfg
();
void
taosInitGlobalCfg
();
int32_t
taosCheckGlobalCfg
();
int32_t
taosCheckGlobalCfg
();
int32_t
taosCfgDynamicOptions
(
char
*
msg
);
int32_t
taosCfgDynamicOptions
(
char
*
msg
);
int
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
bool
taosCheckBalanceCfgOptions
(
const
char
*
option
,
int32_t
*
vnodeId
,
int32_t
*
dnodeId
);
bool
taosCheckBalanceCfgOptions
(
const
char
*
option
,
int32_t
*
vnodeId
,
int32_t
*
dnodeId
);
void
taosAddDataDir
(
int
index
,
char
*
v1
,
int
level
,
int
primary
);
void
taosAddDataDir
(
int
index
,
char
*
v1
,
int
level
,
int
primary
);
void
taosReadDataDirCfg
(
char
*
v1
,
char
*
v2
,
char
*
v3
);
void
taosReadDataDirCfg
(
char
*
v1
,
char
*
v2
,
char
*
v3
);
...
...
include/util/tutil.h
浏览文件 @
23da7d42
...
@@ -21,22 +21,22 @@ extern "C" {
...
@@ -21,22 +21,22 @@ extern "C" {
#endif
#endif
#include "os.h"
#include "os.h"
#include "tmd5.h"
#include "tcrc32c.h"
#include "tcrc32c.h"
#include "tdef.h"
#include "tdef.h"
#include "tmd5.h"
int32_t
strdequote
(
char
*
src
);
int32_t
strdequote
(
char
*
src
);
int32_t
strndequote
(
char
*
dst
,
const
char
*
z
,
int32_t
len
);
int32_t
strndequote
(
char
*
dst
,
const
char
*
z
,
int32_t
len
);
int32_t
strRmquote
(
char
*
z
,
int32_t
len
);
int32_t
strRmquote
(
char
*
z
,
int32_t
len
);
size_t
strtrim
(
char
*
src
);
size_t
strtrim
(
char
*
src
);
char
*
strnchr
(
char
*
haystack
,
char
needle
,
int32_t
len
,
bool
skipquote
);
char
*
strnchr
(
char
*
haystack
,
char
needle
,
int32_t
len
,
bool
skipquote
);
char
**
strsplit
(
char
*
src
,
const
char
*
delim
,
int32_t
*
num
);
char
**
strsplit
(
char
*
src
,
const
char
*
delim
,
int32_t
*
num
);
char
*
strtolower
(
char
*
dst
,
const
char
*
src
);
char
*
strtolower
(
char
*
dst
,
const
char
*
src
);
char
*
strntolower
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
char
*
strntolower
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
char
*
strntolower_s
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
char
*
strntolower_s
(
char
*
dst
,
const
char
*
src
,
int32_t
n
);
int64_t
strnatoi
(
char
*
num
,
int32_t
len
);
int64_t
strnatoi
(
char
*
num
,
int32_t
len
);
char
*
strbetween
(
char
*
string
,
char
*
begin
,
char
*
end
);
char
*
strbetween
(
char
*
string
,
char
*
begin
,
char
*
end
);
char
*
paGetToken
(
char
*
src
,
char
**
token
,
int32_t
*
tokenLen
);
char
*
paGetToken
(
char
*
src
,
char
**
token
,
int32_t
*
tokenLen
);
int32_t
taosByteArrayToHexStr
(
char
bytes
[],
int32_t
len
,
char
hexstr
[]);
int32_t
taosByteArrayToHexStr
(
char
bytes
[],
int32_t
len
,
char
hexstr
[]);
int32_t
taosHexStrToByteArray
(
char
hexstr
[],
char
bytes
[]);
int32_t
taosHexStrToByteArray
(
char
hexstr
[],
char
bytes
[]);
...
@@ -45,11 +45,12 @@ char *taosIpStr(uint32_t ipInt);
...
@@ -45,11 +45,12 @@ char *taosIpStr(uint32_t ipInt);
uint32_t
ip2uint
(
const
char
*
const
ip_addr
);
uint32_t
ip2uint
(
const
char
*
const
ip_addr
);
void
taosIp2String
(
uint32_t
ip
,
char
*
str
);
void
taosIp2String
(
uint32_t
ip
,
char
*
str
);
void
taosIpPort2String
(
uint32_t
ip
,
uint16_t
port
,
char
*
str
);
void
taosIpPort2String
(
uint32_t
ip
,
uint16_t
port
,
char
*
str
);
int32_t
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
static
FORCE_INLINE
void
taosEncryptPass
(
uint8_t
*
inBuf
,
size_t
inLen
,
char
*
target
)
{
static
FORCE_INLINE
void
taosEncryptPass
(
uint8_t
*
inBuf
,
size_t
inLen
,
char
*
target
)
{
MD5_CTX
context
;
MD5_CTX
context
;
MD5Init
(
&
context
);
MD5Init
(
&
context
);
MD5Update
(
&
context
,
inBuf
,
(
u
nsigned
in
t
)
inLen
);
MD5Update
(
&
context
,
inBuf
,
(
u
int32_
t
)
inLen
);
MD5Final
(
&
context
);
MD5Final
(
&
context
);
memcpy
(
target
,
context
.
digest
,
TSDB_KEY_LEN
);
memcpy
(
target
,
context
.
digest
,
TSDB_KEY_LEN
);
}
}
...
@@ -58,4 +59,4 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *tar
...
@@ -58,4 +59,4 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *tar
}
}
#endif
#endif
#endif
/*_TD_UTIL_UTIL_H*/
#endif
/*_TD_UTIL_UTIL_H*/
source/common/src/tglobal.c
浏览文件 @
23da7d42
...
@@ -1738,24 +1738,6 @@ int32_t taosCheckGlobalCfg() {
...
@@ -1738,24 +1738,6 @@ int32_t taosCheckGlobalCfg() {
return
0
;
return
0
;
}
}
int
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
)
{
*
port
=
0
;
strcpy
(
fqdn
,
ep
);
char
*
temp
=
strchr
(
fqdn
,
':'
);
if
(
temp
)
{
*
temp
=
0
;
*
port
=
atoi
(
temp
+
1
);
}
if
(
*
port
==
0
)
{
*
port
=
tsServerPort
;
return
-
1
;
}
return
0
;
}
/*
/*
* alter dnode 1 balance "vnode:1-dnode:2"
* alter dnode 1 balance "vnode:1-dnode:2"
*/
*/
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
23da7d42
...
@@ -286,23 +286,21 @@ typedef struct SFuncObj {
...
@@ -286,23 +286,21 @@ typedef struct SFuncObj {
char
pData
[];
char
pData
[];
}
SFuncObj
;
}
SFuncObj
;
typedef
struct
SShowObj
SShowObj
;
typedef
struct
{
typedef
struct
SShowObj
{
int32_t
id
;
int8_t
type
;
int8_t
type
;
int8_t
maxReplica
;
int8_t
replica
;
int16_t
numOfColumns
;
int16_t
numOfColumns
;
int32_t
id
;
int32_t
rowSize
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfRows
;
int32_t
numOfReads
;
int32_t
numOfReads
;
int32_t
payloadLen
;
uint16_t
payloadLen
;
void
*
pIter
;
void
*
pIter
;
SMnode
*
pMnode
;
void
*
pVgIter
;
char
db
[
TSDB_FULL_DB_NAME_LEN
];
SMnode
*
pMnode
;
int16_t
offset
[
TSDB_MAX_COLUMNS
];
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
char
payload
[];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
char
payload
[];
}
SShowObj
;
}
SShowObj
;
typedef
struct
SMnodeMsg
{
typedef
struct
SMnodeMsg
{
...
...
source/dnode/mnode/impl/inc/mndDnode.h
浏览文件 @
23da7d42
...
@@ -26,6 +26,7 @@ int32_t mndInitDnode(SMnode *pMnode);
...
@@ -26,6 +26,7 @@ int32_t mndInitDnode(SMnode *pMnode);
void
mndCleanupDnode
(
SMnode
*
pMnode
);
void
mndCleanupDnode
(
SMnode
*
pMnode
);
SDnodeObj
*
mndAcquireDnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
SDnodeObj
*
mndAcquireDnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
void
mndReleaseDnode
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
);
void
mndReleaseDnode
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
);
SEpSet
mndGetDnodeEpset
(
SDnodeObj
*
pDnode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndShow.h
浏览文件 @
23da7d42
...
@@ -28,6 +28,7 @@ void mndAddShowMetaHandle(SMnode *pMnode, EShowType showType, ShowMetaFp fp);
...
@@ -28,6 +28,7 @@ void mndAddShowMetaHandle(SMnode *pMnode, EShowType showType, ShowMetaFp fp);
void
mndAddShowRetrieveHandle
(
SMnode
*
pMnode
,
EShowType
showType
,
ShowRetrieveFp
fp
);
void
mndAddShowRetrieveHandle
(
SMnode
*
pMnode
,
EShowType
showType
,
ShowRetrieveFp
fp
);
void
mndAddShowFreeIterHandle
(
SMnode
*
pMnode
,
EShowType
msgType
,
ShowFreeIterFp
fp
);
void
mndAddShowFreeIterHandle
(
SMnode
*
pMnode
,
EShowType
msgType
,
ShowFreeIterFp
fp
);
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
char
*
mndShowStr
(
int32_t
showType
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndVgroup.h
浏览文件 @
23da7d42
...
@@ -24,6 +24,7 @@ extern "C" {
...
@@ -24,6 +24,7 @@ extern "C" {
int32_t
mndInitVgroup
(
SMnode
*
pMnode
);
int32_t
mndInitVgroup
(
SMnode
*
pMnode
);
void
mndCleanupVgroup
(
SMnode
*
pMnode
);
void
mndCleanupVgroup
(
SMnode
*
pMnode
);
int32_t
mndGetVnodesNum
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
23da7d42
...
@@ -16,12 +16,17 @@
...
@@ -16,12 +16,17 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "ttime.h"
#include "ttime.h"
#include "tutil.h"
#define SDB_DNODE_VER 1
#define TSDB_DNODE_VER 1
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN 48
#define TSDB_CONFIG_NUMBER 8
static
char
*
offlineReason
[]
=
{
static
c
onst
c
har
*
offlineReason
[]
=
{
""
,
""
,
"status msg timeout"
,
"status msg timeout"
,
"status not received"
,
"status not received"
,
...
@@ -36,16 +41,27 @@ static char *offlineReason[] = {
...
@@ -36,16 +41,27 @@ static char *offlineReason[] = {
"unknown"
,
"unknown"
,
};
};
static
const
char
*
dnodeStatus
[]
=
{
"offline"
,
"ready"
,
"creating"
,
"dropping"
};
static
int32_t
mndCreateDefaultDnode
(
SMnode
*
pMnode
);
static
int32_t
mndCreateDefaultDnode
(
SMnode
*
pMnode
);
static
SSdbRaw
*
mndDnodeActionEncode
(
SDnodeObj
*
pDnode
);
static
SSdbRaw
*
mndDnodeActionEncode
(
SDnodeObj
*
pDnode
);
static
SSdbRow
*
mndDnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
SSdbRow
*
mndDnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndDnodeActionInsert
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionInsert
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionDelete
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionDelete
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOldDnode
,
SDnodeObj
*
pNewDnode
);
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOldDnode
,
SDnodeObj
*
pNewDnode
);
static
int32_t
mndProcessCreateDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConfigDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessStatusMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConfigDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessStatusMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextDnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitDnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitDnode
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_DNODE
,
SSdbTable
table
=
{.
sdbType
=
SDB_DNODE
,
...
@@ -60,8 +76,16 @@ int32_t mndInitDnode(SMnode *pMnode) {
...
@@ -60,8 +76,16 @@ int32_t mndInitDnode(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_DNODE
,
mndProcessCreateDnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CREATE_DNODE
,
mndProcessCreateDnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_DNODE
,
mndProcessDropDnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_DROP_DNODE
,
mndProcessDropDnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CONFIG_DNODE
,
mndProcessConfigDnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CONFIG_DNODE
,
mndProcessConfigDnodeMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_CONFIG_DNODE_IN_RSP
,
mndProcessConfigDnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_STATUS
,
mndProcessStatusMsg
);
mndSetMsgHandle
(
pMnode
,
TSDB_MSG_TYPE_STATUS
,
mndProcessStatusMsg
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndGetConfigMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndRetrieveConfigs
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndCancelGetNextConfig
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_DNODE
,
mndGetDnodeMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_DNODE
,
mndRetrieveDnodes
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_DNODE
,
mndCancelGetNextDnode
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
}
...
@@ -84,7 +108,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
...
@@ -84,7 +108,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
}
}
static
SSdbRaw
*
mndDnodeActionEncode
(
SDnodeObj
*
pDnode
)
{
static
SSdbRaw
*
mndDnodeActionEncode
(
SDnodeObj
*
pDnode
)
{
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_DNODE
,
SDB_DNODE_VER
,
sizeof
(
SDnodeObj
));
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_DNODE
,
T
SDB_DNODE_VER
,
sizeof
(
SDnodeObj
));
if
(
pRaw
==
NULL
)
return
NULL
;
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
...
@@ -102,7 +126,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
...
@@ -102,7 +126,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
SDB_DNODE_VER
)
{
if
(
sver
!=
T
SDB_DNODE_VER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
mError
(
"failed to decode dnode since %s"
,
terrstr
());
mError
(
"failed to decode dnode since %s"
,
terrstr
());
return
NULL
;
return
NULL
;
...
@@ -168,6 +192,12 @@ void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode) {
...
@@ -168,6 +192,12 @@ void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode) {
sdbRelease
(
pSdb
,
pDnode
);
sdbRelease
(
pSdb
,
pDnode
);
}
}
SEpSet
mndGetDnodeEpset
(
SDnodeObj
*
pDnode
)
{
SEpSet
epSet
=
{.
inUse
=
0
,
.
numOfEps
=
1
,
.
port
[
0
]
=
pDnode
->
port
};
memcpy
(
epSet
.
fqdn
[
0
],
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
return
epSet
;
}
static
SDnodeObj
*
mndAcquireDnodeByEp
(
SMnode
*
pMnode
,
char
*
pEpStr
)
{
static
SDnodeObj
*
mndAcquireDnodeByEp
(
SMnode
*
pMnode
,
char
*
pEpStr
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
@@ -358,8 +388,384 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
...
@@ -358,8 +388,384 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
return
0
;
return
0
;
}
}
static
int32_t
mndProcessCreateDnodeMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndCreateDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCreateDnodeMsg
*
pCreate
)
{
SDnodeObj
dnodeObj
=
{
0
};
dnodeObj
.
id
=
1
;
// todo
dnodeObj
.
createdTime
=
taosGetTimestampMs
();
dnodeObj
.
updateTime
=
dnodeObj
.
createdTime
;
taosGetFqdnPortFromEp
(
pCreate
->
ep
,
dnodeObj
.
fqdn
,
&
dnodeObj
.
port
);
if
(
dnodeObj
.
fqdn
[
0
]
==
0
||
dnodeObj
.
port
<=
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"dnode:%s, failed to create since %s"
,
pCreate
->
ep
,
terrstr
());
return
terrno
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%s, failed to create since %s"
,
pCreate
->
ep
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create dnode:%s"
,
pTrans
->
id
,
pCreate
->
ep
);
SSdbRaw
*
pRedoRaw
=
mndDnodeActionEncode
(
&
dnodeObj
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
);
static
int32_t
mndProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
SSdbRaw
*
pUndoRaw
=
mndDnodeActionEncode
(
&
dnodeObj
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
SSdbRaw
*
pCommitRaw
=
mndDnodeActionEncode
(
&
dnodeObj
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndProcessCreateDnodeMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SCreateDnodeMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"dnode:%s, start to create"
,
pCreate
->
ep
);
if
(
pCreate
->
ep
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"dnode:%s, failed to create since %s"
,
pCreate
->
ep
,
terrstr
());
return
-
1
;
}
SDnodeObj
*
pDnode
=
mndAcquireDnodeByEp
(
pMnode
,
pCreate
->
ep
);
if
(
pDnode
!=
NULL
)
{
mError
(
"dnode:%d, already exist"
,
pDnode
->
id
);
sdbRelease
(
pMnode
->
pSdb
,
pDnode
);
terrno
=
TSDB_CODE_MND_DNODE_ALREADY_EXIST
;
return
-
1
;
}
static
int32_t
mndProcessConfigDnodeMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
int32_t
code
=
mndCreateDnode
(
pMnode
,
pMsg
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"dnode:%s, failed to create since %s"
,
pCreate
->
ep
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%d, failed to drop since %s"
,
pDnode
->
id
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop user:%d"
,
pTrans
->
id
,
pDnode
->
id
);
SSdbRaw
*
pRedoRaw
=
mndDnodeActionEncode
(
pDnode
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
);
SSdbRaw
*
pUndoRaw
=
mndDnodeActionEncode
(
pDnode
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pCommitRaw
=
mndDnodeActionEncode
(
pDnode
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
if
(
mndTransPrepare
(
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
}
static
int32_t
mndProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SDropDnodeMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"dnode:%d, start to drop"
,
pDrop
->
dnodeId
);
if
(
pDrop
->
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"dnode:%d, failed to create since %s"
,
pDrop
->
dnodeId
,
terrstr
());
return
-
1
;
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pDrop
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"dnode:%d, not exist"
,
pDrop
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
}
int32_t
code
=
mndDropDnode
(
pMnode
,
pMsg
,
pDnode
);
if
(
code
!=
0
)
{
mError
(
"dnode:%d, failed to create since %s"
,
pDrop
->
dnodeId
,
terrstr
());
return
-
1
;
}
sdbRelease
(
pMnode
->
pSdb
,
pDnode
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessConfigDnodeMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SCfgDnodeMsg
*
pCfg
=
pMsg
->
rpcMsg
.
pCont
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCfg
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
mError
(
"dnode:%d, failed to cfg since %s "
,
pCfg
->
dnodeId
,
terrstr
());
return
-
1
;
}
SEpSet
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
SCfgDnodeMsg
*
pCfgDnode
=
rpcMallocCont
(
sizeof
(
SCfgDnodeMsg
));
pCfgDnode
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
memcpy
(
pCfgDnode
->
config
,
pCfg
->
config
,
128
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TSDB_MSG_TYPE_CONFIG_DNODE_IN
,
.
pCont
=
pCfgDnode
,
.
contLen
=
sizeof
(
SCfgDnodeMsg
)};
mInfo
(
"dnode:%d, is configured"
,
pCfg
->
dnodeId
);
mndSendMsgToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
return
0
;
}
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
pMsg
)
{
mInfo
(
"cfg dnode rsp is received"
);
}
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
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
));
pSchema
[
cols
].
bytes
=
htons
(
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
));
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
TSDB_CONFIG_NUMBER
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
pIter
=
NULL
;
strcpy
(
pMeta
->
tableFname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
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
[
numOfRows
]
=
"statusInterval"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%d"
,
pMnode
->
cfg
.
statusInterval
);
numOfRows
++
;
cfgOpts
[
numOfRows
]
=
"timezone"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
pMnode
->
cfg
.
timezone
);
numOfRows
++
;
cfgOpts
[
numOfRows
]
=
"locale"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
pMnode
->
cfg
.
locale
);
numOfRows
++
;
cfgOpts
[
numOfRows
]
=
"charset"
;
snprintf
(
cfgVals
[
numOfRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
pMnode
->
cfg
.
charset
);
numOfRows
++
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
i
++
)
{
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
cfgOpts
[
i
],
TSDB_CONFIG_OPTION_LEN
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
cfgVals
[
i
],
TSDB_CONIIG_VALUE_LEN
);
cols
++
;
}
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
)
{}
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"id"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"end point"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"vnodes"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
strcpy
(
pSchema
[
cols
].
name
,
"cores"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
10
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"status"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
24
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"offline reason"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tableFname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SDnodeObj
*
pDnode
=
NULL
;
char
*
pWrite
;
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pShow
->
pIter
,
(
void
**
)
&
pDnode
);
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pDnode
->
id
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pDnode
->
numOfVnodes
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pDnode
->
numOfCores
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
const
char
*
status
=
dnodeStatus
[
pDnode
->
status
];
STR_TO_VARSTR
(
pWrite
,
status
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pDnode
->
createdTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
offlineReason
[
pDnode
->
offlineReason
]);
cols
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pDnode
);
}
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
static
void
mndCancelGetNextDnode
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
23da7d42
...
@@ -20,7 +20,6 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg);
...
@@ -20,7 +20,6 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int32_t
showId
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int32_t
showId
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
char
*
mndShowStr
(
int32_t
showType
);
static
int32_t
mndProcessShowMsg
(
SMnodeMsg
*
pMnodeMsg
);
static
int32_t
mndProcessShowMsg
(
SMnodeMsg
*
pMnodeMsg
);
static
int32_t
mndProcessRetrieveMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessRetrieveMsg
(
SMnodeMsg
*
pMsg
);
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
);
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
);
...
@@ -88,10 +87,6 @@ static void mndFreeShowObj(SShowObj *pShow) {
...
@@ -88,10 +87,6 @@ static void mndFreeShowObj(SShowObj *pShow) {
ShowFreeIterFp
freeFp
=
pMgmt
->
freeIterFps
[
pShow
->
type
];
ShowFreeIterFp
freeFp
=
pMgmt
->
freeIterFps
[
pShow
->
type
];
if
(
freeFp
!=
NULL
)
{
if
(
freeFp
!=
NULL
)
{
if
(
pShow
->
pVgIter
!=
NULL
)
{
// only used in 'show vnodes "ep"'
(
*
freeFp
)(
pMnode
,
pShow
->
pVgIter
);
}
if
(
pShow
->
pIter
!=
NULL
)
{
if
(
pShow
->
pIter
!=
NULL
)
{
(
*
freeFp
)(
pMnode
,
pShow
->
pIter
);
(
*
freeFp
)(
pMnode
,
pShow
->
pIter
);
}
}
...
@@ -259,7 +254,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -259,7 +254,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
char
*
mndShowStr
(
int32_t
showType
)
{
char
*
mndShowStr
(
int32_t
showType
)
{
switch
(
showType
)
{
switch
(
showType
)
{
case
TSDB_MGMT_TABLE_ACCT
:
case
TSDB_MGMT_TABLE_ACCT
:
return
"show accounts"
;
return
"show accounts"
;
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
23da7d42
...
@@ -277,7 +277,7 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOldUser, SUserObj *pNewU
...
@@ -277,7 +277,7 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOldUser, SUserObj *pNewU
return
0
;
return
0
;
}
}
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
S
UserObj
*
pUser
,
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
S
MnodeMsg
*
pMsg
,
SUserObj
*
pUser
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
mError
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
...
@@ -437,7 +437,7 @@ static int32_t mndProcessDropUserMsg(SMnodeMsg *pMsg) {
...
@@ -437,7 +437,7 @@ static int32_t mndProcessDropUserMsg(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropUser
(
pMnode
,
p
User
,
pMsg
);
int32_t
code
=
mndDropUser
(
pMnode
,
p
Msg
,
pUser
);
sdbRelease
(
pMnode
->
pSdb
,
pOperUser
);
sdbRelease
(
pMnode
->
pSdb
,
pOperUser
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -489,7 +489,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
...
@@ -489,7 +489,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_USER
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_USER
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tableFname
,
"show users"
);
strcpy
(
pMeta
->
tableFname
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
23da7d42
...
@@ -14,8 +14,114 @@
...
@@ -14,8 +14,114 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "mndVgroup.h"
#include "mndInt.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "ttime.h"
int32_t
mndInitVgroup
(
SMnode
*
pMnode
)
{
return
0
;
}
static
char
*
syncRole
[]
=
{
"unsynced"
,
"slave"
,
"master"
};
void
mndCleanupVgroup
(
SMnode
*
pMnode
)
{}
\ No newline at end of file
static
int32_t
mndGetVnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveVnodes
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextVnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitVgroup
(
SMnode
*
pMnode
)
{
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_VNODES
,
mndGetVnodeMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VNODES
,
mndRetrieveVnodes
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_VNODES
,
mndCancelGetNextVnode
);
return
0
;
}
void
mndCleanupVgroup
(
SMnode
*
pMnode
)
{}
int32_t
mndGetVnodesNum
(
SMnode
*
pMnode
,
int32_t
dnodeId
)
{
if
(
dnodeId
==
0
)
{
return
0
;
}
return
0
;
}
static
int32_t
mndGetVnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"vgId"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
12
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"status"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int32_t
i
=
1
;
i
<
cols
;
++
i
)
{
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
int32_t
dnodeId
=
0
;
if
(
pShow
->
payloadLen
>
0
)
{
dnodeId
=
atoi
(
pShow
->
payload
);
}
pShow
->
replica
=
dnodeId
;
pShow
->
numOfRows
=
mndGetVnodesNum
(
pMnode
,
dnodeId
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tableFname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
static
int32_t
mndRetrieveVnodes
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SVgObj
*
pVgroup
=
NULL
;
char
*
pWrite
;
int32_t
cols
=
0
;
int32_t
dnodeId
=
pShow
->
replica
;
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pShow
->
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pShow
->
pIter
==
NULL
)
break
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
&&
numOfRows
<
rows
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
if
(
pVgid
->
dnodeId
!=
dnodeId
)
continue
;
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVgroup
->
vgId
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
syncRole
[
pVgid
->
role
]);
cols
++
;
numOfRows
++
;
}
sdbRelease
(
pSdb
,
pVgroup
);
}
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
static
void
mndCancelGetNextVnode
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
\ No newline at end of file
source/util/src/tutil.c
浏览文件 @
23da7d42
...
@@ -187,7 +187,7 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote) {
...
@@ -187,7 +187,7 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote) {
}
}
char
*
strtolower
(
char
*
dst
,
const
char
*
src
)
{
char
*
strtolower
(
char
*
dst
,
const
char
*
src
)
{
int
esc
=
0
;
int
32_t
esc
=
0
;
char
quote
=
0
,
*
p
=
dst
,
c
;
char
quote
=
0
,
*
p
=
dst
,
c
;
assert
(
dst
!=
NULL
);
assert
(
dst
!=
NULL
);
...
@@ -214,7 +214,7 @@ char* strtolower(char *dst, const char *src) {
...
@@ -214,7 +214,7 @@ char* strtolower(char *dst, const char *src) {
}
}
char
*
strntolower
(
char
*
dst
,
const
char
*
src
,
int32_t
n
)
{
char
*
strntolower
(
char
*
dst
,
const
char
*
src
,
int32_t
n
)
{
int
esc
=
0
;
int
32_t
esc
=
0
;
char
quote
=
0
,
*
p
=
dst
,
c
;
char
quote
=
0
,
*
p
=
dst
,
c
;
assert
(
dst
!=
NULL
);
assert
(
dst
!=
NULL
);
...
@@ -347,7 +347,7 @@ char *strbetween(char *string, char *begin, char *end) {
...
@@ -347,7 +347,7 @@ char *strbetween(char *string, char *begin, char *end) {
char
*
_begin
=
strstr
(
string
,
begin
);
char
*
_begin
=
strstr
(
string
,
begin
);
if
(
_begin
!=
NULL
)
{
if
(
_begin
!=
NULL
)
{
char
*
_end
=
strstr
(
_begin
+
strlen
(
begin
),
end
);
char
*
_end
=
strstr
(
_begin
+
strlen
(
begin
),
end
);
int
size
=
(
in
t
)(
_end
-
_begin
);
int
32_t
size
=
(
int32_
t
)(
_end
-
_begin
);
if
(
_end
!=
NULL
&&
size
>
0
)
{
if
(
_end
!=
NULL
&&
size
>
0
)
{
result
=
(
char
*
)
calloc
(
1
,
size
);
result
=
(
char
*
)
calloc
(
1
,
size
);
memcpy
(
result
,
_begin
+
strlen
(
begin
),
size
-
+
strlen
(
begin
));
memcpy
(
result
,
_begin
+
strlen
(
begin
),
size
-
+
strlen
(
begin
));
...
@@ -402,7 +402,7 @@ int32_t taosHexStrToByteArray(char hexstr[], char bytes[]) {
...
@@ -402,7 +402,7 @@ int32_t taosHexStrToByteArray(char hexstr[], char bytes[]) {
char
*
taosIpStr
(
uint32_t
ipInt
)
{
char
*
taosIpStr
(
uint32_t
ipInt
)
{
static
char
ipStrArray
[
3
][
30
];
static
char
ipStrArray
[
3
][
30
];
static
int
ipStrIndex
=
0
;
static
int
32_t
ipStrIndex
=
0
;
char
*
ipStr
=
ipStrArray
[(
ipStrIndex
++
)
%
3
];
char
*
ipStr
=
ipStrArray
[(
ipStrIndex
++
)
%
3
];
//sprintf(ipStr, "0x%x:%u.%u.%u.%u", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
//sprintf(ipStr, "0x%x:%u.%u.%u.%u", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
...
@@ -416,4 +416,17 @@ void taosIp2String(uint32_t ip, char *str) {
...
@@ -416,4 +416,17 @@ void taosIp2String(uint32_t ip, char *str) {
void
taosIpPort2String
(
uint32_t
ip
,
uint16_t
port
,
char
*
str
)
{
void
taosIpPort2String
(
uint32_t
ip
,
uint16_t
port
,
char
*
str
)
{
sprintf
(
str
,
"%u.%u.%u.%u:%u"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
(
uint8_t
)(
ip
>>
24
),
port
);
sprintf
(
str
,
"%u.%u.%u.%u:%u"
,
ip
&
0xFF
,
(
ip
>>
8
)
&
0xFF
,
(
ip
>>
16
)
&
0xFF
,
(
uint8_t
)(
ip
>>
24
),
port
);
}
int32_t
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
)
{
*
port
=
0
;
strcpy
(
fqdn
,
ep
);
char
*
temp
=
strchr
(
fqdn
,
':'
);
if
(
temp
)
{
*
temp
=
0
;
*
port
=
atoi
(
temp
+
1
);
}
return
0
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录