Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1ddbe3ca
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看板
提交
1ddbe3ca
编写于
11月 29, 2022
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mnode): modify server flow
上级
2d44f233
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
137 deletion
+63
-137
src/inc/taosdef.h
src/inc/taosdef.h
+5
-0
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+58
-137
未找到文件。
src/inc/taosdef.h
浏览文件 @
1ddbe3ca
...
...
@@ -438,6 +438,11 @@ do { \
#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P
//define show cluster status and show db.status
#define SHOW_STATUS_NOT_AVAILABLE 0
#define SHOW_STATUS_AVAILABLE 1
#define SHOW_STATUS_HALF_AVAILABLE 2
typedef
enum
{
TAOS_QTYPE_RPC
=
0
,
TAOS_QTYPE_FWD
=
1
,
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
1ddbe3ca
...
...
@@ -60,7 +60,8 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
static
int32_t
mnodeRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
// status
static
int32_t
mnodeGetStatusMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStatus
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStatusDb
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStatusCluster
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mnodeProcessCreateVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mnodeProcessAlterVnodeRsp
(
SRpcMsg
*
rpcMsg
);
...
...
@@ -241,11 +242,11 @@ int32_t mnodeInitVgroups() {
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeCancelGetNextVgroup
);
// cluster status
mnodeAddShowMetaHandle
(
TSDB_MGMT_STATUS_CLUSTER
,
mnodeGetStatusMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_STATUS_CLUSTER
,
mnodeRetrieveStatus
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_STATUS_CLUSTER
,
mnodeRetrieveStatus
Cluster
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_STATUS_CLUSTER
,
mnodeCancelGetNextVgroup
);
// db status
mnodeAddShowMetaHandle
(
TSDB_MGMT_STATUS_DB
,
mnodeGetStatusMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_STATUS_DB
,
mnodeRetrieveStatus
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_STATUS_DB
,
mnodeRetrieveStatus
Db
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_STATUS_DB
,
mnodeCancelGetNextVgroup
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP
,
mnodeProcessCreateVnodeRsp
);
...
...
@@ -793,164 +794,84 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
}
static
int32_t
mnodeGetStatusMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
{
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
}
if
(
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping"
,
pDb
->
name
,
pDb
->
status
);
mnodeDecDbRef
(
pDb
);
return
TSDB_CODE_MND_DB_IN_DROPPING
;
}
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
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"tables"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
+
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
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"onlines"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
maxReplica
=
1
;
for
(
int32_t
v
=
0
;
v
<
pDb
->
numOfVgroups
;
++
v
)
{
SVgObj
*
pVgroup
=
pDb
->
vgList
[
v
];
if
(
pVgroup
!=
NULL
)
{
pShow
->
maxReplica
=
pVgroup
->
numOfVnodes
>
pShow
->
maxReplica
?
pVgroup
->
numOfVnodes
:
pShow
->
maxReplica
;
}
}
for
(
int32_t
i
=
0
;
i
<
pShow
->
maxReplica
;
++
i
)
{
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d_dnode"
,
i
+
1
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
9
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d_status"
,
i
+
1
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
}
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"compacting"
);
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
];
}
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
0
]
=
sizeof
(
int32_t
);
pSchema
[
0
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
0
].
name
,
"status"
);
pSchema
[
0
].
bytes
=
htons
(
pShow
->
bytes
[
0
]);
pShow
->
numOfRows
=
pDb
->
numOfVgroups
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
mnodeDecDbRef
(
pDb
);
return
0
;
}
static
int32_t
mnodeRetrieveStatus
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
static
int32_t
mnodeRetrieveStatus
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
,
SDbObj
*
pDb
)
{
SVgObj
*
pVgroup
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
if
(
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping"
,
pDb
->
name
,
pDb
->
status
);
mnodeDecDbRef
(
pDb
);
return
0
;
}
int32_t
nAvailble
=
0
;
int32_t
nUnAvailble
=
0
;
// get status
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
mnodeGetNextVgroup
(
pShow
->
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
!=
pDb
)
{
// if pDb is not null
if
(
pDb
&&
pVgroup
->
pDb
!=
pDb
)
{
mnodeDecVgroupRef
(
pVgroup
);
continue
;
}
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pVgroup
->
vgId
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pVgroup
->
numOfTables
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
status
=
vgroupStatus
[
pVgroup
->
status
];
STR_TO_VARSTR
(
pWrite
,
status
);
cols
++
;
// status
if
(
pVgroup
->
status
!=
TAOS_VG_STATUS_READY
)
{
// vgroup is not ready
nUnAvailble
++
;
continue
;
}
int32_t
onlineVnodes
=
0
;
// check master
bool
master
=
false
;
for
(
int32_t
i
=
0
;
i
<
pShow
->
maxReplica
;
++
i
)
{
if
(
pVgroup
->
vnodeGid
[
i
].
role
==
TAOS_SYNC_ROLE_SLAVE
||
pVgroup
->
vnodeGid
[
i
].
role
==
TAOS_SYNC_ROLE_MASTER
)
{
onlineVnodes
++
;
if
(
pVgroup
->
vnodeGid
[
i
].
role
==
TAOS_SYNC_ROLE_MASTER
)
{
master
=
true
;
break
;
}
}
if
(
master
)
nAvailble
++
;
else
nUnAvailble
++
;
}
// set col data
int32_t
status
=
0
;
if
(
nAvailble
+
nUnAvailble
==
0
||
nUnAvailble
==
0
)
{
status
=
SHOW_STATUS_AVAILABLE
;
}
else
if
(
nAvailble
>
0
&&
nUnAvailble
>
0
)
{
status
=
SHOW_STATUS_HALF_AVAILABLE
;
}
else
{
status
=
SHOW_STATUS_NOT_AVAILABLE
;
}
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
onlineVnodes
;
cols
++
;
*
(
int32_t
*
)
data
=
status
;
pShow
->
numOfReads
=
1
;
for
(
int32_t
i
=
0
;
i
<
pShow
->
maxReplica
;
++
i
)
{
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int16_t
*
)
pWrite
=
pVgroup
->
vnodeGid
[
i
].
dnodeId
;
cols
++
;
return
1
;
}
SDnodeObj
*
pDnode
=
pVgroup
->
vnodeGid
[
i
].
pDnode
;
const
char
*
role
=
"NULL"
;
if
(
pDnode
!=
NULL
)
{
role
=
syncRole
[
pVgroup
->
vnodeGid
[
i
].
role
];
}
static
int32_t
mnodeRetrieveStatusCluster
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
return
mnodeRetrieveStatus
(
pShow
,
data
,
rows
,
pConn
,
NULL
);
}
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
role
,
pShow
->
bytes
[
cols
]);
cols
++
;
}
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int8_t
*
)
pWrite
=
pVgroup
->
compact
;
cols
++
;
mnodeDecVgroupRef
(
pVgroup
);
numOfRows
++
;
}
static
int32_t
mnodeRetrieveStatusDb
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
mnodeVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
pShow
->
numOfReads
+=
numOfRows
;
if
(
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping"
,
pDb
->
name
,
pDb
->
status
);
mnodeDecDbRef
(
pDb
);
return
0
;
}
int32_t
numOfRows
=
mnodeRetrieveStatus
(
pShow
,
data
,
rows
,
pConn
,
pDb
);
mnodeDecDbRef
(
pDb
);
return
numOfRows
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录