refactor(sync): add test syncRaftIdCheck
This commit is contained in:
parent
fa25fa32e0
commit
71dad1ea78
|
@ -14,6 +14,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "syncUtil.h"
|
#include "syncUtil.h"
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "syncEnv.h"
|
#include "syncEnv.h"
|
||||||
|
|
||||||
void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port);
|
void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port);
|
||||||
|
@ -22,7 +28,20 @@ void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port);
|
||||||
uint64_t syncUtilAddr2U64(const char* host, uint16_t port) {
|
uint64_t syncUtilAddr2U64(const char* host, uint16_t port) {
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
uint32_t hostU32 = (uint32_t)taosInetAddr(host);
|
uint32_t hostU32 = (uint32_t)taosInetAddr(host);
|
||||||
// assert(hostU32 != (uint32_t)-1);
|
if (hostU32 == (uint32_t)-1) {
|
||||||
|
struct hostent* hostEnt = gethostbyname(host);
|
||||||
|
if (hostEnt == NULL) {
|
||||||
|
sError("Get IP address error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* newHost = taosInetNtoa(*(struct in_addr*)(hostEnt->h_addr_list[0]));
|
||||||
|
hostU32 = (uint32_t)taosInetAddr(newHost);
|
||||||
|
if (hostU32 == (uint32_t)-1) {
|
||||||
|
sError("change %s to id, error", newHost);
|
||||||
|
}
|
||||||
|
// ASSERT(hostU32 != (uint32_t)-1);
|
||||||
|
}
|
||||||
u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16);
|
u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16);
|
||||||
return u64;
|
return u64;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue