diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 96d0db5f6a0da50d0471d6c17e569c938e53d13d..dd4678802f8129d6b55cc01e12b8145394121691 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -68,38 +68,6 @@ void dnodeCleanUpModules() { } } -void dnodeProcessModuleStatus(uint32_t status) { - if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { - return; - } - - int news = status; - int olds = tsModuleStatus; - - for (int moduleType = 0; moduleType < TSDB_MOD_MAX; ++moduleType) { - int newStatus = news & (1 << moduleType); - int oldStatus = olds & (1 << moduleType); - - if (oldStatus > 0) { - if (newStatus == 0) { - if (tsModule[moduleType].stopFp) { - dPrint("module:%s is stopped on this node", tsModule[moduleType].name); - (*tsModule[moduleType].stopFp)(); - } - } - } else if (oldStatus == 0) { - if (newStatus > 0) { - if (tsModule[moduleType].startFp) { - dPrint("module:%s is started on this node", tsModule[moduleType].name); - (*tsModule[moduleType].startFp)(); - } - } - } else { - } - } - tsModuleStatus = status; -} - int32_t dnodeInitModules() { for (int mod = 0; mod < TSDB_MOD_MAX; ++mod) { if (tsModule[mod].num != 0 && tsModule[mod].initFp) { diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 67a1d42565dfac1316833208ee1c0e89bddc5293..d6127574c691c9dea8017a9f3f9d4f5b598f88fd 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -33,12 +33,14 @@ #include "dnodeVnodeMgmt.h" #ifdef CLUSTER -//#include "acct.h" -//#include "admin.h" -//#include "cluster.h" -//#include "grant.h" -//#include "replica.h" -//#include "storage.h" +#include "account.h" +#include "admin.h" +#include "balance.h" +#include "cluster.h" +#include "grant.h" +#include "mpeer.h" +#include "storage.h" +#include "vpeer.h" #endif static pthread_mutex_t tsDnodeMutex; @@ -89,8 +91,6 @@ void dnodeCleanUpSystem() { dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED); } - - dnodeCleanupShell(); dnodeCleanUpModules(); dnodeCleanupVnodes(); @@ -112,7 +112,13 @@ void dnodeCheckDataDirOpenned(const char *dir) { void dnodeInitPlugins() { #ifdef CLUSTER - acctInit(); +// acctInit(); +// adminInit(); +// balanceInit(); +// clusterInit(); +// grantInit(); +// mpeerInit(); +// storageInit(); #endif } diff --git a/src/mnode/CMakeLists.txt b/src/mnode/CMakeLists.txt index 6bf4ef34e062b8559a48daf0383e2149a7064a92..acf8b15f2263a35de39ebc9077c0e9372d985948 100644 --- a/src/mnode/CMakeLists.txt +++ b/src/mnode/CMakeLists.txt @@ -14,7 +14,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) TARGET_LINK_LIBRARIES(mnode trpc tutil sdb pthread) IF (TD_CLUSTER) - TARGET_LINK_LIBRARIES(mnode acct) + TARGET_LINK_LIBRARIES(mnode) ENDIF () ENDIF () diff --git a/src/mnode/inc/mgmtMnode.h b/src/mnode/inc/mgmtMnode.h index 9132993994922974ef23571876b4e73a6419d5e8..6e8e91ebc85d4cd84ecb99bc4c87080dc4b06544 100644 --- a/src/mnode/inc/mgmtMnode.h +++ b/src/mnode/inc/mgmtMnode.h @@ -24,8 +24,8 @@ extern "C" { #include #include "mnode.h" -int32_t mgmtInitMnodes(); -void mgmtCleanUpMnodes(); +int32_t mgmtAddMnode(uint32_t privateIp, uint32_t publicIp); +int32_t mgmtRemoveMnode(uint32_t privateIp); int32_t mgmtGetMnodeMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn); int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn); diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index 1e5fc54c5a82102b5a0dd8db840be8d1ccc0bc63..8bd9cf893393255d0259795bcc89c41b50d7d087 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -77,11 +77,3 @@ int32_t mgmtAllocVnodes(SVgObj *pVgroup) { return 0; } } - -char *mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode) { - if (mgmtGetVnodeStatusFp) { - return (*mgmtGetVnodeStatusFp)(pVgroup, pVnode); - } else { - return "master"; - } -} diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index 9cc796ec0fba265d76778253705edf118ac02bb2..b3b70d1d2e7dfa308d8bde2c706821824d9207bc 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -18,11 +18,27 @@ #include "mgmtMnode.h" #include "mgmtUser.h" -int32_t (*mgmtInitMnodesFp)() = NULL; -void (*mgmtCleanUpMnodesFp)() = NULL; +int32_t (*mgmtAddMnodeFp)(uint32_t privateIp, uint32_t publicIp) = NULL; +int32_t (*mgmtRemoveMnodeFp)(uint32_t privateIp) = NULL; int32_t (*mgmtGetMnodesNumFp)() = NULL; void * (*mgmtGetNextMnodeFp)(SShowObj *pShow, SSdbPeer **pMnode) = NULL; +int32_t mgmtAddMnode(uint32_t privateIp, uint32_t publicIp) { + if (mgmtAddMnodeFp) { + return (*mgmtAddMnodeFp)(privateIp, publicIp); + } else { + return 0; + } +} + +int32_t mgmtRemoveMnode(uint32_t privateIp) { + if (mgmtRemoveMnodeFp) { + return (*mgmtRemoveMnodeFp)(privateIp); + } else { + return 0; + } +} + static int32_t mgmtGetMnodesNum() { if (mgmtGetMnodesNumFp) { return (*mgmtGetMnodesNumFp)(); diff --git a/src/plugins/http/CMakeLists.txt b/src/plugins/http/CMakeLists.txt index 9fd299995711f8ed98052db946e5d00bda714deb..7044f5d09d0f1fe2930e4d998af0d970d76f4655 100644 --- a/src/plugins/http/CMakeLists.txt +++ b/src/plugins/http/CMakeLists.txt @@ -13,6 +13,6 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) TARGET_LINK_LIBRARIES(http taos_static z) IF (TD_CLUSTER) - TARGET_LINK_LIBRARIES(http http_admin) + TARGET_LINK_LIBRARIES(http) ENDIF () ENDIF () diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index 41b712048f301bbcbd43ae89dff3c5c0198d5398..aa66af9825e002c341ff719594b0d1c42efef877 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -34,13 +34,21 @@ #include "tgHandle.h" #include "tlog.h" -#ifdef CLUSTER - void adminInitHandle(HttpServer* pServer); - void opInitHandle(HttpServer* pServer); -#else - void adminInitHandle(HttpServer* pServer) {} - void opInitHandle(HttpServer* pServer) {} -#endif + +void (*adminInitHandleFp)(HttpServer* pServer) = NULL; +void (*opInitHandleFp)(HttpServer* pServer) = NULL; + +void adminInitHandle(HttpServer* pServer) { + if (adminInitHandleFp) { + (*adminInitHandleFp)(pServer); + } +} + +void opInitHandle(HttpServer* pServer) { + if (opInitHandleFp) { + (*opInitHandleFp)(pServer); + } +} static HttpServer *httpServer = NULL; void taosInitNote(int numOfNoteLines, int maxNotes, char* lable); diff --git a/src/sdb/CMakeLists.txt b/src/sdb/CMakeLists.txt index b0617353d9e54c40257eb29b68eb0c1ac16a32d3..47ea6e15b8cf5d8ba6f5d24c562e2b133f58f5d0 100644 --- a/src/sdb/CMakeLists.txt +++ b/src/sdb/CMakeLists.txt @@ -11,6 +11,6 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) ADD_LIBRARY(sdb ${SRC}) TARGET_LINK_LIBRARIES(sdb trpc) IF (TD_CLUSTER) - TARGET_LINK_LIBRARIES(sdb mreplica) + TARGET_LINK_LIBRARIES(sdb) ENDIF() ENDIF () diff --git a/src/sdb/inc/sdbint.h b/src/sdb/inc/sdbint.h index 8bb28b100ef88637f18073cdeb667fe4719f5e0a..30ebe0909c83f5fdefd6105e31f0ecd467d1b77d 100644 --- a/src/sdb/inc/sdbint.h +++ b/src/sdb/inc/sdbint.h @@ -84,7 +84,7 @@ typedef struct { char *row; } SSdbUpdate; -typedef struct { +typedef struct _SSdbTable { SSdbHeader header; int maxRows; int dbId; @@ -132,7 +132,7 @@ extern int sdbMaxPeers; extern int sdbNumOfTables; extern int64_t sdbVersion; -int mpeerForwardDbReqToPeer(SSdbTable *pTable, char type, char *data, int dataLen); +int sdbForwardDbReqToPeer(SSdbTable *pTable, char type, char *data, int dataLen); int mpeerRetrieveRows(int fd, SSdbTable *pTable, uint64_t version); void sdbResetTable(SSdbTable *pTable); extern const int16_t sdbFileVersion; diff --git a/src/sdb/src/sdbEngine.c b/src/sdb/src/sdbEngine.c index 0196ff084fa0eb3b1da21639d20e809f33edc234..fbc41089d1c9917aa5adae26b0052450a44e844d 100644 --- a/src/sdb/src/sdbEngine.c +++ b/src/sdb/src/sdbEngine.c @@ -430,7 +430,7 @@ int64_t sdbInsertRow(void *handle, void *row, int rowSize) { pthread_mutex_lock(&pTable->mutex); - if (mpeerForwardDbReqToPeer(pTable, SDB_TYPE_INSERT, rowHead->data, rowHead->rowSize) == 0) { + if (sdbForwardDbReqToPeer(pTable, SDB_TYPE_INSERT, rowHead->data, rowHead->rowSize) == 0) { pTable->id++; sdbVersion++; if (pTable->keyType == SDB_KEYTYPE_AUTO) { @@ -547,7 +547,7 @@ int sdbDeleteRow(void *handle, void *row) { pthread_mutex_lock(&pTable->mutex); - if (mpeerForwardDbReqToPeer(pTable, SDB_TYPE_DELETE, (char *)row, rowSize) == 0) { + if (sdbForwardDbReqToPeer(pTable, SDB_TYPE_DELETE, (char *)row, rowSize) == 0) { pTable->id++; sdbVersion++; @@ -665,7 +665,7 @@ int sdbUpdateRow(void *handle, void *row, int updateSize, char isUpdated) { pthread_mutex_lock(&pTable->mutex); - if (mpeerForwardDbReqToPeer(pTable, SDB_TYPE_UPDATE, rowHead->data, rowHead->rowSize) == 0) { + if (sdbForwardDbReqToPeer(pTable, SDB_TYPE_UPDATE, rowHead->data, rowHead->rowSize) == 0) { pTable->id++; sdbVersion++; @@ -744,7 +744,7 @@ int sdbBatchUpdateRow(void *handle, void *row, int rowSize) { } pthread_mutex_lock(&pTable->mutex); - if (mpeerForwardDbReqToPeer(pTable, SDB_TYPE_BATCH_UPDATE, row, rowSize) == 0) { + if (sdbForwardDbReqToPeer(pTable, SDB_TYPE_BATCH_UPDATE, row, rowSize) == 0) { /* // write action */ /* write(pTable->fd, &action, sizeof(action)); */ /* pTable->size += sizeof(action); */ diff --git a/src/sdb/src/sdbstr.c b/src/sdb/src/sdbstr.c index 6df779dff7acb29c5a94076860f14437ec6cba22..59c01eb15a95a7354b5f37acb1d521a5e89c100d 100644 --- a/src/sdb/src/sdbstr.c +++ b/src/sdb/src/sdbstr.c @@ -12,32 +12,47 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#define _DEFAULT_SOURCE #include "sdbint.h" -char* sdbStatusStr[] = {"offline", "unsynced", "syncing", "serving", "null"}; - -char* sdbRoleStr[] = {"unauthed", "undecided", "master", "slave", "null"}; - -#ifndef CLUSTER - -/* - * Lite Version sync request is always successful - */ -int mpeerForwardDbReqToPeer(SSdbTable *pTable, char type, char *data, int dataLen) { - return 0; +int32_t (*mpeerInitMnodesFp)(char *directory) = NULL; +void (*mpeerCleanUpMnodesFp)() = NULL; +int32_t (*mpeerForwardRequestFp)(SSdbTable *pTable, char type, void *cont, int32_t contLen) = NULL; + +char *sdbStatusStr[] = { + "offline", + "unsynced", + "syncing", + "serving", + "null" +}; + +char *sdbRoleStr[] = { + "unauthed", + "undecided", + "master", + "slave", + "null" +}; + +int32_t sdbForwardDbReqToPeer(SSdbTable *pTable, char type, char *data, int32_t dataLen) { + if (mpeerForwardRequestFp) { + return mpeerForwardRequestFp(pTable, type, data, dataLen); + } else { + return 0; + } } -/* - * Lite Version does not need to initialize peers - */ -int sdbInitPeers(char *directory) { - return 0; +int32_t sdbInitPeers(char *directory) { + if (mpeerInitMnodesFp) { + return (*mpeerInitMnodesFp)(directory); + } else { + return 0; + } } -/* - * Lite Version does not need to cleanup peers - */ -void sdbCleanUpPeers(){} - -#endif \ No newline at end of file +void sdbCleanUpPeers() { + if (mpeerCleanUpMnodesFp) { + (*mpeerCleanUpMnodesFp)(); + } +}