提交 22a6eeb5 编写于 作者: S slguan

fix compile error in 2.0

上级 7efbbc59
...@@ -143,8 +143,6 @@ void dnodeSendStatusMsgToMgmt(void *handle, void *tmrId) { ...@@ -143,8 +143,6 @@ void dnodeSendStatusMsgToMgmt(void *handle, void *tmrId) {
// } // }
dnodeSendMsgToMnode(TSDB_MSG_TYPE_STATUS, pStatus, contLen); dnodeSendMsgToMnode(TSDB_MSG_TYPE_STATUS, pStatus, contLen);
//grantSendMsgToMgmt();
} }
......
...@@ -59,3 +59,6 @@ bool dnodeCheckTableExist(int32_t vnode, int32_t sid, int64_t uid) { ...@@ -59,3 +59,6 @@ bool dnodeCheckTableExist(int32_t vnode, int32_t sid, int64_t uid) {
return true; return true;
} }
int32_t dnodeGetVnodesNum() {
return 1;
}
...@@ -258,10 +258,10 @@ typedef struct { ...@@ -258,10 +258,10 @@ typedef struct {
} SShowObj; } SShowObj;
//mgmtSystem //mgmtSystem
int32_t mgmtInitSystem();
int32_t mgmtStartSystem(); int32_t mgmtStartSystem();
void mgmtCleanUpSystem(); void mgmtCleanUpSystem();
extern void (*mgmtCleanUpRedirect)(); void mgmtStopSystem();
void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *pConn, int32_t code); void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *pConn, int32_t code);
......
...@@ -20,19 +20,13 @@ ...@@ -20,19 +20,13 @@
extern "C" { extern "C" {
#endif #endif
#include "os.h"
#include "mnode.h" #include "mnode.h"
extern void (*mgmtStartBalanceTimer)(int64_t mseconds); void mgmtStartBalanceTimer(int64_t mseconds);
extern int32_t (*mgmtInitBalance)(); int32_t mgmtInitBalance();
extern void (*mgmtCleanupBalance)(); void mgmtCleanupBalance();
extern int32_t (*mgmtAllocVnodes)(SVgObj *pVgroup); int32_t mgmtAllocVnodes(SVgObj *pVgroup);
extern bool (*mgmtCheckModuleInDnode)(SDnodeObj *pDnode, int moduleType); char* mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode);
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);
bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -34,6 +34,7 @@ void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode); ...@@ -34,6 +34,7 @@ void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode);
int32_t mgmtGetConfigMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn); int32_t mgmtGetConfigMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn);
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn); int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType);
int32_t mgmtGetModuleMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn); int32_t mgmtGetModuleMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn);
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn); int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
......
...@@ -27,10 +27,6 @@ int32_t mgmtStartSystem(); ...@@ -27,10 +27,6 @@ int32_t mgmtStartSystem();
void mgmtCleanUpSystem(); void mgmtCleanUpSystem();
void mgmtStopSystem(); void mgmtStopSystem();
extern void (*mgmtCleanUpRedirect)();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -21,76 +21,67 @@ ...@@ -21,76 +21,67 @@
#include "mgmtBalance.h" #include "mgmtBalance.h"
#include "mgmtDnode.h" #include "mgmtDnode.h"
void mgmtStartBalanceTimerImp(int64_t mseconds) {} void (*mgmtStartBalanceTimerFp)(int64_t mseconds) = NULL;
void (*mgmtStartBalanceTimer)(int64_t mseconds) = mgmtStartBalanceTimerImp; int32_t (*mgmtInitBalanceFp)() = NULL;
void (*mgmtCleanupBalanceFp)() = NULL;
int32_t mgmtInitBalanceImp() { return 0; } int32_t (*mgmtAllocVnodesFp)(SVgObj *pVgroup) = NULL;
int32_t (*mgmtInitBalance)() = mgmtInitBalanceImp; char * (*mgmtGetVnodeStatusFp)(SVgObj *pVgroup, SVnodeGid *pVnode) = NULL;
void mgmtCleanupBalanceImp() {} void mgmtStartBalanceTimer(int64_t mseconds) {
void (*mgmtCleanupBalance)() = mgmtCleanupBalanceImp; if (mgmtStartBalanceTimerFp) {
(*mgmtStartBalanceTimerFp)(mseconds);
int32_t mgmtAllocVnodesImp(SVgObj *pVgroup) { }
// int selectedVnode = -1;
// int lastAllocVode = pDnode->lastAllocVnode;
//
// for (int i = 0; i < pDnode->numOfVnodes; i++) {
// int vnode = (i + lastAllocVode) % pDnode->numOfVnodes;
// if (pDnode->vload[vnode].vgId == 0 && pDnode->vload[vnode].status == TSDB_VN_STATUS_OFFLINE) {
// selectedVnode = vnode;
// break;
// }
// }
//
// if (selectedVnode == -1) {
// mError("vgroup:%d alloc vnode failed, free vnodes:%d", pVgroup->vgId, pDnode->numOfFreeVnodes);
// return -1;
// } else {
// mTrace("vgroup:%d allocate vnode:%d, last allocated vnode:%d", pVgroup->vgId, selectedVnode, lastAllocVode);
// pVgroup->vnodeGid[0].vnode = selectedVnode;
// pDnode->lastAllocVnode = selectedVnode + 1;
// if (pDnode->lastAllocVnode >= pDnode->numOfVnodes) pDnode->lastAllocVnode = 0;
// return 0;
// }
return 0;
} }
int32_t (*mgmtAllocVnodes)(SVgObj *pVgroup) = mgmtAllocVnodesImp;
bool mgmtCheckModuleInDnodeImp(SDnodeObj *pDnode, int moduleType) { int32_t mgmtInitBalance() {
return tsModule[moduleType].num != 0; if (mgmtInitBalanceFp) {
return (*mgmtInitBalanceFp)();
} else {
return 0;
}
} }
bool (*mgmtCheckModuleInDnode)(SDnodeObj *pDnode, int moduleType) = mgmtCheckModuleInDnodeImp; void mgmtCleanupBalance() {
if (mgmtCleanupBalanceFp) {
char *mgmtGetVnodeStatusImp(SVgObj *pVgroup, SVnodeGid *pVnode) { (*mgmtCleanupBalanceFp)();
return "master"; }
} }
char *(*mgmtGetVnodeStatus)(SVgObj *pVgroup, SVnodeGid *pVnode) = mgmtGetVnodeStatusImp; int32_t mgmtAllocVnodes(SVgObj *pVgroup) {
if (mgmtAllocVnodesFp) {
bool mgmtCheckVnodeReadyImp(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode) { return mgmtAllocVnodesFp(pVgroup);
return true; }
}
bool (*mgmtCheckVnodeReady)(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode) = mgmtCheckVnodeReadyImp; SDnodeObj *pDnode = mgmtGetDnode(0);
if (pDnode == NULL) return TSDB_CODE_OTHERS;
void mgmtUpdateDnodeStateImp(SDnodeObj *pDnode, int lbStatus) { int selectedVnode = -1;
} int lastAllocVode = pDnode->lastAllocVnode;
void (*mgmtUpdateDnodeState)(SDnodeObj *pDnode, int lbStatus) = mgmtUpdateDnodeStateImp; for (int i = 0; i < pDnode->numOfVnodes; i++) {
int vnode = (i + lastAllocVode) % pDnode->numOfVnodes;
if (pDnode->vload[vnode].vgId == 0 && pDnode->vload[vnode].status == TSDB_VN_STATUS_OFFLINE) {
selectedVnode = vnode;
break;
}
}
void mgmtUpdateVgroupStateImp(SVgObj *pVgroup, int lbStatus, int srcIp) { if (selectedVnode == -1) {
mError("vgroup:%d alloc vnode failed, free vnodes:%d", pVgroup->vgId, pDnode->numOfFreeVnodes);
return -1;
} else {
mTrace("vgroup:%d allocate vnode:%d, last allocated vnode:%d", pVgroup->vgId, selectedVnode, lastAllocVode);
pVgroup->vnodeGid[0].vnode = selectedVnode;
pDnode->lastAllocVnode = selectedVnode + 1;
if (pDnode->lastAllocVnode >= pDnode->numOfVnodes) pDnode->lastAllocVnode = 0;
return 0;
}
} }
void (*mgmtUpdateVgroupState)(SVgObj *pVgroup, int lbStatus, int srcIp) = mgmtUpdateVgroupStateImp; char *mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode) {
if (mgmtGetVnodeStatusFp) {
return (*mgmtGetVnodeStatusFp)(pVgroup, pVnode);
bool (*mgmtAddVnodeFp)(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode) = NULL;
bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode) {
if (mgmtAddVnodeFp) {
return mgmtAddVnodeFp(pVgroup, pSrcDnode, pDestDnode);
} else { } else {
return false; return "master";
} }
} }
...@@ -409,68 +409,69 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) { ...@@ -409,68 +409,69 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) {
} }
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) { int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
int32_t code = TSDB_CODE_SUCCESS; return 0;
// int32_t code = TSDB_CODE_SUCCESS;
SDbObj *pDb = (SDbObj *) sdbGetRow(tsDbSdb, pAlter->db); //
if (pDb == NULL) { // SDbObj *pDb = (SDbObj *) sdbGetRow(tsDbSdb, pAlter->db);
mTrace("db:%s is not exist", pAlter->db); // if (pDb == NULL) {
return TSDB_CODE_INVALID_DB; // mTrace("db:%s is not exist", pAlter->db);
} // return TSDB_CODE_INVALID_DB;
// }
int32_t oldReplicaNum = pDb->cfg.replications; //
if (pAlter->daysToKeep > 0) { // int32_t oldReplicaNum = pDb->cfg.replications;
mTrace("db:%s daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, pAlter->daysToKeep); // if (pAlter->daysToKeep > 0) {
pDb->cfg.daysToKeep = pAlter->daysToKeep; // mTrace("db:%s daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, pAlter->daysToKeep);
} else if (pAlter->replications > 0) { // pDb->cfg.daysToKeep = pAlter->daysToKeep;
mTrace("db:%s replica:%d change to %d", pDb->name, pDb->cfg.replications, pAlter->replications); // } else if (pAlter->replications > 0) {
if (pAlter->replications < TSDB_REPLICA_MIN_NUM || pAlter->replications > TSDB_REPLICA_MAX_NUM) { // mTrace("db:%s replica:%d change to %d", pDb->name, pDb->cfg.replications, pAlter->replications);
mError("invalid db option replica: %d valid range: %d--%d", pAlter->replications, TSDB_REPLICA_MIN_NUM, TSDB_REPLICA_MAX_NUM); // if (pAlter->replications < TSDB_REPLICA_MIN_NUM || pAlter->replications > TSDB_REPLICA_MAX_NUM) {
return TSDB_CODE_INVALID_OPTION; // mError("invalid db option replica: %d valid range: %d--%d", pAlter->replications, TSDB_REPLICA_MIN_NUM, TSDB_REPLICA_MAX_NUM);
} // return TSDB_CODE_INVALID_OPTION;
pDb->cfg.replications = pAlter->replications; // }
} else if (pAlter->maxSessions > 0) { // pDb->cfg.replications = pAlter->replications;
mTrace("db:%s tables:%d change to %d", pDb->name, pDb->cfg.maxSessions, pAlter->maxSessions); // } else if (pAlter->maxSessions > 0) {
if (pAlter->maxSessions < TSDB_MIN_TABLES_PER_VNODE || pAlter->maxSessions > TSDB_MAX_TABLES_PER_VNODE) { // mTrace("db:%s tables:%d change to %d", pDb->name, pDb->cfg.maxSessions, pAlter->maxSessions);
mError("invalid db option tables: %d valid range: %d--%d", pAlter->maxSessions, TSDB_MIN_TABLES_PER_VNODE, TSDB_MAX_TABLES_PER_VNODE); // if (pAlter->maxSessions < TSDB_MIN_TABLES_PER_VNODE || pAlter->maxSessions > TSDB_MAX_TABLES_PER_VNODE) {
return TSDB_CODE_INVALID_OPTION; // mError("invalid db option tables: %d valid range: %d--%d", pAlter->maxSessions, TSDB_MIN_TABLES_PER_VNODE, TSDB_MAX_TABLES_PER_VNODE);
} // return TSDB_CODE_INVALID_OPTION;
if (pAlter->maxSessions < pDb->cfg.maxSessions) { // }
mError("invalid db option tables: %d should larger than original:%d", pAlter->maxSessions, pDb->cfg.maxSessions); // if (pAlter->maxSessions < pDb->cfg.maxSessions) {
return TSDB_CODE_INVALID_OPTION; // mError("invalid db option tables: %d should larger than original:%d", pAlter->maxSessions, pDb->cfg.maxSessions);
} // return TSDB_CODE_INVALID_OPTION;
return TSDB_CODE_INVALID_OPTION; // }
//The modification of tables needs to rewrite the head file, so disable this option // return TSDB_CODE_INVALID_OPTION;
//pDb->cfg.maxSessions = pAlter->maxSessions; // //The modification of tables needs to rewrite the head file, so disable this option
} else { // //pDb->cfg.maxSessions = pAlter->maxSessions;
mError("db:%s alter msg, replica:%d, keep:%d, tables:%d, origin replica:%d keep:%d", pDb->name, // } else {
pAlter->replications, pAlter->maxSessions, pAlter->daysToKeep, // mError("db:%s alter msg, replica:%d, keep:%d, tables:%d, origin replica:%d keep:%d", pDb->name,
pDb->cfg.replications, pDb->cfg.daysToKeep); // pAlter->replications, pAlter->maxSessions, pAlter->daysToKeep,
return TSDB_CODE_INVALID_OPTION; // pDb->cfg.replications, pDb->cfg.daysToKeep);
} // return TSDB_CODE_INVALID_OPTION;
// }
if (sdbUpdateRow(tsDbSdb, pDb, tsDbUpdateSize, 1) < 0) { //
return TSDB_CODE_SDB_ERROR; // if (sdbUpdateRow(tsDbSdb, pDb, tsDbUpdateSize, 1) < 0) {
} // return TSDB_CODE_SDB_ERROR;
// }
SVgObj *pVgroup = pDb->pHead; //
while (pVgroup != NULL) { // SVgObj *pVgroup = pDb->pHead;
mgmtUpdateVgroupState(pVgroup, TSDB_VG_LB_STATUS_UPDATE, 0); // while (pVgroup != NULL) {
if (oldReplicaNum < pDb->cfg.replications) { // mgmtUpdateVgroupState(pVgroup, TSDB_VG_LB_STATUS_UPDATE, 0);
if (!mgmtAddVnode(pVgroup, NULL, NULL)) { // if (oldReplicaNum < pDb->cfg.replications) {
mWarn("db:%s vgroup:%d not enough dnode to add vnode", pAlter->db, pVgroup->vgId); // if (!mgmtAddVnode(pVgroup, NULL, NULL)) {
code = TSDB_CODE_NO_ENOUGH_DNODES; // mWarn("db:%s vgroup:%d not enough dnode to add vnode", pAlter->db, pVgroup->vgId);
} // code = TSDB_CODE_NO_ENOUGH_DNODES;
} // }
if (pAlter->maxSessions > 0) { // }
//rebuild meterList in mgmtVgroup.c // if (pAlter->maxSessions > 0) {
mgmtUpdateVgroup(pVgroup); // //rebuild meterList in mgmtVgroup.c
} // mgmtUpdateVgroup(pVgroup);
// mgmtSendCreateVnodeMsg(pVgroup); // }
pVgroup = pVgroup->next; //// mgmtSendCreateVnodeMsg(pVgroup);
} // pVgroup = pVgroup->next;
mgmtStartBalanceTimer(10); // }
// mgmtStartBalanceTimer(10);
return code; //
// return code;
} }
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup) { int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup) {
......
...@@ -34,7 +34,7 @@ int32_t (*mgmtGetScoresMetaFp)(STableMeta *pMeta, SShowObj *pShow, void *pCon ...@@ -34,7 +34,7 @@ int32_t (*mgmtGetScoresMetaFp)(STableMeta *pMeta, SShowObj *pShow, void *pCon
int32_t (*mgmtRetrieveScoresFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = NULL; int32_t (*mgmtRetrieveScoresFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = NULL;
void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL; void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
static SDnodeObj tsDnodeObj; static SDnodeObj tsDnodeObj = {0};
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) { void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
int32_t maxVnodes = pDnode->numOfCores * tsNumOfVnodesPerCore; int32_t maxVnodes = pDnode->numOfCores * tsNumOfVnodesPerCore;
...@@ -225,6 +225,11 @@ int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pCon ...@@ -225,6 +225,11 @@ int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pCon
return numOfRows; return numOfRows;
} }
bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
uint32_t status = pDnode->moduleStatus & (1 << moduleType);
return status > 0;
}
int32_t mgmtGetModuleMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) { int32_t mgmtGetModuleMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) {
int32_t cols = 0; int32_t cols = 0;
...@@ -543,6 +548,14 @@ int32_t mgmtInitDnodes() { ...@@ -543,6 +548,14 @@ int32_t mgmtInitDnodes() {
tsDnodeObj.thandle = (void *) (1); //hack way tsDnodeObj.thandle = (void *) (1); //hack way
tsDnodeObj.status = TSDB_DN_STATUS_READY; tsDnodeObj.status = TSDB_DN_STATUS_READY;
mgmtSetDnodeMaxVnodes(&tsDnodeObj); mgmtSetDnodeMaxVnodes(&tsDnodeObj);
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_MGMT);
if (tsEnableHttpModule) {
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_HTTP);
}
if (tsEnableMonitorModule) {
tsDnodeObj.moduleStatus |= (1 << TSDB_MOD_MONITOR);
}
return 0; return 0;
} }
} }
......
...@@ -91,8 +91,8 @@ int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, void *pCon ...@@ -91,8 +91,8 @@ int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, void *pCon
pShow->pNode = mgmtGetNextMnode(pShow, (SDnodeObj **)&pMnode); pShow->pNode = mgmtGetNextMnode(pShow, (SDnodeObj **)&pMnode);
pShow->pNode = sdbFetchRow(mnodeSdb, pShow->pNode, (void **)&pMnode); // pShow->pNode = sdbFetchRow(mnodeSdb, pShow->pNode, (void **)&pMnode);
if (pMnode == NULL) break; // if (pMnode == NULL) break;
cols = 0; cols = 0;
......
...@@ -38,7 +38,6 @@ void *tsMgmtTranQhandle = NULL; ...@@ -38,7 +38,6 @@ void *tsMgmtTranQhandle = NULL;
void mgmtCleanUpSystem() { void mgmtCleanUpSystem() {
mPrint("starting to clean up mgmt"); mPrint("starting to clean up mgmt");
mgmtCleanUpRedirect();
sdbCleanUpPeers(); sdbCleanUpPeers();
mgmtCleanupBalance(); mgmtCleanupBalance();
mgmtCleanUpDnodeInt(); mgmtCleanUpDnodeInt();
...@@ -63,8 +62,8 @@ int32_t mgmtCheckMgmtRunning() { ...@@ -63,8 +62,8 @@ int32_t mgmtCheckMgmtRunning() {
tsetModuleStatus(TSDB_MOD_MGMT); tsetModuleStatus(TSDB_MOD_MGMT);
// strcpy(sdbMasterIp, mgmtIpStr[0]); // strcpy(sdbMasterIp, mgmtIpStr[0]);
strcpy(sdbPrivateIp, tsPrivateIp); // strcpy(sdbPrivateIp, tsPrivateIp);
sdbPublicIp = inet_addr(tsPublicIp); // sdbPublicIp = inet_addr(tsPublicIp);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册