enh: update epset on dnode info changed
This commit is contained in:
parent
b09b67acd2
commit
da6722d353
|
@ -84,6 +84,9 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
pData->dnodeEps = NULL;
|
pData->dnodeEps = NULL;
|
||||||
}
|
}
|
||||||
if (pData->oldDnodeEps != NULL) {
|
if (pData->oldDnodeEps != NULL) {
|
||||||
|
if (dmWriteEps(pData) == 0) {
|
||||||
|
dmRemoveDnodePairs(pData);
|
||||||
|
}
|
||||||
taosArrayDestroy(pData->oldDnodeEps);
|
taosArrayDestroy(pData->oldDnodeEps);
|
||||||
pData->oldDnodeEps = NULL;
|
pData->oldDnodeEps = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,7 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
||||||
void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet);
|
void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
||||||
void dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port);
|
void dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port);
|
||||||
|
void dmRemoveDnodePairs(SDnodeData *pData);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,7 @@ _OVER:
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
dError("failed to read dnode file:%s since %s", file, terrstr());
|
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pData->dnodeEps) == 0) {
|
if (taosArrayGetSize(pData->dnodeEps) == 0) {
|
||||||
|
@ -164,6 +165,10 @@ _OVER:
|
||||||
taosArrayPush(pData->dnodeEps, &dnodeEp);
|
taosArrayPush(pData->dnodeEps, &dnodeEp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dmReadDnodePairs(pData) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
dDebug("reset dnode list on startup");
|
dDebug("reset dnode list on startup");
|
||||||
dmResetEps(pData, pData->dnodeEps);
|
dmResetEps(pData, pData->dnodeEps);
|
||||||
|
|
||||||
|
@ -416,6 +421,13 @@ static int32_t dmDecodeEpPairs(SJson *pJson, SDnodeData *pData) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dmRemoveDnodePairs(SDnodeData *pData) {
|
||||||
|
char file[PATH_MAX] = {0};
|
||||||
|
snprintf(file, sizeof(file), "%s%sdnode%sep.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
||||||
|
dInfo("dnode file:%s is removed", file);
|
||||||
|
(void)taosRemoveFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
|
@ -424,12 +436,6 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
snprintf(file, sizeof(file), "%s%sdnode%sep.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
snprintf(file, sizeof(file), "%s%sdnode%sep.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
||||||
|
|
||||||
pData->oldDnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
|
||||||
if (pData->oldDnodeEps == NULL) {
|
|
||||||
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosStatFile(file, NULL, NULL) < 0) {
|
if (taosStatFile(file, NULL, NULL) < 0) {
|
||||||
dDebug("dnode file:%s not exist", file);
|
dDebug("dnode file:%s not exist", file);
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -470,7 +476,15 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pData->oldDnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
||||||
|
if (pData->oldDnodeEps == NULL) {
|
||||||
|
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (dmDecodeEpPairs(pJson, pData) < 0) {
|
if (dmDecodeEpPairs(pJson, pData) < 0) {
|
||||||
|
taosArrayDestroy(pData->oldDnodeEps);
|
||||||
|
pData->oldDnodeEps = NULL;
|
||||||
terrno = TSDB_CODE_INVALID_JSON_FORMAT;
|
terrno = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue