From f9f0e72d1d03d3272ef2ad80a098e322ef864451 Mon Sep 17 00:00:00 2001 From: slguan Date: Wed, 12 Feb 2020 15:32:29 +0800 Subject: [PATCH] vnodePeer.h --- src/inc/taosmsg.h | 9 +- src/mnode/inc/mgmtStable.h | 2 +- src/mnode/src/mgmtStable.c | 1 + src/mnode/src/mgmtTable.c | 2 +- src/vnode/common/inc/vnodePeer.h | 56 +++++++++ .../src/vnodePeer.c} | 0 src/vnode/detail/inc/vnodePeer.h | 108 ------------------ 7 files changed, 66 insertions(+), 112 deletions(-) create mode 100644 src/vnode/common/inc/vnodePeer.h rename src/vnode/{detail/src/vnodePeer.spec.c => common/src/vnodePeer.c} (100%) delete mode 100644 src/vnode/detail/inc/vnodePeer.h diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index af60cc893a..5af7befd87 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -684,10 +684,15 @@ typedef struct { } SSecIe; typedef struct { - uint32_t ip; - uint32_t vnode; + int32_t dnode; //the ID of dnode + int32_t vnode; //the index of vnode } SVPeerDesc; +typedef struct { + int32_t numOfVPeers; + SVPeerDesc vpeerDesc[]; +} SVpeerDescArray; + typedef struct { int32_t vnode; SVnodeCfg cfg; diff --git a/src/mnode/inc/mgmtStable.h b/src/mnode/inc/mgmtStable.h index 62f71606f7..161fd816fe 100644 --- a/src/mnode/inc/mgmtStable.h +++ b/src/mnode/inc/mgmtStable.h @@ -25,7 +25,7 @@ extern "C" { #include #include "mnode.h" - +int32_t mgmtInitSTable(); #ifdef __cplusplus diff --git a/src/mnode/src/mgmtStable.c b/src/mnode/src/mgmtStable.c index 28ac58e23c..ba278f5457 100644 --- a/src/mnode/src/mgmtStable.c +++ b/src/mnode/src/mgmtStable.c @@ -34,3 +34,4 @@ #include "tsqlfunction.h" #include "ttime.h" #include "tstatus.h" + diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index e7a4aebb9c..27a5ffd4f9 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -97,7 +97,7 @@ int32_t mgmtMeterDropColumnByName(STabObj *pTable, const char *name); static int dropMeterImp(SDbObj *pDb, STabObj * pTable, SAcctObj *pAcct); static void dropAllMetersOfMetric(SDbObj *pDb, STabObj * pMetric, SAcctObj *pAcct); -void mgmtMeterActionInit() { +static void mgmtMeterActionInit() { mgmtMeterActionFp[SDB_TYPE_INSERT] = mgmtMeterActionInsert; mgmtMeterActionFp[SDB_TYPE_DELETE] = mgmtMeterActionDelete; mgmtMeterActionFp[SDB_TYPE_UPDATE] = mgmtMeterActionUpdate; diff --git a/src/vnode/common/inc/vnodePeer.h b/src/vnode/common/inc/vnodePeer.h new file mode 100644 index 0000000000..becf9bae39 --- /dev/null +++ b/src/vnode/common/inc/vnodePeer.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_VNODE_PEER_H +#define TDENGINE_VNODEPEER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "tsdb.h" + +/* + * Initialize the resources + */ +int32_t vnodeInitPeer(int numOfThreads); + +/* + * Free the resources + */ +void vnodeCleanUpPeers(); + +/* + * Start a vnode synchronization process + */ +int32_t vnodeOpenPeer(int32_t vnode); + +/* + * Update the peerinfo of vnode + */ +int32_t vnodeConfigPeer(SVpeerDescArray msg); + +/* + * Close a vnode synchronization process + */ +void vnodeCleanUpPeer(int32_t vnode); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_VNODEPEER_H diff --git a/src/vnode/detail/src/vnodePeer.spec.c b/src/vnode/common/src/vnodePeer.c similarity index 100% rename from src/vnode/detail/src/vnodePeer.spec.c rename to src/vnode/common/src/vnodePeer.c diff --git a/src/vnode/detail/inc/vnodePeer.h b/src/vnode/detail/inc/vnodePeer.h deleted file mode 100644 index 4f17e66a70..0000000000 --- a/src/vnode/detail/inc/vnodePeer.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_VNODEPEER_H -#define TDENGINE_VNODEPEER_H - -#include "os.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define TSDB_VMSG_SYNC_DATA 1 -#define TSDB_VMSG_FORWARD 2 -#define TSDB_VMSG_SYNC_REQ 3 -#define TSDB_VMSG_SYNC_RSP 4 -#define TSDB_VMSG_SYNC_MUST 5 -#define TSDB_VMSG_STATUS 6 - -#pragma pack(push, 1) - -typedef struct { - char type; - char version; - short sourceVid; - short destVid; -} SFirstPkt; - -typedef struct { - uint64_t lastCreate; - uint64_t lastRemove; - uint32_t fileId; - uint64_t fmagic[]; -} SSyncMsg; - -typedef struct { - char status; - uint64_t version; -} SPeerState; - -typedef struct { - char status : 6; - char ack : 2; - char commitInProcess; - int32_t fileId; // ID for corrupted file, 0 means no corrupted file - uint64_t version; - SPeerState peerStates[]; -} SPeerStatus; - -#pragma pack(pop) - -typedef struct _thread_obj { - pthread_t thread; - int threadId; - int pollFd; - int numOfFds; -} SThreadObj; - -typedef struct { - int numOfThreads; - SThreadObj **pThread; - pthread_t thread; - int threadId; -} SThreadPool; - -typedef struct _vnodePeer { - void * signature; - int ownId; // own vnode ID - uint32_t ip; - char ipstr[20]; // ip string - int vid; - int status; - int syncStatus; - int32_t fileId; // 0 means no corrupted file - uint64_t version; - int commitInProcess; - int syncFd; - int peerFd; // forward FD - void * hbTimer; - void * syncTimer; - SThreadObj *pThread; -} SVnodePeer; - -typedef struct { - SVnodePeer *pVPeer; - uint64_t lastCreate; - uint64_t lastRemove; - uint32_t fileId; - uint64_t fmagic[]; -} SSyncCmd; - -#ifdef __cplusplus -} -#endif - -#endif // TDENGINE_VNODEPEER_H -- GitLab