mnodeDef.h 8.1 KB
Newer Older
S
slguan 已提交
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/>.
 */

16 17
#ifndef TDENGINE_MNODE_DEF_H
#define TDENGINE_MNODE_DEF_H
S
slguan 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31

#ifdef __cplusplus
extern "C" {
#endif

#include "taosdef.h"
#include "taosmsg.h"

struct SVgObj;
struct SDbObj;
struct SAcctObj;
struct SUserObj;
struct SMnodeObj;

H
Hui Li 已提交
32 33 34 35
/*
struct define notes:
1. The first field must be the xxxxId field or name field , e.g. 'int32_t dnodeId', 'int32_t mnodeId', 'char name[]', 'char user[]', ...
2. From the dnodeId field to the updataEnd field, these information will be falled disc;
H
Hui Li 已提交
36
3. The fields behind the updataEnd field can be changed;
H
Hui Li 已提交
37 38
*/

S
Shengliang Guan 已提交
39
typedef struct SClusterObj {
40
  char    uid[TSDB_CLUSTER_ID_LEN];
S
Shengliang Guan 已提交
41
  int64_t createdTime;
42
  int8_t  reserved[12];
S
Shengliang Guan 已提交
43 44 45 46
  int8_t  updateEnd[4];
  int32_t refCount;
} SClusterObj;

S
slguan 已提交
47 48 49
typedef struct SDnodeObj {
  int32_t    dnodeId;
  int32_t    openVnodes;
H
Hui Li 已提交
50
  int64_t    createdTime;
51
  int64_t    lastAccess;
S
slguan 已提交
52 53
  int32_t    customScore;      // config by user
  uint16_t   numOfCores;       // from dnode status msg
H
Hui Li 已提交
54 55 56
  uint16_t   dnodePort;
  char       dnodeFqdn[TSDB_FQDN_LEN];
  char       dnodeEp[TSDB_EP_LEN];
S
slguan 已提交
57 58 59
  int8_t     alternativeRole;  // from dnode status msg, 0-any, 1-mgmt, 2-dnode
  int8_t     status;           // set in balance function
  int8_t     isMgmt;
S
Shengliang Guan 已提交
60 61
  int8_t     reserve1[11];  
  int8_t     updateEnd[4];
S
slguan 已提交
62 63 64
  int32_t    refCount;
  uint32_t   moduleStatus;
  uint32_t   lastReboot;       // time stamp for last reboot
65
  float      score;            // calc in balance function
S
slguan 已提交
66 67 68 69 70
  float      diskAvailable;    // from dnode status msg
  int16_t    diskAvgUsage;     // calc from sys.disk
  int16_t    cpuAvgUsage;      // calc from sys.cpu
  int16_t    memoryAvgUsage;   // calc from sys.mem
  int16_t    bandwidthUsage;   // calc from sys.band
S
TD-1473  
Shengliang Guan 已提交
71 72
  int8_t     offlineReason;
  int8_t     reserved2[1];
S
slguan 已提交
73 74 75 76
} SDnodeObj;

typedef struct SMnodeObj {
  int32_t    mnodeId;
H
Hui Li 已提交
77
  int8_t     reserved0[4];
S
slguan 已提交
78
  int64_t    createdTime;
S
Shengliang Guan 已提交
79 80
  int8_t     reserved1[4];
  int8_t     updateEnd[4];
S
slguan 已提交
81 82
  int32_t    refCount;
  int8_t     role;
83
  int64_t    roleTime;
H
Hui Li 已提交
84
  int8_t     reserved2[3];
S
slguan 已提交
85 86
} SMnodeObj;

87
typedef struct STableObj {
88
  char  *tableId;
S
slguan 已提交
89 90 91
  int8_t type;
} STableObj;

S
TD-1915  
Shengliang Guan 已提交
92
typedef struct SSTableObj {
H
Hui Li 已提交
93
  STableObj  info; 
94
  int8_t     reserved0[9]; // for fill struct STableObj to 4byte align
L
liu0x54 已提交
95
  int16_t    nextColId;
H
Hui Li 已提交
96
  int32_t    sversion;
S
slguan 已提交
97 98
  uint64_t   uid;
  int64_t    createdTime;
S
TD-355  
Shengliang Guan 已提交
99
  int32_t    tversion;
S
slguan 已提交
100 101
  int32_t    numOfColumns;
  int32_t    numOfTags;
S
Shengliang Guan 已提交
102
  int8_t     updateEnd[4];
S
slguan 已提交
103 104 105
  int32_t    refCount;
  int32_t    numOfTables;
  SSchema *  schema;
106
  void *     vgHash;
S
TD-1915  
Shengliang Guan 已提交
107
} SSTableObj;
S
slguan 已提交
108 109

typedef struct {
H
Hui Li 已提交
110
  STableObj  info;  
111
  int8_t     reserved0[9]; // for fill struct STableObj to 4byte align
L
liu0x54 已提交
112
  int16_t    nextColId;    //used by normal table
H
Hui Li 已提交
113
  int32_t    sversion;     //used by normal table  
S
slguan 已提交
114
  uint64_t   uid;
H
Hui Li 已提交
115
  uint64_t   suid;
S
slguan 已提交
116 117
  int64_t    createdTime;
  int32_t    numOfColumns; //used by normal table
H
Haojun Liao 已提交
118
  int32_t    tid;
S
slguan 已提交
119 120
  int32_t    vgId;
  int32_t    sqlLen;
S
Shengliang Guan 已提交
121
  int8_t     updateEnd[4];
H
Hui Li 已提交
122
  int32_t    refCount;
S
slguan 已提交
123 124
  char*      sql;          //used by normal table
  SSchema*   schema;       //used by normal table
S
TD-1915  
Shengliang Guan 已提交
125 126
  SSTableObj*superTable;
} SCTableObj;
S
slguan 已提交
127

S
slguan 已提交
128 129 130
typedef struct {
  int32_t    dnodeId;
  int8_t     role;
S
TD-2429  
Shengliang Guan 已提交
131 132
  int8_t     vver[3];  // To ensure compatibility, 3 bits are used to represent the remainder of 64 bit version
  SDnodeObj *pDnode;
S
slguan 已提交
133 134
} SVnodeGid;

S
slguan 已提交
135
typedef struct SVgObj {
S
slguan 已提交
136 137
  uint32_t       vgId;
  int32_t        numOfVnodes;
H
Hui Li 已提交
138
  int64_t        createdTime;
S
slguan 已提交
139 140
  int32_t        lbDnodeId;
  int32_t        lbTime;
141
  char           dbName[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
S
slguan 已提交
142
  int8_t         inUse;
143
  int8_t         accessState;
144 145
  int8_t         status;
  int8_t         reserved0[4];
H
Hui Li 已提交
146
  SVnodeGid      vnodeGid[TSDB_MAX_REPLICA];
S
TD-2270  
Shengliang Guan 已提交
147
  int32_t        vgCfgVersion;
148
  int8_t         compact;
S
TD-2270  
Shengliang Guan 已提交
149
  int8_t         reserved1[8];
S
Shengliang Guan 已提交
150
  int8_t         updateEnd[4];
S
slguan 已提交
151 152 153 154 155
  int32_t        refCount;
  int32_t        numOfTables;
  int64_t        totalStorage;
  int64_t        compStorage;
  int64_t        pointsWritten;
H
Hui Li 已提交
156
  struct SDbObj *pDb;
S
slguan 已提交
157
  void *         idPool;
S
slguan 已提交
158 159
} SVgObj;

S
slguan 已提交
160
typedef struct {
S
slguan 已提交
161 162
  int32_t cacheBlockSize;
  int32_t totalBlocks;
S
slguan 已提交
163 164
  int32_t maxTables;
  int32_t daysPerFile;
D
dapan1121 已提交
165
  int32_t daysToKeep0;
S
slguan 已提交
166 167
  int32_t daysToKeep1;
  int32_t daysToKeep2;
S
slguan 已提交
168 169
  int32_t minRowsPerFileBlock;
  int32_t maxRowsPerFileBlock;
S
slguan 已提交
170
  int32_t commitTime;
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
171
  int32_t fsyncPeriod;
S
slguan 已提交
172 173
  int8_t  precision;
  int8_t  compression;
H
hjxilinx 已提交
174
  int8_t  walLevel;
S
slguan 已提交
175
  int8_t  replications;
176
  int8_t  quorum;
S
Shengliang Guan 已提交
177
  int8_t  update;
M
Minglei Jin 已提交
178
  int8_t  cacheLastRow;
S
Shengliang Guan 已提交
179 180 181
  int8_t  dbType;
  int16_t partitions;
  int8_t  reserved[7];
S
slguan 已提交
182 183
} SDbCfg;

S
slguan 已提交
184
typedef struct SDbObj {
185
  char    name[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
H
Hui Li 已提交
186
  int8_t  reserved0[4];
B
Bomin Zhang 已提交
187
  char    acct[TSDB_USER_LEN];
S
slguan 已提交
188
  int64_t createdTime;
S
TD-2270  
Shengliang Guan 已提交
189
  int32_t dbCfgVersion;
S
slguan 已提交
190
  SDbCfg  cfg;
S
slguan 已提交
191
  int8_t  status;
S
Shengliang Guan 已提交
192 193
  int8_t  reserved1[11];
  int8_t  updateEnd[4];
S
slguan 已提交
194 195 196 197
  int32_t refCount;
  int32_t numOfVgroups;
  int32_t numOfTables;
  int32_t numOfSuperTables;
198 199 200
  int32_t vgListSize; 
  int32_t vgListIndex;
  SVgObj **vgList;
S
slguan 已提交
201
  struct SAcctObj *pAcct;
202
  pthread_mutex_t  mutex;
S
slguan 已提交
203 204
} SDbObj;

205 206 207 208 209 210 211 212 213 214 215 216 217 218
// old tags
typedef struct SUserObjOld {
  char              user[TSDB_USER_LEN];
  char              pass[TSDB_KEY_LEN];
  char              acct[TSDB_USER_LEN];
  int64_t           createdTime;
  int8_t            superAuth;
  int8_t            writeAuth;
  int8_t            reserved[10];
  int8_t            updateEnd[4];
  int32_t           refCount;
  struct SAcctObj * pAcct;
} SUserObjOld;

S
slguan 已提交
219
typedef struct SUserObj {
B
Bomin Zhang 已提交
220 221 222
  char              user[TSDB_USER_LEN];
  char              pass[TSDB_KEY_LEN];
  char              acct[TSDB_USER_LEN];
S
slguan 已提交
223 224 225
  int64_t           createdTime;
  int8_t            superAuth;
  int8_t            writeAuth;
S
Shengliang Guan 已提交
226
  int8_t            reserved[10];
227
  char              tags[TSDB_TAGS_LEN];
S
Shengliang Guan 已提交
228
  int8_t            updateEnd[4];
S
slguan 已提交
229 230 231 232
  int32_t           refCount;
  struct SAcctObj * pAcct;
} SUserObj;

233 234
typedef struct SFuncObj {
  char              name[TSDB_FUNC_NAME_LEN];
H
Haojun Liao 已提交
235 236 237
  char              path[128];
  int32_t           contLen;
  char              cont[TSDB_FUNC_CODE_LEN];
238
  int32_t           funcType;
D
dapan1121 已提交
239
  int32_t           bufSize;
240
  int64_t           createdTime;
H
Haojun Liao 已提交
241 242 243 244
  uint8_t           resType;
  int16_t           resBytes;
  int64_t           sig;         // partial md5 sign
  int16_t           type;        // [lua script|so|js]
245 246 247 248 249
  int8_t            reserved[64];
  int8_t            updateEnd[4];
  int32_t           refCount;
} SFuncObj;

S
slguan 已提交
250 251 252 253 254 255 256 257
typedef struct {
  int64_t totalStorage;  // Total storage wrtten from this account
  int64_t compStorage;   // Compressed storage on disk
  int64_t queryTime;
  int64_t totalPoints;
  int64_t inblound;
  int64_t outbound;
  int64_t sKey;
H
Hui Li 已提交
258 259 260 261 262 263 264
  int32_t numOfUsers;
  int32_t numOfDbs;
  int32_t numOfTimeSeries;
  int32_t numOfPointsPerSecond;
  int32_t numOfConns;
  int32_t numOfQueries;
  int32_t numOfStreams;
S
slguan 已提交
265
  int8_t  accessState;   // Checked by mgmt heartbeat message
H
Hui Li 已提交
266
  int8_t  reserved[3];
S
slguan 已提交
267 268 269
} SAcctInfo;

typedef struct SAcctObj {
B
Bomin Zhang 已提交
270
  char      user[TSDB_USER_LEN];
B
Bomin Zhang 已提交
271
  char      pass[TSDB_KEY_LEN];
S
slguan 已提交
272 273
  SAcctCfg  cfg;
  int64_t   createdTime;
H
Hui Li 已提交
274
  int32_t   acctId;
S
slguan 已提交
275
  int8_t    status;
S
Shengliang Guan 已提交
276 277
  int8_t    reserved0[7];
  int8_t    updateEnd[4];
H
Hui Li 已提交
278 279
  int32_t   refCount;
  int8_t    reserved1[4];
S
Shengliang Guan 已提交
280
  SAcctInfo acctInfo;
S
slguan 已提交
281 282 283 284
  pthread_mutex_t  mutex;
} SAcctObj;

typedef struct {
Y
yihaoDeng 已提交
285
  char     db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
H
Hui Li 已提交
286
  int8_t   type;
S
slguan 已提交
287
  int16_t  numOfColumns;
H
Hui Li 已提交
288
  int32_t  index;
S
slguan 已提交
289 290
  int32_t  rowSize;
  int32_t  numOfRows;
H
Hui Li 已提交
291
  void *   pIter;
Y
yihaoDeng 已提交
292
  void *   pVgIter;
S
Shengliang Guan 已提交
293
  void **  ppShow;
S
slguan 已提交
294
  int16_t  offset[TSDB_MAX_COLUMNS];
D
dapan1121 已提交
295
  int32_t  bytes[TSDB_MAX_COLUMNS];
H
Hui Li 已提交
296
  int32_t  numOfReads;
297
  int8_t   maxReplica;
298
  int8_t   reserved0[1];
S
slguan 已提交
299 300 301 302 303 304 305 306 307
  uint16_t payloadLen;
  char     payload[];
} SShowObj;

#ifdef __cplusplus
}
#endif

#endif