add syncReplicateTest.cpp
This commit is contained in:
parent
a6b949831a
commit
49cf252495
|
@ -117,11 +117,9 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
|
|||
|
||||
int64_t rid = syncOpen(&syncInfo);
|
||||
assert(rid > 0);
|
||||
syncStart(rid);
|
||||
|
||||
SSyncNode* pSyncNode = (SSyncNode*)syncNodeAcquire(rid);
|
||||
assert(pSyncNode != NULL);
|
||||
|
||||
gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing;
|
||||
gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply;
|
||||
gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote;
|
||||
|
@ -131,9 +129,9 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
|
|||
gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing;
|
||||
gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply;
|
||||
gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout;
|
||||
gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest;
|
||||
gSyncIO->pSyncNode = pSyncNode;
|
||||
|
||||
syncNodeStart(pSyncNode);
|
||||
syncNodeRelease(pSyncNode);
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
@ -144,8 +142,8 @@ SRpcMsg *createRpcMsg(int i, int count, int myIndex) {
|
|||
SRpcMsg* pMsg = (SRpcMsg*)taosMemoryMalloc(sizeof(SRpcMsg));
|
||||
memset(pMsg, 0, sizeof(SRpcMsg));
|
||||
pMsg->msgType = 9999;
|
||||
pMsg->contLen = 128;
|
||||
pMsg->pCont = taosMemoryMalloc(pMsg->contLen);
|
||||
pMsg->contLen = 256;
|
||||
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
||||
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%ld", myIndex, i, count, taosGetTimestampMs());
|
||||
return pMsg;
|
||||
}
|
||||
|
@ -187,7 +185,6 @@ int main(int argc, char** argv) {
|
|||
int32_t alreadySend = 0;
|
||||
while (1) {
|
||||
char* s = syncNode2SimpleStr(pSyncNode);
|
||||
sTrace("%s", s);
|
||||
|
||||
if (alreadySend < writeRecordNum) {
|
||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||
|
@ -200,8 +197,10 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
alreadySend++;
|
||||
|
||||
//rpcFreeCont(pRpcMsg->pCont);
|
||||
rpcFreeCont(pRpcMsg->pCont);
|
||||
taosMemoryFree(pRpcMsg);
|
||||
} else {
|
||||
sTrace("%s", s);
|
||||
}
|
||||
|
||||
taosMsleep(1000);
|
||||
|
|
Loading…
Reference in New Issue