Merge pull request #3694 from taosdata/feature/http

TD-1617
This commit is contained in:
Shengliang Guan 2020-09-27 21:51:50 +08:00 committed by GitHub
commit 1d7f65e1ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 49 deletions

View File

@ -118,7 +118,7 @@ typedef struct SsyncPeer {
uint32_t ip; uint32_t ip;
uint16_t port; uint16_t port;
char fqdn[TSDB_FQDN_LEN]; // peer ip string char fqdn[TSDB_FQDN_LEN]; // peer ip string
char id[TSDB_EP_LEN+16]; // peer vgId + end point char id[TSDB_EP_LEN + 32]; // peer vgId + end point
int8_t role; int8_t role;
int8_t sstatus; // sync status int8_t sstatus; // sync status
uint64_t version; uint64_t version;
@ -127,11 +127,11 @@ typedef struct SsyncPeer {
int peerFd; // forward FD int peerFd; // forward FD
int numOfRetrieves; // number of retrieves tried int numOfRetrieves; // number of retrieves tried
int fileChanged; // a flag to indicate file is changed during retrieving process int fileChanged; // a flag to indicate file is changed during retrieving process
void *timer; void * timer;
void *pConn; void * pConn;
int notifyFd; int notifyFd;
int watchNum; int watchNum;
int *watchFd; int * watchFd;
int8_t refCount; // reference count int8_t refCount; // reference count
struct SSyncNode *pSyncNode; struct SSyncNode *pSyncNode;
} SSyncPeer; } SSyncPeer;

View File

@ -622,7 +622,7 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) {
if (onlineNum <= replica * 0.5) { if (onlineNum <= replica * 0.5) {
if (nodeRole != TAOS_SYNC_ROLE_UNSYNCED) { if (nodeRole != TAOS_SYNC_ROLE_UNSYNCED) {
nodeRole = TAOS_SYNC_ROLE_UNSYNCED; nodeRole = TAOS_SYNC_ROLE_UNSYNCED;
pNode->peerInfo[pNode->selfIndex]->role = nodeRole; //pNode->peerInfo[pNode->selfIndex]->role = nodeRole;
(*pNode->notifyRole)(pNode->ahandle, nodeRole); (*pNode->notifyRole)(pNode->ahandle, nodeRole);
sInfo("vgId:%d, change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica); sInfo("vgId:%d, change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica);
} }
@ -671,7 +671,7 @@ static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus peersStatus[], int8_t ne
int8_t selfOldRole = nodeRole; int8_t selfOldRole = nodeRole;
int8_t i, syncRequired = 0; int8_t i, syncRequired = 0;
pNode->peerInfo[pNode->selfIndex]->version = nodeVersion; //pNode->peerInfo[pNode->selfIndex]->version = nodeVersion;
pPeer->role = newRole; pPeer->role = newRole;
sDebug("%s, own role:%s, new peer role:%s", pPeer->id, syncRole[nodeRole], syncRole[pPeer->role]); sDebug("%s, own role:%s, new peer role:%s", pPeer->id, syncRole[nodeRole], syncRole[pPeer->role]);
@ -923,7 +923,7 @@ static int syncReadPeerMsg(SSyncPeer *pPeer, SSyncHead *pHead, char *cont) {
static int syncProcessPeerMsg(void *param, void *buffer) { static int syncProcessPeerMsg(void *param, void *buffer) {
SSyncPeer *pPeer = param; SSyncPeer *pPeer = param;
SSyncHead head; SSyncHead head;
char * cont = (char *)buffer; char * cont = buffer;
SSyncNode *pNode = pPeer->pSyncNode; SSyncNode *pNode = pPeer->pSyncNode;
pthread_mutex_lock(&(pNode->mutex)); pthread_mutex_lock(&(pNode->mutex));

View File

@ -35,7 +35,7 @@ static tsem_t tsArbSem;
static ttpool_h tsArbTcpPool; static ttpool_h tsArbTcpPool;
typedef struct { typedef struct {
char id[TSDB_EP_LEN+24]; char id[TSDB_EP_LEN + 24];
int nodeFd; int nodeFd;
void *pConn; void *pConn;
} SNodeConn; } SNodeConn;
@ -43,12 +43,12 @@ typedef struct {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
char arbLogPath[TSDB_FILENAME_LEN + 16] = {0}; char arbLogPath[TSDB_FILENAME_LEN + 16] = {0};
for (int i=1; i<argc; ++i) { for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-p")==0 && i < argc-1) { if (strcmp(argv[i], "-p") == 0 && i < argc - 1) {
tsArbitratorPort = atoi(argv[++i]); tsArbitratorPort = atoi(argv[++i]);
} else if (strcmp(argv[i], "-d")==0 && i < argc-1) { } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) {
debugFlag = atoi(argv[++i]); debugFlag = atoi(argv[++i]);
} else if (strcmp(argv[i], "-g")==0 && i < argc-1) { } else if (strcmp(argv[i], "-g") == 0 && i < argc - 1) {
if (strlen(argv[++i]) > TSDB_FILENAME_LEN) continue; if (strlen(argv[++i]) > TSDB_FILENAME_LEN) continue;
tstrncpy(arbLogPath, argv[i], sizeof(arbLogPath)); tstrncpy(arbLogPath, argv[i], sizeof(arbLogPath));
} else { } else {
@ -108,8 +108,7 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp) static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp) {
{
char ipstr[24]; char ipstr[24];
tinet_ntoa(ipstr, sourceIp); tinet_ntoa(ipstr, sourceIp);
sDebug("peer TCP connection from ip:%s", ipstr); sDebug("peer TCP connection from ip:%s", ipstr);
@ -121,13 +120,14 @@ static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp)
return; return;
} }
SNodeConn *pNode = (SNodeConn *) calloc(sizeof(SNodeConn), 1); SNodeConn *pNode = (SNodeConn *)calloc(sizeof(SNodeConn), 1);
if (pNode == NULL) { if (pNode == NULL) {
sError("failed to allocate memory(%s)", strerror(errno)); sError("failed to allocate memory(%s)", strerror(errno));
taosCloseSocket(connFd); taosCloseSocket(connFd);
return; return;
} }
firstPkt.fqdn[sizeof(firstPkt.fqdn) - 1] = 0;
snprintf(pNode->id, sizeof(pNode->id), "vgId:%d peer:%s:%d", firstPkt.sourceId, firstPkt.fqdn, firstPkt.port); snprintf(pNode->id, sizeof(pNode->id), "vgId:%d peer:%s:%d", firstPkt.sourceId, firstPkt.fqdn, firstPkt.port);
if (firstPkt.syncHead.vgId) { if (firstPkt.syncHead.vgId) {
sDebug("%s, vgId in head is not zero, close the connection", pNode->id); sDebug("%s, vgId in head is not zero, close the connection", pNode->id);
@ -151,10 +151,10 @@ static void arbProcessBrokenLink(void *param) {
} }
static int arbProcessPeerMsg(void *param, void *buffer) { static int arbProcessPeerMsg(void *param, void *buffer) {
SNodeConn * pNode = param; SNodeConn *pNode = param;
SSyncHead head; SSyncHead head;
int bytes = 0; int bytes = 0;
char *cont = (char *)buffer; char * cont = (char *)buffer;
int hlen = taosReadMsg(pNode->nodeFd, &head, sizeof(head)); int hlen = taosReadMsg(pNode->nodeFd, &head, sizeof(head));
if (hlen != sizeof(head)) { if (hlen != sizeof(head)) {