TDengine/source/dnode/mnode/impl/inc/mndDef.h

604 lines
15 KiB
C
Raw Normal View History

2021-09-22 08:15:20 +00:00
/*
* 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/>.
*/
2021-11-27 15:02:20 +00:00
#ifndef _TD_MND_DEF_H_
#define _TD_MND_DEF_H_
2021-10-04 09:44:39 +00:00
#include "os.h"
2021-12-15 02:48:49 +00:00
#include "cJSON.h"
2022-01-24 02:46:55 +00:00
#include "scheduler.h"
2021-12-15 02:48:49 +00:00
#include "sync.h"
#include "thash.h"
2022-01-04 02:40:34 +00:00
#include "tlist.h"
2021-10-17 03:42:05 +00:00
#include "tlog.h"
2022-01-24 02:46:55 +00:00
#include "tmsg.h"
2021-10-17 03:42:05 +00:00
#include "trpc.h"
2022-03-25 13:03:12 +00:00
#include "tstream.h"
2021-10-17 03:42:05 +00:00
#include "ttimer.h"
2021-12-15 02:48:49 +00:00
2021-10-17 03:42:05 +00:00
#include "mnode.h"
2021-10-04 09:44:39 +00:00
2021-10-16 07:16:05 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-10-04 09:44:39 +00:00
2021-10-17 03:42:05 +00:00
typedef enum {
2021-11-29 04:09:18 +00:00
MND_AUTH_ACCT_START = 0,
MND_AUTH_ACCT_USER,
MND_AUTH_ACCT_DNODE,
MND_AUTH_ACCT_MNODE,
MND_AUTH_ACCT_DB,
MND_AUTH_ACCT_TABLE,
MND_AUTH_ACCT_MAX
} EAuthAcct;
2021-10-17 03:42:05 +00:00
typedef enum {
2021-11-29 04:09:18 +00:00
MND_AUTH_OP_START = 0,
MND_AUTH_OP_CREATE_USER,
MND_AUTH_OP_ALTER_USER,
MND_AUTH_OP_DROP_USER,
MND_AUTH_MAX
} EAuthOp;
2021-10-17 03:42:05 +00:00
2021-11-19 06:46:06 +00:00
typedef enum {
TRN_STAGE_PREPARE = 0,
2021-12-26 15:46:22 +00:00
TRN_STAGE_REDO_LOG = 1,
TRN_STAGE_REDO_ACTION = 2,
2022-01-06 04:22:33 +00:00
TRN_STAGE_COMMIT = 3,
TRN_STAGE_COMMIT_LOG = 4,
2022-01-05 06:36:24 +00:00
TRN_STAGE_UNDO_ACTION = 5,
TRN_STAGE_UNDO_LOG = 6,
2021-12-26 15:46:22 +00:00
TRN_STAGE_ROLLBACK = 7,
TRN_STAGE_FINISHED = 8
2021-11-19 06:46:06 +00:00
} ETrnStage;
2022-02-17 07:40:27 +00:00
typedef enum {
2022-02-18 05:34:55 +00:00
TRN_TYPE_BASIC_SCOPE = 1000,
TRN_TYPE_CREATE_USER = 1001,
TRN_TYPE_ALTER_USER = 1002,
TRN_TYPE_DROP_USER = 1003,
2022-02-18 03:49:15 +00:00
TRN_TYPE_CREATE_FUNC = 1004,
TRN_TYPE_DROP_FUNC = 1005,
2022-02-18 05:34:55 +00:00
TRN_TYPE_CREATE_SNODE = 1006,
TRN_TYPE_DROP_SNODE = 1007,
TRN_TYPE_CREATE_QNODE = 1008,
TRN_TYPE_DROP_QNODE = 1009,
TRN_TYPE_CREATE_BNODE = 1010,
TRN_TYPE_DROP_BNODE = 1011,
TRN_TYPE_CREATE_MNODE = 1012,
TRN_TYPE_DROP_MNODE = 1013,
TRN_TYPE_CREATE_TOPIC = 1014,
TRN_TYPE_DROP_TOPIC = 1015,
TRN_TYPE_SUBSCRIBE = 1016,
TRN_TYPE_REBALANCE = 1017,
2022-02-23 08:04:06 +00:00
TRN_TYPE_COMMIT_OFFSET = 1018,
2022-03-10 09:15:45 +00:00
TRN_TYPE_CREATE_STREAM = 1019,
2022-03-16 10:29:31 +00:00
TRN_TYPE_DROP_STREAM = 1020,
TRN_TYPE_ALTER_STREAM = 1021,
TRN_TYPE_CONSUMER_LOST = 1022,
2022-02-18 05:34:55 +00:00
TRN_TYPE_BASIC_SCOPE_END,
TRN_TYPE_GLOBAL_SCOPE = 2000,
TRN_TYPE_CREATE_DNODE = 2001,
TRN_TYPE_DROP_DNODE = 2002,
TRN_TYPE_GLOBAL_SCOPE_END,
TRN_TYPE_DB_SCOPE = 3000,
TRN_TYPE_CREATE_DB = 3001,
TRN_TYPE_ALTER_DB = 3002,
TRN_TYPE_DROP_DB = 3003,
2022-02-18 06:12:29 +00:00
TRN_TYPE_SPLIT_VGROUP = 3004,
TRN_TYPE_MERGE_VGROUP = 3015,
2022-02-18 05:34:55 +00:00
TRN_TYPE_DB_SCOPE_END,
2022-02-18 06:12:29 +00:00
TRN_TYPE_STB_SCOPE = 4000,
TRN_TYPE_CREATE_STB = 4001,
TRN_TYPE_ALTER_STB = 4002,
TRN_TYPE_DROP_STB = 4003,
2022-03-23 05:50:53 +00:00
TRN_TYPE_CREATE_SMA = 4004,
TRN_TYPE_DROP_SMA = 4005,
2022-02-18 06:12:29 +00:00
TRN_TYPE_STB_SCOPE_END,
2022-02-17 07:40:27 +00:00
} ETrnType;
typedef enum { TRN_POLICY_ROLLBACK = 0, TRN_POLICY_RETRY = 1 } ETrnPolicy;
2021-11-19 06:46:06 +00:00
2021-11-30 07:28:51 +00:00
typedef enum {
DND_REASON_ONLINE = 0,
DND_REASON_STATUS_MSG_TIMEOUT,
DND_REASON_STATUS_NOT_RECEIVED,
DND_REASON_VERSION_NOT_MATCH,
DND_REASON_DNODE_ID_NOT_MATCH,
DND_REASON_CLUSTER_ID_NOT_MATCH,
DND_REASON_STATUS_INTERVAL_NOT_MATCH,
DND_REASON_TIME_ZONE_NOT_MATCH,
DND_REASON_LOCALE_NOT_MATCH,
DND_REASON_CHARSET_NOT_MATCH,
DND_REASON_OTHERS
} EDndReason;
2022-04-26 06:14:28 +00:00
typedef void (*TransCbFp)(SMnode* pMnode, void* param);
2021-12-15 10:13:39 +00:00
typedef struct {
2021-11-19 06:46:06 +00:00
int32_t id;
ETrnStage stage;
ETrnPolicy policy;
2022-02-18 03:47:38 +00:00
ETrnType transType;
2021-12-26 15:46:22 +00:00
int32_t code;
int32_t failedTimes;
2022-01-24 02:46:55 +00:00
void* rpcHandle;
void* rpcAHandle;
2022-04-22 15:58:34 +00:00
int64_t rpcRefId;
2022-01-27 01:33:44 +00:00
void* rpcRsp;
int32_t rpcRspLen;
2022-01-24 02:46:55 +00:00
SArray* redoLogs;
SArray* undoLogs;
SArray* commitLogs;
SArray* redoActions;
SArray* undoActions;
2022-02-17 07:40:27 +00:00
int64_t createdTime;
int64_t lastExecTime;
2022-02-23 08:04:06 +00:00
int64_t dbUid;
2022-02-17 14:46:48 +00:00
char dbname[TSDB_DB_FNAME_LEN];
2022-02-18 02:47:58 +00:00
char lastError[TSDB_TRANS_ERROR_LEN];
2022-04-26 06:14:28 +00:00
TransCbFp transCbFp;
void* transCbParam;
2021-11-19 06:46:06 +00:00
} STrans;
2021-10-17 03:42:05 +00:00
2021-12-15 10:13:39 +00:00
typedef struct {
2021-12-27 02:57:31 +00:00
int64_t id;
2021-12-06 10:21:14 +00:00
char name[TSDB_CLUSTER_ID_LEN];
2021-10-17 03:42:05 +00:00
int64_t createdTime;
int64_t updateTime;
} SClusterObj;
2021-12-15 02:48:49 +00:00
typedef struct {
2021-11-30 07:28:51 +00:00
int32_t id;
int64_t createdTime;
int64_t updateTime;
int64_t rebootTime;
2021-12-12 04:14:26 +00:00
int64_t lastAccessTime;
2021-11-30 11:42:51 +00:00
int32_t accessTimes;
2021-12-30 07:09:07 +00:00
int32_t numOfVnodes;
2021-12-30 03:35:46 +00:00
int32_t numOfSupportVnodes;
int32_t numOfCores;
2021-11-30 07:28:51 +00:00
EDndReason offlineReason;
uint16_t port;
char fqdn[TSDB_FQDN_LEN];
char ep[TSDB_EP_LEN];
2021-10-17 03:42:05 +00:00
} SDnodeObj;
2021-12-15 10:13:39 +00:00
typedef struct {
2021-10-17 03:42:05 +00:00
int32_t id;
2021-11-30 07:28:51 +00:00
int64_t createdTime;
int64_t updateTime;
2021-11-30 11:42:51 +00:00
ESyncState role;
2021-10-17 03:42:05 +00:00
int32_t roleTerm;
int64_t roleTime;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2021-10-17 03:42:05 +00:00
} SMnodeObj;
2021-12-29 12:05:10 +00:00
typedef struct {
int32_t id;
int64_t createdTime;
int64_t updateTime;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2021-12-29 12:05:10 +00:00
} SQnodeObj;
typedef struct {
int32_t id;
int64_t createdTime;
int64_t updateTime;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2021-12-29 12:05:10 +00:00
} SSnodeObj;
typedef struct {
int32_t id;
int64_t createdTime;
int64_t updateTime;
2022-01-24 02:46:55 +00:00
SDnodeObj* pDnode;
2021-12-29 12:05:10 +00:00
} SBnodeObj;
2021-10-17 03:42:05 +00:00
typedef struct {
int32_t maxUsers;
int32_t maxDbs;
2021-12-31 06:32:59 +00:00
int32_t maxStbs;
int32_t maxTbs;
2021-10-17 03:42:05 +00:00
int32_t maxTimeSeries;
int32_t maxStreams;
2021-12-31 06:32:59 +00:00
int32_t maxFuncs;
int32_t maxConsumers;
int32_t maxConns;
int32_t maxTopics;
int64_t maxStorage;
2021-11-09 03:37:58 +00:00
int32_t accessState; // Configured only by command
2021-10-17 03:42:05 +00:00
} SAcctCfg;
typedef struct {
int32_t numOfUsers;
int32_t numOfDbs;
int32_t numOfTimeSeries;
int32_t numOfStreams;
2021-10-17 14:26:38 +00:00
int64_t totalStorage; // Total storage wrtten from this account
int64_t compStorage; // Compressed storage on disk
2021-10-17 03:42:05 +00:00
} SAcctInfo;
2021-12-15 10:13:39 +00:00
typedef struct {
2021-10-17 03:42:05 +00:00
char acct[TSDB_USER_LEN];
int64_t createdTime;
int64_t updateTime;
int32_t acctId;
2021-11-09 03:37:58 +00:00
int32_t status;
2021-10-17 03:42:05 +00:00
SAcctCfg cfg;
SAcctInfo info;
} SAcctObj;
2021-12-15 02:48:49 +00:00
typedef struct {
2021-10-17 03:42:05 +00:00
char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN];
2021-10-17 03:42:05 +00:00
char acct[TSDB_USER_LEN];
int64_t createdTime;
int64_t updateTime;
int8_t superUser;
2021-12-03 06:36:41 +00:00
int32_t acctId;
2022-02-10 14:49:53 +00:00
SHashObj* readDbs;
SHashObj* writeDbs;
2021-10-17 03:42:05 +00:00
} SUserObj;
typedef struct {
int32_t numOfVgroups;
2021-10-17 03:42:05 +00:00
int32_t cacheBlockSize;
int32_t totalBlocks;
int32_t daysPerFile;
int32_t daysToKeep0;
int32_t daysToKeep1;
int32_t daysToKeep2;
2021-12-16 05:35:51 +00:00
int32_t minRows;
int32_t maxRows;
2021-10-17 03:42:05 +00:00
int32_t commitTime;
int32_t fsyncPeriod;
2022-04-08 08:05:30 +00:00
int32_t ttl;
2021-12-09 05:07:00 +00:00
int8_t walLevel;
2021-10-17 03:42:05 +00:00
int8_t precision;
int8_t compression;
int8_t replications;
2022-04-20 01:47:38 +00:00
int8_t strict;
2021-10-17 03:42:05 +00:00
int8_t update;
int8_t cacheLastRow;
2022-02-18 07:29:45 +00:00
int8_t streamMode;
2022-04-08 08:05:30 +00:00
int8_t singleSTable;
2022-04-20 01:47:38 +00:00
int8_t hashMethod; // default is 1
2022-03-24 06:54:10 +00:00
int32_t numOfRetensions;
SArray* pRetensions;
2021-10-17 03:42:05 +00:00
} SDbCfg;
2021-12-15 05:22:04 +00:00
typedef struct {
char name[TSDB_DB_FNAME_LEN];
char acct[TSDB_USER_LEN];
char createUser[TSDB_USER_LEN];
int64_t createdTime;
int64_t updateTime;
int64_t uid;
int32_t cfgVersion;
int32_t vgVersion;
SDbCfg cfg;
SRWLatch lock;
2021-10-17 03:42:05 +00:00
} SDbObj;
typedef struct {
int32_t dnodeId;
2021-12-09 08:47:23 +00:00
ESyncState role;
2021-10-17 03:42:05 +00:00
} SVnodeGid;
2021-12-15 10:13:39 +00:00
typedef struct {
2021-12-09 08:47:23 +00:00
int32_t vgId;
2021-10-17 03:42:05 +00:00
int64_t createdTime;
int64_t updateTime;
2021-12-09 08:47:23 +00:00
int32_t version;
2021-12-16 10:04:07 +00:00
uint32_t hashBegin;
uint32_t hashEnd;
2021-12-28 08:06:01 +00:00
char dbName[TSDB_DB_FNAME_LEN];
2021-12-16 09:05:13 +00:00
int64_t dbUid;
2022-02-10 08:26:56 +00:00
int64_t numOfTables;
int64_t numOfTimeSeries;
2021-10-17 03:42:05 +00:00
int64_t totalStorage;
int64_t compStorage;
int64_t pointsWritten;
2021-12-09 08:47:23 +00:00
int8_t compact;
int8_t replica;
2022-02-18 08:59:33 +00:00
int8_t streamMode;
2021-12-09 08:47:23 +00:00
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
2021-10-17 03:42:05 +00:00
} SVgObj;
2021-12-10 07:20:04 +00:00
typedef struct {
2022-03-23 05:50:53 +00:00
char name[TSDB_TABLE_FNAME_LEN];
2022-03-23 08:45:59 +00:00
char stb[TSDB_TABLE_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
2022-03-23 05:50:53 +00:00
int64_t createdTime;
int64_t uid;
int64_t stbUid;
2022-03-23 08:45:59 +00:00
int64_t dbUid;
2022-03-23 05:50:53 +00:00
int8_t intervalUnit;
int8_t slidingUnit;
int8_t timezone;
2022-03-23 09:53:00 +00:00
int32_t dstVgId; // for stream
2022-03-23 05:50:53 +00:00
int64_t interval;
int64_t offset;
int64_t sliding;
2022-03-23 09:53:00 +00:00
int32_t exprLen; // strlen + 1
2022-03-23 05:50:53 +00:00
int32_t tagsFilterLen;
2022-03-23 09:53:00 +00:00
int32_t sqlLen;
int32_t astLen;
2022-03-23 05:50:53 +00:00
char* expr;
char* tagsFilter;
2022-03-23 09:53:00 +00:00
char* sql;
char* ast;
2022-03-23 05:50:53 +00:00
} SSmaObj;
2021-12-10 07:20:04 +00:00
typedef struct {
2021-12-09 10:53:09 +00:00
char name[TSDB_TABLE_FNAME_LEN];
2021-12-28 08:06:01 +00:00
char db[TSDB_DB_FNAME_LEN];
2021-11-29 04:09:18 +00:00
int64_t createdTime;
int64_t updateTime;
2022-02-23 08:04:06 +00:00
int64_t uid;
int64_t dbUid;
2021-12-09 10:53:09 +00:00
int32_t version;
2022-02-08 05:45:24 +00:00
int32_t nextColId;
2022-03-24 02:50:16 +00:00
float xFilesFactor;
int32_t delay;
2022-03-24 05:57:33 +00:00
int32_t ttl;
2021-12-10 06:12:11 +00:00
int32_t numOfColumns;
int32_t numOfTags;
2022-03-23 09:53:00 +00:00
int32_t commentLen;
int32_t ast1Len;
int32_t ast2Len;
2022-02-08 05:45:24 +00:00
SSchema* pColumns;
2022-02-09 09:50:52 +00:00
SSchema* pTags;
2022-03-23 09:53:00 +00:00
char* comment;
char* pAst1;
char* pAst2;
2021-12-10 03:42:03 +00:00
SRWLatch lock;
2021-12-10 07:20:04 +00:00
} SStbObj;
2021-10-17 03:42:05 +00:00
2021-12-15 10:13:39 +00:00
typedef struct {
2021-10-17 03:42:05 +00:00
char name[TSDB_FUNC_NAME_LEN];
int64_t createdTime;
2021-12-08 05:48:18 +00:00
int8_t funcType;
int8_t scriptType;
int8_t align;
int8_t outputType;
int32_t outputLen;
int32_t bufSize;
2022-01-24 02:38:49 +00:00
int64_t signature;
2021-12-08 05:48:18 +00:00
int32_t commentSize;
int32_t codeSize;
2022-01-24 02:46:55 +00:00
char* pComment;
char* pCode;
2021-12-08 05:48:18 +00:00
char pData[];
2021-10-17 03:42:05 +00:00
} SFuncObj;
2021-12-08 10:50:52 +00:00
typedef struct {
2022-04-14 12:34:42 +00:00
int64_t id;
int8_t type;
int8_t replica;
int16_t numOfColumns;
int32_t rowSize;
int32_t numOfRows;
void* pIter;
SMnode* pMnode;
STableMetaRsp* pMeta;
2022-04-14 12:34:42 +00:00
bool sysDbRsp;
char db[TSDB_DB_FNAME_LEN];
int16_t offset[TSDB_MAX_COLUMNS];
int32_t bytes[TSDB_MAX_COLUMNS];
2021-10-17 03:42:05 +00:00
} SShowObj;
2022-03-09 06:58:15 +00:00
typedef struct {
int64_t id;
int8_t type;
int8_t replica;
int16_t numOfColumns;
int32_t rowSize;
int32_t numOfRows;
int32_t numOfReads;
int32_t payloadLen;
void* pIter;
SMnode* pMnode;
char db[TSDB_DB_FNAME_LEN];
int16_t offset[TSDB_MAX_COLUMNS];
int32_t bytes[TSDB_MAX_COLUMNS];
char payload[];
} SSysTableRetrieveObj;
2022-02-23 08:04:06 +00:00
typedef struct {
char key[TSDB_PARTITION_KEY_LEN];
int64_t offset;
} SMqOffsetObj;
static FORCE_INLINE int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset) {
int32_t tlen = 0;
tlen += taosEncodeString(buf, pOffset->key);
tlen += taosEncodeFixedI64(buf, pOffset->offset);
return tlen;
}
static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset) {
buf = taosDecodeStringTo(buf, pOffset->key);
buf = taosDecodeFixedI64(buf, &pOffset->offset);
return buf;
}
2022-02-10 03:22:50 +00:00
typedef struct {
2022-04-26 09:08:42 +00:00
char name[TSDB_TOPIC_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
int64_t createTime;
int64_t updateTime;
int64_t uid;
2022-03-26 12:12:45 +00:00
int64_t dbUid;
int32_t version;
2022-04-21 08:37:55 +00:00
int8_t subType; // db or table
int8_t withTbName;
int8_t withSchema;
int8_t withTag;
2022-03-26 12:12:45 +00:00
SRWLatch lock;
int32_t sqlLen;
2022-04-14 12:34:42 +00:00
int32_t astLen;
2022-03-26 12:12:45 +00:00
char* sql;
2022-04-14 12:34:42 +00:00
char* ast;
2022-03-26 12:12:45 +00:00
char* physicalPlan;
SSchemaWrapper schema;
2022-01-06 02:28:34 +00:00
} SMqTopicObj;
enum {
CONSUMER_UPDATE__TOUCH = 1,
CONSUMER_UPDATE__ADD,
CONSUMER_UPDATE__REMOVE,
CONSUMER_UPDATE__LOST,
CONSUMER_UPDATE__MODIFY,
};
2022-02-10 03:22:50 +00:00
typedef struct {
int64_t consumerId;
char cgroup[TSDB_CGROUP_LEN];
int8_t updateType; // used only for update
int32_t epoch;
2022-02-10 03:22:50 +00:00
int32_t status;
// hbStatus is not applicable to serialization
2022-02-10 03:22:50 +00:00
int32_t hbStatus;
// lock is used for topics update
SRWLatch lock;
2022-04-21 08:37:55 +00:00
SArray* currentTopics; // SArray<char*>
SArray* rebNewTopics; // SArray<char*>
SArray* rebRemovedTopics; // SArray<char*>
2022-01-06 02:28:34 +00:00
} SMqConsumerObj;
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer);
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer);
2022-01-19 08:28:13 +00:00
typedef struct {
int32_t vgId;
char* qmsg;
2022-04-21 08:37:55 +00:00
SEpSet epSet;
} SMqVgEp;
SMqVgEp* tCloneSMqVgEp(const SMqVgEp* pVgEp);
void tDeleteSMqVgEp(SMqVgEp* pVgEp);
int32_t tEncodeSMqVgEp(void** buf, const SMqVgEp* pVgEp);
void* tDecodeSMqVgEp(const void* buf, SMqVgEp* pVgEp);
typedef struct {
int64_t consumerId; // -1 for unassigned
SArray* vgs; // SArray<SMqVgEp*>
} SMqConsumerEpInSub;
SMqConsumerEpInSub* tCloneSMqConsumerEpInSub(const SMqConsumerEpInSub* pEpInSub);
void tDeleteSMqConsumerEpInSub(SMqConsumerEpInSub* pEpInSub);
int32_t tEncodeSMqConsumerEpInSub(void** buf, const SMqConsumerEpInSub* pEpInSub);
void* tDecodeSMqConsumerEpInSub(const void* buf, SMqConsumerEpInSub* pEpInSub);
typedef struct {
char key[TSDB_SUBSCRIBE_KEY_LEN];
SRWLatch lock;
int32_t vgNum;
2022-04-21 08:37:55 +00:00
int8_t subType;
int8_t withTbName;
int8_t withSchema;
int8_t withTag;
SHashObj* consumerHash; // consumerId -> SMqConsumerEpInSub
2022-04-21 08:37:55 +00:00
// TODO put -1 into unassignVgs
// SArray* unassignedVgs;
} SMqSubscribeObj;
SMqSubscribeObj* tNewSubscribeObj(const char key[TSDB_SUBSCRIBE_KEY_LEN]);
SMqSubscribeObj* tCloneSubscribeObj(const SMqSubscribeObj* pSub);
void tDeleteSubscribeObj(SMqSubscribeObj* pSub);
int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub);
void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub);
typedef struct {
int32_t epoch;
SArray* consumers; // SArray<SMqConsumerEpInSub*>
} SMqSubActionLogEntry;
SMqSubActionLogEntry* tCloneSMqSubActionLogEntry(SMqSubActionLogEntry* pEntry);
void tDeleteSMqSubActionLogEntry(SMqSubActionLogEntry* pEntry);
int32_t tEncodeSMqSubActionLogEntry(void** buf, const SMqSubActionLogEntry* pEntry);
void* tDecodeSMqSubActionLogEntry(const void* buf, SMqSubActionLogEntry* pEntry);
typedef struct {
char key[TSDB_SUBSCRIBE_KEY_LEN];
SArray* logs; // SArray<SMqSubActionLogEntry*>
} SMqSubActionLogObj;
SMqSubActionLogObj* tCloneSMqSubActionLogObj(SMqSubActionLogObj* pLog);
void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
int32_t tEncodeSMqSubActionLogObj(void** buf, const SMqSubActionLogObj* pLog);
void* tDecodeSMqSubActionLogObj(const void* buf, SMqSubActionLogObj* pLog);
typedef struct {
const SMqSubscribeObj* pOldSub;
const SMqTopicObj* pTopic;
const SMqRebSubscribe* pRebInfo;
} SMqRebInputObj;
typedef struct {
int64_t oldConsumerId;
int64_t newConsumerId;
SMqVgEp* pVgEp;
} SMqRebOutputVg;
typedef struct {
SArray* rebVgs; // SArray<SMqRebOutputVg>
SArray* newConsumers; // SArray<int64_t>
SArray* removedConsumers; // SArray<int64_t>
SArray* touchedConsumers; // SArray<int64_t>
SMqSubscribeObj* pSub;
SMqSubActionLogEntry* pLogEntry;
} SMqRebOutputObj;
2022-01-19 08:28:13 +00:00
2022-03-07 08:30:28 +00:00
typedef struct {
2022-03-10 09:15:45 +00:00
char name[TSDB_TOPIC_FNAME_LEN];
char db[TSDB_DB_FNAME_LEN];
2022-03-24 08:18:08 +00:00
char outputSTbName[TSDB_TABLE_FNAME_LEN];
2022-03-10 09:15:45 +00:00
int64_t createTime;
int64_t updateTime;
int64_t uid;
int64_t dbUid;
int32_t version;
2022-03-15 12:04:19 +00:00
int32_t vgNum;
2022-03-10 09:15:45 +00:00
SRWLatch lock;
int8_t status;
// int32_t sqlLen;
2022-03-29 02:40:13 +00:00
int8_t createdBy; // STREAM_CREATED_BY__USER or SMA
int32_t fixedSinkVgId; // 0 for shuffle
int64_t smaId; // 0 for unused
2022-03-31 07:52:54 +00:00
int8_t trigger;
int32_t triggerParam;
int64_t waterMark;
2022-03-26 08:48:14 +00:00
char* sql;
char* logicalPlan;
char* physicalPlan;
SArray* tasks; // SArray<SArray<SStreamTask>>
SSchemaWrapper outputSchema;
2022-03-10 09:15:45 +00:00
} SStreamObj;
int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj);
int32_t tDecodeSStreamObj(SCoder* pDecoder, SStreamObj* pObj);
2022-03-07 08:30:28 +00:00
2021-10-16 07:16:05 +00:00
#ifdef __cplusplus
}
#endif
2021-10-04 09:44:39 +00:00
2021-11-27 15:02:20 +00:00
#endif /*_TD_MND_DEF_H_*/