提交 36086393 编写于 作者: S Shengliang Guan

shm

上级 c8a4d491
......@@ -41,17 +41,17 @@ typedef struct SDnodeMgmt {
SDnode *pDnode;
} SDnodeMgmt;
// dmFile.h
void dmGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet);
// dmHandle.h
void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
// dmInt.h
SMgmtFp dmGetMgmtFp();
int32_t dmGetDnodeId(SDnode *pDnode);
int64_t dmGetClusterId(SDnode *pDnode);
// dmMgmt.h
void dmGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet);
// dmHandle.h
void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
#ifdef __cplusplus
}
#endif
......
......@@ -22,12 +22,10 @@
extern "C" {
#endif
int32_t dmInitMgmt(SDnode *pDnode);
void dmStopMgmt(SDnode *pDnode);
void dmCleanupMgmt(SDnode *pDnode);
int32_t dmInit(SMgmtWrapper *pWrapper);
void dmCleanup(SMgmtWrapper *pWrapper);
bool dmRequire(SMgmtWrapper *pWrapper);
int32_t dmGetDnodeId(SDnode *pDnode);
int64_t dmGetClusterId(SDnode *pDnode);
void dmGetDnodeEp(SDnode *pDnode, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort);
void dmGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet);
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http:www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dmInt.h"
#include "dmHandle.h"
#include "dmMgmt.h"
int32_t dmGetDnodeId(SDnode *pDnode) {
SMgmtWrapper *pWrapper = dndGetWrapper(pDnode, DNODE);
SDnodeMgmt *pMgmt = pWrapper->pMgmt;
taosRLockLatch(&pMgmt->latch);
int32_t dnodeId = pMgmt->dnodeId;
taosRUnLockLatch(&pMgmt->latch);
return dnodeId;
}
int64_t dmGetClusterId(SDnode *pDnode) {
SMgmtWrapper *pWrapper = dndGetWrapper(pDnode, DNODE);
SDnodeMgmt *pMgmt = pWrapper->pMgmt;
taosRLockLatch(&pMgmt->latch);
int64_t clusterId = pMgmt->clusterId;
taosRUnLockLatch(&pMgmt->latch);
return clusterId;
}
SMgmtFp dmGetMgmtFp() {
SMgmtFp mgmtFp = {0};
mgmtFp.openFp = dmInit;
mgmtFp.closeFp = dmCleanup;
mgmtFp.requiredFp = dmRequire;
mgmtFp.getMsgHandleFp = dmGetMsgHandle;
return mgmtFp;
}
......@@ -38,22 +38,6 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp);
static void dndProcessAuthRsp(SDnode *pDnode, SRpcMsg *pRsp);
static void dndProcessGrantRsp(SDnode *pDnode, SRpcMsg *pRsp);
int32_t dmGetDnodeId(SDnode *pDnode) {
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
taosRLockLatch(&pMgmt->latch);
int32_t dnodeId = pMgmt->dnodeId;
taosRUnLockLatch(&pMgmt->latch);
return dnodeId;
}
int64_t dmGetClusterId(SDnode *pDnode) {
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
taosRLockLatch(&pMgmt->latch);
int64_t clusterId = pMgmt->clusterId;
taosRUnLockLatch(&pMgmt->latch);
return clusterId;
}
void dmGetDnodeEp(SDnode *pDnode, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
taosRLockLatch(&pMgmt->latch);
......@@ -289,7 +273,7 @@ void dmGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {}
void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq){}
void dmProcessMgmtMsg(SDnode *pDnode, SMgmtWrapper *pWrapper, SNodeMsg *pMsg){}
static int32_t dmInit(SMgmtWrapper *pWrapper) {
int32_t dmInit(SMgmtWrapper *pWrapper) {
SDnodeMgmt *pMgmt = calloc(1, sizeof(SDnodeMgmt));
pMgmt->dnodeId = 0;
......@@ -352,17 +336,6 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) {
#endif
}
static void dmCleanup(SMgmtWrapper *pWrapper){
void dmCleanup(SMgmtWrapper *pWrapper) {}
}
static bool dmRequire(SMgmtWrapper *pWrapper) { return true; }
SMgmtFp dmGetMgmtFp() {
SMgmtFp mgmtFp = {0};
mgmtFp.openFp = dmInit;
mgmtFp.closeFp = dmCleanup;
mgmtFp.requiredFp = dmRequire;
mgmtFp.getMsgHandleFp = dmGetMsgHandle;
return mgmtFp;
}
bool dmRequire(SMgmtWrapper *pWrapper) { return true; }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册