diff --git a/src/inc/mgmt.h b/src/inc/mgmt.h index b7edada200f2a6624a287be55c01a4bf9795079f..b8445a93366878ad6a351ca67a1fbfeab9b548b9 100644 --- a/src/inc/mgmt.h +++ b/src/inc/mgmt.h @@ -376,16 +376,6 @@ int grantRetrieveGrants(SShowObj *pShow, char *data, int rows, SConnObj *pConn); int mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -// dnode balance api -int mgmtInitBalance(); -void mgmtCleanupBalance(); -int mgmtAllocVnodes(SVgObj *pVgroup); -int mgmtSetDnodeShellRemoving(SDnodeObj *pDnode); -void mgmtSetDnodeUnRemove(SDnodeObj *pDnode); -void mgmtStartBalanceTimer(int64_t mseconds); -void mgmtSetDnodeOfflineOnSdbChanged(); -void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbStatus, int srcIp); -bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode); void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType); int mgmtUnSetModuleInDnode(SDnodeObj *pDnode, int moduleType); diff --git a/src/mnode/inc/mgmtBalance.h b/src/mnode/inc/mgmtBalance.h index a97e7948940f7c5c9ddb2dae8370af84a82c0f34..1e9060e5680aff38ec54eee7b8edd493e6f59733 100644 --- a/src/mnode/inc/mgmtBalance.h +++ b/src/mnode/inc/mgmtBalance.h @@ -13,60 +13,32 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_MGMTBALANCE_H -#define TDENGINE_MGMTBALANCE_H +#ifndef TDENGINE_MGMT_BALANCE_H +#define TDENGINE_MGMT_BALANCE_H #ifdef __cplusplus extern "C" { #endif #include "os.h" - -#include "dnodeSystem.h" #include "mgmt.h" #include "tglobalcfg.h" #include "vnodeStatus.h" #include "ttime.h" -void mgmtCreateDnodeOrderList(); - -void mgmtReleaseDnodeOrderList(); - -void mgmtMakeDnodeOrderList(); - -void mgmtCalcSystemScore(); - -float mgmtTryCalcDnodeScore(SDnodeObj *pDnode, int extraVnode); - -bool mgmtCheckDnodeInOfflineState(SDnodeObj *pDnode); - -bool mgmtCheckDnodeInRemoveState(SDnodeObj *pDnode); - -bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int moduleType); - -void mgmtMonitorDnodeModule(); - -void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType); - -int mgmtUnSetModuleInDnode(SDnodeObj *pDnode, int moduleType); - -void mgmtMonitorVgroups(); - -void mgmtMonitorDnodes(); - -void mgmtCalcNumOfFreeVnodes(SDnodeObj *pDnode); - -extern void * dnodeSdb; -extern void * vgSdb; -extern void * balanceTimer; -extern int mgmtOrderedDnodesSize; -extern int mgmtOrderedDnodesMallocSize; -extern SDnodeObj **mgmtOrderedDnodes; -extern uint32_t mgmtAccessSquence; -extern SMgmtIpList mgmtIpList; +extern void (*mgmtStartBalanceTimer)(int64_t mseconds); +extern int32_t (*mgmtInitBalance)(); +extern void (*mgmtCleanupBalance)(); +extern int32_t (*mgmtAllocVnodes)(SVgObj *pVgroup); +extern bool (*mgmtCheckModuleInDnode)(SDnodeObj *pDnode, int moduleType); +extern char* (*mgmtGetVnodeStatus)(SVgObj *pVgroup, SVnodeGid *pVnode); +extern bool (*mgmtCheckVnodeReady)(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode); +extern void (*mgmtUpdateDnodeState)(SDnodeObj *pDnode, int lbStatus); +extern void (*mgmtUpdateVgroupState)(SVgObj *pVgroup, int lbStatus, int srcIp); +extern bool (*mgmtAddVnode)(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode); #ifdef __cplusplus } #endif -#endif // TDENGINE_MGMTBALANCE_H +#endif diff --git a/src/mnode/src/mgmtBalance.spec.c b/src/mnode/src/mgmtBalance.c similarity index 52% rename from src/mnode/src/mgmtBalance.spec.c rename to src/mnode/src/mgmtBalance.c index f2ac4c517e8b4ddde675bf0a5f85589571b92922..d7b4a88a721abd91d088ffce0b26b99a36580cba 100644 --- a/src/mnode/src/mgmtBalance.spec.c +++ b/src/mnode/src/mgmtBalance.c @@ -18,13 +18,16 @@ #include "vnodeStatus.h" #include "dnodeModule.h" -void mgmtStartBalanceTimer(int64_t mseconds) {} +void mgmtStartBalanceTimerImp(int64_t mseconds) {} +void (*mgmtStartBalanceTimer)(int64_t mseconds) = mgmtStartBalanceTimerImp; -int mgmtInitBalance() { return 0; } +int32_t mgmtInitBalanceImp() { return 0; } +int32_t (*mgmtInitBalance)() = mgmtInitBalanceImp; -void mgmtCleanupBalance() {} +void mgmtCleanupBalanceImp() {} +void (*mgmtCleanupBalance)() = mgmtCleanupBalanceImp; -int mgmtAllocVnodes(SVgObj *pVgroup) { +int32_t mgmtAllocVnodesImp(SVgObj *pVgroup) { int selectedVnode = -1; SDnodeObj *pDnode = &dnodeObj; int lastAllocVode = pDnode->lastAllocVnode; @@ -48,17 +51,26 @@ int mgmtAllocVnodes(SVgObj *pVgroup) { return 0; } } +int32_t (*mgmtAllocVnodes)(SVgObj *pVgroup) = mgmtAllocVnodesImp; -bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int moduleType) { +bool mgmtCheckModuleInDnodeImp(SDnodeObj *pDnode, int moduleType) { return tsModule[moduleType].num != 0; } +bool (*mgmtCheckModuleInDnode)(SDnodeObj *pDnode, int moduleType) = mgmtCheckModuleInDnodeImp; -char *mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode) { return "master"; } +char *mgmtGetVnodeStatusImp(SVgObj *pVgroup, SVnodeGid *pVnode) { return "master"; } +char *(*mgmtGetVnodeStatus)(SVgObj *pVgroup, SVnodeGid *pVnode) = mgmtGetVnodeStatusImp; -bool mgmtCheckVnodeReady(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode) { return true; } +bool mgmtCheckVnodeReadyImp(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode) { return true; } +bool (*mgmtCheckVnodeReady)(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode) = mgmtCheckVnodeReadyImp; -void mgmtUpdateDnodeState(SDnodeObj *pDnode, int lbStatus) {} -void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbStatus, int srcIp) {} +void mgmtUpdateDnodeStateImp(SDnodeObj *pDnode, int lbStatus) {} +void (*mgmtUpdateDnodeState)(SDnodeObj *pDnode, int lbStatus) = mgmtUpdateDnodeStateImp; + +void mgmtUpdateVgroupStateImp(SVgObj *pVgroup, int lbStatus, int srcIp) {} +void (*mgmtUpdateVgroupState)(SVgObj *pVgroup, int lbStatus, int srcIp) = mgmtUpdateVgroupStateImp; + +bool mgmtAddVnodeImp(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode) { return false; } +bool (*mgmtAddVnode)(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode) = mgmtAddVnodeImp; -bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode) { return false; } \ No newline at end of file diff --git a/src/mnode/src/mgmtConn.c b/src/mnode/src/mgmtConn.c index b440a1042e30756f50481f63afb5d82c37c5afc7..cc9265834bb81b702ca93d89113c712637a8e3b4 100644 --- a/src/mnode/src/mgmtConn.c +++ b/src/mnode/src/mgmtConn.c @@ -14,9 +14,7 @@ */ #define _DEFAULT_SOURCE - #include "os.h" - #include "mgmt.h" #include "taosmsg.h" #include "tschemautil.h"