[TD-509] add db name to vnodeObj
This commit is contained in:
parent
05872a7d68
commit
775c5313d4
|
@ -590,6 +590,7 @@ typedef struct {
|
|||
} SMDVnodeDesc;
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
SMDVnodeCfg cfg;
|
||||
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
||||
} SMDCreateVnodeMsg;
|
||||
|
|
|
@ -539,6 +539,8 @@ SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) {
|
|||
SMDCreateVnodeMsg *pVnode = rpcMallocCont(sizeof(SMDCreateVnodeMsg));
|
||||
if (pVnode == NULL) return NULL;
|
||||
|
||||
strcpy(pVnode->db, pVgroup->dbName);
|
||||
|
||||
SMDVnodeCfg *pCfg = &pVnode->cfg;
|
||||
pCfg->vgId = htonl(pVgroup->vgId);
|
||||
pCfg->cfgVersion = htonl(pDb->cfgVersion);
|
||||
|
@ -594,7 +596,7 @@ SRpcIpSet mnodeGetIpSetFromIp(char *ep) {
|
|||
}
|
||||
|
||||
void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
|
||||
mTrace("vgId:%d, send create vnode:%d msg, ahandle:%p", pVgroup->vgId, pVgroup->vgId, ahandle);
|
||||
mTrace("vgId:%d, send create vnode:%d msg, ahandle:%p db:%s", pVgroup->vgId, pVgroup->vgId, ahandle, pVgroup->dbName);
|
||||
SMDCreateVnodeMsg *pCreate = mnodeBuildCreateVnodeMsg(pVgroup);
|
||||
SRpcMsg rpcMsg = {
|
||||
.handle = ahandle,
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef struct {
|
|||
SSyncCfg syncCfg;
|
||||
SWalCfg walCfg;
|
||||
char *rootDir;
|
||||
char db[TSDB_DB_NAME_LEN + 1];
|
||||
} SVnodeObj;
|
||||
|
||||
int vnodeWriteToQueue(void *param, void *pHead, int type);
|
||||
|
|
|
@ -496,7 +496,7 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) {
|
|||
}
|
||||
|
||||
len += snprintf(content + len, maxLen - len, "{\n");
|
||||
|
||||
len += snprintf(content + len, maxLen - len, " \"db\": \"%s\",\n", pVnodeCfg->db);
|
||||
len += snprintf(content + len, maxLen - len, " \"cfgVersion\": %d,\n", pVnodeCfg->cfg.cfgVersion);
|
||||
len += snprintf(content + len, maxLen - len, " \"cacheBlockSize\": %d,\n", pVnodeCfg->cfg.cacheBlockSize);
|
||||
len += snprintf(content + len, maxLen - len, " \"totalBlocks\": %d,\n", pVnodeCfg->cfg.totalBlocks);
|
||||
|
@ -568,6 +568,13 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
|||
goto PARSE_OVER;
|
||||
}
|
||||
|
||||
cJSON *db = cJSON_GetObjectItem(root, "db");
|
||||
if (!db || db->type != cJSON_String || db->valuestring == NULL) {
|
||||
vError("vgId:%d, failed to read vnode cfg, db not found", pVnode->vgId);
|
||||
goto PARSE_OVER;
|
||||
}
|
||||
strcpy(pVnode->db, db->valuestring);
|
||||
|
||||
cJSON *cfgVersion = cJSON_GetObjectItem(root, "cfgVersion");
|
||||
if (!cfgVersion || cfgVersion->type != cJSON_Number) {
|
||||
vError("vgId:%d, failed to read vnode cfg, cfgVersion not found", pVnode->vgId);
|
||||
|
|
Loading…
Reference in New Issue