add test case
This commit is contained in:
parent
aa14e67da9
commit
04538f9049
|
@ -51,6 +51,7 @@ bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2);
|
||||||
void epsetAssign(SEpSet* dst, const SEpSet* pSrc);
|
void epsetAssign(SEpSet* dst, const SEpSet* pSrc);
|
||||||
void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet);
|
void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet);
|
||||||
SEpSet getEpSet_s(SCorEpSet* pEpSet);
|
SEpSet getEpSet_s(SCorEpSet* pEpSet);
|
||||||
|
void epsetSort(SEpSet* pEpSet);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,8 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
#include "tjson.h"
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlog.h"
|
#include "tjson.h"
|
||||||
#include "tname.h"
|
|
||||||
|
|
||||||
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
||||||
pEp->port = 0;
|
pEp->port = 0;
|
||||||
memset(pEp->fqdn, 0, TSDB_FQDN_LEN);
|
memset(pEp->fqdn, 0, TSDB_FQDN_LEN);
|
||||||
|
@ -73,6 +70,32 @@ void epsetAssign(SEpSet* pDst, const SEpSet* pSrc) {
|
||||||
tstrncpy(pDst->eps[i].fqdn, pSrc->eps[i].fqdn, tListLen(pSrc->eps[i].fqdn));
|
tstrncpy(pDst->eps[i].fqdn, pSrc->eps[i].fqdn, tListLen(pSrc->eps[i].fqdn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void epAssign(SEp* pDst, SEp* pSrc) {
|
||||||
|
if (pSrc == NULL || pDst == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset(pDst->fqdn, 0, tListLen(pSrc->fqdn));
|
||||||
|
tstrncpy(pDst->fqdn, pSrc->fqdn, tListLen(pSrc->fqdn));
|
||||||
|
pDst->port = pSrc->port;
|
||||||
|
}
|
||||||
|
void epsetSort(SEpSet* pDst) {
|
||||||
|
if (pDst->numOfEps <= 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < pDst->numOfEps - 1; i++) {
|
||||||
|
for (int j = 0; j < pDst->numOfEps - 1 - i; j++) {
|
||||||
|
SEp* f = &pDst->eps[j];
|
||||||
|
SEp* s = &pDst->eps[j + 1];
|
||||||
|
int cmp = strncmp(f->fqdn, s->fqdn, sizeof(f->fqdn));
|
||||||
|
if (cmp > 0 || (cmp == 0 && f->port > s->port)) {
|
||||||
|
SEp ep = {0};
|
||||||
|
epAssign(&ep, f);
|
||||||
|
epAssign(f, s);
|
||||||
|
epAssign(s, &ep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) {
|
void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) {
|
||||||
taosCorBeginWrite(&pEpSet->version);
|
taosCorBeginWrite(&pEpSet->version);
|
||||||
|
|
|
@ -579,13 +579,15 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
if (pSyncNode == NULL) return;
|
if (pSyncNode == NULL) return;
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) {
|
for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) {
|
||||||
if (pSyncNode->raftCfg.cfg.nodeInfo[i].nodeRole == TAOS_SYNC_ROLE_LEARNER) continue;
|
if (pSyncNode->raftCfg.cfg.nodeInfo[i].nodeRole == TAOS_SYNC_ROLE_LEARNER) continue;
|
||||||
SEp* pEp = &pEpSet->eps[i];
|
SEp* pEp = &pEpSet->eps[j];
|
||||||
tstrncpy(pEp->fqdn, pSyncNode->raftCfg.cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN);
|
tstrncpy(pEp->fqdn, pSyncNode->raftCfg.cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN);
|
||||||
pEp->port = (pSyncNode->raftCfg.cfg.nodeInfo)[i].nodePort;
|
pEp->port = (pSyncNode->raftCfg.cfg.nodeInfo)[i].nodePort;
|
||||||
pEpSet->numOfEps++;
|
pEpSet->numOfEps++;
|
||||||
sDebug("vgId:%d, sync get retry epset, index:%d %s:%d", pSyncNode->vgId, i, pEp->fqdn, pEp->port);
|
sDebug("vgId:%d, sync get retry epset, index:%d %s:%d", pSyncNode->vgId, i, pEp->fqdn, pEp->port);
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
if (pEpSet->numOfEps > 0) {
|
if (pEpSet->numOfEps > 0) {
|
||||||
pEpSet->inUse = (pSyncNode->raftCfg.cfg.myIndex + 1) % pEpSet->numOfEps;
|
pEpSet->inUse = (pSyncNode->raftCfg.cfg.myIndex + 1) % pEpSet->numOfEps;
|
||||||
|
|
Loading…
Reference in New Issue