mnodeDef.h 6.6 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
slguan 已提交
39 40 41
typedef struct SDnodeObj {
  int32_t    dnodeId;
  int32_t    openVnodes;
H
Hui Li 已提交
42
  int64_t    createdTime;
S
slguan 已提交
43 44
  int32_t    totalVnodes;      // from dnode status msg, config information
  int32_t    customScore;      // config by user
H
Hui Li 已提交
45
  uint32_t   lastAccess;
S
slguan 已提交
46
  uint16_t   numOfCores;       // from dnode status msg
H
Hui Li 已提交
47 48 49
  uint16_t   dnodePort;
  char       dnodeFqdn[TSDB_FQDN_LEN];
  char       dnodeEp[TSDB_EP_LEN];
S
slguan 已提交
50 51 52
  int8_t     alternativeRole;  // from dnode status msg, 0-any, 1-mgmt, 2-dnode
  int8_t     status;           // set in balance function
  int8_t     isMgmt;
H
Hui Li 已提交
53
  int8_t     reserved0[14];  
S
slguan 已提交
54 55 56 57
  int8_t     updateEnd[1];
  int32_t    refCount;
  uint32_t   moduleStatus;
  uint32_t   lastReboot;       // time stamp for last reboot
58
  float      score;            // calc in balance function
S
slguan 已提交
59 60 61 62 63
  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
H
Hui Li 已提交
64
  int8_t     reserved1[2];
S
slguan 已提交
65 66 67 68
} SDnodeObj;

typedef struct SMnodeObj {
  int32_t    mnodeId;
H
Hui Li 已提交
69
  int8_t     reserved0[4];
S
slguan 已提交
70
  int64_t    createdTime;
H
Hui Li 已提交
71
  int8_t     reserved1[7];
S
slguan 已提交
72 73 74
  int8_t     updateEnd[1];
  int32_t    refCount;
  int8_t     role;
H
Hui Li 已提交
75
  int8_t     reserved2[3];
S
slguan 已提交
76 77
} SMnodeObj;

78
typedef struct STableObj {
79
  char  *tableId;
S
slguan 已提交
80
  int8_t type;
H
Hui Li 已提交
81
  int8_t reserved[7];
S
slguan 已提交
82 83 84 85 86 87 88
} STableObj;

typedef struct SSuperTableObj {
  STableObj  info;
  uint64_t   uid;
  int64_t    createdTime;
  int32_t    sversion;
S
TD-355  
Shengliang Guan 已提交
89
  int32_t    tversion;
S
slguan 已提交
90 91
  int32_t    numOfColumns;
  int32_t    numOfTags;
H
Hui Li 已提交
92
  int8_t     reserved0[15];
S
slguan 已提交
93 94 95 96
  int8_t     updateEnd[1];
  int32_t    refCount;
  int32_t    numOfTables;
  SSchema *  schema;
97
  void *     vgHash;
H
Hui Li 已提交
98 99
  int16_t    nextColId;
  int8_t     reserved1[6];
S
slguan 已提交
100 101 102 103 104
} SSuperTableObj;

typedef struct {
  STableObj  info;
  uint64_t   uid;
H
Hui Li 已提交
105
  uint64_t   suid;
S
slguan 已提交
106 107 108 109 110 111
  int64_t    createdTime;
  int32_t    sversion;     //used by normal table
  int32_t    numOfColumns; //used by normal table
  int32_t    sid;
  int32_t    vgId;
  int32_t    sqlLen;
H
Hui Li 已提交
112
  int8_t     reserved0[3]; 
S
slguan 已提交
113 114
  int8_t     updateEnd[1];
  int32_t    refCount;
H
Hui Li 已提交
115 116
  int16_t    nextColId;    //used by normal table
  int8_t     reserved1[2];
S
slguan 已提交
117 118 119 120 121
  char*      sql;          //used by normal table
  SSchema*   schema;       //used by normal table
  SSuperTableObj *superTable;
} SChildTableObj;

S
slguan 已提交
122 123 124 125 126 127 128
typedef struct {
  int32_t    dnodeId;
  int8_t     role;
  int8_t     reserved[3];
  SDnodeObj* pDnode;
} SVnodeGid;

S
slguan 已提交
129
typedef struct SVgObj {
S
slguan 已提交
130 131
  uint32_t       vgId;
  int32_t        numOfVnodes;
H
Hui Li 已提交
132
  int64_t        createdTime;
S
slguan 已提交
133 134
  int32_t        lbDnodeId;
  int32_t        lbTime;
H
Hui Li 已提交
135
  char           dbName[TSDB_DB_NAME_LEN];
S
slguan 已提交
136
  int8_t         inUse;
137
  int8_t         accessState;
H
Hui Li 已提交
138 139 140
  int8_t         reserved0[5];
  SVnodeGid      vnodeGid[TSDB_MAX_REPLICA];
  int8_t         reserved1[7];
S
slguan 已提交
141 142 143 144 145 146
  int8_t         updateEnd[1];
  int32_t        refCount;
  int32_t        numOfTables;
  int64_t        totalStorage;
  int64_t        compStorage;
  int64_t        pointsWritten;
H
Hui Li 已提交
147 148
  struct SVgObj *prev, *next;
  struct SDbObj *pDb;
S
slguan 已提交
149 150
  void *         idPool;
  SChildTableObj **tableList;
S
slguan 已提交
151 152
} SVgObj;

S
slguan 已提交
153
typedef struct {
S
slguan 已提交
154 155
  int32_t cacheBlockSize;
  int32_t totalBlocks;
S
slguan 已提交
156 157 158 159 160
  int32_t maxTables;
  int32_t daysPerFile;
  int32_t daysToKeep;
  int32_t daysToKeep1;
  int32_t daysToKeep2;
S
slguan 已提交
161 162
  int32_t minRowsPerFileBlock;
  int32_t maxRowsPerFileBlock;
S
slguan 已提交
163 164 165
  int32_t commitTime;
  int8_t  precision;
  int8_t  compression;
H
hjxilinx 已提交
166
  int8_t  walLevel;
S
slguan 已提交
167
  int8_t  replications;
H
Hui Li 已提交
168
  int8_t  reserved[12];
S
slguan 已提交
169 170
} SDbCfg;

S
slguan 已提交
171
typedef struct SDbObj {
B
Bomin Zhang 已提交
172
  char    name[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN];
H
Hui Li 已提交
173
  int8_t  reserved0[4];
B
Bomin Zhang 已提交
174
  char    acct[TSDB_USER_LEN];
S
slguan 已提交
175
  int64_t createdTime;
S
slguan 已提交
176
  int32_t cfgVersion;
S
slguan 已提交
177
  SDbCfg  cfg;
S
slguan 已提交
178
  int8_t  status;
H
Hui Li 已提交
179
  int8_t  reserved1[14];
S
slguan 已提交
180 181 182 183 184 185 186 187 188 189 190
  int8_t  updateEnd[1];
  int32_t refCount;
  int32_t numOfVgroups;
  int32_t numOfTables;
  int32_t numOfSuperTables;
  SVgObj *pHead;
  SVgObj *pTail;
  struct SAcctObj *pAcct;
} SDbObj;

typedef struct SUserObj {
B
Bomin Zhang 已提交
191 192 193
  char              user[TSDB_USER_LEN];
  char              pass[TSDB_KEY_LEN];
  char              acct[TSDB_USER_LEN];
S
slguan 已提交
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
  int64_t           createdTime;
  int8_t            superAuth;
  int8_t            writeAuth;
  int8_t            reserved[13];
  int8_t            updateEnd[1];
  int32_t           refCount;
  struct SAcctObj * pAcct;
} SUserObj;

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 已提交
211 212 213 214 215 216 217
  int32_t numOfUsers;
  int32_t numOfDbs;
  int32_t numOfTimeSeries;
  int32_t numOfPointsPerSecond;
  int32_t numOfConns;
  int32_t numOfQueries;
  int32_t numOfStreams;
S
slguan 已提交
218
  int8_t  accessState;   // Checked by mgmt heartbeat message
H
Hui Li 已提交
219
  int8_t  reserved[3];
S
slguan 已提交
220 221 222
} SAcctInfo;

typedef struct SAcctObj {
B
Bomin Zhang 已提交
223
  char      user[TSDB_USER_LEN];
B
Bomin Zhang 已提交
224
  char      pass[TSDB_KEY_LEN];
S
slguan 已提交
225 226
  SAcctCfg  cfg;
  int64_t   createdTime;
H
Hui Li 已提交
227
  int32_t   acctId;
S
slguan 已提交
228
  int8_t    status;
H
Hui Li 已提交
229
  int8_t    reserved0[10];
S
slguan 已提交
230 231
  int8_t    updateEnd[1];
  SAcctInfo acctInfo;
H
Hui Li 已提交
232 233
  int32_t   refCount;
  int8_t    reserved1[4];
S
slguan 已提交
234 235 236 237
  pthread_mutex_t  mutex;
} SAcctObj;

typedef struct {
B
Bomin Zhang 已提交
238
  char     db[TSDB_DB_NAME_LEN];
H
Hui Li 已提交
239
  int8_t   type;
S
slguan 已提交
240
  int16_t  numOfColumns;
H
Hui Li 已提交
241
  int32_t  index;
S
slguan 已提交
242 243
  int32_t  rowSize;
  int32_t  numOfRows;
H
Hui Li 已提交
244
  void *   pIter;
S
slguan 已提交
245 246
  int16_t  offset[TSDB_MAX_COLUMNS];
  int16_t  bytes[TSDB_MAX_COLUMNS];
H
Hui Li 已提交
247 248
  int32_t  numOfReads;
  int8_t   reserved0[2];
S
slguan 已提交
249 250 251 252 253 254 255 256 257
  uint16_t payloadLen;
  char     payload[];
} SShowObj;

#ifdef __cplusplus
}
#endif

#endif