TD-10431 interface of mnode
This commit is contained in:
parent
6781400508
commit
939c3b3a26
|
@ -30,28 +30,132 @@ typedef void (*SendRedirectMsgFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
|
|||
typedef int32_t (*PutMsgToMnodeQFp)(SDnode *pDnode, SMnodeMsg *pMsg);
|
||||
|
||||
typedef struct SMnodeLoad {
|
||||
/**
|
||||
* @brief the number of dnodes in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfDnode;
|
||||
|
||||
/**
|
||||
* @brief the number of mnodes in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfMnode;
|
||||
|
||||
/**
|
||||
* @brief the number of vgroups in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfVgroup;
|
||||
|
||||
/**
|
||||
* @brief the number of databases in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfDatabase;
|
||||
|
||||
/**
|
||||
* @brief the number of super tables in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfSuperTable;
|
||||
|
||||
/**
|
||||
* @brief the number of child tables in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfChildTable;
|
||||
|
||||
/**
|
||||
* @brief the number of normal tables in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfNormalTable;
|
||||
|
||||
/**
|
||||
* @brief the number of numOfTimeseries in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t numOfColumn;
|
||||
|
||||
/**
|
||||
* @brief total points written in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t totalPoints;
|
||||
|
||||
/**
|
||||
* @brief total storage in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t totalStorage;
|
||||
|
||||
/**
|
||||
* @brief total compressed storage in cluster.
|
||||
*
|
||||
*/
|
||||
int64_t compStorage;
|
||||
} SMnodeLoad;
|
||||
|
||||
typedef struct {
|
||||
int32_t dnodeId;
|
||||
int64_t clusterId;
|
||||
int8_t replica;
|
||||
int8_t selfIndex;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
SDnode *pDnode;
|
||||
PutMsgToMnodeQFp putMsgToApplyMsgFp;
|
||||
SendMsgToDnodeFp sendMsgToDnodeFp;
|
||||
SendMsgToMnodeFp sendMsgToMnodeFp;
|
||||
/**
|
||||
* @brief dnodeId of this mnode.
|
||||
*
|
||||
*/
|
||||
int32_t dnodeId;
|
||||
|
||||
/**
|
||||
* @brief clusterId of this mnode.
|
||||
*
|
||||
*/
|
||||
int64_t clusterId;
|
||||
|
||||
/**
|
||||
* @brief replica num of this mnode.
|
||||
*
|
||||
*/
|
||||
int8_t replica;
|
||||
|
||||
/**
|
||||
* @brief self index in the array of replicas.
|
||||
*
|
||||
*/
|
||||
int8_t selfIndex;
|
||||
|
||||
/**
|
||||
* @brief detail replica information of this mnode.
|
||||
*
|
||||
*/
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
|
||||
/**
|
||||
* @brief the parent dnode of this mnode.
|
||||
*
|
||||
*/
|
||||
SDnode *pDnode;
|
||||
|
||||
/**
|
||||
* @brief put apply msg to the write queue in dnode.
|
||||
*
|
||||
*/
|
||||
PutMsgToMnodeQFp putMsgToApplyMsgFp;
|
||||
|
||||
/**
|
||||
* @brief the callback function while send msg to dnode.
|
||||
*
|
||||
*/
|
||||
SendMsgToDnodeFp sendMsgToDnodeFp;
|
||||
|
||||
/**
|
||||
* @brief the callback function while send msg to mnode.
|
||||
*
|
||||
*/
|
||||
SendMsgToMnodeFp sendMsgToMnodeFp;
|
||||
|
||||
/**
|
||||
* @brief the callback function while send redirect msg to clients or peers.
|
||||
*
|
||||
*/
|
||||
SendRedirectMsgFp sendRedirectMsgFp;
|
||||
} SMnodeOpt;
|
||||
|
||||
|
@ -59,25 +163,25 @@ typedef struct {
|
|||
/**
|
||||
* @brief Open a mnode.
|
||||
*
|
||||
* @param path Path of the mnode
|
||||
* @param pOption Option of the mnode
|
||||
* @return SMnode* The mnode object
|
||||
* @param path Path of the mnode.
|
||||
* @param pOption Option of the mnode.
|
||||
* @return SMnode* The mnode object.
|
||||
*/
|
||||
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption);
|
||||
|
||||
/**
|
||||
* @brief Close a mnode
|
||||
* @brief Close a mnode.
|
||||
*
|
||||
* @param pMnode The mnode object to close
|
||||
* @param pMnode The mnode object to close.
|
||||
*/
|
||||
void mndClose(SMnode *pMnode);
|
||||
|
||||
/**
|
||||
* @brief Close a mnode
|
||||
* @brief Close a mnode.
|
||||
*
|
||||
* @param pMnode The mnode object to close
|
||||
* @param pOption Options of the mnode
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @param pMnode The mnode object to close.
|
||||
* @param pOption Options of the mnode.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
|
||||
|
||||
|
@ -89,80 +193,80 @@ int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
|
|||
void mndDestroy(const char *path);
|
||||
|
||||
/**
|
||||
* @brief Get mnode statistics info
|
||||
* @brief Get mnode statistics info.
|
||||
*
|
||||
* @param pMnode The mnode object
|
||||
* @param pMnode The mnode object.
|
||||
* @param pLoad Statistics of the mnode.
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
||||
|
||||
/**
|
||||
* @brief Get user authentication info
|
||||
* @brief Get user authentication info.
|
||||
*
|
||||
* @param pMnode The mnode object
|
||||
* @param pMnode The mnode object.
|
||||
* @param user
|
||||
* @param spi
|
||||
* @param encrypt
|
||||
* @param secret
|
||||
* @param ckey
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
|
||||
/**
|
||||
* @brief Initialize mnode msg
|
||||
* @brief Initialize mnode msg.
|
||||
*
|
||||
* @param pMnode The mnode object
|
||||
* @param pMsg The request rpc msg
|
||||
* @return int32_t The created mnode msg
|
||||
* @param pMnode The mnode object.
|
||||
* @param pMsg The request rpc msg.
|
||||
* @return int32_t The created mnode msg.
|
||||
*/
|
||||
SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg);
|
||||
|
||||
/**
|
||||
* @brief Cleanup mnode msg
|
||||
* @brief Cleanup mnode msg.
|
||||
*
|
||||
* @param pMsg The request msg
|
||||
* @param pMsg The request msg.
|
||||
*/
|
||||
void mndCleanupMsg(SMnodeMsg *pMsg);
|
||||
|
||||
/**
|
||||
* @brief Cleanup mnode msg
|
||||
* @brief Cleanup mnode msg.
|
||||
*
|
||||
* @param pMsg The request msg
|
||||
* @param code The error code
|
||||
* @param pMsg The request msg.
|
||||
* @param code The error code.
|
||||
*/
|
||||
void mndSendRsp(SMnodeMsg *pMsg, int32_t code);
|
||||
|
||||
/**
|
||||
* @brief Process the read request
|
||||
* @brief Process the read request.
|
||||
*
|
||||
* @param pMsg The request msg
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @param pMsg The request msg.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
void mndProcessReadMsg(SMnodeMsg *pMsg);
|
||||
|
||||
/**
|
||||
* @brief Process the write request
|
||||
* @brief Process the write request.
|
||||
*
|
||||
* @param pMsg The request msg
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @param pMsg The request msg.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
void mndProcessWriteMsg(SMnodeMsg *pMsg);
|
||||
|
||||
/**
|
||||
* @brief Process the sync request
|
||||
* @brief Process the sync request.
|
||||
*
|
||||
* @param pMsg The request msg
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @param pMsg The request msg.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
void mndProcessSyncMsg(SMnodeMsg *pMsg);
|
||||
|
||||
/**
|
||||
* @brief Process the apply request
|
||||
* @brief Process the apply request.
|
||||
*
|
||||
* @param pMsg The request msg
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
* @param pMsg The request msg.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
void mndProcessApplyMsg(SMnodeMsg *pMsg);
|
||||
|
||||
|
|
|
@ -130,36 +130,162 @@ typedef struct SSdb SSdb;
|
|||
typedef int32_t (*SdbInsertFp)(SSdb *pSdb, void *pObj);
|
||||
typedef int32_t (*SdbUpdateFp)(SSdb *pSdb, void *pSrcObj, void *pDstObj);
|
||||
typedef int32_t (*SdbDeleteFp)(SSdb *pSdb, void *pObj);
|
||||
typedef int32_t (*SdbDeployFp)(SSdb*pSdb);
|
||||
typedef int32_t (*SdbDeployFp)(SSdb *pSdb);
|
||||
typedef SSdbRow *(*SdbDecodeFp)(SSdbRaw *pRaw);
|
||||
typedef SSdbRaw *(*SdbEncodeFp)(void *pObj);
|
||||
|
||||
typedef struct {
|
||||
ESdbType sdbType;
|
||||
EKeyType keyType;
|
||||
/**
|
||||
* @brief The sdb type of the table.
|
||||
*
|
||||
*/
|
||||
ESdbType sdbType;
|
||||
|
||||
/**
|
||||
* @brief The key type of the table.
|
||||
*
|
||||
*/
|
||||
EKeyType keyType;
|
||||
|
||||
/**
|
||||
* @brief The callback function when the table is first deployed.
|
||||
*
|
||||
*/
|
||||
SdbDeployFp deployFp;
|
||||
|
||||
/**
|
||||
* @brief Encode one row of the table into rawdata.
|
||||
*
|
||||
*/
|
||||
SdbEncodeFp encodeFp;
|
||||
|
||||
/**
|
||||
* @brief Decode one row of the table from rawdata.
|
||||
*
|
||||
*/
|
||||
SdbDecodeFp decodeFp;
|
||||
|
||||
/**
|
||||
* @brief The callback function when insert a row to sdb.
|
||||
*
|
||||
*/
|
||||
SdbInsertFp insertFp;
|
||||
|
||||
/**
|
||||
* @brief The callback function when undate a row in sdb.
|
||||
*
|
||||
*/
|
||||
SdbUpdateFp updateFp;
|
||||
|
||||
/**
|
||||
* @brief The callback function when delete a row from sdb.
|
||||
*
|
||||
*/
|
||||
SdbDeleteFp deleteFp;
|
||||
} SSdbTable;
|
||||
|
||||
typedef struct SSdbOpt {
|
||||
/**
|
||||
* @brief The path of the sdb file.
|
||||
*
|
||||
*/
|
||||
const char *path;
|
||||
} SSdbOpt;
|
||||
|
||||
SSdb *sdbInit(SSdbOpt *pOption);
|
||||
void sdbCleanup(SSdb *pSdb);
|
||||
/**
|
||||
* @brief Initialize and start the sdb.
|
||||
*
|
||||
* @param pOption Option of the sdb.
|
||||
* @return SSdb* The sdb object.
|
||||
*/
|
||||
SSdb *sdbInit(SSdbOpt *pOption);
|
||||
|
||||
/**
|
||||
* @brief Stop and cleanup the sdb.
|
||||
*
|
||||
* @param pSdb The sdb object to close.
|
||||
*/
|
||||
void sdbCleanup(SSdb *pSdb);
|
||||
|
||||
/**
|
||||
* @brief Set the properties of sdb table.
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param table The properties of the table.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t sdbSetTable(SSdb *pSdb, SSdbTable table);
|
||||
|
||||
/**
|
||||
* @brief Set the initial rows of sdb.
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t sdbDeploy(SSdb *pSdb);
|
||||
|
||||
/**
|
||||
* @brief Load sdb from file.
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t sdbReadFile(SSdb *pSdb);
|
||||
|
||||
/**
|
||||
* @brief Parse and write raw data to sdb.
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param pRaw The raw data.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t sdbWrite(SSdb *pSdb, SSdbRaw *pRaw);
|
||||
|
||||
void *sdbAcquire(SSdb *pSdb, ESdbType type, void *pKey);
|
||||
void sdbRelease(SSdb *pSdb, void *pObj);
|
||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj);
|
||||
void sdbCancelFetch(SSdb *pSdb, void *pIter);
|
||||
/**
|
||||
* @brief Acquire a row from sdb
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param type The type of the row.
|
||||
* @param pKey The key value of the row.
|
||||
* @return void* The object of the row.
|
||||
*/
|
||||
void *sdbAcquire(SSdb *pSdb, ESdbType type, void *pKey);
|
||||
|
||||
/**
|
||||
* @brief Release a row from sdb.
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param pObj The object of the row.
|
||||
*/
|
||||
void sdbRelease(SSdb *pSdb, void *pObj);
|
||||
|
||||
/**
|
||||
* @brief Traverse a sdb table
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param type The type of the table.
|
||||
* @param type The initial iterator of the table.
|
||||
* @param pObj The object of the row just fetched.
|
||||
* @return void* The next iterator of the table.
|
||||
*/
|
||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj);
|
||||
|
||||
/**
|
||||
* @brief Cancel a traversal
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param pIter The iterator of the table.
|
||||
* @param type The initial iterator of table.
|
||||
*/
|
||||
void sdbCancelFetch(SSdb *pSdb, void *pIter);
|
||||
|
||||
/**
|
||||
* @brief Get the number of rows in the table
|
||||
*
|
||||
* @param pSdb The sdb object.
|
||||
* @param pIter The type of the table.
|
||||
* @record int32_t The number of rows in the table
|
||||
*/
|
||||
int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
|
||||
|
||||
SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen);
|
||||
|
|
|
@ -12,5 +12,5 @@ target_link_libraries(
|
|||
target_include_directories(
|
||||
dnode
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mgmt"
|
||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
|
|
@ -3,11 +3,11 @@ add_library(mnode ${MNODE_SRC})
|
|||
target_include_directories(
|
||||
mnode
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode"
|
||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
mnode
|
||||
PRIVATE sdb
|
||||
PUBLIC transport
|
||||
PUBLIC cjson
|
||||
PRIVATE transport
|
||||
PRIVATE cjson
|
||||
)
|
|
@ -3,7 +3,7 @@ add_library(sdb ${MNODE_SRC})
|
|||
target_include_directories(
|
||||
sdb
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode/sdb"
|
||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
sdb
|
||||
|
|
Loading…
Reference in New Issue