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