提交 750650c7 编写于 作者: S Shengliang Guan

TD-2680

上级 a56e677f
......@@ -36,6 +36,7 @@ extern int8_t tsEnableVnodeBak;
extern int8_t tsEnableTelemetryReporting;
extern char tsEmail[];
extern char tsArbitrator[];
extern int8_t tsArbOnline;
// common
extern int tsRpcTimer;
......
......@@ -41,6 +41,7 @@ int32_t tsStatusInterval = 1; // second
int32_t tsNumOfMnodes = 3;
int8_t tsEnableVnodeBak = 1;
int8_t tsEnableTelemetryReporting = 1;
int8_t tsArbOnline = 0;
char tsEmail[TSDB_FQDN_LEN] = {0};
// common
......
......@@ -810,6 +810,10 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
}
pShow->numOfRows = mnodeGetDnodesNum();
if (tsArbitrator[0] != 0) {
pShow->numOfRows++;
}
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
pShow->pIter = NULL;
......@@ -821,7 +825,7 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
int32_t numOfRows = 0;
int32_t cols = 0;
SDnodeObj *pDnode = NULL;
SDnodeObj *pDnode = NULL;
char *pWrite;
while (numOfRows < rows) {
......@@ -864,10 +868,49 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo
STR_TO_VARSTR(pWrite, offlineReason[pDnode->offlineReason]);
cols++;
numOfRows++;
numOfRows++;
mnodeDecDnodeRef(pDnode);
}
if (tsArbitrator[0] != 0) {
cols = 0;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = 0;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tsArbitrator, pShow->bytes[cols]);
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = 0;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int16_t *)pWrite = 0;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
char *status = dnodeStatus[tsArbOnline > 0 ? TAOS_DN_STATUS_READY : TAOS_DN_STATUS_OFFLINE];
STR_TO_VARSTR(pWrite, status);
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_TO_VARSTR(pWrite, "arb");
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*(int64_t *)pWrite = 0;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
STR_TO_VARSTR(pWrite, "-");
cols++;
numOfRows++;
}
mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow);
pShow->numOfReads += numOfRows;
return numOfRows;
......
......@@ -87,6 +87,7 @@ typedef struct SsyncPeer {
int32_t numOfRetrieves; // number of retrieves tried
int32_t fileChanged; // a flag to indicate file is changed during retrieving process
int32_t refCount;
int8_t isArb;
int64_t rid;
void * timer;
void * pConn;
......
......@@ -475,7 +475,13 @@ static void syncAddArbitrator(SSyncNode *pNode) {
}
}
pNode->peerInfo[TAOS_SYNC_MAX_REPLICA] = syncAddPeer(pNode, &nodeInfo);
pPeer = syncAddPeer(pNode, &nodeInfo);
if (pPeer != NULL) {
pPeer->isArb = 1;
sInfo("%s, is added as arbitrator", pPeer->id);
}
pNode->peerInfo[TAOS_SYNC_MAX_REPLICA] = pPeer;
}
static void syncFreeNode(void *param) {
......@@ -651,9 +657,14 @@ static void syncChooseMaster(SSyncNode *pNode) {
// add arbitrator connection
SSyncPeer *pArb = pNode->peerInfo[TAOS_SYNC_MAX_REPLICA];
if (pArb && pArb->role != TAOS_SYNC_ROLE_OFFLINE) {
onlineNum++;
replica = pNode->replica + 1;
if (pArb) {
if (pArb->role != TAOS_SYNC_ROLE_OFFLINE) {
onlineNum++;
replica = pNode->replica + 1;
sDebug("vgId:%d, arb:%s is used while choose master", pNode->vgId, pArb->id);
} else {
sError("vgId:%d, arb:%s is not used while choose master for its offline", pNode->vgId, pArb->id);
}
}
if (index < 0 && onlineNum > replica / 2.0) {
......@@ -1118,6 +1129,7 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) {
pPeer->peerFd = connFd;
pPeer->role = TAOS_SYNC_ROLE_UNSYNCED;
pPeer->pConn = syncAllocateTcpConn(tsTcpPool, pPeer->rid, connFd);
if (pPeer->isArb) tsArbOnline = 1;
} else {
sDebug("%s, failed to setup peer connection to server since %s, try later", pPeer->id, strerror(errno));
taosClose(connFd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册