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

TD-2680

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