mndDef.h 14.0 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

S
Shengliang Guan 已提交
16 17
#ifndef _TD_MND_DEF_H_
#define _TD_MND_DEF_H_
S
Shengliang Guan 已提交
18

19
#include "os.h"
S
Shengliang Guan 已提交
20 21

#include "cJSON.h"
L
Liu Jicong 已提交
22
#include "scheduler.h"
S
Shengliang Guan 已提交
23 24
#include "sync.h"
#include "thash.h"
L
Liu Jicong 已提交
25
#include "tlist.h"
S
Shengliang Guan 已提交
26
#include "tlog.h"
L
Liu Jicong 已提交
27
#include "tmsg.h"
S
Shengliang Guan 已提交
28
#include "trpc.h"
L
Liu Jicong 已提交
29
#include "tstream.h"
S
Shengliang Guan 已提交
30
#include "ttimer.h"
S
Shengliang Guan 已提交
31

S
Shengliang Guan 已提交
32
#include "mnode.h"
S
Shengliang Guan 已提交
33

S
Shengliang Guan 已提交
34 35 36
#ifdef __cplusplus
extern "C" {
#endif
S
Shengliang Guan 已提交
37

S
Shengliang Guan 已提交
38
typedef enum {
39 40 41 42 43 44 45 46
  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;
S
Shengliang Guan 已提交
47 48

typedef enum {
49 50 51 52 53 54
  MND_AUTH_OP_START = 0,
  MND_AUTH_OP_CREATE_USER,
  MND_AUTH_OP_ALTER_USER,
  MND_AUTH_OP_DROP_USER,
  MND_AUTH_MAX
} EAuthOp;
S
Shengliang Guan 已提交
55

S
Shengliang Guan 已提交
56
typedef enum {
57 58 59
  TRN_CONFLICT_NOTHING = 0,
  TRN_CONFLICT_GLOBAL = 1,
  TRN_CONFLICT_DB = 2,
60
  TRN_CONFLICT_DB_INSIDE = 3,
61
} ETrnConflct;
S
Shengliang Guan 已提交
62

S
Shengliang Guan 已提交
63
typedef enum {
64
  TRN_STAGE_PREPARE = 0,
65 66 67 68 69 70
  TRN_STAGE_REDO_ACTION = 1,
  TRN_STAGE_ROLLBACK = 2,
  TRN_STAGE_UNDO_ACTION = 3,
  TRN_STAGE_COMMIT = 4,
  TRN_STAGE_COMMIT_ACTION = 5,
  TRN_STAGE_FINISHED = 6
S
Shengliang Guan 已提交
71 72
} ETrnStage;

S
Shengliang Guan 已提交
73 74 75 76
typedef enum {
  TRN_POLICY_ROLLBACK = 0,
  TRN_POLICY_RETRY = 1,
} ETrnPolicy;
S
Shengliang Guan 已提交
77

78
typedef enum {
79 80 81
  TRN_EXEC_PRARLLEL = 0,
  TRN_EXEC_SERIAL = 1,
} ETrnExec;
82

S
Shengliang Guan 已提交
83 84 85 86 87 88 89 90 91 92 93 94 95 96
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;

S
Shengliang Guan 已提交
97 98 99 100 101 102 103 104 105
typedef enum {
  CONSUMER_UPDATE__TOUCH = 1,
  CONSUMER_UPDATE__ADD,
  CONSUMER_UPDATE__REMOVE,
  CONSUMER_UPDATE__LOST,
  CONSUMER_UPDATE__RECOVER,
  CONSUMER_UPDATE__MODIFY,
} ECsmUpdateType;

S
Shengliang Guan 已提交
106
typedef struct {
S
Shengliang Guan 已提交
107 108 109
  int32_t        id;
  ETrnStage      stage;
  ETrnPolicy     policy;
110 111
  ETrnConflct    conflict;
  ETrnExec       exec;
S
Shengliang Guan 已提交
112 113 114 115 116
  int32_t        code;
  int32_t        failedTimes;
  SRpcHandleInfo rpcInfo;
  void*          rpcRsp;
  int32_t        rpcRspLen;
117
  int32_t        redoActionPos;
S
Shengliang Guan 已提交
118 119
  SArray*        redoActions;
  SArray*        undoActions;
120
  SArray*        commitActions;
S
Shengliang Guan 已提交
121 122
  int64_t        createdTime;
  int64_t        lastExecTime;
123 124 125 126
  int32_t        lastErrorAction;
  int32_t        lastErrorNo;
  tmsg_t         lastErrorMsgType;
  SEpSet         lastErrorEpset;
S
Shengliang Guan 已提交
127 128 129 130 131
  char           dbname[TSDB_DB_FNAME_LEN];
  int32_t        startFunc;
  int32_t        stopFunc;
  int32_t        paramLen;
  void*          param;
S
Shengliang Guan 已提交
132
} STrans;
S
Shengliang Guan 已提交
133

S
Shengliang Guan 已提交
134
typedef struct {
135
  int64_t id;
S
Shengliang Guan 已提交
136
  char    name[TSDB_CLUSTER_ID_LEN];
S
Shengliang Guan 已提交
137 138 139 140
  int64_t createdTime;
  int64_t updateTime;
} SClusterObj;

S
Shengliang Guan 已提交
141
typedef struct {
S
Shengliang Guan 已提交
142 143 144 145
  int32_t    id;
  int64_t    createdTime;
  int64_t    updateTime;
  int64_t    rebootTime;
146
  int64_t    lastAccessTime;
S
Shengliang Guan 已提交
147
  int32_t    accessTimes;
S
Shengliang Guan 已提交
148
  int32_t    numOfVnodes;
S
Shengliang Guan 已提交
149 150
  int32_t    numOfSupportVnodes;
  int32_t    numOfCores;
S
Shengliang Guan 已提交
151 152 153 154
  EDndReason offlineReason;
  uint16_t   port;
  char       fqdn[TSDB_FQDN_LEN];
  char       ep[TSDB_EP_LEN];
S
Shengliang Guan 已提交
155 156
} SDnodeObj;

S
Shengliang Guan 已提交
157
typedef struct {
S
Shengliang Guan 已提交
158
  int32_t    id;
S
Shengliang Guan 已提交
159 160
  int64_t    createdTime;
  int64_t    updateTime;
161 162
  ESyncState state;
  int64_t    stateStartTime;
L
Liu Jicong 已提交
163
  SDnodeObj* pDnode;
S
Shengliang Guan 已提交
164 165
} SMnodeObj;

S
Shengliang Guan 已提交
166 167 168 169
typedef struct {
  int32_t    id;
  int64_t    createdTime;
  int64_t    updateTime;
L
Liu Jicong 已提交
170
  SDnodeObj* pDnode;
D
dapan1121 已提交
171
  SQnodeLoad load;  
S
Shengliang Guan 已提交
172 173 174 175 176 177
} SQnodeObj;

typedef struct {
  int32_t    id;
  int64_t    createdTime;
  int64_t    updateTime;
L
Liu Jicong 已提交
178
  SDnodeObj* pDnode;
S
Shengliang Guan 已提交
179 180 181 182 183 184
} SSnodeObj;

typedef struct {
  int32_t    id;
  int64_t    createdTime;
  int64_t    updateTime;
L
Liu Jicong 已提交
185
  SDnodeObj* pDnode;
S
Shengliang Guan 已提交
186 187
} SBnodeObj;

S
Shengliang Guan 已提交
188 189 190
typedef struct {
  int32_t maxUsers;
  int32_t maxDbs;
S
Shengliang Guan 已提交
191 192
  int32_t maxStbs;
  int32_t maxTbs;
S
Shengliang Guan 已提交
193 194
  int32_t maxTimeSeries;
  int32_t maxStreams;
S
Shengliang Guan 已提交
195 196 197 198
  int32_t maxFuncs;
  int32_t maxConsumers;
  int32_t maxConns;
  int32_t maxTopics;
199
  int64_t maxStorage;
S
Shengliang Guan 已提交
200
  int32_t accessState;  // Configured only by command
S
Shengliang Guan 已提交
201 202 203 204 205 206 207
} SAcctCfg;

typedef struct {
  int32_t numOfUsers;
  int32_t numOfDbs;
  int32_t numOfTimeSeries;
  int32_t numOfStreams;
S
Shengliang Guan 已提交
208 209
  int64_t totalStorage;  // Total storage wrtten from this account
  int64_t compStorage;   // Compressed storage on disk
S
Shengliang Guan 已提交
210 211
} SAcctInfo;

S
Shengliang Guan 已提交
212
typedef struct {
S
Shengliang Guan 已提交
213 214 215 216
  char      acct[TSDB_USER_LEN];
  int64_t   createdTime;
  int64_t   updateTime;
  int32_t   acctId;
S
Shengliang Guan 已提交
217
  int32_t   status;
S
Shengliang Guan 已提交
218 219 220 221
  SAcctCfg  cfg;
  SAcctInfo info;
} SAcctObj;

S
Shengliang Guan 已提交
222
typedef struct {
S
Shengliang Guan 已提交
223
  char      user[TSDB_USER_LEN];
224
  char      pass[TSDB_PASSWORD_LEN];
S
Shengliang Guan 已提交
225 226 227
  char      acct[TSDB_USER_LEN];
  int64_t   createdTime;
  int64_t   updateTime;
228
  int8_t    superUser;
S
Shengliang Guan 已提交
229
  int32_t   acctId;
D
dapan 已提交
230
  int32_t   authVersion;
231 232
  SHashObj* readDbs;
  SHashObj* writeDbs;
S
Shengliang Guan 已提交
233
  SRWLatch  lock;
S
Shengliang Guan 已提交
234 235 236
} SUserObj;

typedef struct {
237
  int32_t numOfVgroups;
S
Shengliang Guan 已提交
238 239 240 241
  int32_t numOfStables;
  int32_t buffer;
  int32_t pageSize;
  int32_t pages;
S
Shengliang Guan 已提交
242 243 244 245
  int32_t daysPerFile;
  int32_t daysToKeep0;
  int32_t daysToKeep1;
  int32_t daysToKeep2;
S
Shengliang Guan 已提交
246 247
  int32_t minRows;
  int32_t maxRows;
S
Shengliang Guan 已提交
248
  int32_t fsyncPeriod;
S
Shengliang Guan 已提交
249
  int8_t  walLevel;
S
Shengliang Guan 已提交
250 251 252
  int8_t  precision;
  int8_t  compression;
  int8_t  replications;
S
Shengliang Guan 已提交
253
  int8_t  strict;
S
Shengliang Guan 已提交
254
  int8_t  cacheLastRow;
S
Shengliang Guan 已提交
255
  int8_t  hashMethod;  // default is 1
S
sma  
Shengliang Guan 已提交
256 257
  int32_t numOfRetensions;
  SArray* pRetensions;
S
Shengliang Guan 已提交
258 259
} SDbCfg;

S
Shengliang Guan 已提交
260
typedef struct {
261 262 263 264 265 266 267 268 269 270
  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;
S
Shengliang Guan 已提交
271 272 273 274
} SDbObj;

typedef struct {
  int32_t    dnodeId;
S
Shengliang Guan 已提交
275
  ESyncState role;
S
Shengliang Guan 已提交
276 277
} SVnodeGid;

S
Shengliang Guan 已提交
278
typedef struct {
S
Shengliang Guan 已提交
279
  int32_t   vgId;
S
Shengliang Guan 已提交
280 281
  int64_t   createdTime;
  int64_t   updateTime;
S
Shengliang Guan 已提交
282
  int32_t   version;
S
Shengliang Guan 已提交
283 284
  uint32_t  hashBegin;
  uint32_t  hashEnd;
285
  char      dbName[TSDB_DB_FNAME_LEN];
S
Shengliang Guan 已提交
286
  int64_t   dbUid;
S
Shengliang Guan 已提交
287 288
  int64_t   numOfTables;
  int64_t   numOfTimeSeries;
S
Shengliang Guan 已提交
289 290 291
  int64_t   totalStorage;
  int64_t   compStorage;
  int64_t   pointsWritten;
S
Shengliang Guan 已提交
292
  int8_t    compact;
S
Shengliang Guan 已提交
293
  int8_t    isTsma;
S
Shengliang Guan 已提交
294 295
  int8_t    replica;
  SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
C
Cary Xu 已提交
296
  void*     pTsma;
S
Shengliang Guan 已提交
297 298
} SVgObj;

S
Shengliang Guan 已提交
299
typedef struct {
S
Shengliang Guan 已提交
300
  char    name[TSDB_TABLE_FNAME_LEN];
S
sma  
Shengliang Guan 已提交
301 302
  char    stb[TSDB_TABLE_FNAME_LEN];
  char    db[TSDB_DB_FNAME_LEN];
S
Shengliang Guan 已提交
303 304 305
  int64_t createdTime;
  int64_t uid;
  int64_t stbUid;
S
sma  
Shengliang Guan 已提交
306
  int64_t dbUid;
S
Shengliang Guan 已提交
307 308 309
  int8_t  intervalUnit;
  int8_t  slidingUnit;
  int8_t  timezone;
S
sma  
Shengliang Guan 已提交
310
  int32_t dstVgId;  // for stream
S
Shengliang Guan 已提交
311 312 313
  int64_t interval;
  int64_t offset;
  int64_t sliding;
S
sma  
Shengliang Guan 已提交
314
  int32_t exprLen;  // strlen + 1
S
Shengliang Guan 已提交
315
  int32_t tagsFilterLen;
S
sma  
Shengliang Guan 已提交
316 317
  int32_t sqlLen;
  int32_t astLen;
S
Shengliang Guan 已提交
318 319
  char*   expr;
  char*   tagsFilter;
S
sma  
Shengliang Guan 已提交
320 321
  char*   sql;
  char*   ast;
S
Shengliang Guan 已提交
322 323
} SSmaObj;

S
Shengliang Guan 已提交
324
typedef struct {
S
Shengliang Guan 已提交
325
  char     name[TSDB_TABLE_FNAME_LEN];
326
  char     db[TSDB_DB_FNAME_LEN];
327 328
  int64_t  createdTime;
  int64_t  updateTime;
L
Liu Jicong 已提交
329 330
  int64_t  uid;
  int64_t  dbUid;
331 332
  int32_t  tagVer;
  int32_t  colVer;
S
Shengliang Guan 已提交
333
  int32_t  nextColId;
S
sma  
Shengliang Guan 已提交
334 335
  float    xFilesFactor;
  int32_t  delay;
S
sma  
Shengliang Guan 已提交
336
  int32_t  ttl;
S
Shengliang Guan 已提交
337 338
  int32_t  numOfColumns;
  int32_t  numOfTags;
S
sma  
Shengliang Guan 已提交
339
  int32_t  commentLen;
340 341
  int32_t  ast1Len;
  int32_t  ast2Len;
S
Shengliang Guan 已提交
342
  SSchema* pColumns;
S
Shengliang Guan 已提交
343
  SSchema* pTags;
S
sma  
Shengliang Guan 已提交
344
  char*    comment;
345 346
  char*    pAst1;
  char*    pAst2;
S
Shengliang Guan 已提交
347
  SRWLatch lock;
S
Shengliang Guan 已提交
348
} SStbObj;
S
Shengliang Guan 已提交
349

S
Shengliang Guan 已提交
350
typedef struct {
S
Shengliang Guan 已提交
351 352
  char    name[TSDB_FUNC_NAME_LEN];
  int64_t createdTime;
S
Shengliang Guan 已提交
353 354 355 356 357 358
  int8_t  funcType;
  int8_t  scriptType;
  int8_t  align;
  int8_t  outputType;
  int32_t outputLen;
  int32_t bufSize;
S
Shengliang 已提交
359
  int64_t signature;
S
Shengliang Guan 已提交
360 361
  int32_t commentSize;
  int32_t codeSize;
L
Liu Jicong 已提交
362 363
  char*   pComment;
  char*   pCode;
S
Shengliang Guan 已提交
364 365
} SFuncObj;

S
Shengliang Guan 已提交
366
typedef struct {
L
Liu Jicong 已提交
367 368 369 370 371 372 373
  int64_t        id;
  int8_t         type;
  int8_t         replica;
  int16_t        numOfColumns;
  int32_t        numOfRows;
  void*          pIter;
  SMnode*        pMnode;
374
  STableMetaRsp* pMeta;
L
Liu Jicong 已提交
375 376
  bool           sysDbRsp;
  char           db[TSDB_DB_FNAME_LEN];
S
Shengliang Guan 已提交
377 378
} SShowObj;

379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
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;

L
Liu Jicong 已提交
396 397
typedef struct {
  char    key[TSDB_PARTITION_KEY_LEN];
L
Liu Jicong 已提交
398
  int64_t dbUid;
L
Liu Jicong 已提交
399 400 401
  int64_t offset;
} SMqOffsetObj;

S
Shengliang Guan 已提交
402 403
int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset);
void*   tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset);
L
Liu Jicong 已提交
404

L
Liu Jicong 已提交
405
typedef struct {
L
Liu Jicong 已提交
406 407 408 409 410 411 412 413 414 415 416
  char    name[TSDB_TOPIC_FNAME_LEN];
  char    db[TSDB_DB_FNAME_LEN];
  int64_t createTime;
  int64_t updateTime;
  int64_t uid;
  int64_t dbUid;
  int32_t version;
  int8_t  subType;  // column, db or stable
  // int8_t         withTbName;
  // int8_t         withSchema;
  // int8_t         withTag;
L
Liu Jicong 已提交
417
  SRWLatch       lock;
L
Liu Jicong 已提交
418
  int32_t        consumerCnt;
L
Liu Jicong 已提交
419
  int32_t        sqlLen;
L
Liu Jicong 已提交
420
  int32_t        astLen;
L
Liu Jicong 已提交
421
  char*          sql;
L
Liu Jicong 已提交
422
  char*          ast;
L
Liu Jicong 已提交
423 424
  char*          physicalPlan;
  SSchemaWrapper schema;
L
Liu Jicong 已提交
425
  // int32_t        refConsumerCnt;
L
Liu Jicong 已提交
426 427
} SMqTopicObj;

L
Liu Jicong 已提交
428
typedef struct {
S
Shengliang Guan 已提交
429 430
  int64_t  consumerId;
  char     cgroup[TSDB_CGROUP_LEN];
L
Liu Jicong 已提交
431
  char     clientId[256];
S
Shengliang Guan 已提交
432 433 434 435 436
  int8_t   updateType;  // used only for update
  int32_t  epoch;
  int32_t  status;
  int32_t  hbStatus;          // hbStatus is not applicable to serialization
  SRWLatch lock;              // lock is used for topics update
L
Liu Jicong 已提交
437 438 439
  SArray*  currentTopics;     // SArray<char*>
  SArray*  rebNewTopics;      // SArray<char*>
  SArray*  rebRemovedTopics;  // SArray<char*>
L
Liu Jicong 已提交
440

L
Liu Jicong 已提交
441 442 443
  // subscribed by user
  SArray* assignedTopics;  // SArray<char*>

L
Liu Jicong 已提交
444 445 446 447 448 449
  // data for display
  int32_t pid;
  SEpSet  ep;
  int64_t upTime;
  int64_t subscribeTime;
  int64_t rebalanceTime;
L
Liu Jicong 已提交
450 451
} SMqConsumerObj;

452 453 454 455
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);
L
Liu Jicong 已提交
456

457 458 459
typedef struct {
  int32_t vgId;
  char*   qmsg;
L
Liu Jicong 已提交
460
  SEpSet  epSet;
461 462 463 464 465 466 467 468 469 470
} 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*>
471
} SMqConsumerEp;
472

473 474 475 476
SMqConsumerEp* tCloneSMqConsumerEp(const SMqConsumerEp* pEp);
void           tDeleteSMqConsumerEp(SMqConsumerEp* pEp);
int32_t        tEncodeSMqConsumerEp(void** buf, const SMqConsumerEp* pEp);
void*          tDecodeSMqConsumerEp(const void* buf, SMqConsumerEp* pEp);
477 478

typedef struct {
L
Liu Jicong 已提交
479 480 481 482 483 484 485 486
  char     key[TSDB_SUBSCRIBE_KEY_LEN];
  SRWLatch lock;
  int64_t  dbUid;
  int32_t  vgNum;
  int8_t   subType;
  // int8_t    withTbName;
  // int8_t    withSchema;
  // int8_t    withTag;
487 488
  SHashObj* consumerHash;   // consumerId -> SMqConsumerEp
  SArray*   unassignedVgs;  // SArray<SMqVgEp*>
489 490 491 492 493 494 495 496 497 498
} 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;
499
  SArray* consumers;  // SArray<SMqConsumerEp*>
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
} 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 {
L
Liu Jicong 已提交
518 519
  int32_t           oldConsumerNum;
  const SMqRebInfo* pRebInfo;
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
} 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;
L
Liu Jicong 已提交
536

L
Liu Jicong 已提交
537
typedef struct {
S
Shengliang Guan 已提交
538 539 540 541
  char           name[TSDB_TOPIC_FNAME_LEN];
  char           sourceDb[TSDB_DB_FNAME_LEN];
  char           targetDb[TSDB_DB_FNAME_LEN];
  char           targetSTbName[TSDB_TABLE_FNAME_LEN];
L
Liu Jicong 已提交
542
  int64_t        targetStbUid;
S
Shengliang Guan 已提交
543 544 545 546 547 548 549 550
  int64_t        createTime;
  int64_t        updateTime;
  int64_t        uid;
  int64_t        dbUid;
  int32_t        version;
  int32_t        vgNum;
  SRWLatch       lock;
  int8_t         status;
L
Liu Jicong 已提交
551 552
  int8_t         createdBy;      // STREAM_CREATED_BY__USER or SMA
  int32_t        fixedSinkVgId;  // 0 for shuffle
L
Liu Jicong 已提交
553 554
  SVgObj         fixedSinkVg;
  int64_t        smaId;  // 0 for unused
L
fix  
Liu Jicong 已提交
555 556 557
  int8_t         trigger;
  int32_t        triggerParam;
  int64_t        waterMark;
L
Liu Jicong 已提交
558 559 560 561
  char*          sql;
  char*          physicalPlan;
  SArray*        tasks;  // SArray<SArray<SStreamTask>>
  SSchemaWrapper outputSchema;
L
Liu Jicong 已提交
562 563
} SStreamObj;

H
Hongze Cheng 已提交
564 565
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
int32_t tDecodeSStreamObj(SDecoder* pDecoder, SStreamObj* pObj);
L
Liu Jicong 已提交
566

S
Shengliang Guan 已提交
567 568 569
#ifdef __cplusplus
}
#endif
S
Shengliang Guan 已提交
570

S
Shengliang Guan 已提交
571
#endif /*_TD_MND_DEF_H_*/