Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dgr6878
TDengine
提交
f6265074
T
TDengine
项目概览
dgr6878
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f6265074
编写于
2月 20, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reorganize the file mgmtAcct.c and mgmtUser.c
上级
dfafa1be
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
146 addition
and
196 deletion
+146
-196
src/inc/mnode.h
src/inc/mnode.h
+0
-1
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+0
-12
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+6
-6
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+54
-81
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+16
-16
src/mnode/src/mgmtSystem.c
src/mnode/src/mgmtSystem.c
+0
-1
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+68
-77
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+2
-2
未找到文件。
src/inc/mnode.h
浏览文件 @
f6265074
...
...
@@ -51,7 +51,6 @@ extern int tsAcctUpdateSize;
extern
int
tsDbUpdateSize
;
extern
int
tsDnodeUpdateSize
;
extern
int
tsMnodeUpdateSize
;
extern
int
tsUserUpdateSize
;
extern
int
tsVgUpdateSize
;
typedef
struct
{
...
...
src/mnode/inc/mgmtAcct.h
浏览文件 @
f6265074
...
...
@@ -22,21 +22,13 @@ extern "C" {
#include "mnode.h"
int32_t
mgmtCreateAcct
(
char
*
name
,
char
*
pass
,
SAcctCfg
*
pCfg
);
int32_t
mgmtUpdateAcct
(
SAcctObj
*
pAcct
);
int32_t
mgmtDropAcct
(
char
*
name
);
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
mgmtAddConnIntoAcct
(
SConnObj
*
pConn
);
int32_t
mgmtRemoveConnFromAcct
(
SConnObj
*
pConn
);
int32_t
mgmtAlterAcct
(
char
*
name
,
char
*
pass
,
SAcctCfg
*
pCfg
);
int64_t
mgmtGetAcctStatistic
(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtInitAccts
)();
extern
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
);
extern
void
(
*
mgmtCreateRootAcct
)();
extern
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
);
...
...
@@ -45,10 +37,6 @@ extern void (*mgmtCleanUpAccts)();
extern
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
void
mgmtAddMeterStatisticToAcct
(
SAcctObj
*
pAcct
,
int
numOfColumns
);
#ifdef __cplusplus
}
#endif
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
f6265074
...
...
@@ -24,13 +24,13 @@ extern "C" {
#include <stdbool.h>
#include "mnode.h"
int
mgmtInitUsers
();
int
32_t
mgmtInitUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
int
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
int
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
int
mgmtUpdateUser
(
SUserObj
*
pUser
);
int
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
);
int
32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
int
32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
int
32_t
mgmtUpdateUser
(
SUserObj
*
pUser
);
int
32_t
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
);
void
mgmtCleanUpUsers
();
#ifdef __cplusplus
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
f6265074
...
...
@@ -15,26 +15,25 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tschemautil.h"
#include "taoserror.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
#include "tschemautil.h"
#include "taoserror.h"
extern
void
*
u
serSdb
;
extern
void
*
d
bSdb
;
extern
void
*
tsU
serSdb
;
extern
void
*
tsD
bSdb
;
SAcctObj
acctObj
;
int
mgmtGetAcctsNum
();
SShowObj
*
mgmtGetNextAcct
(
SShowObj
*
pShow
,
SAcctObj
**
pAcct
);
int
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pDb
->
next
=
pAcct
->
pHead
;
pDb
->
prev
=
NULL
;
if
(
pAcct
->
pHead
)
pAcct
->
pHead
->
prev
=
pDb
;
if
(
pAcct
->
pHead
)
{
pAcct
->
pHead
->
prev
=
pDb
;
}
pAcct
->
pHead
=
pDb
;
pAcct
->
acctInfo
.
numOfDbs
++
;
...
...
@@ -43,13 +42,19 @@ int mgmtAddDbIntoAcct(SAcctObj *pAcct, SDbObj *pDb) {
return
0
;
}
int
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
int
32_t
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pDb
->
prev
)
pDb
->
prev
->
next
=
pDb
->
next
;
if
(
pDb
->
prev
)
{
pDb
->
prev
->
next
=
pDb
->
next
;
}
if
(
pDb
->
next
)
pDb
->
next
->
prev
=
pDb
->
prev
;
if
(
pDb
->
next
)
{
pDb
->
next
->
prev
=
pDb
->
prev
;
}
if
(
pDb
->
prev
==
NULL
)
pAcct
->
pHead
=
pDb
->
next
;
if
(
pDb
->
prev
==
NULL
)
{
pAcct
->
pHead
=
pDb
->
next
;
}
pAcct
->
acctInfo
.
numOfDbs
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
...
...
@@ -57,12 +62,14 @@ int mgmtRemoveDbFromAcct(SAcctObj *pAcct, SDbObj *pDb) {
return
0
;
}
int
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
int
32_t
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pUser
->
next
=
pAcct
->
pUser
;
pUser
->
prev
=
NULL
;
if
(
pAcct
->
pUser
)
pAcct
->
pUser
->
prev
=
pUser
;
if
(
pAcct
->
pUser
)
{
pAcct
->
pUser
->
prev
=
pUser
;
}
pAcct
->
pUser
=
pUser
;
pAcct
->
acctInfo
.
numOfUsers
++
;
...
...
@@ -71,13 +78,17 @@ int mgmtAddUserIntoAcct(SAcctObj *pAcct, SUserObj *pUser) {
return
0
;
}
int
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
int
32_t
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pUser
->
prev
)
pUser
->
prev
->
next
=
pUser
->
next
;
if
(
pUser
->
prev
)
{
pUser
->
prev
->
next
=
pUser
->
next
;
}
if
(
pUser
->
next
)
pUser
->
next
->
prev
=
pUser
->
prev
;
if
(
pUser
->
prev
==
NULL
)
pAcct
->
pUser
=
pUser
->
next
;
if
(
pUser
->
prev
==
NULL
)
{
pAcct
->
pUser
=
pUser
->
next
;
}
pAcct
->
acctInfo
.
numOfUsers
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
...
...
@@ -85,85 +96,44 @@ int mgmtRemoveUserFromAcct(SAcctObj *pAcct, SUserObj *pUser) {
return
0
;
}
int
mgmtAddConnIntoAcct
(
SConnObj
*
pConn
)
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
if
(
pAcct
==
NULL
)
return
0
;
pthread_mutex_lock
(
&
pAcct
->
mutex
);
assert
(
pConn
!=
pAcct
->
pConn
);
pConn
->
next
=
pAcct
->
pConn
;
pConn
->
prev
=
NULL
;
if
(
pAcct
->
pConn
)
pAcct
->
pConn
->
prev
=
pConn
;
pAcct
->
pConn
=
pConn
;
pAcct
->
acctInfo
.
numOfConns
++
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
}
int
mgmtRemoveConnFromAcct
(
SConnObj
*
pConn
)
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
if
(
pAcct
==
NULL
)
return
0
;
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pConn
->
prev
)
pConn
->
prev
->
next
=
pConn
->
next
;
if
(
pConn
->
next
)
pConn
->
next
->
prev
=
pConn
->
prev
;
if
(
pConn
->
prev
==
NULL
)
pAcct
->
pConn
=
pConn
->
next
;
pAcct
->
acctInfo
.
numOfConns
--
;
// pAcct->numOfUsers--;
if
(
pConn
->
pQList
)
{
pAcct
->
acctInfo
.
numOfQueries
-=
pConn
->
pQList
->
numOfQueries
;
pAcct
->
acctInfo
.
numOfStreams
-=
pConn
->
pSList
->
numOfStreams
;
}
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pConn
->
next
=
NULL
;
pConn
->
prev
=
NULL
;
int32_t
mgmtInitAcctsImp
()
{
return
0
;
}
int32_t
mgmtInitAcctsImp
()
{
return
0
;
}
int32_t
(
*
mgmtInitAccts
)()
=
mgmtInitAcctsImp
;
void
mgmtCreateRootAcctImp
()
{}
void
(
*
mgmtCreateRootAcct
)()
=
mgmtCreateRootAcctImp
;
SAcctObj
*
mgmtGetAcctImp
(
char
*
acctName
)
{
return
&
acctObj
;
}
SAcctObj
*
mgmtGetAcctImp
(
char
*
acctName
)
{
return
&
acctObj
;
}
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
)
=
mgmtGetAcctImp
;
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
)
=
mgmtGetAcctImp
;
int32_t
mgmtCheckUserLimitImp
(
SAcctObj
*
pAcct
)
{
int
numOfUsers
=
sdbGetNumOfRows
(
u
serSdb
);
int
32_t
numOfUsers
=
sdbGetNumOfRows
(
tsU
serSdb
);
if
(
numOfUsers
>=
tsMaxUsers
)
{
mWarn
(
"numOfUsers:%d, exceed tsMaxUsers:%d"
,
numOfUsers
,
tsMaxUsers
);
return
TSDB_CODE_TOO_MANY_USERS
;
}
return
0
;
}
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckUserLimitImp
;
int32_t
mgmtCheckDbLimitImp
(
SAcctObj
*
pAcct
)
{
int
numOfDbs
=
sdbGetNumOfRows
(
d
bSdb
);
int
32_t
numOfDbs
=
sdbGetNumOfRows
(
tsD
bSdb
);
if
(
numOfDbs
>=
tsMaxDbs
)
{
mWarn
(
"numOfDbs:%d, exceed tsMaxDbs:%d"
,
numOfDbs
,
tsMaxDbs
);
return
TSDB_CODE_TOO_MANY_DATABASES
;
}
return
0
;
}
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckDbLimitImp
;
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
void
mgmtCheckAcctImp
()
{
...
...
@@ -175,19 +145,22 @@ void mgmtCheckAcctImp() {
mgmtCreateUser
(
pAcct
,
"monitor"
,
tsInternalPass
);
mgmtCreateUser
(
pAcct
,
"_root"
,
tsInternalPass
);
}
void
(
*
mgmtCheckAcct
)()
=
mgmtCheckAcctImp
;
void
mgmtCleanUpAcctsImp
()
{}
void
(
*
mgmtCleanUpAccts
)()
=
mgmtCleanUpAcctsImp
;
void
(
*
mgmtCheckAcct
)()
=
mgmtCheckAcctImp
;
int32_t
mgmtGetAcctMetaImp
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
mgmtGetAcctMetaImp
;
void
mgmtCleanUpAcctsImp
()
{
}
int32_t
mgmtRetrieveAcctsImp
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
=
mgmtRetrieveAcctsImp
;
void
(
*
mgmtCleanUpAccts
)()
=
mgmtCleanUpAcctsImp
;
int32_t
mgmtGetAcctMetaImp
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
mgmtGetAcctMetaImp
;
void
mgmtAddMeterStatisticToAcct
(
SAcctObj
*
pAcct
,
int
numOfColumns
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
numOfColumns
-
1
)
;
int32_t
mgmtRetrieveAcctsImp
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
)
=
mgmtRetrieveAcctsImp
;
src/mnode/src/mgmtDb.c
浏览文件 @
f6265074
...
...
@@ -29,7 +29,7 @@
#include "mnode.h"
#include "taoserror.h"
void
*
d
bSdb
=
NULL
;
void
*
tsD
bSdb
=
NULL
;
extern
void
*
vgSdb
;
int
tsDbUpdateSize
;
...
...
@@ -83,14 +83,14 @@ int32_t mgmtInitDbs() {
mgmtDbActionInit
();
d
bSdb
=
sdbOpenTable
(
tsMaxDbs
,
sizeof
(
SDbObj
),
"db"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtDbAction
);
if
(
d
bSdb
==
NULL
)
{
tsD
bSdb
=
sdbOpenTable
(
tsMaxDbs
,
sizeof
(
SDbObj
),
"db"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtDbAction
);
if
(
tsD
bSdb
==
NULL
)
{
mError
(
"failed to init db data"
);
return
-
1
;
}
while
(
1
)
{
pNode
=
sdbFetchRow
(
d
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
pNode
=
sdbFetchRow
(
tsD
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
if
(
pDb
==
NULL
)
break
;
pDb
->
pHead
=
NULL
;
...
...
@@ -118,7 +118,7 @@ int32_t mgmtInitDbs() {
return
0
;
}
SDbObj
*
mgmtGetDb
(
char
*
db
)
{
return
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
db
);
}
SDbObj
*
mgmtGetDb
(
char
*
db
)
{
return
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
db
);
}
SDbObj
*
mgmtGetDbByMeterId
(
char
*
meterId
)
{
char
db
[
TSDB_TABLE_ID_LEN
],
*
pos
;
...
...
@@ -128,7 +128,7 @@ SDbObj *mgmtGetDbByMeterId(char *meterId) {
memset
(
db
,
0
,
sizeof
(
db
));
strncpy
(
db
,
meterId
,
pos
-
meterId
);
return
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
db
);
return
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
db
);
}
int
mgmtCheckDbParams
(
SCreateDbMsg
*
pCreate
)
{
...
...
@@ -185,7 +185,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
return
code
;
}
pDb
=
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
pCreate
->
db
);
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
return
TSDB_CODE_DB_ALREADY_EXIST
;
}
...
...
@@ -207,7 +207,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
cfg
=
*
pCreate
;
if
(
sdbInsertRow
(
d
bSdb
,
pDb
,
0
)
<
0
)
{
if
(
sdbInsertRow
(
tsD
bSdb
,
pDb
,
0
)
<
0
)
{
code
=
TSDB_CODE_SDB_ERROR
;
tfree
(
pDb
);
}
...
...
@@ -215,7 +215,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
return
code
;
}
int
mgmtUpdateDb
(
SDbObj
*
pDb
)
{
return
sdbUpdateRow
(
d
bSdb
,
pDb
,
tsDbUpdateSize
,
1
);
}
int
mgmtUpdateDb
(
SDbObj
*
pDb
)
{
return
sdbUpdateRow
(
tsD
bSdb
,
pDb
,
tsDbUpdateSize
,
1
);
}
int
mgmtSetDbDropping
(
SDbObj
*
pDb
)
{
if
(
pDb
->
dropStatus
==
TSDB_DB_STATUS_DROP_FROM_SDB
)
return
0
;
...
...
@@ -288,7 +288,7 @@ void mgmtDropDbFromSdb(SDbObj *pDb) {
}
mPrint
(
"db:%s all meters drop finished"
,
pDb
->
name
);
sdbDeleteRow
(
d
bSdb
,
pDb
);
sdbDeleteRow
(
tsD
bSdb
,
pDb
);
mPrint
(
"db:%s database drop finished"
,
pDb
->
name
);
}
...
...
@@ -317,7 +317,7 @@ int mgmtDropDb(SDbObj *pDb) {
int
mgmtDropDbByName
(
SAcctObj
*
pAcct
,
char
*
name
,
short
ignoreNotExists
)
{
SDbObj
*
pDb
;
pDb
=
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
name
);
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
name
);
if
(
pDb
==
NULL
)
{
if
(
ignoreNotExists
)
return
TSDB_CODE_SUCCESS
;
mWarn
(
"db:%s is not there"
,
name
);
...
...
@@ -336,7 +336,7 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) {
SDbObj
*
pDb
=
NULL
;
while
(
1
)
{
pNode
=
sdbFetchRow
(
d
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
pNode
=
sdbFetchRow
(
tsD
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
if
(
pDb
==
NULL
)
break
;
if
(
pDb
->
dropStatus
!=
TSDB_DB_STATUS_DROPPING
)
continue
;
mgmtDropDb
(
pDb
);
...
...
@@ -348,7 +348,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
SDbObj
*
pDb
;
int
code
=
TSDB_CODE_SUCCESS
;
pDb
=
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
pAlter
->
db
);
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
pAlter
->
db
);
if
(
pDb
==
NULL
)
{
mTrace
(
"db:%s is not exist"
,
pAlter
->
db
);
return
TSDB_CODE_INVALID_DB
;
...
...
@@ -385,7 +385,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
sdbUpdateRow
(
d
bSdb
,
pDb
,
tsDbUpdateSize
,
1
)
<
0
)
{
if
(
sdbUpdateRow
(
tsD
bSdb
,
pDb
,
tsDbUpdateSize
,
1
)
<
0
)
{
return
TSDB_CODE_SDB_ERROR
;
}
...
...
@@ -488,7 +488,7 @@ int mgmtShowTables(SAcctObj *pAcct, char *db) {
return
code
;
}
void
mgmtCleanUpDbs
()
{
sdbCloseTable
(
d
bSdb
);
}
void
mgmtCleanUpDbs
()
{
sdbCloseTable
(
tsD
bSdb
);
}
int
mgmtGetDbMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
...
...
@@ -623,7 +623,7 @@ int mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
// pShow->numOfRows = sdbGetNumOfRows (
d
bSdb);
// pShow->numOfRows = sdbGetNumOfRows (
tsD
bSdb);
pShow
->
numOfRows
=
pConn
->
pAcct
->
acctInfo
.
numOfDbs
;
pShow
->
pNode
=
pConn
->
pAcct
->
pHead
;
...
...
src/mnode/src/mgmtSystem.c
浏览文件 @
f6265074
...
...
@@ -28,7 +28,6 @@
#include "mgmtSystem.h"
#include "mgmtTable.h"
#include "mgmtShell.h"
#include "dnodeModule.h"
char
tsMgmtDirectory
[
128
]
=
{
0
};
void
*
tsMgmtTmr
=
NULL
;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
f6265074
...
...
@@ -15,69 +15,58 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tschemautil.h"
#include "ttime.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtUser.h"
#include "mgmtGrant.h"
#include "mgmtTable.h"
#include "tschemautil.h"
#include "ttime.h"
void
*
userSdb
=
NULL
;
int
tsUserUpdateSize
;
void
*
(
*
mgmtUserActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionBeforeBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionAfterBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
tsUserSdb
=
NULL
;
void
*
(
*
mgmtUserActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
mgmtUserActionInit
()
{
mgmtUserActionFp
[
SDB_TYPE_INSERT
]
=
mgmtUserActionInsert
;
mgmtUserActionFp
[
SDB_TYPE_DELETE
]
=
mgmtUserActionDelete
;
mgmtUserActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtUserActionUpdate
;
mgmtUserActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtUserActionEncode
;
mgmtUserActionFp
[
SDB_TYPE_DECODE
]
=
mgmtUserActionDecode
;
mgmtUserActionFp
[
SDB_TYPE_BEFORE_BATCH_UPDATE
]
=
mgmtUserActionBeforeBatchUpdate
;
mgmtUserActionFp
[
SDB_TYPE_BATCH_UPDATE
]
=
mgmtUserActionBatchUpdate
;
mgmtUserActionFp
[
SDB_TYPE_AFTER_BATCH_UPDATE
]
=
mgmtUserActionAfterBatchUpdate
;
mgmtUserActionFp
[
SDB_TYPE_RESET
]
=
mgmtUserActionReset
;
mgmtUserActionFp
[
SDB_TYPE_INSERT
]
=
mgmtUserActionInsert
;
mgmtUserActionFp
[
SDB_TYPE_DELETE
]
=
mgmtUserActionDelete
;
mgmtUserActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtUserActionUpdate
;
mgmtUserActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtUserActionEncode
;
mgmtUserActionFp
[
SDB_TYPE_DECODE
]
=
mgmtUserActionDecode
;
mgmtUserActionFp
[
SDB_TYPE_RESET
]
=
mgmtUserActionReset
;
mgmtUserActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtUserActionDestroy
;
}
void
*
mgmtUserAction
(
char
action
,
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
if
(
mgmtUserActionFp
[(
uint8_t
)
action
]
!=
NULL
)
{
return
(
*
(
mgmtUserActionFp
[(
uint8_t
)
action
]))(
row
,
str
,
size
,
ssize
);
void
*
mgmtUserAction
(
char
action
,
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
if
(
mgmtUserActionFp
[(
uint8_t
)
action
]
!=
NULL
)
{
return
(
*
(
mgmtUserActionFp
[(
uint8_t
)
action
]))(
row
,
str
,
size
,
ssize
);
}
return
NULL
;
}
int
mgmtInitUsers
()
{
void
*
pNode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SAcctObj
*
pAcct
=
NULL
;
int
numOfUsers
=
0
;
int
32_t
mgmtInitUsers
()
{
void
*
pNode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SAcctObj
*
pAcct
=
NULL
;
int
32_t
numOfUsers
=
0
;
mgmtUserActionInit
();
u
serSdb
=
sdbOpenTable
(
tsMaxUsers
,
sizeof
(
SUserObj
),
"user"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtUserAction
);
if
(
u
serSdb
==
NULL
)
{
tsU
serSdb
=
sdbOpenTable
(
tsMaxUsers
,
sizeof
(
SUserObj
),
"user"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtUserAction
);
if
(
tsU
serSdb
==
NULL
)
{
mError
(
"failed to init user data"
);
return
-
1
;
}
mgmtCreateRootAcct
();
while
(
1
)
{
pNode
=
sdbFetchRow
(
u
serSdb
,
pNode
,
(
void
**
)
&
pUser
);
pNode
=
sdbFetchRow
(
tsU
serSdb
,
pNode
,
(
void
**
)
&
pUser
);
if
(
pUser
==
NULL
)
break
;
pUser
->
prev
=
NULL
;
...
...
@@ -89,27 +78,28 @@ int mgmtInitUsers() {
numOfUsers
++
;
}
SUserObj
tObj
;
tsUserUpdateSize
=
tObj
.
updateEnd
-
(
char
*
)
&
tObj
;
mTrace
(
"user data is initialized"
);
return
0
;
}
SUserObj
*
mgmtGetUser
(
char
*
name
)
{
return
(
SUserObj
*
)
sdbGetRow
(
userSdb
,
name
);
}
SUserObj
*
mgmtGetUser
(
char
*
name
)
{
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
int
mgmtUpdateUser
(
SUserObj
*
pUser
)
{
return
sdbUpdateRow
(
userSdb
,
pUser
,
0
,
1
);
}
int32_t
mgmtUpdateUser
(
SUserObj
*
pUser
)
{
return
sdbUpdateRow
(
tsUserSdb
,
pUser
,
0
,
1
);
}
int
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int
32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
SUserObj
*
pUser
;
int
code
;
int
32_t
code
;
code
=
mgmtCheckUserLimit
(
pAcct
);
if
(
code
!=
0
)
{
return
code
;
}
pUser
=
(
SUserObj
*
)
sdbGetRow
(
u
serSdb
,
name
);
pUser
=
(
SUserObj
*
)
sdbGetRow
(
tsU
serSdb
,
name
);
if
(
pUser
!=
NULL
)
{
mWarn
(
"user:%s is already there"
,
name
);
return
TSDB_CODE_USER_ALREADY_EXIST
;
...
...
@@ -133,37 +123,38 @@ int mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass) {
}
code
=
TSDB_CODE_SUCCESS
;
if
(
sdbInsertRow
(
u
serSdb
,
pUser
,
0
)
<
0
)
{
if
(
sdbInsertRow
(
tsU
serSdb
,
pUser
,
0
)
<
0
)
{
tfree
(
pUser
);
code
=
TSDB_CODE_SDB_ERROR
;
}
// mgmtAddUserIntoAcct(pAcct, pUser);
return
code
;
}
int
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
)
{
int
32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
)
{
SUserObj
*
pUser
;
pUser
=
(
SUserObj
*
)
sdbGetRow
(
u
serSdb
,
name
);
pUser
=
(
SUserObj
*
)
sdbGetRow
(
tsU
serSdb
,
name
);
if
(
pUser
==
NULL
)
{
mWarn
(
"user:%s is not there"
,
name
);
return
TSDB_CODE_INVALID_USER
;
}
if
(
strcmp
(
pAcct
->
user
,
pUser
->
acct
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
if
(
strcmp
(
pAcct
->
user
,
pUser
->
acct
)
!=
0
)
{
return
TSDB_CODE_NO_RIGHTS
;
}
// mgmtRemoveUserFromAcct(pAcct, pUser);
sdbDeleteRow
(
userSdb
,
pUser
);
sdbDeleteRow
(
tsUserSdb
,
pUser
);
return
0
;
}
void
mgmtCleanUpUsers
()
{
sdbCloseTable
(
userSdb
);
}
void
mgmtCleanUpUsers
()
{
sdbCloseTable
(
tsUserSdb
);
}
int
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
32_t
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
...
...
@@ -188,9 +179,8 @@ int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
// pShow->numOfRows = sdbGetNumOfRows (userSdb);
pShow
->
numOfRows
=
pConn
->
pAcct
->
acctInfo
.
numOfUsers
;
pShow
->
pNode
=
pConn
->
pAcct
->
pUser
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
...
...
@@ -198,14 +188,13 @@ int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
)
{
int
numOfRows
=
0
;
int
32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
)
{
int
32_t
numOfRows
=
0
;
SUserObj
*
pUser
=
NULL
;
char
*
pWrite
;
int
cols
=
0
;
int
32_t
cols
=
0
;
while
(
numOfRows
<
rows
)
{
// pShow->pNode = sdbFetchRow(userSdb, pShow->pNode, (void **)&pUser);
pUser
=
(
SUserObj
*
)
pShow
->
pNode
;
if
(
pUser
==
NULL
)
break
;
pShow
->
pNode
=
(
void
*
)
pUser
->
next
;
...
...
@@ -236,26 +225,29 @@ int mgmtRetrieveUsers(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
return
numOfRows
;
}
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
mgmtAddUserIntoAcct
(
pAcct
,
pUser
);
return
NULL
;
}
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
mgmtRemoveUserFromAcct
(
pAcct
,
pUser
);
return
NULL
;
}
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
return
mgmtUserActionReset
(
row
,
str
,
size
,
ssize
);
}
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
int
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int
32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
if
(
size
<
tsize
)
{
*
ssize
=
-
1
;
}
else
{
...
...
@@ -264,27 +256,26 @@ void *mgmtUserActionEncode(void *row, char *str, int size, int *ssize) {
}
return
NULL
;
}
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
malloc
(
sizeof
(
SUserObj
));
if
(
pUser
==
NULL
)
return
NULL
;
memset
(
pUser
,
0
,
sizeof
(
SUserObj
));
int
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int
32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
memcpy
(
pUser
,
str
,
tsize
);
return
(
void
*
)
pUser
;
}
void
*
mgmtUserActionBeforeBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
return
NULL
;
}
void
*
mgmtUserActionBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
return
NULL
;
}
void
*
mgmtUserActionAfterBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
return
NULL
;
}
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
int
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int
32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
memcpy
(
pUser
,
str
,
tsize
);
return
NULL
;
}
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
tfree
(
row
);
return
NULL
;
}
src/mnode/src/mgmtVgroup.c
浏览文件 @
f6265074
...
...
@@ -30,9 +30,9 @@
void
*
vgSdb
=
NULL
;
int
tsVgUpdateSize
;
extern
void
*
d
bSdb
;
extern
void
*
tsD
bSdb
;
extern
void
*
acctSdb
;
extern
void
*
u
serSdb
;
extern
void
*
tsU
serSdb
;
extern
void
*
dnodeSdb
;
void
*
(
*
mgmtVgroupActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录