Merge branch '3.0' of github.com:taosdata/tdengine into 3.0
This commit is contained in:
commit
05b1554a35
|
@ -0,0 +1,42 @@
|
||||||
|
# Small Materialized Aggragates
|
||||||
|
|
||||||
|
**SMA** (**S**mall **M**aterialized **A**ggrates) is used to speed up the query process on materialized data cube in TDengine. TDengine 3.0 gives more flexibility on the SMA configurations.
|
||||||
|
|
||||||
|
There are two kinds of SMA in TDengine:
|
||||||
|
1. Block-wise SMA
|
||||||
|
2. Time-range-wise SMA
|
||||||
|
|
||||||
|
<!--
|
||||||
|
```plantuml
|
||||||
|
@startmindmap mind_map_test
|
||||||
|
* SMA
|
||||||
|
** Block-wise SMA
|
||||||
|
** Time-range-wise SMA
|
||||||
|
@endmindmap
|
||||||
|
``` -->
|
||||||
|
|
||||||
|

|
||||||
|
## Block-wise SMA
|
||||||
|
Block-wise SMA is created by default when the data are committed. Since time-series data are saved as block data in files, a corresponding SMA is create when the data block is written. The default block-wise SMA includes:
|
||||||
|
1. sum(*)
|
||||||
|
2. max(*)
|
||||||
|
3. min(*)
|
||||||
|
|
||||||
|
By default, the system will create SMA for each column except those columns with type *binary* and *nchar*. However, users can change the behavior by the keyword **NOSMA** to disable the SMA for a certain column like below:
|
||||||
|
```SQL
|
||||||
|
# create a super table with the SMA on column b disabled
|
||||||
|
create table st (ts timestamp, a int, b int NOSMA, c double) tags (tg1 binary(10), tg2 int);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Time-range-wise SMA
|
||||||
|
In addition to the default block-wise SMA, users can create their own SMAs ondemand. Below is an example to create a SMA.
|
||||||
|
```SQL
|
||||||
|
# create a SMA every 10 minutes with SMA of sum, max and min
|
||||||
|
create sma_indx sma_10min on st (sum(*), max(*), min(*), twa(*)) interval(10m);
|
||||||
|
```
|
||||||
|
Users can also drop a time-range-wise SMA like below:
|
||||||
|
```SQL
|
||||||
|
# drop the sma index
|
||||||
|
drop sma_index sma_5min on st;
|
||||||
|
```
|
||||||
|
**NOTE: Creating an SMA index is a heavy operation which may take a long time and block the write operation. So create the time-range-wise SMA when creating the table or when there are not too much data.**
|
|
@ -36,91 +36,104 @@ enum {
|
||||||
TSDB_MESSAGE_NULL = 0,
|
TSDB_MESSAGE_NULL = 0,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// message from client to dnode
|
// message from client to vnode
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SUBMIT, "submit" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SUBMIT, "submit" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_QUERY, "query" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_QUERY, "query" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_FETCH, "fetch" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_FETCH, "fetch" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_TABLE, "create-table" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_TABLE, "drop-table" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_TABLE, "alter-table" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_UPDATE_TAG_VAL, "update-tag-val" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_UPDATE_TAG_VAL, "update-tag-val" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONNECT, "mq-connect" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_TABLE_META, "table-meta" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_DISCONNECT, "mq-disconnect" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_TABLES_META, "tables-meta" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONSUME, "mq-consume" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONSUME, "mq-consume" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_QUERY, "mq-query" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_QUERY, "mq-query" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_CONNECT, "mq-connect" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_DISCONNECT, "mq-disconnect" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_ACK, "mq-ack" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_ACK, "mq-ack" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_RESET, "mq-reset" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MQ_RESET, "mq-reset" )
|
||||||
|
// message from client to mnode
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONNECT, "connect" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_ACCT, "create-acct" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_ACCT, "alter-acct" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_ACCT, "drop-acct" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_USER, "create-user" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_USER, "alter-user" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_USER, "drop-user" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_DNODE, "create-dnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONFIG_DNODE, "config-dnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_DNODE, "drop-dnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_DB, "create-db" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_DB, "drop-db" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_USE_DB, "use-db" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_DB, "alter-db" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SYNC_DB, "sync-db" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_TOPIC, "create-topic" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_TOPIC, "drop-topic" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_TOPIC, "alter-topic" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_FUNCTION, "create-function" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_FUNCTION, "alter-function" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_FUNCTION, "drop-function" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_STABLE, "create-stable" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_STABLE_VGROUP, "stable-vgroup" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_STABLE, "drop-stable" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_STABLE, "alter-stable" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_KILL_QUERY, "kill-query" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_KILL_CONN, "kill-conn" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_HEARTBEAT, "heartbeat" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SHOW, "show" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SHOW_RETRIEVE, "retrieve" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SHOW_RETRIEVE_FUNC, "retrieve-func" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_COMPACT_VNODE, "compact-vnode" )
|
||||||
|
// message from client to qnode
|
||||||
|
// message from client to dnode
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_NETWORK_TEST, "nettest" )
|
||||||
|
|
||||||
|
// message from vnode to vnode
|
||||||
|
// message from vnode to mnode
|
||||||
|
// message from vnode to qnode
|
||||||
|
// message from vnode to dnode
|
||||||
|
|
||||||
|
// message from mnode to vnode
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_STABLE_IN, "create-stable" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_STABLE_IN, "alter-stable" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_STABLE_IN, "drop-stable" )
|
||||||
|
// message from mnode to mnode
|
||||||
|
// message from mnode to qnode
|
||||||
|
// message from mnode to dnode
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_VNODE_IN, "create-vnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_ALTER_VNODE_IN, "alter-vnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_VNODE_IN, "drop-vnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_AUTH_VNODE_IN, "auth-vnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SYNC_VNODE_IN, "sync-vnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_COMPACT_VNODE_IN, "compact-vnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CREATE_MNODE_IN, "create-mnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DROP_MNODE_IN, "drop-mnode" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CONFIG_DNODE_IN, "config-dnode" )
|
||||||
|
|
||||||
|
// message from qnode to vnode
|
||||||
|
// message from qnode to mnode
|
||||||
|
// message from qnode to qnode
|
||||||
|
// message from qnode to dnode
|
||||||
|
|
||||||
|
// message from dnode to vnode
|
||||||
|
// message from dnode to mnode
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_STATUS, "status" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_GRANT, "grant" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_AUTH, "auth" )
|
||||||
|
// message from dnode to qnode
|
||||||
|
// message from dnode to dnode
|
||||||
|
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY0, "dummy0" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY1, "dummy1" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY1, "dummy1" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY2, "dummy2" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY2, "dummy2" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY3, "dummy3" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY3, "dummy3" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY4, "dummy4" )
|
||||||
// message from mnode to dnode
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY5, "dummy5" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_TABLE, "create-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_TABLE, "drop-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_TABLE, "alter-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_VNODE, "create-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_VNODE, "drop-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_STABLE, "drop-stable" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_STREAM, "alter-stream" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CONFIG_DNODE, "config-dnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_VNODE, "alter-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_SYNC_VNODE, "sync-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_MNODE, "create-mnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_COMPACT_VNODE, "compact-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY6, "dummy6" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY6, "dummy6" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY7, "dummy7" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY7, "dummy7" )
|
||||||
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY8, "dummy8" )
|
||||||
|
|
||||||
// message from client to mnode
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONNECT, "connect" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_ACCT, "create-acct" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_ACCT, "alter-acct" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_ACCT, "drop-acct" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_USER, "create-user" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_USER, "alter-user" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_USER, "drop-user" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DNODE, "create-dnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_DNODE, "drop-dnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DB, "create-db" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_FUNCTION, "create-function" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_DB, "drop-db" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_FUNCTION, "drop-function" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_USE_DB, "use-db" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_DB, "alter-db" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_SYNC_DB, "sync-db-replica" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_TABLE, "create-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_TABLE, "drop-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_TABLE, "alter-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLE_META, "table-meta" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_STABLE_VGROUP, "stable-vgroup" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_COMPACT_VNODE, "compact-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLES_META, "multiTable-meta" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_STREAM, "alter-stream" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_SHOW, "show" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_RETRIEVE, "retrieve" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_QUERY, "kill-query" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_STREAM, "kill-stream" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_CONN, "kill-conn" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONFIG_DNODE, "cm-config-dnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_HEARTBEAT, "heartbeat" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_RETRIEVE_FUNC, "retrieve-func" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY9, "dummy9" )
|
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY9, "dummy9" )
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY10, "dummy10" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY11, "dummy11" )
|
|
||||||
|
|
||||||
// message from dnode to mnode
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_AUTH, "auth" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_NETWORK_TEST, "nettest" )
|
|
||||||
|
|
||||||
// message for topic
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_TP, "create-tp" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_DROP_TP, "drop-tp" )
|
|
||||||
//TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_USE_TP, "use-tp" )
|
|
||||||
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_TP, "alter-tp" )
|
|
||||||
|
|
||||||
#ifndef TAOS_MESSAGE_C
|
#ifndef TAOS_MESSAGE_C
|
||||||
TSDB_MSG_TYPE_MAX // 147
|
TSDB_MSG_TYPE_MAX // 147
|
||||||
|
@ -312,7 +325,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
char tableFname[TSDB_TABLE_FNAME_LEN];
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
int16_t type; /* operation type */
|
int16_t type; /* operation type */
|
||||||
int16_t numOfCols; /* number of schema */
|
int16_t numOfCols; /* number of schema */
|
||||||
int32_t tagValLen;
|
int32_t tagValLen;
|
||||||
|
@ -404,10 +417,6 @@ typedef struct {
|
||||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
char tableFname[TSDB_TABLE_FNAME_LEN];
|
||||||
} SDropSTableMsg;
|
} SDropSTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t vgId;
|
|
||||||
} SDropVnodeMsg, SSyncVnodeMsg, SCompactVnodeMsg;
|
|
||||||
|
|
||||||
typedef struct SColIndex {
|
typedef struct SColIndex {
|
||||||
int16_t colId; // column id
|
int16_t colId; // column id
|
||||||
int16_t colIndex; // column index in colList if it is a normal column or index in tagColList if a tag
|
int16_t colIndex; // column index in colList if it is a normal column or index in tagColList if a tag
|
||||||
|
@ -561,21 +570,7 @@ typedef struct SRetrieveTableRsp {
|
||||||
} SRetrieveTableRsp;
|
} SRetrieveTableRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
int32_t dbCfgVersion;
|
|
||||||
int64_t totalStorage;
|
|
||||||
int64_t compStorage;
|
|
||||||
int64_t pointsWritten;
|
|
||||||
uint64_t vnodeVersion;
|
|
||||||
int32_t vgCfgVersion;
|
|
||||||
uint8_t status;
|
|
||||||
uint8_t role;
|
|
||||||
uint8_t replica;
|
|
||||||
uint8_t compact;
|
|
||||||
} SVnodeLoad;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
|
||||||
int32_t cacheBlockSize; //MB
|
int32_t cacheBlockSize; //MB
|
||||||
int32_t totalBlocks;
|
int32_t totalBlocks;
|
||||||
int32_t maxTables;
|
int32_t maxTables;
|
||||||
|
@ -640,28 +635,46 @@ typedef struct {
|
||||||
uint8_t ignoreNotExists;
|
uint8_t ignoreNotExists;
|
||||||
} SDropDbMsg, SUseDbMsg, SSyncDbMsg;
|
} SDropDbMsg, SUseDbMsg, SSyncDbMsg;
|
||||||
|
|
||||||
// IMPORTANT: sizeof(SVnodeStatisticInfo) should not exceed
|
|
||||||
// TSDB_FILE_HEADER_LEN/4 - TSDB_FILE_HEADER_VERSION_SIZE
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t pointsWritten; // In unit of points
|
int32_t statusInterval;
|
||||||
int64_t totalStorage; // In unit of bytes
|
int8_t reserved[4];
|
||||||
int64_t compStorage; // In unit of bytes
|
int64_t checkTime; // 1970-01-01 00:00:00.000
|
||||||
int64_t queryTime; // In unit of second ??
|
char timezone[TSDB_TIMEZONE_LEN]; // tsTimezone
|
||||||
char reserved[64];
|
char locale[TSDB_LOCALE_LEN]; // tsLocale
|
||||||
} SVnodeStatisticInfo;
|
char charset[TSDB_LOCALE_LEN]; // tsCharset
|
||||||
|
} SClusterCfg;
|
||||||
|
|
||||||
typedef struct SVgroupAccess {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int8_t accessState;
|
int8_t role;
|
||||||
} SVgroupAccess;
|
int8_t reserved[3];
|
||||||
|
int64_t totalStorage;
|
||||||
|
int64_t compStorage;
|
||||||
|
int64_t pointsWritten;
|
||||||
|
int64_t tablesNum;
|
||||||
|
} SVnodeLoad;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t num;
|
||||||
|
SVnodeLoad data[];
|
||||||
|
} SVnodeLoads;
|
||||||
|
|
||||||
|
typedef struct SStatusMsg {
|
||||||
|
uint32_t sversion;
|
||||||
|
int32_t dnodeId;
|
||||||
|
int64_t clusterId;
|
||||||
|
uint32_t rebootTime; // time stamp for last reboot
|
||||||
|
int32_t numOfCores;
|
||||||
|
char dnodeEp[TSDB_EP_LEN];
|
||||||
|
SClusterCfg clusterCfg;
|
||||||
|
SVnodeLoads vnodeLoads;
|
||||||
|
} SStatusMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int8_t dropped;
|
int8_t dropped;
|
||||||
char reserved[19];
|
char reserved[3];
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
int32_t numOfDnodes;
|
|
||||||
int32_t numOfVnodes;
|
|
||||||
} SDnodeCfg;
|
} SDnodeCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -677,32 +690,9 @@ typedef struct {
|
||||||
SDnodeEp dnodeEps[];
|
SDnodeEp dnodeEps[];
|
||||||
} SDnodeEps;
|
} SDnodeEps;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t statusInterval; // tsStatusInterval
|
|
||||||
int8_t reserved[36];
|
|
||||||
int64_t checkTime; // 1970-01-01 00:00:00.000
|
|
||||||
char timezone[64]; // tsTimezone
|
|
||||||
char locale[TSDB_LOCALE_LEN]; // tsLocale
|
|
||||||
char charset[TSDB_LOCALE_LEN]; // tsCharset
|
|
||||||
} SClusterCfg;
|
|
||||||
|
|
||||||
typedef struct SStatusMsg {
|
|
||||||
uint32_t version;
|
|
||||||
int32_t dnodeId;
|
|
||||||
uint32_t lastReboot; // time stamp for last reboot
|
|
||||||
int32_t openVnodes;
|
|
||||||
int32_t numOfCores;
|
|
||||||
float diskAvailable;
|
|
||||||
int8_t reserved[36];
|
|
||||||
char dnodeEp[TSDB_EP_LEN];
|
|
||||||
int64_t clusterId;
|
|
||||||
SClusterCfg clusterCfg;
|
|
||||||
SVnodeLoad load[];
|
|
||||||
} SStatusMsg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SDnodeCfg dnodeCfg;
|
SDnodeCfg dnodeCfg;
|
||||||
SVgroupAccess vgAccess[];
|
SDnodeEps dnodeEps;
|
||||||
} SStatusRsp;
|
} SStatusRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -711,7 +701,7 @@ typedef struct {
|
||||||
} SVnodeDesc;
|
} SVnodeDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
uint32_t vgId;
|
uint32_t vgId;
|
||||||
int32_t cacheBlockSize;
|
int32_t cacheBlockSize;
|
||||||
int32_t totalBlocks;
|
int32_t totalBlocks;
|
||||||
|
@ -731,9 +721,18 @@ typedef struct {
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
int8_t quorum;
|
int8_t quorum;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
SVnodeDesc nodes[TSDB_MAX_REPLICA];
|
SVnodeDesc replicas[TSDB_MAX_REPLICA];
|
||||||
} SCreateVnodeMsg, SAlterVnodeMsg;
|
} SCreateVnodeMsg, SAlterVnodeMsg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
} SDropVnodeMsg, SSyncVnodeMsg, SCompactVnodeMsg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
int8_t accessState;
|
||||||
|
} SAuthVnodeMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
char tableFname[TSDB_TABLE_FNAME_LEN];
|
||||||
int16_t createFlag;
|
int16_t createFlag;
|
||||||
|
@ -805,13 +804,13 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
uint16_t payloadLen;
|
uint16_t payloadLen;
|
||||||
char payload[];
|
char payload[];
|
||||||
} SShowMsg;
|
} SShowMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
int32_t numOfVgroup;
|
int32_t numOfVgroup;
|
||||||
int32_t vgid[];
|
int32_t vgid[];
|
||||||
} SCompactMsg;
|
} SCompactMsg;
|
||||||
|
@ -827,9 +826,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int32_t mnodeNum;
|
} SCreateMnodeMsg, SDropMnodeMsg;
|
||||||
SDnodeEp mnodeEps[];
|
|
||||||
} SCreateMnodeMsg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
|
@ -895,16 +892,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char queryId[TSDB_KILL_MSG_LEN + 1];
|
char queryId[TSDB_KILL_MSG_LEN + 1];
|
||||||
} SKillQueryMsg, SKillStreamMsg, SKillConnMsg;
|
} SKillQueryMsg, SKillConnMsg;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t vnode;
|
|
||||||
int32_t sid;
|
|
||||||
uint64_t uid;
|
|
||||||
uint64_t stime; // stream starting time
|
|
||||||
int32_t status;
|
|
||||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
|
||||||
} SAlterStreamMsg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
|
@ -919,8 +907,7 @@ typedef struct {
|
||||||
int8_t reserved1[7];
|
int8_t reserved1[7];
|
||||||
char name[TSDB_STEP_NAME_LEN];
|
char name[TSDB_STEP_NAME_LEN];
|
||||||
char desc[TSDB_STEP_DESC_LEN];
|
char desc[TSDB_STEP_DESC_LEN];
|
||||||
char reserved2[64];
|
} SStartupMsg;
|
||||||
} SStartupStep;
|
|
||||||
|
|
||||||
// mq related
|
// mq related
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1008,6 +995,7 @@ typedef struct {
|
||||||
/* data */
|
/* data */
|
||||||
} SUpdateTagValRsp;
|
} SUpdateTagValRsp;
|
||||||
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -198,7 +198,7 @@ extern SDiskCfg tsDiskCfg[];
|
||||||
|
|
||||||
void taosInitGlobalCfg();
|
void taosInitGlobalCfg();
|
||||||
int32_t taosCheckGlobalCfg();
|
int32_t taosCheckGlobalCfg();
|
||||||
bool taosCfgDynamicOptions(char *msg);
|
int32_t taosCfgDynamicOptions(char *msg);
|
||||||
int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port);
|
int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port);
|
||||||
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
||||||
void taosAddDataDir(int index, char *v1, int level, int primary);
|
void taosAddDataDir(int index, char *v1, int level, int primary);
|
||||||
|
|
|
@ -22,22 +22,16 @@ extern "C" {
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
|
||||||
#define TAOS_CONN_SERVER 0
|
#define TAOS_CONN_SERVER 0
|
||||||
#define TAOS_CONN_CLIENT 1
|
#define TAOS_CONN_CLIENT 1
|
||||||
|
|
||||||
extern int tsRpcHeadSize;
|
extern int tsRpcHeadSize;
|
||||||
|
|
||||||
typedef struct SRpcEpSet {
|
|
||||||
int8_t inUse;
|
|
||||||
int8_t numOfEps;
|
|
||||||
uint16_t port[TSDB_MAX_REPLICA];
|
|
||||||
char fqdn[TSDB_MAX_REPLICA][TSDB_FQDN_LEN];
|
|
||||||
} SRpcEpSet;
|
|
||||||
|
|
||||||
typedef struct SRpcCorEpSet {
|
typedef struct SRpcCorEpSet {
|
||||||
int32_t version;
|
int32_t version;
|
||||||
SRpcEpSet epSet;
|
SEpSet epSet;
|
||||||
} SRpcCorEpSet;
|
} SRpcCorEpSet;
|
||||||
|
|
||||||
typedef struct SRpcConnInfo {
|
typedef struct SRpcConnInfo {
|
||||||
|
@ -72,7 +66,7 @@ typedef struct SRpcInit {
|
||||||
char *ckey; // ciphering key
|
char *ckey; // ciphering key
|
||||||
|
|
||||||
// call back to process incoming msg, code shall be ignored by server app
|
// call back to process incoming msg, code shall be ignored by server app
|
||||||
void (*cfp)(SRpcMsg *, SRpcEpSet *);
|
void (*cfp)(SRpcMsg *, SEpSet *);
|
||||||
|
|
||||||
// call back to retrieve the client auth info, for server app only
|
// call back to retrieve the client auth info, for server app only
|
||||||
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
@ -85,11 +79,11 @@ void rpcClose(void *);
|
||||||
void *rpcMallocCont(int contLen);
|
void *rpcMallocCont(int contLen);
|
||||||
void rpcFreeCont(void *pCont);
|
void rpcFreeCont(void *pCont);
|
||||||
void *rpcReallocCont(void *ptr, int contLen);
|
void *rpcReallocCont(void *ptr, int contLen);
|
||||||
void rpcSendRequest(void *thandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
void rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||||
void rpcSendResponse(const SRpcMsg *pMsg);
|
void rpcSendResponse(const SRpcMsg *pMsg);
|
||||||
void rpcSendRedirectRsp(void *pConn, const SRpcEpSet *pEpSet);
|
void rpcSendRedirectRsp(void *pConn, const SEpSet *pEpSet);
|
||||||
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
||||||
void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
||||||
void rpcCancelRequest(int64_t rid);
|
void rpcCancelRequest(int64_t rid);
|
||||||
|
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_DNODE_H_
|
|
||||||
#define _TD_DNODE_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct SRpcEpSet;
|
|
||||||
struct SRpcMsg;
|
|
||||||
/**
|
|
||||||
* Initialize and start the dnode module.
|
|
||||||
*
|
|
||||||
* @return Error code.
|
|
||||||
*/
|
|
||||||
int32_t dnodeInit();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop and cleanup dnode module.
|
|
||||||
*/
|
|
||||||
void dnodeCleanup();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send messages to other dnodes, such as create vnode message.
|
|
||||||
*
|
|
||||||
* @param epSet, the endpoint list of the dnodes.
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
*/
|
|
||||||
void dnodeSendMsgToDnode(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send messages to mnode, such as config message.
|
|
||||||
*
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
*/
|
|
||||||
void dnodeSendMsgToMnode(struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send redirect message to dnode or shell.
|
|
||||||
*
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
* @param forShell, used to identify whether to send to shell or dnode.
|
|
||||||
*/
|
|
||||||
void dnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the corresponding endpoint information from dnodeId.
|
|
||||||
*
|
|
||||||
* @param dnodeId, the id ot dnode.
|
|
||||||
* @param ep, the endpoint of dnode.
|
|
||||||
* @param fqdn, the fqdn of dnode.
|
|
||||||
* @param port, the port of dnode.
|
|
||||||
*/
|
|
||||||
void dnodeGetEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report the startup progress.
|
|
||||||
*/
|
|
||||||
void dnodeReportStartup(char *name, char *desc);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_DNODE_H_*/
|
|
|
@ -20,82 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum { MN_STATUS_UNINIT = 0, MN_STATUS_INIT = 1, MN_STATUS_READY = 2, MN_STATUS_CLOSING = 3 } EMnStatus;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
/**
|
|
||||||
* Send messages to other dnodes, such as create vnode message.
|
|
||||||
*
|
|
||||||
* @param epSet, the endpoint list of the dnodes.
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
*/
|
|
||||||
void (*SendMsgToDnode)(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send messages to mnode, such as config message.
|
|
||||||
*
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
*/
|
|
||||||
void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send redirect message to dnode or shell.
|
|
||||||
*
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
* @param forShell, used to identify whether to send to shell or dnode.
|
|
||||||
*/
|
|
||||||
void (*SendRedirectMsg)(struct SRpcMsg *rpcMsg, bool forShell);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the corresponding endpoint information from dnodeId.
|
|
||||||
*
|
|
||||||
* @param dnode, the instance of dDnode module.
|
|
||||||
* @param dnodeId, the id ot dnode.
|
|
||||||
* @param ep, the endpoint of dnode.
|
|
||||||
* @param fqdn, the fqdn of dnode.
|
|
||||||
* @param port, the port of dnode.
|
|
||||||
*/
|
|
||||||
void (*GetDnodeEp)(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
|
||||||
} SMnodeFp;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SMnodeFp fp;
|
|
||||||
int64_t clusterId;
|
|
||||||
int32_t dnodeId;
|
|
||||||
} SMnodePara;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize and start mnode module.
|
|
||||||
*
|
|
||||||
* @param para, initialization parameters.
|
|
||||||
* @return Error code.
|
|
||||||
*/
|
|
||||||
int32_t mnodeInit(SMnodePara para);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop and cleanup mnode module.
|
|
||||||
*/
|
|
||||||
void mnodeCleanup();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deploy mnode instances in dnode.
|
|
||||||
*
|
|
||||||
* @return Error Code.
|
|
||||||
*/
|
|
||||||
int32_t mnodeDeploy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the mnode instance deployed in dnode.
|
|
||||||
*/
|
|
||||||
void mnodeUnDeploy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the mnode is in service.
|
|
||||||
*
|
|
||||||
* @return Server status.
|
|
||||||
*/
|
|
||||||
EMnStatus mnodeGetStatus();
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t numOfDnode;
|
int64_t numOfDnode;
|
||||||
int64_t numOfMnode;
|
int64_t numOfMnode;
|
||||||
|
@ -109,32 +33,29 @@ typedef struct {
|
||||||
int64_t compStorage;
|
int64_t compStorage;
|
||||||
} SMnodeStat;
|
} SMnodeStat;
|
||||||
|
|
||||||
/**
|
typedef struct {
|
||||||
* Get the statistical information of Mnode.
|
void (*SendMsgToDnode)(struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
||||||
*
|
void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg);
|
||||||
* @param stat, statistical information.
|
void (*SendRedirectMsg)(struct SRpcMsg *rpcMsg, bool forShell);
|
||||||
* @return Error Code.
|
void (*GetDnodeEp)(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
||||||
*/
|
} SMnodeFp;
|
||||||
int32_t mnodeGetStatistics(SMnodeStat *stat);
|
|
||||||
|
|
||||||
/**
|
typedef struct {
|
||||||
* Get the auth information of Mnode.
|
SMnodeFp fp;
|
||||||
*
|
int64_t clusterId;
|
||||||
* @param user, username.
|
int32_t dnodeId;
|
||||||
* @param spi, security parameter index.
|
} SMnodePara;
|
||||||
* @param encrypt, encrypt algorithm.
|
|
||||||
* @param secret, key for authentication.
|
int32_t mnodeInit(SMnodePara para);
|
||||||
* @param ckey, ciphering key.
|
void mnodeCleanup();
|
||||||
* @return Error Code.
|
int32_t mnodeDeploy();
|
||||||
*/
|
void mnodeUnDeploy();
|
||||||
|
int32_t mnodeStart();
|
||||||
|
void mnodeStop();
|
||||||
|
|
||||||
|
int32_t mnodeGetStatistics(SMnodeStat *stat);
|
||||||
int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for processing messages.
|
|
||||||
*
|
|
||||||
* @param rpcMsg, message to be processed.
|
|
||||||
* @return Error code.
|
|
||||||
*/
|
|
||||||
void mnodeProcessMsg(SRpcMsg *rpcMsg);
|
void mnodeProcessMsg(SRpcMsg *rpcMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
|
#define TQ_ACTION_INSERT 0x7f7f7f7fULL
|
||||||
|
#define TQ_ACTION_DELETE 0x80808080ULL
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,17 +13,21 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_MQTT_PLYLOAD_H
|
#ifndef _TD_TSDB_IMPL_H_
|
||||||
#define TDENGINE_MQTT_PLYLOAD_H
|
#define _TD_TSDB_IMPL_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char* mqttConverJsonToSql(char* json, int maxSize);
|
struct STsdbOptions {
|
||||||
|
/* TODO */
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /*_TD_TSDB_IMPL_H_*/
|
|
@ -16,67 +16,24 @@
|
||||||
#ifndef _TD_TSDB_H_
|
#ifndef _TD_TSDB_H_
|
||||||
#define _TD_TSDB_H_
|
#define _TD_TSDB_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "impl/tsdbImpl.h"
|
||||||
#include "taosmsg.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Types exported
|
// TYPES EXPOSED
|
||||||
typedef struct STsdb STsdb;
|
typedef struct STsdb STsdb;
|
||||||
typedef struct STsdbOptions STsdbOptions;
|
typedef struct STsdbOptions STsdbOptions;
|
||||||
typedef struct STsdbSMAOptions STsdbSMAOptions; // SMA stands for Small Materialized Aggregation
|
|
||||||
typedef struct STsdbReadOptions STsdbReadOptions;
|
|
||||||
typedef struct STsdbSnapshot STsdbSnapshot;
|
|
||||||
typedef struct STsdbQueryHandle STsdbQueryHandle;
|
|
||||||
|
|
||||||
// DB operations
|
// STsdb
|
||||||
int tsdbCreate(const char *path);
|
STsdb *tsdbOpen(const char *path, const STsdbOptions *);
|
||||||
int tsdbDestroy(const char *path);
|
|
||||||
STsdb *tsdbOpen(const STsdbOptions *options);
|
|
||||||
void tsdbClose(STsdb *);
|
void tsdbClose(STsdb *);
|
||||||
int tsdbReset(STsdb *, const STsdbOptions *);
|
void tsdbRemove(const char *path);
|
||||||
int tsdbInsert(STsdb *, SSubmitReq *, SSubmitRsp *);
|
|
||||||
int tsdbCommit(STsdb *);
|
|
||||||
int tsdbCompact(STsdb *);
|
|
||||||
|
|
||||||
// Options
|
// STsdbOptions
|
||||||
STsdbOptions *tsdbOptionsCreate();
|
int tsdbOptionsInit(STsdbOptions *);
|
||||||
void tsdbOptionsDestroy(STsdbOptions *);
|
void tsdbOptionsClear(STsdbOptions *);
|
||||||
void tsdbOptionsSetId(STsdbOptions *, int id);
|
|
||||||
void tsdbOptionsSetHoursPerFile(STsdbOptions *, int hours);
|
|
||||||
void tsdbOptionsSetRetention(STsdbOptions *, int keep, int keep1, int keep2);
|
|
||||||
void tsdbOptionsSetMinAndMaxRows(STsdbOptions *, int minRows, int maxRows);
|
|
||||||
void tsdbOptionsSetPrecision(STsdbOptions *, int);
|
|
||||||
void tsdbOptionsSetCache(STsdbOptions *, int);
|
|
||||||
typedef enum { TSDB_NO_UPDATE = 0, TSDB_WHOLE_ROW_UPDATE = 1, TSDB_PARTIAL_ROW_UPDATE = 2 } ETsdbUpdateType;
|
|
||||||
void tsdbOptionsSetUpdate(STsdbOptions *, ETsdbUpdateType);
|
|
||||||
void tsdbOptionsSetSMA(STsdbOptions *, STsdbSMAOptions *);
|
|
||||||
|
|
||||||
// STsdbSMAOptions
|
|
||||||
STsdbSMAOptions *tsdbSMAOptionsCreate();
|
|
||||||
void tsdbSMAOptionsDestroy(STsdbSMAOptions *);
|
|
||||||
// void tsdbSMAOptionsSetFuncs(STsdbSMAOptions *, SArray * /*Array of function to perform on each block*/);
|
|
||||||
// void tsdbSMAOptionsSetIntervals(STsdbSMAOptions *, SArray *);
|
|
||||||
// void tsdbSMAOptionsSetColTypes(STsdbSMAOptions *, SArray *);
|
|
||||||
|
|
||||||
// STsdbQueryHandle
|
|
||||||
STsdbQueryHandle *tsdbQueryHandleCreate(STsdb *, STsdbReadOptions *);
|
|
||||||
void tsdbQueryHandleDestroy(STsdbQueryHandle *);
|
|
||||||
void tsdbResetQueryHandle(STsdbQueryHandle *, STsdbReadOptions *);
|
|
||||||
bool tsdbNextDataBlock(STsdbQueryHandle *);
|
|
||||||
// void tsdbGetDataBlockInfo(STsdbQueryHandle *, SDataBlockInfo *);
|
|
||||||
// void tsdbGetDataBlockStatisInfo(STsdbQueryHandle *, SDataStatis **);
|
|
||||||
|
|
||||||
// STsdbReadOptions
|
|
||||||
STsdbReadOptions *tsdbReadOptionsCreate();
|
|
||||||
void tsdbReadOptionsDestroy(STsdbReadOptions *);
|
|
||||||
void tsdbReadOptionsSetSnapshot(STsdbReadOptions *, STsdbSnapshot *);
|
|
||||||
|
|
||||||
// STsdbSnapshot
|
|
||||||
STsdbSnapshot *tsdbSnapshotCreate(STsdb *);
|
|
||||||
void tsdbSnapshotDestroy(STsdbSnapshot *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,93 +16,74 @@
|
||||||
#ifndef _TD_VNODE_H_
|
#ifndef _TD_VNODE_H_
|
||||||
#define _TD_VNODE_H_
|
#define _TD_VNODE_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct SVnode SVnode;
|
||||||
/**
|
|
||||||
* Send messages to other dnodes, such as create vnode message.
|
|
||||||
*
|
|
||||||
* @param epSet, the endpoint list of dnodes.
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
*/
|
|
||||||
void (*SendMsgToDnode)(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send messages to mnode, such as config message.
|
|
||||||
*
|
|
||||||
* @param rpcMsg, message to be sent.
|
|
||||||
*/
|
|
||||||
void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the corresponding endpoint information from dnodeId.
|
|
||||||
*
|
|
||||||
* @param dnodeId, the id ot dnode.
|
|
||||||
* @param ep, the endpoint of dnode.
|
|
||||||
* @param fqdn, the fqdn of dnode.
|
|
||||||
* @param port, the port of dnode.
|
|
||||||
*/
|
|
||||||
void (*GetDnodeEp)(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report the startup progress.
|
|
||||||
*/
|
|
||||||
void (*ReportStartup)(char *name, char *desc);
|
|
||||||
|
|
||||||
} SVnodeFp;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SVnodeFp fp;
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
|
int32_t cacheBlockSize; // MB
|
||||||
|
int32_t totalBlocks;
|
||||||
|
int32_t daysPerFile;
|
||||||
|
int32_t daysToKeep0;
|
||||||
|
int32_t daysToKeep1;
|
||||||
|
int32_t daysToKeep2;
|
||||||
|
int32_t minRowsPerFileBlock;
|
||||||
|
int32_t maxRowsPerFileBlock;
|
||||||
|
int8_t precision; // time resolution
|
||||||
|
int8_t compression;
|
||||||
|
int8_t cacheLastRow;
|
||||||
|
int8_t update;
|
||||||
|
int8_t quorum;
|
||||||
|
int8_t replica;
|
||||||
|
int8_t walLevel;
|
||||||
|
int32_t fsyncPeriod; // millisecond
|
||||||
|
SVnodeDesc replicas[TSDB_MAX_REPLICA];
|
||||||
|
} SVnodeCfg;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VN_MSG_TYPE_WRITE = 1,
|
||||||
|
VN_MSG_TYPE_APPLY,
|
||||||
|
VN_MSG_TYPE_SYNC,
|
||||||
|
VN_MSG_TYPE_QUERY,
|
||||||
|
VN_MSG_TYPE_FETCH
|
||||||
|
} EVnMsgType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t curNum;
|
||||||
|
int32_t allocNum;
|
||||||
|
SRpcMsg rpcMsg[];
|
||||||
|
} SVnodeMsg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void (*SendMsgToDnode)(SEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
|
void (*SendMsgToMnode)(SRpcMsg *pMsg);
|
||||||
|
int32_t (*PutMsgIntoApplyQueue)(int32_t vgId, SVnodeMsg *pMsg);
|
||||||
} SVnodePara;
|
} SVnodePara;
|
||||||
|
|
||||||
/**
|
int32_t vnodeInit(SVnodePara);
|
||||||
* Start initialize vnode module.
|
|
||||||
*
|
|
||||||
* @param para, initialization parameters.
|
|
||||||
* @return Error code.
|
|
||||||
*/
|
|
||||||
int32_t vnodeInit(SVnodePara para);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanup vnode module.
|
|
||||||
*/
|
|
||||||
void vnodeCleanup();
|
void vnodeCleanup();
|
||||||
|
|
||||||
typedef struct {
|
SVnode *vnodeOpen(int32_t vgId, const char *path);
|
||||||
int32_t unused;
|
void vnodeClose(SVnode *pVnode);
|
||||||
} SVnodeStat;
|
int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg);
|
||||||
|
SVnode *vnodeCreate(int32_t vgId, const char *path, const SVnodeCfg *pCfg);
|
||||||
|
void vnodeDrop(SVnode *pVnode);
|
||||||
|
int32_t vnodeCompact(SVnode *pVnode);
|
||||||
|
int32_t vnodeSync(SVnode *pVnode);
|
||||||
|
|
||||||
/**
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
* Get the statistical information of vnode.
|
|
||||||
*
|
|
||||||
* @param stat, statistical information.
|
|
||||||
* @return Error Code.
|
|
||||||
*/
|
|
||||||
int32_t vnodeGetStatistics(SVnodeStat *stat);
|
|
||||||
|
|
||||||
/**
|
SVnodeMsg *vnodeInitMsg(int32_t msgNum);
|
||||||
* Get the status of all vnodes.
|
int32_t vnodeAppendMsg(SVnodeMsg *pMsg, SRpcMsg *pRpcMsg);
|
||||||
*
|
void vnodeCleanupMsg(SVnodeMsg *pMsg);
|
||||||
* @param status, status msg.
|
void vnodeProcessMsg(SVnode *pVnode, SVnodeMsg *pMsg, EVnMsgType msgType);
|
||||||
*/
|
|
||||||
void vnodeGetStatus(struct SStatusMsg *status);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set access permissions for all vnodes.
|
|
||||||
*
|
|
||||||
* @param access, access permissions of vnodes.
|
|
||||||
* @param numOfVnodes, the size of vnodes.
|
|
||||||
*/
|
|
||||||
void vnodeSetAccess(struct SVgroupAccess *access, int32_t numOfVnodes);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for processing messages.
|
|
||||||
*
|
|
||||||
* @param msg, message to be processed.
|
|
||||||
*/
|
|
||||||
void vnodeProcessMsg(SRpcMsg *msg);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,11 +216,14 @@ int32_t* taosGetErrno();
|
||||||
// dnode
|
// dnode
|
||||||
#define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) //"Message not processed")
|
#define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) //"Message not processed")
|
||||||
#define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) //"Dnode out of memory")
|
#define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) //"Dnode out of memory")
|
||||||
#define TSDB_CODE_DND_NO_WRITE_ACCESS TAOS_DEF_ERROR_CODE(0, 0x0402) //"No permission for disk files in dnode")
|
#define TSDB_CODE_DND_DNODE_ID_NOT_MATCHED TAOS_DEF_ERROR_CODE(0, 0x0402) //"Dnode Id not matched")
|
||||||
#define TSDB_CODE_DND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0403) //"Invalid message length")
|
#define TSDB_CODE_DND_MNODE_ALREADY_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0403) //"Mnode already deployed")
|
||||||
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0404) //"Action in progress")
|
#define TSDB_CODE_DND_NO_WRITE_ACCESS TAOS_DEF_ERROR_CODE(0, 0x0404) //"No permission for disk files in dnode")
|
||||||
#define TSDB_CODE_DND_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0405) //"Too many vnode directories")
|
#define TSDB_CODE_DND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0405) //"Invalid message length")
|
||||||
#define TSDB_CODE_DND_EXITING TAOS_DEF_ERROR_CODE(0, 0x0406) //"Dnode is exiting"
|
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0406) //"Action in progress")
|
||||||
|
#define TSDB_CODE_DND_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0407) //"Too many vnode directories")
|
||||||
|
#define TSDB_CODE_DND_EXITING TAOS_DEF_ERROR_CODE(0, 0x0408) //"Dnode is exiting"
|
||||||
|
#define TSDB_CODE_DND_PARSE_VNODE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0409) //"Parse vnodes.json error")
|
||||||
|
|
||||||
// vnode
|
// vnode
|
||||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) //"Action in progress")
|
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) //"Action in progress")
|
||||||
|
|
|
@ -160,11 +160,12 @@ do { \
|
||||||
#define TSDB_NODE_NAME_LEN 64
|
#define TSDB_NODE_NAME_LEN 64
|
||||||
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
|
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
|
||||||
#define TSDB_DB_NAME_LEN 33
|
#define TSDB_DB_NAME_LEN 33
|
||||||
|
#define TSDB_FULL_DB_NAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN)
|
||||||
#define TSDB_FUNC_NAME_LEN 65
|
#define TSDB_FUNC_NAME_LEN 65
|
||||||
#define TSDB_FUNC_CODE_LEN (65535 - 512)
|
#define TSDB_FUNC_CODE_LEN (65535 - 512)
|
||||||
#define TSDB_FUNC_BUF_SIZE 512
|
#define TSDB_FUNC_BUF_SIZE 512
|
||||||
#define TSDB_TYPE_STR_MAX_LEN 32
|
#define TSDB_TYPE_STR_MAX_LEN 32
|
||||||
#define TSDB_TABLE_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN)
|
#define TSDB_TABLE_FNAME_LEN (TSDB_FULL_DB_NAME_LEN + TSDB_TABLE_NAME_LEN)
|
||||||
#define TSDB_COL_NAME_LEN 65
|
#define TSDB_COL_NAME_LEN 65
|
||||||
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
|
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
|
||||||
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
|
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
|
||||||
|
@ -218,7 +219,7 @@ do { \
|
||||||
#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth
|
#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth
|
||||||
#define TSDB_CQ_SQL_SIZE 1024
|
#define TSDB_CQ_SQL_SIZE 1024
|
||||||
#define TSDB_MIN_VNODES 64
|
#define TSDB_MIN_VNODES 64
|
||||||
#define TSDB_MAX_VNODES 2048
|
#define TSDB_MAX_VNODES 512
|
||||||
#define TSDB_MIN_VNODES_PER_DB 2
|
#define TSDB_MIN_VNODES_PER_DB 2
|
||||||
#define TSDB_MAX_VNODES_PER_DB 64
|
#define TSDB_MAX_VNODES_PER_DB 64
|
||||||
|
|
||||||
|
|
|
@ -40,18 +40,22 @@ shall be used to set up the protection.
|
||||||
typedef void *taos_queue;
|
typedef void *taos_queue;
|
||||||
typedef void *taos_qset;
|
typedef void *taos_qset;
|
||||||
typedef void *taos_qall;
|
typedef void *taos_qall;
|
||||||
|
typedef void (*FProcessItem)(void *ahandle, void *pItem);
|
||||||
|
typedef void (*FProcessItems)(void *ahandle, taos_qall qall, int numOfItems);
|
||||||
|
|
||||||
taos_queue taosOpenQueue();
|
taos_queue taosOpenQueue();
|
||||||
void taosCloseQueue(taos_queue);
|
void taosCloseQueue(taos_queue);
|
||||||
|
void taosSetQueueFp(taos_queue, FProcessItem, FProcessItems);
|
||||||
void *taosAllocateQitem(int size);
|
void *taosAllocateQitem(int size);
|
||||||
void taosFreeQitem(void *item);
|
void taosFreeQitem(void *pItem);
|
||||||
int taosWriteQitem(taos_queue, int type, void *item);
|
int taosWriteQitem(taos_queue, void *pItem);
|
||||||
int taosReadQitem(taos_queue, int *type, void **pitem);
|
int taosReadQitem(taos_queue, void **pItem);
|
||||||
|
bool taosQueueEmpty(taos_queue);
|
||||||
|
|
||||||
taos_qall taosAllocateQall();
|
taos_qall taosAllocateQall();
|
||||||
void taosFreeQall(taos_qall);
|
void taosFreeQall(taos_qall);
|
||||||
int taosReadAllQitems(taos_queue, taos_qall);
|
int taosReadAllQitems(taos_queue, taos_qall);
|
||||||
int taosGetQitem(taos_qall, int *type, void **pitem);
|
int taosGetQitem(taos_qall, void **pItem);
|
||||||
void taosResetQitems(taos_qall);
|
void taosResetQitems(taos_qall);
|
||||||
|
|
||||||
taos_qset taosOpenQset();
|
taos_qset taosOpenQset();
|
||||||
|
@ -61,8 +65,8 @@ int taosAddIntoQset(taos_qset, taos_queue, void *ahandle);
|
||||||
void taosRemoveFromQset(taos_qset, taos_queue);
|
void taosRemoveFromQset(taos_qset, taos_queue);
|
||||||
int taosGetQueueNumber(taos_qset);
|
int taosGetQueueNumber(taos_qset);
|
||||||
|
|
||||||
int taosReadQitemFromQset(taos_qset, int *type, void **pitem, void **handle);
|
int taosReadQitemFromQset(taos_qset, void **pItem, void **ahandle, FProcessItem *);
|
||||||
int taosReadAllQitemsFromQset(taos_qset, taos_qall, void **handle);
|
int taosReadAllQitemsFromQset(taos_qset, taos_qall, void **ahandle, FProcessItems *);
|
||||||
|
|
||||||
int taosGetQueueItemsNumber(taos_queue param);
|
int taosGetQueueItemsNumber(taos_queue param);
|
||||||
int taosGetQsetItemsNumber(taos_qset param);
|
int taosGetQsetItemsNumber(taos_qset param);
|
||||||
|
|
|
@ -22,13 +22,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int32_t (*ProcessStartFp)(void *ahandle, void *pMsg, int32_t qtype);
|
|
||||||
typedef void (*ProcessEndFp)(void *ahandle, void *pMsg, int32_t qtype, int32_t code);
|
|
||||||
|
|
||||||
typedef bool (*ProcessWriteStartFp)(void *ahandle, void *pMsg, int32_t qtype);
|
|
||||||
typedef void (*ProcessWriteSyncFp)(void *ahandle, int32_t code);
|
|
||||||
typedef void (*ProcessWriteEndFp)(void *ahandle, void *pMsg, int32_t qtype);
|
|
||||||
|
|
||||||
typedef struct SWorker {
|
typedef struct SWorker {
|
||||||
int32_t id; // worker ID
|
int32_t id; // worker ID
|
||||||
pthread_t thread; // thread
|
pthread_t thread; // thread
|
||||||
|
@ -41,40 +34,35 @@ typedef struct SWorkerPool {
|
||||||
int32_t num; // current number of workers
|
int32_t num; // current number of workers
|
||||||
taos_qset qset;
|
taos_qset qset;
|
||||||
const char *name;
|
const char *name;
|
||||||
ProcessStartFp startFp;
|
|
||||||
ProcessEndFp endFp;
|
|
||||||
SWorker *workers;
|
SWorker *workers;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} SWorkerPool;
|
} SWorkerPool;
|
||||||
|
|
||||||
typedef struct SWriteWorker {
|
typedef struct SMWorker {
|
||||||
int32_t id; // worker id
|
int32_t id; // worker id
|
||||||
pthread_t thread; // thread
|
pthread_t thread; // thread
|
||||||
taos_qall qall;
|
taos_qall qall;
|
||||||
taos_qset qset; // queue set
|
taos_qset qset; // queue set
|
||||||
struct SWriteWorkerPool *pool;
|
struct SMWorkerPool *pool;
|
||||||
} SWriteWorker;
|
} SMWorker;
|
||||||
|
|
||||||
typedef struct SWriteWorkerPool {
|
typedef struct SMWorkerPool {
|
||||||
int32_t max; // max number of workers
|
int32_t max; // max number of workers
|
||||||
int32_t nextId; // from 0 to max-1, cyclic
|
int32_t nextId; // from 0 to max-1, cyclic
|
||||||
const char *name;
|
const char *name;
|
||||||
ProcessWriteStartFp startFp;
|
SMWorker *workers;
|
||||||
ProcessWriteSyncFp syncFp;
|
|
||||||
ProcessWriteEndFp endFp;
|
|
||||||
SWriteWorker * workers;
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} SWriteWorkerPool;
|
} SMWorkerPool;
|
||||||
|
|
||||||
int32_t tWorkerInit(SWorkerPool *pool);
|
int32_t tWorkerInit(SWorkerPool *pool);
|
||||||
void tWorkerCleanup(SWorkerPool *pool);
|
void tWorkerCleanup(SWorkerPool *pool);
|
||||||
taos_queue tWorkerAllocQueue(SWorkerPool *pool, void *ahandle);
|
taos_queue tWorkerAllocQueue(SWorkerPool *pool, void *ahandle, FProcessItem fp);
|
||||||
void tWorkerFreeQueue(SWorkerPool *pool, taos_queue queue);
|
void tWorkerFreeQueue(SWorkerPool *pool, taos_queue queue);
|
||||||
|
|
||||||
int32_t tWriteWorkerInit(SWriteWorkerPool *pool);
|
int32_t tMWorkerInit(SMWorkerPool *pool);
|
||||||
void tWriteWorkerCleanup(SWriteWorkerPool *pool);
|
void tMWorkerCleanup(SMWorkerPool *pool);
|
||||||
taos_queue tWriteWorkerAllocQueue(SWriteWorkerPool *pool, void *ahandle);
|
taos_queue tMWorkerAllocQueue(SMWorkerPool *pool, void *ahandle, FProcessItems fp);
|
||||||
void tWriteWorkerFreeQueue(SWriteWorkerPool *pool, taos_queue queue);
|
void tMWorkerFreeQueue(SMWorkerPool *pool, taos_queue queue);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ add_subdirectory(util)
|
||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
add_subdirectory(libs)
|
add_subdirectory(libs)
|
||||||
add_subdirectory(client)
|
add_subdirectory(client)
|
||||||
add_subdirectory(server)
|
add_subdirectory(dnode)
|
|
@ -277,13 +277,13 @@ void taosSetAllDebugFlag() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosCfgDynamicOptions(char *msg) {
|
int32_t taosCfgDynamicOptions(char *msg) {
|
||||||
char *option, *value;
|
char *option, *value;
|
||||||
int32_t olen, vlen;
|
int32_t olen, vlen;
|
||||||
int32_t vint = 0;
|
int32_t vint = 0;
|
||||||
|
|
||||||
paGetToken(msg, &option, &olen);
|
paGetToken(msg, &option, &olen);
|
||||||
if (olen == 0) return false;;
|
if (olen == 0) return -1;;
|
||||||
|
|
||||||
paGetToken(option + olen + 1, &value, &vlen);
|
paGetToken(option + olen + 1, &value, &vlen);
|
||||||
if (vlen == 0)
|
if (vlen == 0)
|
||||||
|
@ -324,18 +324,18 @@ bool taosCfgDynamicOptions(char *msg) {
|
||||||
uError("monitor can't be updated, for monitor not initialized");
|
uError("monitor can't be updated, for monitor not initialized");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
|
if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
|
||||||
taosSetAllDebugFlag();
|
taosSetAllDebugFlag();
|
||||||
}
|
}
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncasecmp(option, "resetlog", 8) == 0) {
|
if (strncasecmp(option, "resetlog", 8) == 0) {
|
||||||
taosResetLog();
|
taosResetLog();
|
||||||
taosPrintGlobalCfg();
|
taosPrintGlobalCfg();
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncasecmp(option, "resetQueryCache", 15) == 0) {
|
if (strncasecmp(option, "resetQueryCache", 15) == 0) {
|
||||||
|
|
|
@ -201,7 +201,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = snprintf(dst, TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN, "%s.%s", name->acctId, name->dbname);
|
int32_t len = snprintf(dst, TSDB_FULL_DB_NAME_LEN, "%s.%s", name->acctId, name->dbname);
|
||||||
|
|
||||||
size_t tnameLen = strlen(name->tname);
|
size_t tnameLen = strlen(name->tname);
|
||||||
if (tnameLen > 0) {
|
if (tnameLen > 0) {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
add_subdirectory(mnode)
|
||||||
|
add_subdirectory(vnode)
|
||||||
|
add_subdirectory(qnode)
|
||||||
|
add_subdirectory(mgmt)
|
|
@ -1,7 +1,7 @@
|
||||||
aux_source_directory(src DNODE_SRC)
|
aux_source_directory(src DNODE_SRC)
|
||||||
add_library(dnode ${DNODE_SRC})
|
add_executable(taosd ${DNODE_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dnode
|
taosd
|
||||||
PUBLIC cjson
|
PUBLIC cjson
|
||||||
PUBLIC mnode
|
PUBLIC mnode
|
||||||
PUBLIC vnode
|
PUBLIC vnode
|
||||||
|
@ -10,7 +10,7 @@ target_link_libraries(
|
||||||
PUBLIC taos
|
PUBLIC taos
|
||||||
)
|
)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
dnode
|
taosd
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/dnode"
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/dnode"
|
||||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
|
@ -13,30 +13,27 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DNODE_EPS_H_
|
#ifndef _TD_DNODE_DNODE_H_
|
||||||
#define _TD_DNODE_EPS_H_
|
#define _TD_DNODE_DNODE_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include "dnodeInt.h"
|
#include "dnodeInt.h"
|
||||||
|
|
||||||
int32_t dnodeInitEps();
|
int32_t dnodeInitDnode();
|
||||||
void dnodeCleanupEps();
|
void dnodeCleanupDnode();
|
||||||
|
void dnodeProcessDnodeMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
|
||||||
void dnodeUpdateCfg(SDnodeCfg *data);
|
|
||||||
void dnodeUpdateDnodeEps(SDnodeEps *data);
|
|
||||||
void dnodeUpdateMnodeEps(SRpcEpSet *pEpSet);
|
|
||||||
int32_t dnodeGetDnodeId();
|
int32_t dnodeGetDnodeId();
|
||||||
int64_t dnodeGetClusterId();
|
int64_t dnodeGetClusterId();
|
||||||
void dnodeGetEp(int32_t dnodeId, char *epstr, char *fqdn, uint16_t *port);
|
void dnodeGetDnodeEp(int32_t dnodeId, char *epstr, char *fqdn, uint16_t *port);
|
||||||
|
void dnodeGetMnodeEpSetForPeer(SEpSet *epSet);
|
||||||
void dnodeGetEpSetForPeer(SRpcEpSet *epSet);
|
void dnodeGetMnodeEpSetForShell(SEpSet *epSet);
|
||||||
void dnodeGetEpSetForShell(SRpcEpSet *epSet);
|
|
||||||
void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell);
|
void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DNODE_EPS_H_*/
|
#endif /*_TD_DNODE_DNODE_H_*/
|
|
@ -24,8 +24,6 @@ extern "C" {
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "ttimer.h"
|
|
||||||
#include "dnode.h"
|
|
||||||
|
|
||||||
extern int32_t dDebugFlag;
|
extern int32_t dDebugFlag;
|
||||||
|
|
||||||
|
@ -37,10 +35,17 @@ extern int32_t dDebugFlag;
|
||||||
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
|
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
typedef enum { DN_RUN_STAT_INIT, DN_RUN_STAT_RUNNING, DN_RUN_STAT_STOPPED } EDnStat;
|
typedef enum { DN_RUN_STAT_INIT, DN_RUN_STAT_RUNNING, DN_RUN_STAT_STOPPED } EDnStat;
|
||||||
|
typedef void (*MsgFp)(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
|
||||||
|
int32_t dnodeInit();
|
||||||
|
void dnodeCleanup();
|
||||||
|
|
||||||
EDnStat dnodeGetRunStat();
|
EDnStat dnodeGetRunStat();
|
||||||
void dnodeSetRunStat();
|
void dnodeSetRunStat();
|
||||||
void dnodeGetStartup(SStartupStep *);
|
|
||||||
|
void dnodeReportStartup(char *name, char *desc);
|
||||||
|
void dnodeReportStartupFinished(char *name, char *desc);
|
||||||
|
void dnodeGetStartup(SStartupMsg *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -13,28 +13,21 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_VNODE_MGMT_H_
|
#ifndef _TD_DNODE_MNODE_H_
|
||||||
#define _TD_VNODE_MGMT_H_
|
#define _TD_DNODE_MNODE_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include "vnodeInt.h"
|
#include "dnodeInt.h"
|
||||||
|
|
||||||
|
int32_t dnodeInitMnode();
|
||||||
typedef struct {
|
void dnodeCleanupMnode();
|
||||||
SVnode *pVnode;
|
void dnodeProcessMnodeMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
SRpcMsg rpcMsg;
|
int32_t dnodeGetUserAuthFromMnode(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
char pCont[];
|
|
||||||
} SVnMgmtMsg;
|
|
||||||
|
|
||||||
|
|
||||||
int32_t vnodeInitMgmt();
|
|
||||||
void vnodeCleanupMgmt();
|
|
||||||
void vnodeProcessMgmtMsg(SRpcMsg *pMsg);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_VNODE_MGMT_H_*/
|
#endif /*_TD_DNODE_MNODE_H_*/
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DNODE_TRANS_H_
|
#ifndef _TD_DNODE_TRANSPORT_H_
|
||||||
#define _TD_DNODE_TRANS_H_
|
#define _TD_DNODE_TRANSPORT_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -24,10 +24,10 @@ extern "C" {
|
||||||
int32_t dnodeInitTrans();
|
int32_t dnodeInitTrans();
|
||||||
void dnodeCleanupTrans();
|
void dnodeCleanupTrans();
|
||||||
void dnodeSendMsgToMnode(SRpcMsg *rpcMsg);
|
void dnodeSendMsgToMnode(SRpcMsg *rpcMsg);
|
||||||
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg);
|
void dnodeSendMsgToDnode(SEpSet *epSet, SRpcMsg *rpcMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DNODE_TRANS_H_*/
|
#endif /*_TD_DNODE_TRANSPORT_H_*/
|
|
@ -13,23 +13,26 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DNODE_STATUS_H_
|
#ifndef _TD_DNODE_VNODES_H_
|
||||||
#define _TD_DNODE_STATUS_H_
|
#define _TD_DNODE_VNODES_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include "dnodeInt.h"
|
#include "dnodeInt.h"
|
||||||
|
|
||||||
int32_t dnodeInitMsg();
|
int32_t dnodeInitVnodes();
|
||||||
void dnodeCleanupMsg();
|
void dnodeCleanupVnodes();
|
||||||
void dnodeProcessStatusRsp(SRpcMsg *pMsg);
|
void dnodeGetVnodeLoads(SVnodeLoads *pVloads);
|
||||||
void dnodeProcessStartupReq(SRpcMsg *pMsg);
|
|
||||||
void dnodeProcessCreateMnodeReq(SRpcMsg *pMsg);
|
void dnodeProcessVnodeMgmtMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
void dnodeProcessConfigDnodeReq(SRpcMsg *pMsg);
|
void dnodeProcessVnodeWriteMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
void dnodeProcessVnodeSyncMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
void dnodeProcessVnodeQueryMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
void dnodeProcessVnodeFetchMsg(SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DNODE_STATUS_H_*/
|
#endif /*_TD_DNODE_VNODES_H_*/
|
|
@ -12,9 +12,9 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "os.h"
|
|
||||||
#include "ulog.h"
|
#define _DEFAULT_SOURCE
|
||||||
#include "dnode.h"
|
#include "dnodeInt.h"
|
||||||
|
|
||||||
static bool stop = false;
|
static bool stop = false;
|
||||||
static void sigintHandler(int32_t signum, void *info, void *ctx) { stop = true; }
|
static void sigintHandler(int32_t signum, void *info, void *ctx) { stop = true; }
|
||||||
|
@ -31,17 +31,15 @@ int main(int argc, char const *argv[]) {
|
||||||
|
|
||||||
int32_t code = dnodeInit();
|
int32_t code = dnodeInit();
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
uInfo("Failed to start TDengine, please check the log at:%s", tsLogDir);
|
dInfo("Failed to start TDengine, please check the log at:%s", tsLogDir);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
uInfo("Started TDengine service successfully.");
|
|
||||||
|
|
||||||
while (!stop) {
|
while (!stop) {
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
uInfo("TDengine is shut down!");
|
dInfo("TDengine is shut down!");
|
||||||
dnodeCleanup();
|
dnodeCleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
|
@ -0,0 +1,553 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "dnodeDnode.h"
|
||||||
|
#include "dnodeTransport.h"
|
||||||
|
#include "dnodeVnodes.h"
|
||||||
|
#include "cJSON.h"
|
||||||
|
#include "thash.h"
|
||||||
|
#include "tthread.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
int32_t dnodeId;
|
||||||
|
int64_t clusterId;
|
||||||
|
SDnodeEps *dnodeEps;
|
||||||
|
SHashObj *dnodeHash;
|
||||||
|
SEpSet mnodeEpSetForShell;
|
||||||
|
SEpSet mnodeEpSetForPeer;
|
||||||
|
char file[PATH_MAX + 20];
|
||||||
|
uint32_t rebootTime;
|
||||||
|
int8_t dropped;
|
||||||
|
int8_t threadStop;
|
||||||
|
pthread_t *threadId;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
} tsDnode = {0};
|
||||||
|
|
||||||
|
int32_t dnodeGetDnodeId() {
|
||||||
|
int32_t dnodeId = 0;
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
dnodeId = tsDnode.dnodeId;
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
return dnodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t dnodeGetClusterId() {
|
||||||
|
int64_t clusterId = 0;
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
clusterId = tsDnode.clusterId;
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
return clusterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeGetDnodeEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port) {
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
|
||||||
|
SDnodeEp *pEp = taosHashGet(tsDnode.dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
|
if (pEp != NULL) {
|
||||||
|
if (port) *port = pEp->dnodePort;
|
||||||
|
if (fqdn) tstrncpy(fqdn, pEp->dnodeFqdn, TSDB_FQDN_LEN);
|
||||||
|
if (ep) snprintf(ep, TSDB_EP_LEN, "%s:%u", pEp->dnodeFqdn, pEp->dnodePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeGetMnodeEpSetForPeer(SEpSet *pEpSet) {
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
*pEpSet = tsDnode.mnodeEpSetForPeer;
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeGetMnodeEpSetForShell(SEpSet *pEpSet) {
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
*pEpSet = tsDnode.mnodeEpSetForShell;
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeSendRedirectMsg(SRpcMsg *pMsg, bool forShell) {
|
||||||
|
int32_t msgType = pMsg->msgType;
|
||||||
|
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
if (forShell) {
|
||||||
|
dnodeGetMnodeEpSetForShell(&epSet);
|
||||||
|
} else {
|
||||||
|
dnodeGetMnodeEpSetForPeer(&epSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
dDebug("RPC %p, msg:%s is redirected, num:%d use:%d", pMsg->handle, taosMsg[msgType], epSet.numOfEps, epSet.inUse);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
|
dDebug("mnode index:%d %s:%u", i, epSet.fqdn[i], epSet.port[i]);
|
||||||
|
if (strcmp(epSet.fqdn[i], tsLocalFqdn) == 0) {
|
||||||
|
if ((epSet.port[i] == tsServerPort + TSDB_PORT_DNODEDNODE && !forShell) ||
|
||||||
|
(epSet.port[i] == tsServerPort && forShell)) {
|
||||||
|
epSet.inUse = (i + 1) % epSet.numOfEps;
|
||||||
|
dDebug("mnode index:%d %s:%d set inUse to %d", i, epSet.fqdn[i], epSet.port[i], epSet.inUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
epSet.port[i] = htons(epSet.port[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcSendRedirectRsp(pMsg->handle, &epSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeUpdateMnodeEpSet(SEpSet *pEpSet) {
|
||||||
|
if (pEpSet == NULL || pEpSet->numOfEps <= 0) {
|
||||||
|
dError("mnode is changed, but content is invalid, discard it");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
|
||||||
|
tsDnode.mnodeEpSetForPeer = *pEpSet;
|
||||||
|
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
||||||
|
pEpSet->port[i] -= TSDB_PORT_DNODEDNODE;
|
||||||
|
dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i]);
|
||||||
|
}
|
||||||
|
tsDnode.mnodeEpSetForShell = *pEpSet;
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodePrintDnodes() {
|
||||||
|
dDebug("print dnode endpoint list, num:%d", tsDnode.dnodeEps->dnodeNum);
|
||||||
|
for (int32_t i = 0; i < tsDnode.dnodeEps->dnodeNum; i++) {
|
||||||
|
SDnodeEp *ep = &tsDnode.dnodeEps->dnodeEps[i];
|
||||||
|
dDebug("dnode:%d, fqdn:%s port:%u isMnode:%d", ep->dnodeId, ep->dnodeFqdn, ep->dnodePort, ep->isMnode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeResetDnodes(SDnodeEps *pEps) {
|
||||||
|
assert(pEps != NULL);
|
||||||
|
int32_t size = sizeof(SDnodeEps) + pEps->dnodeNum * sizeof(SDnodeEp);
|
||||||
|
|
||||||
|
if (pEps->dnodeNum > tsDnode.dnodeEps->dnodeNum) {
|
||||||
|
SDnodeEps *tmp = calloc(1, size);
|
||||||
|
if (tmp == NULL) return;
|
||||||
|
|
||||||
|
tfree(tsDnode.dnodeEps);
|
||||||
|
tsDnode.dnodeEps = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsDnode.dnodeEps != pEps) {
|
||||||
|
memcpy(tsDnode.dnodeEps, pEps, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsDnode.mnodeEpSetForPeer.inUse = 0;
|
||||||
|
tsDnode.mnodeEpSetForShell.inUse = 0;
|
||||||
|
|
||||||
|
int32_t mIndex = 0;
|
||||||
|
for (int32_t i = 0; i < tsDnode.dnodeEps->dnodeNum; i++) {
|
||||||
|
SDnodeEp *ep = &tsDnode.dnodeEps->dnodeEps[i];
|
||||||
|
if (!ep->isMnode) continue;
|
||||||
|
if (mIndex >= TSDB_MAX_REPLICA) continue;
|
||||||
|
strcpy(tsDnode.mnodeEpSetForShell.fqdn[mIndex], ep->dnodeFqdn);
|
||||||
|
strcpy(tsDnode.mnodeEpSetForPeer.fqdn[mIndex], ep->dnodeFqdn);
|
||||||
|
tsDnode.mnodeEpSetForShell.port[mIndex] = ep->dnodePort;
|
||||||
|
tsDnode.mnodeEpSetForShell.port[mIndex] = ep->dnodePort + tsDnodeDnodePort;
|
||||||
|
mIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < tsDnode.dnodeEps->dnodeNum; ++i) {
|
||||||
|
SDnodeEp *ep = &tsDnode.dnodeEps->dnodeEps[i];
|
||||||
|
taosHashPut(tsDnode.dnodeHash, &ep->dnodeId, sizeof(int32_t), ep, sizeof(SDnodeEp));
|
||||||
|
}
|
||||||
|
|
||||||
|
dnodePrintDnodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool dnodeIsEpChanged(int32_t dnodeId, char *epStr) {
|
||||||
|
bool changed = false;
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
|
||||||
|
SDnodeEp *pEp = taosHashGet(tsDnode.dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
|
if (pEp != NULL) {
|
||||||
|
char epSaved[TSDB_EP_LEN + 1];
|
||||||
|
snprintf(epSaved, TSDB_EP_LEN, "%s:%u", pEp->dnodeFqdn, pEp->dnodePort);
|
||||||
|
changed = strcmp(epStr, epSaved) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeReadDnodes() {
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t maxLen = 30000;
|
||||||
|
char *content = calloc(1, maxLen + 1);
|
||||||
|
cJSON *root = NULL;
|
||||||
|
FILE *fp = NULL;
|
||||||
|
|
||||||
|
fp = fopen(tsDnode.file, "r");
|
||||||
|
if (!fp) {
|
||||||
|
dDebug("file %s not exist", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||||
|
if (len <= 0) {
|
||||||
|
dError("failed to read %s since content is null", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
content[len] = 0;
|
||||||
|
root = cJSON_Parse(content);
|
||||||
|
if (root == NULL) {
|
||||||
|
dError("failed to read %s since invalid json format", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *dnodeId = cJSON_GetObjectItem(root, "dnodeId");
|
||||||
|
if (!dnodeId || dnodeId->type != cJSON_String) {
|
||||||
|
dError("failed to read %s since dnodeId not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
tsDnode.dnodeId = atoi(dnodeId->valuestring);
|
||||||
|
|
||||||
|
cJSON *clusterId = cJSON_GetObjectItem(root, "clusterId");
|
||||||
|
if (!clusterId || clusterId->type != cJSON_String) {
|
||||||
|
dError("failed to read %s since clusterId not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
tsDnode.clusterId = atoll(clusterId->valuestring);
|
||||||
|
|
||||||
|
cJSON *dropped = cJSON_GetObjectItem(root, "dropped");
|
||||||
|
if (!dropped || dropped->type != cJSON_String) {
|
||||||
|
dError("failed to read %s since dropped not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
tsDnode.dropped = atoi(dropped->valuestring);
|
||||||
|
|
||||||
|
cJSON *dnodeInfos = cJSON_GetObjectItem(root, "dnodeInfos");
|
||||||
|
if (!dnodeInfos || dnodeInfos->type != cJSON_Array) {
|
||||||
|
dError("failed to read %s since dnodeInfos not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dnodeInfosSize = cJSON_GetArraySize(dnodeInfos);
|
||||||
|
if (dnodeInfosSize <= 0) {
|
||||||
|
dError("failed to read %s since dnodeInfos size:%d invalid", tsDnode.file, dnodeInfosSize);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsDnode.dnodeEps = calloc(1, dnodeInfosSize * sizeof(SDnodeEp) + sizeof(SDnodeEps));
|
||||||
|
if (tsDnode.dnodeEps == NULL) {
|
||||||
|
dError("failed to calloc dnodeEpList since %s", strerror(errno));
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
tsDnode.dnodeEps->dnodeNum = dnodeInfosSize;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < dnodeInfosSize; ++i) {
|
||||||
|
cJSON *dnodeInfo = cJSON_GetArrayItem(dnodeInfos, i);
|
||||||
|
if (dnodeInfo == NULL) break;
|
||||||
|
|
||||||
|
SDnodeEp *pEp = &tsDnode.dnodeEps->dnodeEps[i];
|
||||||
|
|
||||||
|
cJSON *dnodeId = cJSON_GetObjectItem(dnodeInfo, "dnodeId");
|
||||||
|
if (!dnodeId || dnodeId->type != cJSON_String) {
|
||||||
|
dError("failed to read %s, dnodeId not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
pEp->dnodeId = atoi(dnodeId->valuestring);
|
||||||
|
|
||||||
|
cJSON *isMnode = cJSON_GetObjectItem(dnodeInfo, "isMnode");
|
||||||
|
if (!isMnode || isMnode->type != cJSON_String) {
|
||||||
|
dError("failed to read %s, isMnode not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
pEp->isMnode = atoi(isMnode->valuestring);
|
||||||
|
|
||||||
|
cJSON *dnodeFqdn = cJSON_GetObjectItem(dnodeInfo, "dnodeFqdn");
|
||||||
|
if (!dnodeFqdn || dnodeFqdn->type != cJSON_String || dnodeFqdn->valuestring == NULL) {
|
||||||
|
dError("failed to read %s, dnodeFqdn not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
tstrncpy(pEp->dnodeFqdn, dnodeFqdn->valuestring, TSDB_FQDN_LEN);
|
||||||
|
|
||||||
|
cJSON *dnodePort = cJSON_GetObjectItem(dnodeInfo, "dnodePort");
|
||||||
|
if (!dnodePort || dnodePort->type != cJSON_String) {
|
||||||
|
dError("failed to read %s, dnodePort not found", tsDnode.file);
|
||||||
|
goto PRASE_DNODE_OVER;
|
||||||
|
}
|
||||||
|
pEp->dnodePort = atoi(dnodePort->valuestring);
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("succcessed to read file %s", tsDnode.file);
|
||||||
|
dnodePrintDnodes();
|
||||||
|
|
||||||
|
PRASE_DNODE_OVER:
|
||||||
|
if (content != NULL) free(content);
|
||||||
|
if (root != NULL) cJSON_Delete(root);
|
||||||
|
if (fp != NULL) fclose(fp);
|
||||||
|
|
||||||
|
if (dnodeIsEpChanged(tsDnode.dnodeId, tsLocalEp)) {
|
||||||
|
dError("localEp %s different with %s and need reconfigured", tsLocalEp, tsDnode.file);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dnodeResetDnodes(tsDnode.dnodeEps);
|
||||||
|
|
||||||
|
terrno = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeWriteDnodes() {
|
||||||
|
FILE *fp = fopen(tsDnode.file, "w");
|
||||||
|
if (!fp) {
|
||||||
|
dError("failed to write %s since %s", tsDnode.file, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t maxLen = 30000;
|
||||||
|
char *content = calloc(1, maxLen + 1);
|
||||||
|
|
||||||
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dnodeId\": \"%d\",\n", tsDnode.dnodeId);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"clusterId\": \"%" PRId64 "\",\n", tsDnode.clusterId);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dropped\": \"%d\",\n", tsDnode.dropped);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dnodeInfos\": [{\n");
|
||||||
|
for (int32_t i = 0; i < tsDnode.dnodeEps->dnodeNum; ++i) {
|
||||||
|
SDnodeEp *ep = &tsDnode.dnodeEps->dnodeEps[i];
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dnodeId\": \"%d\",\n", ep->dnodeId);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"isMnode\": \"%d\",\n", ep->isMnode);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dnodeFqdn\": \"%s\",\n", ep->dnodeFqdn);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dnodePort\": \"%u\"\n", ep->dnodePort);
|
||||||
|
if (i < tsDnode.dnodeEps->dnodeNum - 1) {
|
||||||
|
len += snprintf(content + len, maxLen - len, " },{\n");
|
||||||
|
} else {
|
||||||
|
len += snprintf(content + len, maxLen - len, " }]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
len += snprintf(content + len, maxLen - len, "}\n");
|
||||||
|
|
||||||
|
fwrite(content, 1, len, fp);
|
||||||
|
taosFsyncFile(fileno(fp));
|
||||||
|
fclose(fp);
|
||||||
|
free(content);
|
||||||
|
terrno = 0;
|
||||||
|
|
||||||
|
dInfo("successed to write %s", tsDnode.file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeSendStatusMsg() {
|
||||||
|
int32_t contLen = sizeof(SStatusMsg) + TSDB_MAX_VNODES * sizeof(SVnodeLoad);
|
||||||
|
|
||||||
|
SStatusMsg *pStatus = rpcMallocCont(contLen);
|
||||||
|
if (pStatus == NULL) {
|
||||||
|
dError("failed to malloc status message");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStatus->sversion = htonl(tsVersion);
|
||||||
|
pStatus->dnodeId = htonl(dnodeGetDnodeId());
|
||||||
|
pStatus->clusterId = htobe64(dnodeGetClusterId());
|
||||||
|
pStatus->rebootTime = htonl(tsDnode.rebootTime);
|
||||||
|
pStatus->numOfCores = htonl(tsNumOfCores);
|
||||||
|
tstrncpy(pStatus->dnodeEp, tsLocalEp, TSDB_EP_LEN);
|
||||||
|
|
||||||
|
pStatus->clusterCfg.statusInterval = htonl(tsStatusInterval);
|
||||||
|
pStatus->clusterCfg.checkTime = 0;
|
||||||
|
tstrncpy(pStatus->clusterCfg.timezone, tsTimezone, TSDB_TIMEZONE_LEN);
|
||||||
|
tstrncpy(pStatus->clusterCfg.locale, tsLocale, TSDB_LOCALE_LEN);
|
||||||
|
tstrncpy(pStatus->clusterCfg.charset, tsCharset, TSDB_LOCALE_LEN);
|
||||||
|
char timestr[32] = "1970-01-01 00:00:00.00";
|
||||||
|
(void)taosParseTime(timestr, &pStatus->clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||||
|
|
||||||
|
dnodeGetVnodeLoads(&pStatus->vnodeLoads);
|
||||||
|
contLen = sizeof(SStatusMsg) + pStatus->vnodeLoads.num * sizeof(SVnodeLoad);
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {.pCont = pStatus, .contLen = contLen, .msgType = TSDB_MSG_TYPE_STATUS};
|
||||||
|
dnodeSendMsgToMnode(&rpcMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeUpdateCfg(SDnodeCfg *pCfg) {
|
||||||
|
if (tsDnode.dnodeId == 0) return;
|
||||||
|
if (tsDnode.dropped) return;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
|
||||||
|
tsDnode.dnodeId = pCfg->dnodeId;
|
||||||
|
tsDnode.clusterId = pCfg->clusterId;
|
||||||
|
tsDnode.dropped = pCfg->dropped;
|
||||||
|
dInfo("dnodeId is set to %d, clusterId is set to %" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
||||||
|
|
||||||
|
dnodeWriteDnodes();
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeUpdateDnodeEps(SDnodeEps *pEps) {
|
||||||
|
if (pEps == NULL || pEps->dnodeNum <= 0) return;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
|
||||||
|
if (pEps->dnodeNum != tsDnode.dnodeEps->dnodeNum) {
|
||||||
|
dnodeResetDnodes(pEps);
|
||||||
|
dnodeWriteDnodes();
|
||||||
|
} else {
|
||||||
|
int32_t size = pEps->dnodeNum * sizeof(SDnodeEp) + sizeof(SDnodeEps);
|
||||||
|
if (memcmp(tsDnode.dnodeEps, pEps, size) != 0) {
|
||||||
|
dnodeResetDnodes(pEps);
|
||||||
|
dnodeWriteDnodes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
|
||||||
|
if (pMsg->code != TSDB_CODE_SUCCESS) return;
|
||||||
|
|
||||||
|
SStatusRsp *pStatusRsp = pMsg->pCont;
|
||||||
|
|
||||||
|
SDnodeCfg *pCfg = &pStatusRsp->dnodeCfg;
|
||||||
|
pCfg->dnodeId = htonl(pCfg->dnodeId);
|
||||||
|
pCfg->clusterId = htobe64(pCfg->clusterId);
|
||||||
|
dnodeUpdateCfg(pCfg);
|
||||||
|
|
||||||
|
if (pCfg->dropped) return;
|
||||||
|
|
||||||
|
SDnodeEps *pEps = &pStatusRsp->dnodeEps;
|
||||||
|
pEps->dnodeNum = htonl(pEps->dnodeNum);
|
||||||
|
for (int32_t i = 0; i < pEps->dnodeNum; ++i) {
|
||||||
|
pEps->dnodeEps[i].dnodeId = htonl(pEps->dnodeEps[i].dnodeId);
|
||||||
|
pEps->dnodeEps[i].dnodePort = htons(pEps->dnodeEps[i].dnodePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
dnodeUpdateDnodeEps(pEps);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessConfigDnodeReq(SRpcMsg *pMsg) {
|
||||||
|
SCfgDnodeMsg *pCfg = pMsg->pCont;
|
||||||
|
|
||||||
|
int32_t code = taosCfgDynamicOptions(pCfg->config);
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->handle, .pCont = NULL, .contLen = 0, .code = code};
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessStartupReq(SRpcMsg *pMsg) {
|
||||||
|
dInfo("startup msg is received, cont:%s", (char *)pMsg->pCont);
|
||||||
|
|
||||||
|
SStartupMsg *pStartup = rpcMallocCont(sizeof(SStartupMsg));
|
||||||
|
dnodeGetStartup(pStartup);
|
||||||
|
|
||||||
|
dInfo("startup msg is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished);
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {.handle = pMsg->handle, .pCont = pStartup, .contLen = sizeof(SStartupMsg)};
|
||||||
|
rpcSendResponse(&rpcRsp);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *dnodeThreadRoutine(void *param) {
|
||||||
|
int32_t ms = tsStatusInterval * 1000;
|
||||||
|
|
||||||
|
while (!tsDnode.threadStop) {
|
||||||
|
if (dnodeGetRunStat() != DN_RUN_STAT_RUNNING) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
dnodeSendStatusMsg();
|
||||||
|
}
|
||||||
|
taosMsleep(ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dnodeInitDnode() {
|
||||||
|
tsDnode.dnodeId = 0;
|
||||||
|
tsDnode.clusterId = 0;
|
||||||
|
tsDnode.dnodeEps = NULL;
|
||||||
|
snprintf(tsDnode.file, sizeof(tsDnode.file), "%s/dnode.json", tsDnodeDir);
|
||||||
|
tsDnode.rebootTime = taosGetTimestampSec();
|
||||||
|
tsDnode.dropped = 0;
|
||||||
|
pthread_mutex_init(&tsDnode.mutex, NULL);
|
||||||
|
tsDnode.threadStop = false;
|
||||||
|
|
||||||
|
tsDnode.dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||||
|
if (tsDnode.dnodeHash == NULL) {
|
||||||
|
dError("failed to init dnode hash");
|
||||||
|
return TSDB_CODE_DND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsDnode.threadId = taosCreateThread(dnodeThreadRoutine, NULL);
|
||||||
|
if (tsDnode.threadId == NULL) {
|
||||||
|
dError("failed to init dnode thread");
|
||||||
|
return TSDB_CODE_DND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = dnodeReadDnodes();
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to read file:%s since %s", tsDnode.file, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("dnode-dnode is initialized");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeCleanupDnode() {
|
||||||
|
if (tsDnode.threadId != NULL) {
|
||||||
|
tsDnode.threadStop = true;
|
||||||
|
taosDestoryThread(tsDnode.threadId);
|
||||||
|
tsDnode.threadId = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock(&tsDnode.mutex);
|
||||||
|
|
||||||
|
if (tsDnode.dnodeEps != NULL) {
|
||||||
|
free(tsDnode.dnodeEps);
|
||||||
|
tsDnode.dnodeEps = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsDnode.dnodeHash) {
|
||||||
|
taosHashCleanup(tsDnode.dnodeHash);
|
||||||
|
tsDnode.dnodeHash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&tsDnode.mutex);
|
||||||
|
pthread_mutex_destroy(&tsDnode.mutex);
|
||||||
|
|
||||||
|
dInfo("dnode-dnode is cleaned up");
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeProcessDnodeMsg(SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
int32_t msgType = pMsg->msgType;
|
||||||
|
|
||||||
|
if (msgType == TSDB_MSG_TYPE_STATUS_RSP && pEpSet) {
|
||||||
|
dnodeUpdateMnodeEpSet(pEpSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (msgType) {
|
||||||
|
case TSDB_MSG_TYPE_NETWORK_TEST:
|
||||||
|
dnodeProcessStartupReq(pMsg);
|
||||||
|
break;
|
||||||
|
case TSDB_MSG_TYPE_CONFIG_DNODE_IN:
|
||||||
|
dnodeProcessConfigDnodeReq(pMsg);
|
||||||
|
break;
|
||||||
|
case TSDB_MSG_TYPE_STATUS_RSP:
|
||||||
|
dnodeProcessStatusRsp(pMsg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dError("RPC %p, %s not processed", pMsg->handle, taosMsg[msgType]);
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_DND_MSG_NOT_PROCESSED};
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,108 +14,42 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dnodeCheck.h"
|
#include "dnodeDnode.h"
|
||||||
#include "dnodeEps.h"
|
#include "dnodeMnode.h"
|
||||||
#include "dnodeMsg.h"
|
#include "dnodeTransport.h"
|
||||||
#include "dnodeTrans.h"
|
#include "dnodeVnodes.h"
|
||||||
#include "mnode.h"
|
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
#include "tnote.h"
|
#include "tnote.h"
|
||||||
#include "tstep.h"
|
#include "tstep.h"
|
||||||
#include "vnode.h"
|
|
||||||
#include "wal.h"
|
#include "wal.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
EDnStat runStatus;
|
SStartupMsg startup;
|
||||||
SStartupStep startup;
|
EDnStat runStat;
|
||||||
SSteps *steps;
|
SSteps *steps;
|
||||||
} tsDnode;
|
} tsInt;
|
||||||
|
|
||||||
EDnStat dnodeGetRunStat() { return tsDnode.runStatus; }
|
EDnStat dnodeGetRunStat() { return tsInt.runStat; }
|
||||||
|
|
||||||
void dnodeSetRunStat(EDnStat stat) { tsDnode.runStatus = stat; }
|
void dnodeSetRunStat(EDnStat stat) { tsInt.runStat = stat; }
|
||||||
|
|
||||||
void dnodeReportStartup(char *name, char *desc) {
|
void dnodeReportStartup(char *name, char *desc) {
|
||||||
SStartupStep *startup = &tsDnode.startup;
|
SStartupMsg *pStartup = &tsInt.startup;
|
||||||
tstrncpy(startup->name, name, strlen(startup->name));
|
tstrncpy(pStartup->name, name, strlen(pStartup->name));
|
||||||
tstrncpy(startup->desc, desc, strlen(startup->desc));
|
tstrncpy(pStartup->desc, desc, strlen(pStartup->desc));
|
||||||
startup->finished = 0;
|
pStartup->finished = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeReportStartupFinished(char *name, char *desc) {
|
void dnodeReportStartupFinished(char *name, char *desc) {
|
||||||
SStartupStep *startup = &tsDnode.startup;
|
SStartupMsg *pStartup = &tsInt.startup;
|
||||||
tstrncpy(startup->name, name, strlen(startup->name));
|
tstrncpy(pStartup->name, name, strlen(pStartup->name));
|
||||||
tstrncpy(startup->desc, desc, strlen(startup->desc));
|
tstrncpy(pStartup->desc, desc, strlen(pStartup->desc));
|
||||||
startup->finished = 1;
|
pStartup->finished = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeGetStartup(SStartupStep *pStep) { memcpy(pStep, &tsDnode.startup, sizeof(SStartupStep)); }
|
void dnodeGetStartup(SStartupMsg *pStartup) { memcpy(pStartup, &tsInt.startup, sizeof(SStartupMsg)); }
|
||||||
|
|
||||||
static int32_t dnodeInitVnode() {
|
|
||||||
SVnodePara para;
|
|
||||||
para.fp.GetDnodeEp = dnodeGetEp;
|
|
||||||
para.fp.SendMsgToDnode = dnodeSendMsgToDnode;
|
|
||||||
para.fp.SendMsgToMnode = dnodeSendMsgToMnode;
|
|
||||||
para.fp.ReportStartup = dnodeReportStartup;
|
|
||||||
|
|
||||||
return vnodeInit(para);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dnodeInitMnode() {
|
|
||||||
SMnodePara para;
|
|
||||||
para.fp.GetDnodeEp = dnodeGetEp;
|
|
||||||
para.fp.SendMsgToDnode = dnodeSendMsgToDnode;
|
|
||||||
para.fp.SendMsgToMnode = dnodeSendMsgToMnode;
|
|
||||||
para.fp.SendRedirectMsg = dnodeSendRedirectMsg;
|
|
||||||
para.dnodeId = dnodeGetDnodeId();
|
|
||||||
para.clusterId = dnodeGetClusterId();
|
|
||||||
|
|
||||||
return mnodeInit(para);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dnodeInitTfs() {}
|
|
||||||
|
|
||||||
static int32_t dnodeInitMain() {
|
|
||||||
tsDnode.runStatus = DN_RUN_STAT_STOPPED;
|
|
||||||
tscEmbedded = 1;
|
|
||||||
taosIgnSIGPIPE();
|
|
||||||
taosBlockSIGPIPE();
|
|
||||||
taosResolveCRC();
|
|
||||||
taosInitGlobalCfg();
|
|
||||||
taosReadGlobalLogCfg();
|
|
||||||
taosSetCoreDump(tsEnableCoreFile);
|
|
||||||
|
|
||||||
if (!taosMkDir(tsLogDir)) {
|
|
||||||
printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char temp[TSDB_FILENAME_LEN];
|
|
||||||
sprintf(temp, "%s/taosdlog", tsLogDir);
|
|
||||||
if (taosInitLog(temp, tsNumOfLogLines, 1) < 0) {
|
|
||||||
printf("failed to init log file\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!taosReadGlobalCfg()) {
|
|
||||||
taosPrintGlobalCfg();
|
|
||||||
dError("TDengine read global config failed");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dInfo("start to initialize TDengine");
|
|
||||||
|
|
||||||
taosInitNotes();
|
|
||||||
|
|
||||||
return taosCheckGlobalCfg();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dnodeCleanupMain() {
|
|
||||||
taos_cleanup();
|
|
||||||
taosCloseLog();
|
|
||||||
taosStopCacheRefreshWorker();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dnodeCheckRunning(char *dir) {
|
static int32_t dnodeCheckRunning(char *dir) {
|
||||||
char filepath[256] = {0};
|
char filepath[256] = {0};
|
||||||
|
@ -164,27 +98,68 @@ static int32_t dnodeInitDir() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeCleanupDir() {}
|
static int32_t dnodeInitMain() {
|
||||||
|
tsInt.runStat = DN_RUN_STAT_STOPPED;
|
||||||
|
tscEmbedded = 1;
|
||||||
|
taosIgnSIGPIPE();
|
||||||
|
taosBlockSIGPIPE();
|
||||||
|
taosResolveCRC();
|
||||||
|
taosInitGlobalCfg();
|
||||||
|
taosReadGlobalLogCfg();
|
||||||
|
taosSetCoreDump(tsEnableCoreFile);
|
||||||
|
|
||||||
|
if (!taosMkDir(tsLogDir)) {
|
||||||
|
printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char temp[TSDB_FILENAME_LEN];
|
||||||
|
sprintf(temp, "%s/taosdlog", tsLogDir);
|
||||||
|
if (taosInitLog(temp, tsNumOfLogLines, 1) < 0) {
|
||||||
|
printf("failed to init log file\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!taosReadGlobalCfg()) {
|
||||||
|
taosPrintGlobalCfg();
|
||||||
|
dError("TDengine read global config failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("start to initialize TDengine");
|
||||||
|
|
||||||
|
taosInitNotes();
|
||||||
|
|
||||||
|
if (taosCheckGlobalCfg() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dnodeInitDir();
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeCleanupMain() {
|
||||||
|
taos_cleanup();
|
||||||
|
taosCloseLog();
|
||||||
|
taosStopCacheRefreshWorker();
|
||||||
|
}
|
||||||
|
|
||||||
int32_t dnodeInit() {
|
int32_t dnodeInit() {
|
||||||
SSteps *steps = taosStepInit(24, dnodeReportStartup);
|
SSteps *steps = taosStepInit(24, dnodeReportStartup);
|
||||||
if (steps == NULL) return -1;
|
if (steps == NULL) return -1;
|
||||||
|
|
||||||
taosStepAdd(steps, "dnode-main", dnodeInitMain, dnodeCleanupMain);
|
taosStepAdd(steps, "dnode-main", dnodeInitMain, dnodeCleanupMain);
|
||||||
taosStepAdd(steps, "dnode-dir", dnodeInitDir, dnodeCleanupDir);
|
|
||||||
taosStepAdd(steps, "dnode-check", dnodeInitCheck, dnodeCleanupCheck);
|
|
||||||
taosStepAdd(steps, "dnode-rpc", rpcInit, rpcCleanup);
|
taosStepAdd(steps, "dnode-rpc", rpcInit, rpcCleanup);
|
||||||
taosStepAdd(steps, "dnode-tfs", dnodeInitTfs, NULL);
|
taosStepAdd(steps, "dnode-tfs", NULL, NULL);
|
||||||
taosStepAdd(steps, "dnode-wal", walInit, walCleanUp);
|
taosStepAdd(steps, "dnode-wal", walInit, walCleanUp);
|
||||||
taosStepAdd(steps, "dnode-sync", syncInit, syncCleanUp);
|
taosStepAdd(steps, "dnode-sync", syncInit, syncCleanUp);
|
||||||
taosStepAdd(steps, "dnode-eps", dnodeInitEps, dnodeCleanupEps);
|
taosStepAdd(steps, "dnode-dnode", dnodeInitDnode, dnodeCleanupDnode);
|
||||||
taosStepAdd(steps, "dnode-vnode", dnodeInitVnode, vnodeCleanup);
|
taosStepAdd(steps, "dnode-vnodes", dnodeInitVnodes, dnodeCleanupVnodes);
|
||||||
taosStepAdd(steps, "dnode-mnode", dnodeInitMnode, mnodeCleanup);
|
taosStepAdd(steps, "dnode-mnode", dnodeInitMnode, dnodeCleanupMnode);
|
||||||
taosStepAdd(steps, "dnode-trans", dnodeInitTrans, dnodeCleanupTrans);
|
taosStepAdd(steps, "dnode-trans", dnodeInitTrans, dnodeCleanupTrans);
|
||||||
taosStepAdd(steps, "dnode-msg", dnodeInitMsg, dnodeCleanupMsg);
|
|
||||||
|
|
||||||
tsDnode.steps = steps;
|
tsInt.steps = steps;
|
||||||
taosStepExec(tsDnode.steps);
|
taosStepExec(tsInt.steps);
|
||||||
|
|
||||||
dnodeSetRunStat(DN_RUN_STAT_RUNNING);
|
dnodeSetRunStat(DN_RUN_STAT_RUNNING);
|
||||||
dnodeReportStartupFinished("TDengine", "initialized successfully");
|
dnodeReportStartupFinished("TDengine", "initialized successfully");
|
||||||
|
@ -196,7 +171,7 @@ int32_t dnodeInit() {
|
||||||
void dnodeCleanup() {
|
void dnodeCleanup() {
|
||||||
if (dnodeGetRunStat() != DN_RUN_STAT_STOPPED) {
|
if (dnodeGetRunStat() != DN_RUN_STAT_STOPPED) {
|
||||||
dnodeSetRunStat(DN_RUN_STAT_STOPPED);
|
dnodeSetRunStat(DN_RUN_STAT_STOPPED);
|
||||||
taosStepCleanup(tsDnode.steps);
|
taosStepCleanup(tsInt.steps);
|
||||||
tsDnode.steps = NULL;
|
tsInt.steps = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,293 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "dnodeMnode.h"
|
||||||
|
#include "dnodeDnode.h"
|
||||||
|
#include "dnodeTransport.h"
|
||||||
|
#include "cJSON.h"
|
||||||
|
#include "mnode.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
int8_t deployed;
|
||||||
|
int8_t dropped;
|
||||||
|
char file[PATH_MAX + 20];
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
} tsMnode = {0};
|
||||||
|
|
||||||
|
static int32_t dnodeReadMnode() {
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t maxLen = 300;
|
||||||
|
char *content = calloc(1, maxLen + 1);
|
||||||
|
cJSON *root = NULL;
|
||||||
|
FILE *fp = NULL;
|
||||||
|
|
||||||
|
fp = fopen(tsMnode.file, "r");
|
||||||
|
if (!fp) {
|
||||||
|
dDebug("file %s not exist", tsMnode.file);
|
||||||
|
goto PRASE_MNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||||
|
if (len <= 0) {
|
||||||
|
dError("failed to read %s since content is null", tsMnode.file);
|
||||||
|
goto PRASE_MNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
content[len] = 0;
|
||||||
|
root = cJSON_Parse(content);
|
||||||
|
if (root == NULL) {
|
||||||
|
dError("failed to read %s since invalid json format", tsMnode.file);
|
||||||
|
goto PRASE_MNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *deployed = cJSON_GetObjectItem(root, "deployed");
|
||||||
|
if (!deployed || deployed->type != cJSON_String) {
|
||||||
|
dError("failed to read %s since deployed not found", tsMnode.file);
|
||||||
|
goto PRASE_MNODE_OVER;
|
||||||
|
}
|
||||||
|
tsMnode.deployed = atoi(deployed->valuestring);
|
||||||
|
|
||||||
|
cJSON *dropped = cJSON_GetObjectItem(root, "dropped");
|
||||||
|
if (!dropped || dropped->type != cJSON_String) {
|
||||||
|
dError("failed to read %s since dropped not found", tsMnode.file);
|
||||||
|
goto PRASE_MNODE_OVER;
|
||||||
|
}
|
||||||
|
tsMnode.dropped = atoi(dropped->valuestring);
|
||||||
|
|
||||||
|
dInfo("succcessed to read file %s", tsMnode.file);
|
||||||
|
|
||||||
|
PRASE_MNODE_OVER:
|
||||||
|
if (content != NULL) free(content);
|
||||||
|
if (root != NULL) cJSON_Delete(root);
|
||||||
|
if (fp != NULL) fclose(fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeWriteMnode() {
|
||||||
|
FILE *fp = fopen(tsMnode.file, "w");
|
||||||
|
if (!fp) {
|
||||||
|
dError("failed to write %s since %s", tsMnode.file, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t maxLen = 300;
|
||||||
|
char *content = calloc(1, maxLen + 1);
|
||||||
|
|
||||||
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"deployed\": \"%d\",\n", tsMnode.dropped);
|
||||||
|
len += snprintf(content + len, maxLen - len, " \"dropped\": \"%d\",\n", tsMnode.dropped);
|
||||||
|
len += snprintf(content + len, maxLen - len, "}\n");
|
||||||
|
|
||||||
|
fwrite(content, 1, len, fp);
|
||||||
|
taosFsyncFile(fileno(fp));
|
||||||
|
fclose(fp);
|
||||||
|
free(content);
|
||||||
|
terrno = 0;
|
||||||
|
|
||||||
|
dInfo("successed to write %s", tsMnode.file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeStartMnode(SCreateMnodeMsg *pCfg) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (pCfg->dnodeId != dnodeGetDnodeId()) {
|
||||||
|
code = TSDB_CODE_DND_DNODE_ID_NOT_MATCHED;
|
||||||
|
dError("failed to start mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsMnode.dropped) {
|
||||||
|
code = TSDB_CODE_DND_MNODE_ALREADY_DROPPED;
|
||||||
|
dError("failed to start mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsMnode.deployed) {
|
||||||
|
dError("failed to start mnode since its already deployed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsMnode.deployed = 1;
|
||||||
|
tsMnode.dropped = 0;
|
||||||
|
|
||||||
|
code = dnodeWriteMnode();
|
||||||
|
if (code != 0) {
|
||||||
|
tsMnode.deployed = 0;
|
||||||
|
dError("failed to start mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mnodeDeploy();
|
||||||
|
if (code != 0) {
|
||||||
|
tsMnode.deployed = 0;
|
||||||
|
dError("failed to start mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mnodeStart();
|
||||||
|
if (code != 0) {
|
||||||
|
tsMnode.deployed = 0;
|
||||||
|
dError("failed to start mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsMnode.deployed = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeDropMnode(SDropMnodeMsg *pCfg) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (pCfg->dnodeId != dnodeGetDnodeId()) {
|
||||||
|
code = TSDB_CODE_DND_DNODE_ID_NOT_MATCHED;
|
||||||
|
dError("failed to drop mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsMnode.dropped) {
|
||||||
|
code = TSDB_CODE_DND_MNODE_ALREADY_DROPPED;
|
||||||
|
dError("failed to drop mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tsMnode.deployed) {
|
||||||
|
dError("failed to drop mnode since not deployed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mnodeStop();
|
||||||
|
|
||||||
|
tsMnode.deployed = 0;
|
||||||
|
tsMnode.dropped = 1;
|
||||||
|
|
||||||
|
code = dnodeWriteMnode();
|
||||||
|
if (code != 0) {
|
||||||
|
tsMnode.deployed = 1;
|
||||||
|
tsMnode.dropped = 0;
|
||||||
|
dError("failed to drop mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
mnodeUnDeploy();
|
||||||
|
|
||||||
|
tsMnode.deployed = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessCreateMnodeReq(SRpcMsg *pMsg) {
|
||||||
|
SCreateMnodeMsg *pCfg = pMsg->pCont;
|
||||||
|
pCfg->dnodeId = htonl(pCfg->dnodeId);
|
||||||
|
|
||||||
|
int32_t code = dnodeStartMnode(pCfg);
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->handle, .code = code};
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessDropMnodeReq(SRpcMsg *pMsg) {
|
||||||
|
SDropMnodeMsg *pCfg = pMsg->pCont;
|
||||||
|
pCfg->dnodeId = htonl(pCfg->dnodeId);
|
||||||
|
|
||||||
|
int32_t code = dnodeDropMnode(pCfg);
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->handle, .code = code};
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool dnodeNeedDeployMnode() {
|
||||||
|
if (dnodeGetDnodeId() > 0) return false;
|
||||||
|
if (dnodeGetClusterId() > 0) return false;
|
||||||
|
if (strcmp(tsFirst, tsLocalEp) != 0) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dnodeInitMnode() {
|
||||||
|
tsMnode.dropped = 0;
|
||||||
|
tsMnode.deployed = 0;
|
||||||
|
snprintf(tsMnode.file, sizeof(tsMnode.file), "%s/mnode.json", tsDnodeDir);
|
||||||
|
|
||||||
|
SMnodePara para;
|
||||||
|
para.fp.GetDnodeEp = dnodeGetDnodeEp;
|
||||||
|
para.fp.SendMsgToDnode = dnodeSendMsgToDnode;
|
||||||
|
para.fp.SendMsgToMnode = dnodeSendMsgToMnode;
|
||||||
|
para.fp.SendRedirectMsg = dnodeSendRedirectMsg;
|
||||||
|
para.dnodeId = dnodeGetDnodeId();
|
||||||
|
para.clusterId = dnodeGetClusterId();
|
||||||
|
|
||||||
|
int32_t code = mnodeInit(para);
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to init mnode module since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = dnodeReadMnode();
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to read file:%s since %s", tsMnode.file, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsMnode.dropped) {
|
||||||
|
dError("mnode already dropped, undeploy it");
|
||||||
|
mnodeUnDeploy();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tsMnode.deployed) {
|
||||||
|
bool needDeploy = dnodeNeedDeployMnode();
|
||||||
|
if (needDeploy) {
|
||||||
|
code = mnodeDeploy();
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to deploy mnode since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsMnode.deployed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mnodeStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeCleanupMnode() {
|
||||||
|
if (tsMnode.deployed) {
|
||||||
|
mnodeStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
mnodeCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeProcessMnodeMsg(SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
switch (pMsg->msgType) {
|
||||||
|
case TSDB_MSG_TYPE_CREATE_MNODE_IN:
|
||||||
|
dnodeProcessCreateMnodeReq(pMsg);
|
||||||
|
break;
|
||||||
|
case TSDB_MSG_TYPE_DROP_MNODE_IN:
|
||||||
|
dnodeProcessDropMnodeReq(pMsg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mnodeProcessMsg(pMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dnodeGetUserAuthFromMnode(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
||||||
|
return mnodeRetriveAuth(user, spi, encrypt, secret, ckey);
|
||||||
|
}
|
|
@ -0,0 +1,376 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* this file is mainly responsible for the communication between DNODEs. Each
|
||||||
|
* dnode works as both server and client. Dnode may send status, grant, config
|
||||||
|
* messages to mnode, mnode may send create/alter/drop table/vnode messages
|
||||||
|
* to dnode. All theses messages are handled from here
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "dnodeTransport.h"
|
||||||
|
#include "dnodeDnode.h"
|
||||||
|
#include "dnodeMnode.h"
|
||||||
|
#include "dnodeVnodes.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
void *peerRpc;
|
||||||
|
void *shellRpc;
|
||||||
|
void *clientRpc;
|
||||||
|
MsgFp msgFp[TSDB_MSG_TYPE_MAX];
|
||||||
|
} tsTrans;
|
||||||
|
|
||||||
|
static void dnodeInitMsgFp() {
|
||||||
|
// msg from client to dnode
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_QUERY] = dnodeProcessVnodeQueryMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_FETCH] = dnodeProcessVnodeFetchMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_TABLE] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_TABLE] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_TABLE] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_UPDATE_TAG_VAL] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_TABLE_META] = dnodeProcessVnodeQueryMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_TABLES_META] = dnodeProcessVnodeQueryMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_MQ_QUERY] = dnodeProcessVnodeQueryMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_MQ_CONSUME] = dnodeProcessVnodeQueryMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_MQ_CONNECT] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_MQ_DISCONNECT] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_MQ_ACK] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_MQ_RESET] = dnodeProcessVnodeWriteMsg;
|
||||||
|
|
||||||
|
// msg from client to mnode
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CONNECT] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_ACCT] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_ACCT] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_ACCT] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_USER] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_USER] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_USER] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_DNODE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CONFIG_DNODE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_DNODE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_DB] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_DB] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_USE_DB] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_DB] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SYNC_DB] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_TOPIC] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_TOPIC] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_TOPIC] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_FUNCTION] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_FUNCTION] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_FUNCTION] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_STABLE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_STABLE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_STABLE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_STABLE_VGROUP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_KILL_QUERY] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_KILL_CONN] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_HEARTBEAT] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SHOW] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SHOW_RETRIEVE] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SHOW_RETRIEVE_FUNC] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_COMPACT_VNODE] = dnodeProcessMnodeMsg;
|
||||||
|
|
||||||
|
// message from client to dnode
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_NETWORK_TEST] = dnodeProcessDnodeMsg;
|
||||||
|
|
||||||
|
// message from mnode to vnode
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_STABLE_IN] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_STABLE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_STABLE_IN] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_STABLE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_STABLE_IN] = dnodeProcessVnodeWriteMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_STABLE_IN] = dnodeProcessMnodeMsg;
|
||||||
|
|
||||||
|
// message from mnode to dnode
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_VNODE_IN] = dnodeProcessVnodeMgmtMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_VNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_VNODE_IN] = dnodeProcessVnodeMgmtMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_ALTER_VNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_VNODE_IN] = dnodeProcessVnodeMgmtMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_VNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SYNC_VNODE_IN] = dnodeProcessVnodeMgmtMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_SYNC_VNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_AUTH_VNODE_IN] = dnodeProcessVnodeMgmtMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_AUTH_VNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_COMPACT_VNODE_IN] = dnodeProcessVnodeMgmtMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_COMPACT_VNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_MNODE_IN] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CREATE_MNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_MNODE_IN] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_DROP_MNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CONFIG_DNODE_IN] = dnodeProcessDnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_CONFIG_DNODE_IN_RSP] = dnodeProcessMnodeMsg;
|
||||||
|
|
||||||
|
// message from dnode to mnode
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_AUTH] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_AUTH_RSP] = dnodeProcessDnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_GRANT] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_GRANT_RSP] = dnodeProcessDnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_STATUS] = dnodeProcessMnodeMsg;
|
||||||
|
tsTrans.msgFp[TSDB_MSG_TYPE_STATUS_RSP] = dnodeProcessDnodeMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessPeerReq(SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->handle};
|
||||||
|
int32_t msgType = pMsg->msgType;
|
||||||
|
|
||||||
|
if (msgType == TSDB_MSG_TYPE_NETWORK_TEST) {
|
||||||
|
dnodeProcessDnodeMsg(pMsg, pEpSet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dnodeGetRunStat() != DN_RUN_STAT_RUNNING) {
|
||||||
|
rspMsg.code = TSDB_CODE_APP_NOT_READY;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
dTrace("RPC %p, peer req:%s is ignored since dnode not running", pMsg->handle, taosMsg[msgType]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMsg->pCont == NULL) {
|
||||||
|
rspMsg.code = TSDB_CODE_DND_INVALID_MSG_LEN;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MsgFp fp = tsTrans.msgFp[msgType];
|
||||||
|
if (fp != NULL) {
|
||||||
|
dTrace("RPC %p, peer req:%s will be processed", pMsg->handle, taosMsg[msgType]);
|
||||||
|
(*fp)(pMsg, pEpSet);
|
||||||
|
} else {
|
||||||
|
dError("RPC %p, peer req:%s not processed", pMsg->handle, taosMsg[msgType]);
|
||||||
|
rspMsg.code = TSDB_CODE_DND_MSG_NOT_PROCESSED;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeInitPeerServer() {
|
||||||
|
SRpcInit rpcInit;
|
||||||
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
rpcInit.localPort = tsDnodeDnodePort;
|
||||||
|
rpcInit.label = "DND-S";
|
||||||
|
rpcInit.numOfThreads = 1;
|
||||||
|
rpcInit.cfp = dnodeProcessPeerReq;
|
||||||
|
rpcInit.sessions = TSDB_MAX_VNODES << 4;
|
||||||
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
|
|
||||||
|
tsTrans.peerRpc = rpcOpen(&rpcInit);
|
||||||
|
if (tsTrans.peerRpc == NULL) {
|
||||||
|
dError("failed to init peer rpc server");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("dnode peer rpc server is initialized");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeCleanupPeerServer() {
|
||||||
|
if (tsTrans.peerRpc) {
|
||||||
|
rpcClose(tsTrans.peerRpc);
|
||||||
|
tsTrans.peerRpc = NULL;
|
||||||
|
dInfo("dnode peer server is closed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessPeerRsp(SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
int32_t msgType = pMsg->msgType;
|
||||||
|
|
||||||
|
if (dnodeGetRunStat() == DN_RUN_STAT_STOPPED) {
|
||||||
|
if (pMsg == NULL || pMsg->pCont == NULL) return;
|
||||||
|
dTrace("RPC %p, peer rsp:%s is ignored since dnode is stopping", pMsg->handle, taosMsg[msgType]);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MsgFp fp = tsTrans.msgFp[msgType];
|
||||||
|
if (fp != NULL) {
|
||||||
|
dTrace("RPC %p, peer rsp:%s will be processed, code:%s", pMsg->handle, taosMsg[msgType], tstrerror(pMsg->code));
|
||||||
|
(*fp)(pMsg, pEpSet);
|
||||||
|
} else {
|
||||||
|
dDebug("RPC %p, peer rsp:%s not processed", pMsg->handle, taosMsg[msgType]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeInitClient() {
|
||||||
|
char secret[TSDB_KEY_LEN] = "secret";
|
||||||
|
|
||||||
|
SRpcInit rpcInit;
|
||||||
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
rpcInit.label = "DND-C";
|
||||||
|
rpcInit.numOfThreads = 1;
|
||||||
|
rpcInit.cfp = dnodeProcessPeerRsp;
|
||||||
|
rpcInit.sessions = TSDB_MAX_VNODES << 4;
|
||||||
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
|
rpcInit.user = "t";
|
||||||
|
rpcInit.ckey = "key";
|
||||||
|
rpcInit.secret = secret;
|
||||||
|
|
||||||
|
tsTrans.clientRpc = rpcOpen(&rpcInit);
|
||||||
|
if (tsTrans.clientRpc == NULL) {
|
||||||
|
dError("failed to init peer rpc client");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("dnode peer rpc client is initialized");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeCleanupClient() {
|
||||||
|
if (tsTrans.clientRpc) {
|
||||||
|
rpcClose(tsTrans.clientRpc);
|
||||||
|
tsTrans.clientRpc = NULL;
|
||||||
|
dInfo("dnode peer rpc client is closed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeProcessShellReq(SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->handle};
|
||||||
|
int32_t msgType = pMsg->msgType;
|
||||||
|
|
||||||
|
if (dnodeGetRunStat() == DN_RUN_STAT_STOPPED) {
|
||||||
|
dError("RPC %p, shell req:%s is ignored since dnode exiting", pMsg->handle, taosMsg[msgType]);
|
||||||
|
rspMsg.code = TSDB_CODE_DND_EXITING;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
return;
|
||||||
|
} else if (dnodeGetRunStat() != DN_RUN_STAT_RUNNING) {
|
||||||
|
dError("RPC %p, shell req:%s is ignored since dnode not running", pMsg->handle, taosMsg[msgType]);
|
||||||
|
rspMsg.code = TSDB_CODE_APP_NOT_READY;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMsg->pCont == NULL) {
|
||||||
|
rspMsg.code = TSDB_CODE_DND_INVALID_MSG_LEN;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MsgFp fp = tsTrans.msgFp[msgType];
|
||||||
|
if (fp != NULL) {
|
||||||
|
dTrace("RPC %p, shell req:%s will be processed", pMsg->handle, taosMsg[msgType]);
|
||||||
|
(*fp)(pMsg, pEpSet);
|
||||||
|
} else {
|
||||||
|
dError("RPC %p, shell req:%s is not processed", pMsg->handle, taosMsg[msgType]);
|
||||||
|
rspMsg.code = TSDB_CODE_DND_MSG_NOT_PROCESSED;
|
||||||
|
rpcSendResponse(&rspMsg);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
dnodeGetMnodeEpSetForPeer(&epSet);
|
||||||
|
rpcSendRecv(tsTrans.clientRpc, &epSet, rpcMsg, rpcRsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
||||||
|
int32_t code = dnodeGetUserAuthFromMnode(user, spi, encrypt, secret, ckey);
|
||||||
|
if (code != TSDB_CODE_APP_NOT_READY) return code;
|
||||||
|
|
||||||
|
SAuthMsg *pMsg = rpcMallocCont(sizeof(SAuthMsg));
|
||||||
|
tstrncpy(pMsg->user, user, sizeof(pMsg->user));
|
||||||
|
|
||||||
|
dDebug("user:%s, send auth msg to mnodes", user);
|
||||||
|
SRpcMsg rpcMsg = {.pCont = pMsg, .contLen = sizeof(SAuthMsg), .msgType = TSDB_MSG_TYPE_AUTH};
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
dnodeSendMsgToMnodeRecv(&rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
if (rpcRsp.code != 0) {
|
||||||
|
dError("user:%s, auth msg received from mnodes, error:%s", user, tstrerror(rpcRsp.code));
|
||||||
|
} else {
|
||||||
|
dDebug("user:%s, auth msg received from mnodes", user);
|
||||||
|
SAuthRsp *pRsp = rpcRsp.pCont;
|
||||||
|
memcpy(secret, pRsp->secret, TSDB_KEY_LEN);
|
||||||
|
memcpy(ckey, pRsp->ckey, TSDB_KEY_LEN);
|
||||||
|
*spi = pRsp->spi;
|
||||||
|
*encrypt = pRsp->encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcFreeCont(rpcRsp.pCont);
|
||||||
|
return rpcRsp.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeInitShellServer() {
|
||||||
|
int32_t numOfThreads = (int32_t)((tsNumOfCores * tsNumOfThreadsPerCore) / 2.0);
|
||||||
|
if (numOfThreads < 1) {
|
||||||
|
numOfThreads = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcInit rpcInit;
|
||||||
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
rpcInit.localPort = tsDnodeShellPort;
|
||||||
|
rpcInit.label = "SHELL";
|
||||||
|
rpcInit.numOfThreads = numOfThreads;
|
||||||
|
rpcInit.cfp = dnodeProcessShellReq;
|
||||||
|
rpcInit.sessions = tsMaxShellConns;
|
||||||
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
|
rpcInit.afp = dnodeRetrieveUserAuthInfo;
|
||||||
|
|
||||||
|
tsTrans.shellRpc = rpcOpen(&rpcInit);
|
||||||
|
if (tsTrans.shellRpc == NULL) {
|
||||||
|
dError("failed to init shell rpc server");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("dnode shell rpc server is initialized");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dnodeCleanupShellServer() {
|
||||||
|
if (tsTrans.shellRpc) {
|
||||||
|
rpcClose(tsTrans.shellRpc);
|
||||||
|
tsTrans.shellRpc = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dnodeInitTrans() {
|
||||||
|
if (dnodeInitClient() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dnodeInitPeerServer() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dnodeInitShellServer() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeCleanupTrans() {
|
||||||
|
dnodeCleanupShellServer();
|
||||||
|
dnodeCleanupPeerServer();
|
||||||
|
dnodeCleanupClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeSendMsgToDnode(SEpSet *epSet, SRpcMsg *rpcMsg) { rpcSendRequest(tsTrans.clientRpc, epSet, rpcMsg, NULL); }
|
||||||
|
|
||||||
|
void dnodeSendMsgToMnode(SRpcMsg *rpcMsg) {
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
dnodeGetMnodeEpSetForPeer(&epSet);
|
||||||
|
dnodeSendMsgToDnode(&epSet, rpcMsg);
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -120,7 +120,7 @@ typedef struct SDnodeObj {
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int64_t lastAccess;
|
int64_t lastAccess;
|
||||||
int64_t lastReboot; // time stamp for last reboot
|
int64_t rebootTime; // time stamp for last reboot
|
||||||
char fqdn[TSDB_FQDN_LEN];
|
char fqdn[TSDB_FQDN_LEN];
|
||||||
char ep[TSDB_EP_LEN];
|
char ep[TSDB_EP_LEN];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
@ -208,7 +208,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct SDbObj {
|
typedef struct SDbObj {
|
||||||
SdbHead head;
|
SdbHead head;
|
||||||
char name[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char name[TSDB_FULL_DB_NAME_LEN];
|
||||||
char acct[TSDB_USER_LEN];
|
char acct[TSDB_USER_LEN];
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
|
@ -236,7 +236,7 @@ typedef struct SVgObj {
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int32_t lbDnodeId;
|
int32_t lbDnodeId;
|
||||||
int32_t lbTime;
|
int32_t lbTime;
|
||||||
char dbName[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char dbName[TSDB_FULL_DB_NAME_LEN];
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
int8_t accessState;
|
int8_t accessState;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
|
@ -288,7 +288,7 @@ typedef struct {
|
||||||
void *pIter;
|
void *pIter;
|
||||||
void *pVgIter;
|
void *pVgIter;
|
||||||
void **ppShow;
|
void **ppShow;
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
int16_t offset[TSDB_MAX_COLUMNS];
|
int16_t offset[TSDB_MAX_COLUMNS];
|
||||||
int32_t bytes[TSDB_MAX_COLUMNS];
|
int32_t bytes[TSDB_MAX_COLUMNS];
|
||||||
char payload[];
|
char payload[];
|
|
@ -22,12 +22,14 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum { MN_STATUS_UNINIT = 0, MN_STATUS_INIT = 1, MN_STATUS_READY = 2, MN_STATUS_CLOSING = 3 } EMnStatus;
|
||||||
|
|
||||||
tmr_h mnodeGetTimer();
|
tmr_h mnodeGetTimer();
|
||||||
int32_t mnodeGetDnodeId();
|
int32_t mnodeGetDnodeId();
|
||||||
int64_t mnodeGetClusterId();
|
int64_t mnodeGetClusterId();
|
||||||
EMnStatus mnodeGetStatus();
|
EMnStatus mnodeGetStatus();
|
||||||
|
|
||||||
void mnodeSendMsgToDnode(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg);
|
void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
||||||
void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg);
|
void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg);
|
||||||
void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell);
|
void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell);
|
||||||
void mnodeGetDnodeEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
void mnodeGetDnodeEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
|
@ -24,8 +24,8 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mnodeInitMnode();
|
int32_t mnodeInitMnode();
|
||||||
void mnodeCleanupMnode();
|
void mnodeCleanupMnode();
|
||||||
void mnodeGetMnodeEpSetForPeer(SRpcEpSet *epSet, bool redirect);
|
void mnodeGetMnodeEpSetForPeer(SEpSet *epSet, bool redirect);
|
||||||
void mnodeGetMnodeEpSetForShell(SRpcEpSet *epSet, bool redirect);
|
void mnodeGetMnodeEpSetForShell(SEpSet *epSet, bool redirect);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -20,5 +20,5 @@
|
||||||
int32_t mnodeInitMnode() { return 0; }
|
int32_t mnodeInitMnode() { return 0; }
|
||||||
void mnodeCleanupMnode() {}
|
void mnodeCleanupMnode() {}
|
||||||
|
|
||||||
void mnodeGetMnodeEpSetForPeer(SRpcEpSet *epSet, bool redirect) {}
|
void mnodeGetMnodeEpSetForPeer(SEpSet *epSet, bool redirect) {}
|
||||||
void mnodeGetMnodeEpSetForShell(SRpcEpSet *epSet, bool redirect) {}
|
void mnodeGetMnodeEpSetForShell(SEpSet *epSet, bool redirect) {}
|
|
@ -81,7 +81,7 @@ static void mnodeDispatchToWriteQueue(SRpcMsg *pRpcMsg) {
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
} else {
|
} else {
|
||||||
mTrace("msg:%p, app:%p type:%s is put into wqueue", pMsg, pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType]);
|
mTrace("msg:%p, app:%p type:%s is put into wqueue", pMsg, pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType]);
|
||||||
taosWriteQitem(tsMworker.writeQ, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsMworker.writeQ, pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ void mnodeReDispatchToWriteQueue(SMnMsg *pMsg) {
|
||||||
mnodeSendRedirectMsg(&pMsg->rpcMsg, true);
|
mnodeSendRedirectMsg(&pMsg->rpcMsg, true);
|
||||||
mnodeCleanupMsg(pMsg);
|
mnodeCleanupMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
taosWriteQitem(tsMworker.writeQ, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsMworker.writeQ, pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ static void mnodeDispatchToReadQueue(SRpcMsg *pRpcMsg) {
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
} else {
|
} else {
|
||||||
mTrace("msg:%p, app:%p type:%s is put into rqueue", pMsg, pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType]);
|
mTrace("msg:%p, app:%p type:%s is put into rqueue", pMsg, pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType]);
|
||||||
taosWriteQitem(tsMworker.readQ, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsMworker.readQ, pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ static void mnodeDispatchToPeerQueue(SRpcMsg *pRpcMsg) {
|
||||||
} else {
|
} else {
|
||||||
mTrace("msg:%p, app:%p type:%s is put into peer req queue", pMsg, pMsg->rpcMsg.ahandle,
|
mTrace("msg:%p, app:%p type:%s is put into peer req queue", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
taosMsg[pMsg->rpcMsg.msgType]);
|
taosMsg[pMsg->rpcMsg.msgType]);
|
||||||
taosWriteQitem(tsMworker.peerReqQ, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsMworker.peerReqQ, pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,13 +140,13 @@ void mnodeDispatchToPeerRspQueue(SRpcMsg *pRpcMsg) {
|
||||||
} else {
|
} else {
|
||||||
mTrace("msg:%p, app:%p type:%s is put into peer rsp queue", pMsg, pMsg->rpcMsg.ahandle,
|
mTrace("msg:%p, app:%p type:%s is put into peer rsp queue", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
taosMsg[pMsg->rpcMsg.msgType]);
|
taosMsg[pMsg->rpcMsg.msgType]);
|
||||||
taosWriteQitem(tsMworker.peerRspQ, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsMworker.peerRspQ, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rpcFreeCont(pRpcMsg->pCont);
|
// rpcFreeCont(pRpcMsg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeSendRpcRsp(void *ahandle, SMnMsg *pMsg, int32_t qtype, int32_t code) {
|
void mnodeSendRsp(SMnMsg *pMsg, int32_t code) {
|
||||||
if (pMsg == NULL) return;
|
if (pMsg == NULL) return;
|
||||||
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
||||||
if (code == TSDB_CODE_MND_ACTION_NEED_REPROCESSED) {
|
if (code == TSDB_CODE_MND_ACTION_NEED_REPROCESSED) {
|
||||||
|
@ -165,24 +165,18 @@ static void mnodeSendRpcRsp(void *ahandle, SMnMsg *pMsg, int32_t qtype, int32_t
|
||||||
mnodeCleanupMsg(pMsg);
|
mnodeCleanupMsg(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeSendRsp(SMnMsg *pMsg, int32_t code) { mnodeSendRpcRsp(NULL, pMsg, 0, code); }
|
|
||||||
|
|
||||||
static void mnodeProcessPeerRspEnd(void *ahandle, SMnMsg *pMsg, int32_t qtype, int32_t code) {
|
|
||||||
mnodeCleanupMsg(pMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mnodeInitMsgFp() {
|
static void mnodeInitMsgFp() {
|
||||||
// // peer req
|
// // peer req
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mnodeDispatchToPeerQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mnodeDispatchToPeerQueue;
|
||||||
// tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mnodeProcessTableCfgMsg;
|
// tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mnodeProcessTableCfgMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mnodeDispatchToPeerQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mnodeDispatchToPeerQueue;
|
||||||
// tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mnodeProcessVnodeCfgMsg;
|
// tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mnodeProcessVnodeCfgMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_DM_AUTH] = mnodeDispatchToPeerQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_AUTH] = mnodeDispatchToPeerQueue;
|
||||||
// tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_AUTH] = mnodeProcessAuthMsg;
|
// tsMworker.peerReqFp[TSDB_MSG_TYPE_AUTH] = mnodeProcessAuthMsg;
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_DM_GRANT] = mnodeDispatchToPeerQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_GRANT] = mnodeDispatchToPeerQueue;
|
||||||
// // tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_GRANT] = grantProcessMsgInMgmt;
|
// // tsMworker.peerReqFp[TSDB_MSG_TYPE_GRANT] = grantProcessMsgInMgmt;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_DM_STATUS] = mnodeDispatchToPeerQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_STATUS] = mnodeDispatchToPeerQueue;
|
||||||
// tsMworker.peerReqFp[TSDB_MSG_TYPE_DM_STATUS] = mnodeProcessDnodeStatusMsg;
|
// tsMworker.peerReqFp[TSDB_MSG_TYPE_STATUS] = mnodeProcessDnodeStatusMsg;
|
||||||
|
|
||||||
// // peer rsp
|
// // peer rsp
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP] = mnodeDispatchToPeerRspQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP] = mnodeDispatchToPeerRspQueue;
|
||||||
|
@ -207,189 +201,211 @@ static void mnodeInitMsgFp() {
|
||||||
// tsMworker.peerRspFp[TSDB_MSG_TYPE_MD_DROP_VNODE_RSP] = mnodeProcessDropVnodeRsp;
|
// tsMworker.peerRspFp[TSDB_MSG_TYPE_MD_DROP_VNODE_RSP] = mnodeProcessDropVnodeRsp;
|
||||||
|
|
||||||
// // read msg
|
// // read msg
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_HEARTBEAT] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = mnodeProcessHeartBeatMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_HEARTBEAT] = mnodeProcessHeartBeatMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CONNECT] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CONNECT] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_CONNECT] = mnodeProcessConnectMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CONNECT] = mnodeProcessConnectMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_USE_DB] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_USE_DB] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_USE_DB] = mnodeProcessUseMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_USE_DB] = mnodeProcessUseMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_TABLE_META] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_TABLE_META] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_TABLE_META] = mnodeProcessTableMetaMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_TABLE_META] = mnodeProcessTableMetaMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_TABLES_META] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_TABLES_META] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_TABLES_META] = mnodeProcessMultiTableMetaMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_TABLES_META] = mnodeProcessMultiTableMetaMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_STABLE_VGROUP] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_STABLE_VGROUP] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_STABLE_VGROUP] = mnodeProcessSuperTableVgroupMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_STABLE_VGROUP] = mnodeProcessSuperTableVgroupMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_SHOW] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_SHOW] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_SHOW] = mnodeProcessShowMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_SHOW] = mnodeProcessShowMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_RETRIEVE] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_SHOW_RETRIEVE] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_RETRIEVE] = mnodeProcessRetrieveMsg;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_SHOW_RETRIEVE] = mnodeProcessRetrieveMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_RETRIEVE_FUNC] = mnodeDispatchToReadQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_RETRIEVE_FUNC] = mnodeDispatchToReadQueue;
|
||||||
// tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_RETRIEVE_FUNC] = mnodeProcessRetrieveFuncReq;
|
// tsMworker.readMsgFp[TSDB_MSG_TYPE_RETRIEVE_FUNC] = mnodeProcessRetrieveFuncReq;
|
||||||
|
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_ACCT] = mnodeDispatchToWriteQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_ACCT] = mnodeDispatchToWriteQueue;
|
||||||
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_CREATE_ACCT] = acctProcessCreateAcctMsg;
|
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CREATE_ACCT] = acctProcessCreateAcctMsg;
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_CM_ALTER_ACCT] = mnodeDispatchToWriteQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_ALTER_ACCT] = mnodeDispatchToWriteQueue;
|
||||||
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_ALTER_ACCT] = acctProcessDropAcctMsg;
|
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_ALTER_ACCT] = acctProcessDropAcctMsg;
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_ACCT] = mnodeDispatchToWriteQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_DROP_ACCT] = mnodeDispatchToWriteQueue;
|
||||||
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_DROP_ACCT] = acctProcessAlterAcctMsg;
|
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_DROP_ACCT] = acctProcessAlterAcctMsg;
|
||||||
|
|
||||||
// // write msg
|
// // write msg
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_USER] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_USER] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_CREATE_USER] = mnodeProcessCreateUserMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CREATE_USER] = mnodeProcessCreateUserMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_ALTER_USER] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_ALTER_USER] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_ALTER_USER] = mnodeProcessAlterUserMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_ALTER_USER] = mnodeProcessAlterUserMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_USER] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DROP_USER] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_DROP_USER] = mnodeProcessDropUserMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_DROP_USER] = mnodeProcessDropUserMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_DNODE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE] = mnodeProcessCreateDnodeMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CREATE_DNODE] = mnodeProcessCreateDnodeMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DROP_DNODE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = mnodeProcessDropDnodeMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_DROP_DNODE] = mnodeProcessDropDnodeMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CONFIG_DNODE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE] = mnodeProcessCfgDnodeMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CONFIG_DNODE] = mnodeProcessCfgDnodeMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_DB] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = mnodeProcessCreateDbMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CREATE_DB] = mnodeProcessCreateDbMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_ALTER_DB] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = mnodeProcessAlterDbMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_ALTER_DB] = mnodeProcessAlterDbMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_DB] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DROP_DB] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = mnodeProcessDropDbMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_DROP_DB] = mnodeProcessDropDbMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_SYNC_DB] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_SYNC_DB] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_SYNC_DB] = mnodeProcessSyncDbMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_SYNC_DB] = mnodeProcessSyncDbMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_COMPACT_VNODE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_COMPACT_VNODE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_COMPACT_VNODE] = mnodeProcessCompactMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_COMPACT_VNODE] = mnodeProcessCompactMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_FUNCTION] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_FUNCTION] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_CREATE_FUNCTION] = mnodeProcessCreateFuncMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CREATE_FUNCTION] = mnodeProcessCreateFuncMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_FUNCTION] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DROP_FUNCTION] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_DROP_FUNCTION] = mnodeProcessDropFuncMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_DROP_FUNCTION] = mnodeProcessDropFuncMsg;
|
||||||
|
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_TP] = mnodeDispatchToWriteQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_TP] = mnodeDispatchToWriteQueue;
|
||||||
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_CREATE_TP] = tpProcessCreateTpMsg;
|
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CREATE_TP] = tpProcessCreateTpMsg;
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_TP] = mnodeDispatchToWriteQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_DROP_TP] = mnodeDispatchToWriteQueue;
|
||||||
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_DROP_TP] = tpProcessAlterTpMsg;
|
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_DROP_TP] = tpProcessAlterTpMsg;
|
||||||
// // tsMworker.msgFp[TSDB_MSG_TYPE_CM_ALTER_TP] = mnodeDispatchToWriteQueue;
|
// // tsMworker.msgFp[TSDB_MSG_TYPE_ALTER_TP] = mnodeDispatchToWriteQueue;
|
||||||
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_CM_ALTER_TP] = tpProcessDropTpMsg;
|
// // tsMworker.readMsgFp[TSDB_MSG_TYPE_ALTER_TP] = tpProcessDropTpMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_CREATE_TABLE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE] = mnodeProcessCreateTableMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CREATE_TABLE] = mnodeProcessCreateTableMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_DROP_TABLE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = mnodeProcessDropTableMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_DROP_TABLE] = mnodeProcessDropTableMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_ALTER_TABLE] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = mnodeProcessAlterTableMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_ALTER_TABLE] = mnodeProcessAlterTableMsg;
|
||||||
|
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_ALTER_STREAM] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_ALTER_STREAM] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_ALTER_STREAM] = NULL;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_ALTER_STREAM] = NULL;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_KILL_QUERY] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_KILL_QUERY] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_KILL_QUERY] = mnodeProcessKillQueryMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_KILL_QUERY] = mnodeProcessKillQueryMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_KILL_STREAM] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = mnodeProcessKillStreamMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_KILL_STREAM] = mnodeProcessKillStreamMsg;
|
||||||
// tsMworker.msgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = mnodeDispatchToWriteQueue;
|
// tsMworker.msgFp[TSDB_MSG_TYPE_KILL_CONN] = mnodeDispatchToWriteQueue;
|
||||||
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = mnodeProcessKillConnectionMsg;
|
// tsMworker.writeMsgFp[TSDB_MSG_TYPE_KILL_CONN] = mnodeProcessKillConnectionMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessWriteReq(void *unused, SMnMsg *pMsg, int32_t qtype) {
|
static void mnodeProcessWriteReq(SMnMsg *pMsg, void *unused) {
|
||||||
int32_t msgType = pMsg->rpcMsg.msgType;
|
int32_t msgType = pMsg->rpcMsg.msgType;
|
||||||
void *ahandle = pMsg->rpcMsg.ahandle;
|
void *ahandle = pMsg->rpcMsg.ahandle;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pMsg->rpcMsg.pCont == NULL) {
|
if (pMsg->rpcMsg.pCont == NULL) {
|
||||||
mError("msg:%p, app:%p type:%s content is null", pMsg, ahandle, taosMsg[msgType]);
|
mError("msg:%p, app:%p type:%s content is null", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return TSDB_CODE_MND_INVALID_MSG_LEN;
|
code = TSDB_CODE_MND_INVALID_MSG_LEN;
|
||||||
|
goto PROCESS_WRITE_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mnodeIsMaster()) {
|
if (!mnodeIsMaster()) {
|
||||||
SMnRsp *rpcRsp = &pMsg->rpcRsp;
|
SMnRsp *rpcRsp = &pMsg->rpcRsp;
|
||||||
SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet));
|
SEpSet *epSet = rpcMallocCont(sizeof(SEpSet));
|
||||||
mnodeGetMnodeEpSetForShell(epSet, true);
|
mnodeGetMnodeEpSetForShell(epSet, true);
|
||||||
rpcRsp->rsp = epSet;
|
rpcRsp->rsp = epSet;
|
||||||
rpcRsp->len = sizeof(SRpcEpSet);
|
rpcRsp->len = sizeof(SEpSet);
|
||||||
|
|
||||||
mDebug("msg:%p, app:%p type:%s in write queue, is redirected, numOfEps:%d inUse:%d", pMsg, ahandle,
|
mDebug("msg:%p, app:%p type:%s in write queue, is redirected, numOfEps:%d inUse:%d", pMsg, ahandle,
|
||||||
taosMsg[msgType], epSet->numOfEps, epSet->inUse);
|
taosMsg[msgType], epSet->numOfEps, epSet->inUse);
|
||||||
|
|
||||||
return TSDB_CODE_RPC_REDIRECT;
|
code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
goto PROCESS_WRITE_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsMworker.writeMsgFp[msgType] == NULL) {
|
if (tsMworker.writeMsgFp[msgType] == NULL) {
|
||||||
mError("msg:%p, app:%p type:%s not processed", pMsg, ahandle, taosMsg[msgType]);
|
mError("msg:%p, app:%p type:%s not processed", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
code = TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
||||||
|
goto PROCESS_WRITE_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*tsMworker.writeMsgFp[msgType])(pMsg);
|
code = (*tsMworker.writeMsgFp[msgType])(pMsg);
|
||||||
|
|
||||||
|
PROCESS_WRITE_REQ_END:
|
||||||
|
mnodeSendRsp(pMsg, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessReadReq(void* unused, SMnMsg *pMsg, int32_t qtype) {
|
static void mnodeProcessReadReq(SMnMsg *pMsg, void *unused) {
|
||||||
int32_t msgType = pMsg->rpcMsg.msgType;
|
int32_t msgType = pMsg->rpcMsg.msgType;
|
||||||
void *ahandle = pMsg->rpcMsg.ahandle;
|
void *ahandle = pMsg->rpcMsg.ahandle;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pMsg->rpcMsg.pCont == NULL) {
|
if (pMsg->rpcMsg.pCont == NULL) {
|
||||||
mError("msg:%p, app:%p type:%s in mread queue, content is null", pMsg, ahandle, taosMsg[msgType]);
|
mError("msg:%p, app:%p type:%s in mread queue, content is null", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return TSDB_CODE_MND_INVALID_MSG_LEN;
|
code = TSDB_CODE_MND_INVALID_MSG_LEN;
|
||||||
|
goto PROCESS_READ_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mnodeIsMaster()) {
|
if (!mnodeIsMaster()) {
|
||||||
SMnRsp *rpcRsp = &pMsg->rpcRsp;
|
SMnRsp *rpcRsp = &pMsg->rpcRsp;
|
||||||
SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet));
|
SEpSet *epSet = rpcMallocCont(sizeof(SEpSet));
|
||||||
if (!epSet) {
|
if (!epSet) {
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
code = TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
goto PROCESS_READ_REQ_END;
|
||||||
}
|
}
|
||||||
mnodeGetMnodeEpSetForShell(epSet, true);
|
mnodeGetMnodeEpSetForShell(epSet, true);
|
||||||
rpcRsp->rsp = epSet;
|
rpcRsp->rsp = epSet;
|
||||||
rpcRsp->len = sizeof(SRpcEpSet);
|
rpcRsp->len = sizeof(SEpSet);
|
||||||
|
|
||||||
mDebug("msg:%p, app:%p type:%s in mread queue is redirected, numOfEps:%d inUse:%d", pMsg, ahandle, taosMsg[msgType],
|
mDebug("msg:%p, app:%p type:%s in mread queue is redirected, numOfEps:%d inUse:%d", pMsg, ahandle, taosMsg[msgType],
|
||||||
epSet->numOfEps, epSet->inUse);
|
epSet->numOfEps, epSet->inUse);
|
||||||
return TSDB_CODE_RPC_REDIRECT;
|
code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
goto PROCESS_READ_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsMworker.readMsgFp[msgType] == NULL) {
|
if (tsMworker.readMsgFp[msgType] == NULL) {
|
||||||
mError("msg:%p, app:%p type:%s in mread queue, not processed", pMsg, ahandle, taosMsg[msgType]);
|
mError("msg:%p, app:%p type:%s in mread queue, not processed", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
code = TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
||||||
|
goto PROCESS_READ_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
mTrace("msg:%p, app:%p type:%s will be processed in mread queue", pMsg, ahandle, taosMsg[msgType]);
|
mTrace("msg:%p, app:%p type:%s will be processed in mread queue", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return (*tsMworker.readMsgFp[msgType])(pMsg);
|
code = (*tsMworker.readMsgFp[msgType])(pMsg);
|
||||||
|
|
||||||
|
PROCESS_READ_REQ_END:
|
||||||
|
mnodeSendRsp(pMsg, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessPeerReq(void *unused, SMnMsg *pMsg, int32_t qtype) {
|
static void mnodeProcessPeerReq(SMnMsg *pMsg, void *unused) {
|
||||||
int32_t msgType = pMsg->rpcMsg.msgType;
|
int32_t msgType = pMsg->rpcMsg.msgType;
|
||||||
void *ahandle = pMsg->rpcMsg.ahandle;
|
void *ahandle = pMsg->rpcMsg.ahandle;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pMsg->rpcMsg.pCont == NULL) {
|
if (pMsg->rpcMsg.pCont == NULL) {
|
||||||
mError("msg:%p, ahandle:%p type:%s in mpeer queue, content is null", pMsg, ahandle, taosMsg[msgType]);
|
mError("msg:%p, ahandle:%p type:%s in mpeer queue, content is null", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return TSDB_CODE_MND_INVALID_MSG_LEN;
|
code = TSDB_CODE_MND_INVALID_MSG_LEN;
|
||||||
|
goto PROCESS_PEER_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mnodeIsMaster()) {
|
if (!mnodeIsMaster()) {
|
||||||
SMnRsp *rpcRsp = &pMsg->rpcRsp;
|
SMnRsp *rpcRsp = &pMsg->rpcRsp;
|
||||||
SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet));
|
SEpSet *epSet = rpcMallocCont(sizeof(SEpSet));
|
||||||
mnodeGetMnodeEpSetForPeer(epSet, true);
|
mnodeGetMnodeEpSetForPeer(epSet, true);
|
||||||
rpcRsp->rsp = epSet;
|
rpcRsp->rsp = epSet;
|
||||||
rpcRsp->len = sizeof(SRpcEpSet);
|
rpcRsp->len = sizeof(SEpSet);
|
||||||
|
|
||||||
mDebug("msg:%p, ahandle:%p type:%s in mpeer queue is redirected, numOfEps:%d inUse:%d", pMsg, ahandle,
|
mDebug("msg:%p, ahandle:%p type:%s in mpeer queue is redirected, numOfEps:%d inUse:%d", pMsg, ahandle,
|
||||||
taosMsg[msgType], epSet->numOfEps, epSet->inUse);
|
taosMsg[msgType], epSet->numOfEps, epSet->inUse);
|
||||||
|
|
||||||
return TSDB_CODE_RPC_REDIRECT;
|
code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
goto PROCESS_PEER_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsMworker.peerReqFp[msgType] == NULL) {
|
if (tsMworker.peerReqFp[msgType] == NULL) {
|
||||||
mError("msg:%p, ahandle:%p type:%s in mpeer queue, not processed", pMsg, ahandle, taosMsg[msgType]);
|
mError("msg:%p, ahandle:%p type:%s in mpeer queue, not processed", pMsg, ahandle, taosMsg[msgType]);
|
||||||
return TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
code = TSDB_CODE_MND_MSG_NOT_PROCESSED;
|
||||||
|
goto PROCESS_PEER_REQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*tsMworker.peerReqFp[msgType])(pMsg);
|
code = (*tsMworker.peerReqFp[msgType])(pMsg);
|
||||||
|
|
||||||
|
PROCESS_PEER_REQ_END:
|
||||||
|
mnodeSendRsp(pMsg, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessPeerRsp(void *ahandle, SMnMsg *pMsg, int32_t qtype) {
|
static void mnodeProcessPeerRsp(SMnMsg *pMsg, void *unused) {
|
||||||
int32_t msgType = pMsg->rpcMsg.msgType;
|
int32_t msgType = pMsg->rpcMsg.msgType;
|
||||||
SRpcMsg *pRpcMsg = &pMsg->rpcMsg;
|
SRpcMsg *pRpcMsg = &pMsg->rpcMsg;
|
||||||
|
|
||||||
if (!mnodeIsMaster()) {
|
if (!mnodeIsMaster()) {
|
||||||
mError("msg:%p, ahandle:%p type:%s not processed for not master", pRpcMsg, pRpcMsg->ahandle, taosMsg[msgType]);
|
mError("msg:%p, ahandle:%p type:%s not processed for not master", pRpcMsg, pRpcMsg->ahandle, taosMsg[msgType]);
|
||||||
return 0;
|
mnodeCleanupMsg(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsMworker.peerRspFp[msgType]) {
|
if (tsMworker.peerRspFp[msgType]) {
|
||||||
|
@ -398,7 +414,7 @@ static int32_t mnodeProcessPeerRsp(void *ahandle, SMnMsg *pMsg, int32_t qtype) {
|
||||||
mError("msg:%p, ahandle:%p type:%s is not processed", pRpcMsg, pRpcMsg->ahandle, taosMsg[msgType]);
|
mError("msg:%p, ahandle:%p type:%s is not processed", pRpcMsg, pRpcMsg->ahandle, taosMsg[msgType]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
mnodeCleanupMsg(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mnodeInitWorker() {
|
int32_t mnodeInitWorker() {
|
||||||
|
@ -406,20 +422,16 @@ int32_t mnodeInitWorker() {
|
||||||
|
|
||||||
SWorkerPool *pPool = &tsMworker.write;
|
SWorkerPool *pPool = &tsMworker.write;
|
||||||
pPool->name = "mnode-write";
|
pPool->name = "mnode-write";
|
||||||
pPool->startFp = (ProcessStartFp)mnodeProcessWriteReq;
|
|
||||||
pPool->endFp = (ProcessEndFp)mnodeSendRpcRsp;
|
|
||||||
pPool->min = 1;
|
pPool->min = 1;
|
||||||
pPool->max = 1;
|
pPool->max = 1;
|
||||||
if (tWorkerInit(pPool) != 0) {
|
if (tWorkerInit(pPool) != 0) {
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
tsMworker.writeQ = tWorkerAllocQueue(pPool, NULL);
|
tsMworker.writeQ = tWorkerAllocQueue(pPool, NULL, (FProcessItem)mnodeProcessWriteReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
pPool = &tsMworker.read;
|
pPool = &tsMworker.read;
|
||||||
pPool->name = "mnode-read";
|
pPool->name = "mnode-read";
|
||||||
pPool->startFp = (ProcessStartFp)mnodeProcessReadReq;
|
|
||||||
pPool->endFp = (ProcessEndFp)mnodeSendRpcRsp;
|
|
||||||
pPool->min = 2;
|
pPool->min = 2;
|
||||||
pPool->max = (int32_t)(tsNumOfCores * tsNumOfThreadsPerCore / 2);
|
pPool->max = (int32_t)(tsNumOfCores * tsNumOfThreadsPerCore / 2);
|
||||||
pPool->max = MAX(2, pPool->max);
|
pPool->max = MAX(2, pPool->max);
|
||||||
|
@ -427,31 +439,27 @@ int32_t mnodeInitWorker() {
|
||||||
if (tWorkerInit(pPool) != 0) {
|
if (tWorkerInit(pPool) != 0) {
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
tsMworker.readQ = tWorkerAllocQueue(pPool, NULL);
|
tsMworker.readQ = tWorkerAllocQueue(pPool, NULL, (FProcessItem)mnodeProcessReadReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
pPool = &tsMworker.peerReq;
|
pPool = &tsMworker.peerReq;
|
||||||
pPool->name = "mnode-peer-req";
|
pPool->name = "mnode-peer-req";
|
||||||
pPool->startFp = (ProcessStartFp)mnodeProcessPeerReq;
|
|
||||||
pPool->endFp = (ProcessEndFp)mnodeSendRpcRsp;
|
|
||||||
pPool->min = 1;
|
pPool->min = 1;
|
||||||
pPool->max = 1;
|
pPool->max = 1;
|
||||||
if (tWorkerInit(pPool) != 0) {
|
if (tWorkerInit(pPool) != 0) {
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
tsMworker.peerReqQ = tWorkerAllocQueue(pPool, NULL);
|
tsMworker.peerReqQ = tWorkerAllocQueue(pPool, NULL, (FProcessItem)mnodeProcessPeerReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
pPool = &tsMworker.peerRsp;
|
pPool = &tsMworker.peerRsp;
|
||||||
pPool->name = "mnode-peer-rsp";
|
pPool->name = "mnode-peer-rsp";
|
||||||
pPool->startFp = (ProcessStartFp)mnodeProcessPeerRsp;
|
|
||||||
pPool->endFp = (ProcessEndFp)mnodeProcessPeerRspEnd;
|
|
||||||
pPool->min = 1;
|
pPool->min = 1;
|
||||||
pPool->max = 1;
|
pPool->max = 1;
|
||||||
if (tWorkerInit(pPool) != 0) {
|
if (tWorkerInit(pPool) != 0) {
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
tsMworker.peerRspQ = tWorkerAllocQueue(pPool, NULL);
|
tsMworker.peerRspQ = tWorkerAllocQueue(pPool, NULL, (FProcessItem)mnodeProcessPeerRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("mnode worker is initialized");
|
mInfo("mnode worker is initialized");
|
|
@ -54,7 +54,7 @@ int64_t mnodeGetClusterId() { return tsMint.clusterId; }
|
||||||
|
|
||||||
EMnStatus mnodeGetStatus() { return tsMint.state; }
|
EMnStatus mnodeGetStatus() { return tsMint.state; }
|
||||||
|
|
||||||
void mnodeSendMsgToDnode(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg) {
|
void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg) {
|
||||||
(*tsMint.fp.SendMsgToDnode)(epSet, rpcMsg);
|
(*tsMint.fp.SendMsgToDnode)(epSet, rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,3 +250,6 @@ void mnodeCleanup() {
|
||||||
mInfo("mnode is cleaned up");
|
mInfo("mnode is cleaned up");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mnodeStart() { return 0; }
|
||||||
|
void mnodeStop() {}
|
|
@ -0,0 +1,4 @@
|
||||||
|
add_subdirectory(meta)
|
||||||
|
add_subdirectory(tq)
|
||||||
|
add_subdirectory(tsdb)
|
||||||
|
add_subdirectory(impl)
|
|
@ -1,7 +1,3 @@
|
||||||
add_subdirectory(meta)
|
|
||||||
add_subdirectory(tq)
|
|
||||||
add_subdirectory(tsdb)
|
|
||||||
|
|
||||||
aux_source_directory(src VNODE_SRC)
|
aux_source_directory(src VNODE_SRC)
|
||||||
add_library(vnode STATIC ${VNODE_SRC})
|
add_library(vnode STATIC ${VNODE_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
|
@ -16,6 +16,8 @@
|
||||||
#ifndef _TD_VNODE_COMMIT_H_
|
#ifndef _TD_VNODE_COMMIT_H_
|
||||||
#define _TD_VNODE_COMMIT_H_
|
#define _TD_VNODE_COMMIT_H_
|
||||||
|
|
||||||
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_VNODE_INT_H_
|
||||||
|
#define _TD_VNODE_INT_H_
|
||||||
|
|
||||||
|
#include "vnode.h"
|
||||||
|
|
||||||
|
#include "amalloc.h"
|
||||||
|
#include "meta.h"
|
||||||
|
#include "sync.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
#include "tq.h"
|
||||||
|
#include "tsdb.h"
|
||||||
|
#include "wal.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int32_t vDebugFlag;
|
||||||
|
|
||||||
|
#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", 255, __VA_ARGS__); }}
|
||||||
|
#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", 255, __VA_ARGS__); }}
|
||||||
|
#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", 255, __VA_ARGS__); }}
|
||||||
|
#define vInfo(...) { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", 255, __VA_ARGS__); }}
|
||||||
|
#define vDebug(...) { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }}
|
||||||
|
#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
|
typedef struct SVnode {
|
||||||
|
int32_t vgId;
|
||||||
|
SVnodeCfg cfg;
|
||||||
|
SMeta *pMeta;
|
||||||
|
STsdb *pTsdb;
|
||||||
|
STQ *pTQ;
|
||||||
|
SWal *pWal;
|
||||||
|
SSyncNode *pSync;
|
||||||
|
} SVnode;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_VNODE_INT_H_*/
|
|
@ -16,7 +16,7 @@
|
||||||
#ifndef _TD_VNODE_MEM_ALLOCATOR_H_
|
#ifndef _TD_VNODE_MEM_ALLOCATOR_H_
|
||||||
#define _TD_VNODE_MEM_ALLOCATOR_H_
|
#define _TD_VNODE_MEM_ALLOCATOR_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
|
@ -13,21 +13,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_PLUGINS_SYNC_H
|
#ifndef _TD_VNODE_READ_H_
|
||||||
#define TDENGINE_PLUGINS_SYNC_H
|
#define _TD_VNODE_READ_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
void vnodeProcessReadMsg(SVnode *pVnode, SVnodeMsg *pMsg);
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
int32_t syncTest1();
|
|
||||||
int32_t syncTest2();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /*_TD_VNODE_READ_H_*/
|
|
@ -13,19 +13,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DNODE_CHECK_H_
|
#ifndef _TD_VNODE_WRITE_H_
|
||||||
#define _TD_DNODE_CHECK_H_
|
#define _TD_VNODE_WRITE_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include "dnodeInt.h"
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
int32_t dnodeInitCheck();
|
void vnodeProcessWriteMsg(SVnode* pVnode, SVnodeMsg* pMsg);
|
||||||
void dnodeCleanupCheck();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DNODE_CHECK_H_*/
|
#endif /*_TD_VNODE_WRITE_H_*/
|
|
@ -19,6 +19,7 @@ static int vnodeStartCommit(SVnode *pVnode);
|
||||||
static int vnodeEndCommit(SVnode *pVnode);
|
static int vnodeEndCommit(SVnode *pVnode);
|
||||||
|
|
||||||
int vnodeAsyncCommit(SVnode *pVnode) {
|
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||||
|
#if 0
|
||||||
if (vnodeStartCommit(pVnode) < 0) {
|
if (vnodeStartCommit(pVnode) < 0) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
@ -39,6 +40,7 @@ int vnodeAsyncCommit(SVnode *pVnode) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "vnodeInt.h"
|
||||||
|
#include "tqueue.h"
|
||||||
|
|
||||||
|
int32_t vnodeInit(SVnodePara para) { return 0; }
|
||||||
|
void vnodeCleanup() {}
|
||||||
|
|
||||||
|
SVnode *vnodeOpen(int32_t vgId, const char *path) { return NULL; }
|
||||||
|
void vnodeClose(SVnode *pVnode) {}
|
||||||
|
int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; }
|
||||||
|
SVnode *vnodeCreate(int32_t vgId, const char *path, const SVnodeCfg *pCfg) { return NULL; }
|
||||||
|
void vnodeDrop(SVnode *pVnode) {}
|
||||||
|
int32_t vnodeCompact(SVnode *pVnode) { return 0; }
|
||||||
|
int32_t vnodeSync(SVnode *pVnode) { return 0; }
|
||||||
|
|
||||||
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { return 0; }
|
||||||
|
|
||||||
|
SVnodeMsg *vnodeInitMsg(int32_t msgNum) {
|
||||||
|
SVnodeMsg *pMsg = taosAllocateQitem(msgNum * sizeof(SRpcMsg *) + sizeof(SVnodeMsg));
|
||||||
|
if (pMsg == NULL) {
|
||||||
|
terrno = TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
pMsg->allocNum = msgNum;
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vnodeAppendMsg(SVnodeMsg *pMsg, SRpcMsg *pRpcMsg) {
|
||||||
|
if (pMsg->curNum >= pMsg->allocNum) {
|
||||||
|
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMsg->rpcMsg[pMsg->curNum++] = *pRpcMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnodeCleanupMsg(SVnodeMsg *pMsg) {
|
||||||
|
for (int32_t i = 0; i < pMsg->curNum; ++i) {
|
||||||
|
rpcFreeCont(pMsg->rpcMsg[i].pCont);
|
||||||
|
}
|
||||||
|
taosFreeQitem(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnodeProcessMsg(SVnode *pVnode, SVnodeMsg *pMsg, EVnMsgType msgType) {
|
||||||
|
switch (msgType) {
|
||||||
|
case VN_MSG_TYPE_WRITE:
|
||||||
|
break;
|
||||||
|
case VN_MSG_TYPE_APPLY:
|
||||||
|
break;
|
||||||
|
case VN_MSG_TYPE_SYNC:
|
||||||
|
break;
|
||||||
|
case VN_MSG_TYPE_QUERY:
|
||||||
|
break;
|
||||||
|
case VN_MSG_TYPE_FETCH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,11 +13,5 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_HTTP_HANDLE_H
|
#define _DEFAULT_SOURCE
|
||||||
#define TDENGINE_HTTP_HANDLE_H
|
#include "vnodeRead.h"
|
||||||
|
|
||||||
// http request handler
|
|
||||||
void httpProcessRequest(HttpContext *pContext);
|
|
||||||
bool httpProcessData(HttpContext *pContext);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "vnodeWrite.h"
|
|
@ -6,4 +6,4 @@ target_sources(VMATest
|
||||||
"vnodeMemAllocatorTest.cpp"
|
"vnodeMemAllocatorTest.cpp"
|
||||||
)
|
)
|
||||||
target_include_directories(VMATest PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../inc")
|
target_include_directories(VMATest PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../inc")
|
||||||
target_link_libraries(VMATest os gtest_main)
|
target_link_libraries(VMATest os gtest_main vnode)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue