From 7444bf5098bcda9e01d9db35e40bd77a7af43bec Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 5 Nov 2021 19:35:21 +0800 Subject: [PATCH] minor changes --- include/dnode/mnode/sdb/sdb.h | 30 ++++++++++++++++++- source/dnode/mnode/impl/CMakeLists.txt | 1 + source/dnode/mnode/impl/inc/mnodeDef.h | 27 +---------------- source/dnode/mnode/impl/src/mnodeAcct.c | 2 +- source/dnode/mnode/impl/src/mnodeUser.c | 2 +- source/dnode/mnode/impl/src/mnodeWorker.c | 2 +- source/dnode/mnode/impl/src/mondeInt.c | 2 +- source/dnode/mnode/sdb/CMakeLists.txt | 7 +++-- source/dnode/mnode/sdb/src/sdb.c | 16 +++++++++- source/dnode/mnode/transaction/CMakeLists.txt | 2 +- 10 files changed, 56 insertions(+), 35 deletions(-) diff --git a/include/dnode/mnode/sdb/sdb.h b/include/dnode/mnode/sdb/sdb.h index cba9538ac2..678052e615 100644 --- a/include/dnode/mnode/sdb/sdb.h +++ b/include/dnode/mnode/sdb/sdb.h @@ -16,12 +16,40 @@ #ifndef _TD_MNODE_SDB_H_ #define _TD_MNODE_SDB_H_ -#include "mnodeInt.h" +#include "cJSON.h" #ifdef __cplusplus extern "C" { #endif +typedef enum { + MN_SDB_START = 0, + MN_SDB_CLUSTER = 1, + MN_SDB_DNODE = 2, + MN_SDB_MNODE = 3, + MN_SDB_ACCT = 4, + MN_SDB_AUTH = 5, + MN_SDB_USER = 6, + MN_SDB_DB = 7, + MN_SDB_VGROUP = 8, + MN_SDB_STABLE = 9, + MN_SDB_FUNC = 10, + MN_SDB_OPER = 11, + MN_SDB_MAX = 12 +} EMnSdb; + +typedef enum { MN_OP_START = 0, MN_OP_INSERT = 1, MN_OP_UPDATE = 2, MN_OP_DELETE = 3, MN_OP_MAX = 4 } EMnOp; + +typedef enum { MN_KEY_START = 0, MN_KEY_BINARY = 1, MN_KEY_INT32 = 2, MN_KEY_INT64 = 3, MN_KEY_MAX } EMnKey; + +typedef enum { MN_SDB_STAT_AVAIL = 0, MN_SDB_STAT_DROPPED = 1 } EMnSdbStat; + +typedef struct { + int8_t type; + int8_t status; + int8_t align[6]; +} SdbHead; + typedef void (*SdbDeployFp)(); typedef void *(*SdbDecodeFp)(cJSON *root); typedef int32_t (*SdbEncodeFp)(void *pHead, char *buf, int32_t maxLen); diff --git a/source/dnode/mnode/impl/CMakeLists.txt b/source/dnode/mnode/impl/CMakeLists.txt index 7c9e33c5b5..49c9d54513 100644 --- a/source/dnode/mnode/impl/CMakeLists.txt +++ b/source/dnode/mnode/impl/CMakeLists.txt @@ -7,6 +7,7 @@ target_include_directories( ) target_link_libraries( mnode + PRIVATE sdb PUBLIC transport PUBLIC cjson ) \ No newline at end of file diff --git a/source/dnode/mnode/impl/inc/mnodeDef.h b/source/dnode/mnode/impl/inc/mnodeDef.h index 0825815bc7..d3ddba332e 100644 --- a/source/dnode/mnode/impl/inc/mnodeDef.h +++ b/source/dnode/mnode/impl/inc/mnodeDef.h @@ -24,6 +24,7 @@ #include "thash.h" #include "cJSON.h" #include "mnode.h" +#include "sdb.h" #ifdef __cplusplus extern "C" { @@ -59,26 +60,6 @@ typedef struct SFuncObj SFuncObj; typedef struct SOperObj SOperObj; typedef struct SMnMsg SMnMsg; -typedef enum { - MN_SDB_START = 0, - MN_SDB_CLUSTER = 1, - MN_SDB_DNODE = 2, - MN_SDB_MNODE = 3, - MN_SDB_ACCT = 4, - MN_SDB_AUTH = 5, - MN_SDB_USER = 6, - MN_SDB_DB = 7, - MN_SDB_VGROUP = 8, - MN_SDB_STABLE = 9, - MN_SDB_FUNC = 10, - MN_SDB_OPER = 11, - MN_SDB_MAX = 12 -} EMnSdb; - -typedef enum { MN_OP_START = 0, MN_OP_INSERT = 1, MN_OP_UPDATE = 2, MN_OP_DELETE = 3, MN_OP_MAX = 4 } EMnOp; - -typedef enum { MN_KEY_START = 0, MN_KEY_BINARY = 1, MN_KEY_INT32 = 2, MN_KEY_INT64 = 3, MN_KEY_MAX } EMnKey; - typedef enum { MN_AUTH_ACCT_START = 0, MN_AUTH_ACCT_USER, @@ -97,13 +78,7 @@ typedef enum { MN_AUTH_MAX } EMnAuthOp; -typedef enum { MN_SDB_STAT_AVAIL = 0, MN_SDB_STAT_DROPPED = 1 } EMnSdbStat; -typedef struct { - int8_t type; - int8_t status; - int8_t align[6]; -} SdbHead; typedef struct SClusterObj { SdbHead head; diff --git a/source/dnode/mnode/impl/src/mnodeAcct.c b/source/dnode/mnode/impl/src/mnodeAcct.c index 39db95b6d1..ae9d666da4 100644 --- a/source/dnode/mnode/impl/src/mnodeAcct.c +++ b/source/dnode/mnode/impl/src/mnodeAcct.c @@ -15,7 +15,7 @@ #define _DEFAULT_SOURCE #include "os.h" -#include "mnodeSdb.h" +#include "mnodeInt.h" static void mnodeCreateDefaultAcct() { int32_t code = TSDB_CODE_SUCCESS; diff --git a/source/dnode/mnode/impl/src/mnodeUser.c b/source/dnode/mnode/impl/src/mnodeUser.c index 381a16ae26..4a4c086422 100644 --- a/source/dnode/mnode/impl/src/mnodeUser.c +++ b/source/dnode/mnode/impl/src/mnodeUser.c @@ -17,7 +17,7 @@ #include "os.h" #include "tkey.h" #include "tglobal.h" -#include "mnodeSdb.h" +#include "mnodeInt.h" static int32_t mnodeCreateDefaultUser(char *acct, char *user, char *pass) { int32_t code = TSDB_CODE_SUCCESS; diff --git a/source/dnode/mnode/impl/src/mnodeWorker.c b/source/dnode/mnode/impl/src/mnodeWorker.c index bdf0e869fc..4b0676f756 100644 --- a/source/dnode/mnode/impl/src/mnodeWorker.c +++ b/source/dnode/mnode/impl/src/mnodeWorker.c @@ -18,7 +18,7 @@ #include "tworker.h" #include "tglobal.h" #include "mnodeMnode.h" -#include "mnodeSdb.h" +#include "mnodeInt.h" #include "mnodeShow.h" #include "mnodeSync.h" #include "mnodeWorker.h" diff --git a/source/dnode/mnode/impl/src/mondeInt.c b/source/dnode/mnode/impl/src/mondeInt.c index eed710a1bd..d92c52e6c8 100644 --- a/source/dnode/mnode/impl/src/mondeInt.c +++ b/source/dnode/mnode/impl/src/mondeInt.c @@ -27,7 +27,7 @@ #include "mnodeMnode.h" #include "mnodeOper.h" #include "mnodeProfile.h" -#include "mnodeSdb.h" +#include "mnodeInt.h" #include "mnodeShow.h" #include "mnodeStable.h" #include "mnodeSync.h" diff --git a/source/dnode/mnode/sdb/CMakeLists.txt b/source/dnode/mnode/sdb/CMakeLists.txt index a441e38118..9bbfff3138 100644 --- a/source/dnode/mnode/sdb/CMakeLists.txt +++ b/source/dnode/mnode/sdb/CMakeLists.txt @@ -2,10 +2,13 @@ aux_source_directory(src MNODE_SRC) add_library(sdb ${MNODE_SRC}) target_include_directories( sdb - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode/sdb/inc" + PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode/sdb" private "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( sdb - PUBLIC transport + PRIVATE os + PRIVATE common + PRIVATE util + PRIVATE cjson ) \ No newline at end of file diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index f676729469..f92c487c7d 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -18,7 +18,21 @@ #include "thash.h" #include "tglobal.h" #include "cJSON.h" -#include "mnodeSdb.h" +#include "sdb.h" + +#include "os.h" +#include "taosmsg.h" +#include "tlog.h" +extern int32_t mDebugFlag; + +// mnode log function +#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", 255, __VA_ARGS__); }} +#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", 255, __VA_ARGS__); }} +#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", 255, __VA_ARGS__); }} +#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", 255, __VA_ARGS__); }} +#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} +#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} + static struct { char currDir[PATH_MAX]; diff --git a/source/dnode/mnode/transaction/CMakeLists.txt b/source/dnode/mnode/transaction/CMakeLists.txt index 59be0528e4..c598b424f2 100644 --- a/source/dnode/mnode/transaction/CMakeLists.txt +++ b/source/dnode/mnode/transaction/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src MNODE_SRC) add_library(transaction ${MNODE_SRC}) target_include_directories( transaction - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode/transaction/inc" + PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode/transaction" private "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( -- GitLab