2022-02-22 03:28:15 +00:00
|
|
|
#include <stdio.h>
|
2022-02-23 07:17:49 +00:00
|
|
|
#include "syncIO.h"
|
2022-02-23 01:54:44 +00:00
|
|
|
#include "syncInt.h"
|
2022-02-23 12:14:37 +00:00
|
|
|
#include "syncRaftStore.h"
|
2022-02-22 03:28:15 +00:00
|
|
|
|
2022-02-23 08:14:02 +00:00
|
|
|
void *pingFunc(void *param) {
|
|
|
|
|
SSyncIO *io = (SSyncIO *)param;
|
|
|
|
|
while (1) {
|
|
|
|
|
sDebug("io->ping");
|
|
|
|
|
io->ping(io);
|
|
|
|
|
sleep(1);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-22 03:28:15 +00:00
|
|
|
int main() {
|
2022-02-24 12:22:55 +00:00
|
|
|
taosInitLog((char *)"syncTest.log", 100000, 10);
|
2022-02-25 06:38:12 +00:00
|
|
|
tsAsyncLog = 0;
|
|
|
|
|
sDebugFlag = 143 + 64;
|
|
|
|
|
|
|
|
|
|
sTrace("sync log test: trace");
|
|
|
|
|
sDebug("sync log test: debug");
|
|
|
|
|
sInfo("sync log test: info");
|
|
|
|
|
sWarn("sync log test: warn");
|
|
|
|
|
sError("sync log test: error");
|
|
|
|
|
sFatal("sync log test: fatal");
|
|
|
|
|
|
|
|
|
|
|
2022-02-24 12:22:55 +00:00
|
|
|
|
|
|
|
|
SRaftStore *pRaftStore = raftStoreOpen("./raft_store.json");
|
|
|
|
|
assert(pRaftStore != NULL);
|
|
|
|
|
|
|
|
|
|
raftStorePrint(pRaftStore);
|
|
|
|
|
|
|
|
|
|
pRaftStore->currentTerm = 100;
|
|
|
|
|
pRaftStore->voteFor.addr = 200;
|
|
|
|
|
pRaftStore->voteFor.vgId = 300;
|
|
|
|
|
|
|
|
|
|
raftStorePrint(pRaftStore);
|
|
|
|
|
|
|
|
|
|
raftStorePersist(pRaftStore);
|
|
|
|
|
|
2022-02-23 07:17:49 +00:00
|
|
|
sDebug("sync test");
|
2022-02-24 13:03:25 +00:00
|
|
|
|
2022-02-23 07:17:49 +00:00
|
|
|
SSyncIO *syncIO = syncIOCreate();
|
|
|
|
|
assert(syncIO != NULL);
|
2022-02-23 01:54:44 +00:00
|
|
|
|
2022-02-23 08:14:02 +00:00
|
|
|
syncIO->start(syncIO);
|
|
|
|
|
|
|
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
|
|
pthread_t tid;
|
|
|
|
|
pthread_create(&tid, NULL, pingFunc, syncIO);
|
|
|
|
|
|
2022-02-23 07:17:49 +00:00
|
|
|
while (1) {
|
2022-02-23 08:14:02 +00:00
|
|
|
sleep(1);
|
2022-02-23 07:17:49 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
2022-02-22 03:28:15 +00:00
|
|
|
}
|