sync timeout
This commit is contained in:
parent
8d789bba31
commit
98b3530699
|
@ -49,6 +49,7 @@ typedef struct SSyncIO {
|
||||||
int32_t (*FpOnSyncRequestVoteReply)(SSyncNode *pSyncNode, SyncRequestVoteReply *pMsg);
|
int32_t (*FpOnSyncRequestVoteReply)(SSyncNode *pSyncNode, SyncRequestVoteReply *pMsg);
|
||||||
int32_t (*FpOnSyncAppendEntries)(SSyncNode *pSyncNode, SyncAppendEntries *pMsg);
|
int32_t (*FpOnSyncAppendEntries)(SSyncNode *pSyncNode, SyncAppendEntries *pMsg);
|
||||||
int32_t (*FpOnSyncAppendEntriesReply)(SSyncNode *pSyncNode, SyncAppendEntriesReply *pMsg);
|
int32_t (*FpOnSyncAppendEntriesReply)(SSyncNode *pSyncNode, SyncAppendEntriesReply *pMsg);
|
||||||
|
int32_t (*FpOnSyncTimeout)(SSyncNode *pSyncNode, SyncTimeout *pMsg);
|
||||||
|
|
||||||
int8_t isStart;
|
int8_t isStart;
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,9 @@ extern int32_t sDebugFlag;
|
||||||
struct SRaft;
|
struct SRaft;
|
||||||
typedef struct SRaft SRaft;
|
typedef struct SRaft SRaft;
|
||||||
|
|
||||||
|
struct SyncTimeout;
|
||||||
|
typedef struct SyncTimeout SyncTimeout;
|
||||||
|
|
||||||
struct SyncPing;
|
struct SyncPing;
|
||||||
typedef struct SyncPing SyncPing;
|
typedef struct SyncPing SyncPing;
|
||||||
|
|
||||||
|
@ -174,6 +177,7 @@ typedef struct SSyncNode {
|
||||||
int32_t (*FpOnRequestVoteReply)(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
int32_t (*FpOnRequestVoteReply)(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||||
int32_t (*FpOnAppendEntries)(SSyncNode* ths, SyncAppendEntries* pMsg);
|
int32_t (*FpOnAppendEntries)(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
int32_t (*FpOnAppendEntriesReply)(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
int32_t (*FpOnAppendEntriesReply)(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
|
int32_t (*FpOnTimeout)(SSyncNode* pSyncNode, SyncTimeout* pMsg);
|
||||||
|
|
||||||
} SSyncNode;
|
} SSyncNode;
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,26 @@ typedef enum ESyncMessageType {
|
||||||
SYNC_REQUEST_VOTE_REPLY = 111,
|
SYNC_REQUEST_VOTE_REPLY = 111,
|
||||||
SYNC_APPEND_ENTRIES = 113,
|
SYNC_APPEND_ENTRIES = 113,
|
||||||
SYNC_APPEND_ENTRIES_REPLY = 115,
|
SYNC_APPEND_ENTRIES_REPLY = 115,
|
||||||
|
SYNC_TIMEOUT = 117,
|
||||||
} ESyncMessageType;
|
} ESyncMessageType;
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg);
|
cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg);
|
||||||
cJSON* syncRpcUnknownMsg2Json();
|
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 {
|
typedef struct SyncPing {
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
|
|
|
@ -244,6 +244,8 @@ static void *syncIOConsumerFunc(void *param) {
|
||||||
io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg);
|
io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg);
|
||||||
syncPingReplyDestroy(pSyncMsg);
|
syncPingReplyDestroy(pSyncMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == SYNC_TIMEOUT) {
|
||||||
} else {
|
} else {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ static int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg);
|
||||||
static int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
static int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||||
static int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
static int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
static int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
static int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
|
static int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg);
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
|
|
||||||
int32_t syncInit() {
|
int32_t syncInit() {
|
||||||
|
@ -326,6 +327,11 @@ static int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesR
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
|
||||||
|
int32_t ret = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void syncNodePingTimerCb(void* param, void* tmrId) {
|
static void syncNodePingTimerCb(void* param, void* tmrId) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)param;
|
SSyncNode* pSyncNode = (SSyncNode*)param;
|
||||||
if (atomic_load_8(&pSyncNode->pingTimerEnable)) {
|
if (atomic_load_8(&pSyncNode->pingTimerEnable)) {
|
||||||
|
|
Loading…
Reference in New Issue