diff --git a/include/dnode/mnode/sdb/sdb.h b/include/dnode/mnode/sdb/sdb.h index cba9538ac259c840642ade0399f3e1239c79c535..678052e615bcacb1eced9ab1c5a56072ab8b8723 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 7c9e33c5b545e4004fdc24f4a5d66814f8fe643c..49c9d5451355b4b9567a84e5ddccd6781b4b4569 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 0825815bc7a418cc50e0bd66932c7eb9ec63f5ac..d3ddba332e2fe2bdf1f0bb9c69ce0df7fbef0cbb 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 39db95b6d12fd019dd128e790d8fc487fd1edc3a..ae9d666da4a0392909ea84691d51a50ab8b7f1f1 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 381a16ae265af7f3aaf277f818b9022c444b138c..4a4c0864225012516afe364c8dad92e079da271f 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 bdf0e869fc4732b339e677609a686076e9533d82..4b0676f756a70a8f66aa76ce131d86c819f6ebad 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 eed710a1bd7f2bda371bd6c43a0333f2addfc445..d92c52e6c8438c735fee860b0940188ca7b60375 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 a441e38118c2c0b8aa9a5e2368c59a45d4523828..9bbfff3138079062b5202ea114ea4d313c81474c 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 f676729469173a15e98967723bc640c7a9092344..f92c487c7d417852518bfd5ff4fa1bcfcf190a57 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 59be0528e4efa3f1451e3c383deddb7707dc3a75..c598b424f22f0db320936fecc0cebc5a9741a141 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(