sync timeout
This commit is contained in:
parent
8d789bba31
commit
98b3530699
|
@ -31,11 +31,11 @@ extern "C" {
|
|||
|
||||
typedef struct SSyncIO {
|
||||
STaosQueue *pMsgQ;
|
||||
STaosQset * pQset;
|
||||
STaosQset *pQset;
|
||||
pthread_t consumerTid;
|
||||
|
||||
void * serverRpc;
|
||||
void * clientRpc;
|
||||
void *serverRpc;
|
||||
void *clientRpc;
|
||||
SEpSet myAddr;
|
||||
|
||||
void *ioTimerTickQ;
|
||||
|
@ -49,6 +49,7 @@ typedef struct SSyncIO {
|
|||
int32_t (*FpOnSyncRequestVoteReply)(SSyncNode *pSyncNode, SyncRequestVoteReply *pMsg);
|
||||
int32_t (*FpOnSyncAppendEntries)(SSyncNode *pSyncNode, SyncAppendEntries *pMsg);
|
||||
int32_t (*FpOnSyncAppendEntriesReply)(SSyncNode *pSyncNode, SyncAppendEntriesReply *pMsg);
|
||||
int32_t (*FpOnSyncTimeout)(SSyncNode *pSyncNode, SyncTimeout *pMsg);
|
||||
|
||||
int8_t isStart;
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ extern int32_t sDebugFlag;
|
|||
struct SRaft;
|
||||
typedef struct SRaft SRaft;
|
||||
|
||||
struct SyncTimeout;
|
||||
typedef struct SyncTimeout SyncTimeout;
|
||||
|
||||
struct SyncPing;
|
||||
typedef struct SyncPing SyncPing;
|
||||
|
||||
|
@ -174,6 +177,7 @@ typedef struct SSyncNode {
|
|||
int32_t (*FpOnRequestVoteReply)(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||
int32_t (*FpOnAppendEntries)(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||
int32_t (*FpOnAppendEntriesReply)(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||
int32_t (*FpOnTimeout)(SSyncNode* pSyncNode, SyncTimeout* pMsg);
|
||||
|
||||
} SSyncNode;
|
||||
|
||||
|
|
|
@ -39,12 +39,26 @@ typedef enum ESyncMessageType {
|
|||
SYNC_REQUEST_VOTE_REPLY = 111,
|
||||
SYNC_APPEND_ENTRIES = 113,
|
||||
SYNC_APPEND_ENTRIES_REPLY = 115,
|
||||
SYNC_TIMEOUT = 117,
|
||||
} ESyncMessageType;
|
||||
|
||||
// ---------------------------------------------
|
||||
cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg);
|
||||
cJSON* syncRpcUnknownMsg2Json();
|
||||
|
||||
// ---------------------------------------------
|
||||
typedef enum ESyncTimeoutType {
|
||||
SYNC_TIMEOUT_PING = 0,
|
||||
SYNC_TIMEOUT_ELECTION,
|
||||
SYNC_TIMEOUT_HEARTBEAT,
|
||||
|
||||
} ESyncTimeoutType;
|
||||
|
||||
typedef struct SyncTimeout {
|
||||
ESyncTimeoutType type;
|
||||
void* data;
|
||||
} SyncTimeout;
|
||||
|
||||
// ---------------------------------------------
|
||||
typedef struct SyncPing {
|
||||
uint32_t bytes;
|
||||
|
|
|
@ -80,7 +80,7 @@ int32_t syncIOSendMsg(void *clientRpc, const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
pMsg->msgType, pMsg->contLen);
|
||||
{
|
||||
cJSON *pJson = syncRpcMsg2Json(pMsg);
|
||||
char * serialized = cJSON_Print(pJson);
|
||||
char *serialized = cJSON_Print(pJson);
|
||||
sTrace("process syncMessage send: pMsg:%s ", serialized);
|
||||
free(serialized);
|
||||
cJSON_Delete(pJson);
|
||||
|
@ -211,7 +211,7 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
SSyncIO *io = param;
|
||||
|
||||
STaosQall *qall;
|
||||
SRpcMsg * pRpcMsg, rpcMsg;
|
||||
SRpcMsg *pRpcMsg, rpcMsg;
|
||||
int type;
|
||||
|
||||
qall = taosAllocateQall();
|
||||
|
@ -244,6 +244,8 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg);
|
||||
syncPingReplyDestroy(pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == SYNC_TIMEOUT) {
|
||||
} else {
|
||||
;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ static int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg);
|
|||
static int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||
static int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||
static int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||
static int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg);
|
||||
// ---------------------------------
|
||||
|
||||
int32_t syncInit() {
|
||||
|
@ -326,6 +327,11 @@ static int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesR
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
|
||||
int32_t ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void syncNodePingTimerCb(void* param, void* tmrId) {
|
||||
SSyncNode* pSyncNode = (SSyncNode*)param;
|
||||
if (atomic_load_8(&pSyncNode->pingTimerEnable)) {
|
||||
|
|
Loading…
Reference in New Issue