dndEnv.h 3.3 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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_DND_ENV_H_
#define _TD_DND_ENV_H_

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
23
#include "dndInt.h"
S
Shengliang Guan 已提交
24

S
Shengliang Guan 已提交
25 26 27 28 29 30 31 32 33
typedef struct {
  EWorkerType type;
  const char *name;
  int32_t     minNum;
  int32_t     maxNum;
  void       *queueFp;
  SDnode     *pDnode;
  STaosQueue *queue;
  union {
S
Shengliang Guan 已提交
34
    SQWorkerPool pool;
S
Shengliang Guan 已提交
35
    SWWorkerPool mpool;
S
Shengliang Guan 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
  };
} SDnodeWorker;

typedef struct {
  char *dnode;
  char *mnode;
  char *snode;
  char *bnode;
  char *vnodes;
} SDnodeDir;

typedef struct {
  int32_t      dnodeId;
  int32_t      dropped;
  int64_t      clusterId;
  int64_t      dver;
  int64_t      rebootTime;
  int64_t      updateTime;
  int8_t       statusSent;
  SEpSet       mnodeEpSet;
  char        *file;
  SHashObj    *dnodeHash;
S
Shengliang Guan 已提交
58
  SArray      *pDnodeEps;
S
Shengliang Guan 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
  pthread_t   *threadId;
  SRWLatch     latch;
  SDnodeWorker mgmtWorker;
  SDnodeWorker statusWorker;
} SDnodeMgmt;

typedef struct {
  int32_t      refCount;
  int8_t       deployed;
  int8_t       dropped;
  SMnode      *pMnode;
  SRWLatch     latch;
  SDnodeWorker readWorker;
  SDnodeWorker writeWorker;
  SDnodeWorker syncWorker;
  int8_t       replica;
  int8_t       selfIndex;
  SReplica     replicas[TSDB_MAX_REPLICA];
} SMnodeMgmt;

typedef struct {
  int32_t      refCount;
  int8_t       deployed;
  int8_t       dropped;
  SQnode      *pQnode;
  SRWLatch     latch;
  SDnodeWorker queryWorker;
  SDnodeWorker fetchWorker;
} SQnodeMgmt;

typedef struct {
  int32_t      refCount;
  int8_t       deployed;
  int8_t       dropped;
  SSnode      *pSnode;
  SRWLatch     latch;
  SDnodeWorker writeWorker;
} SSnodeMgmt;

typedef struct {
  int32_t      refCount;
  int8_t       deployed;
  int8_t       dropped;
  SBnode      *pBnode;
  SRWLatch     latch;
  SDnodeWorker writeWorker;
} SBnodeMgmt;

typedef struct {
S
Shengliang Guan 已提交
108 109 110 111 112 113 114 115 116 117 118 119
  int32_t openVnodes;
  int32_t totalVnodes;
  int32_t masterNum;
  int64_t numOfSelectReqs;
  int64_t numOfInsertReqs;
  int64_t numOfInsertSuccessReqs;
  int64_t numOfBatchInsertReqs;
  int64_t numOfBatchInsertSuccessReqs;
} SVnodesStat;

typedef struct {
  SVnodesStat  stat;
S
Shengliang Guan 已提交
120 121
  SHashObj    *hash;
  SRWLatch     latch;
S
Shengliang Guan 已提交
122
  SQWorkerPool queryPool;
S
Shengliang Guan 已提交
123
  SFWorkerPool fetchPool;
S
Shengliang Guan 已提交
124 125
  SWWorkerPool syncPool;
  SWWorkerPool writePool;
S
Shengliang Guan 已提交
126 127 128 129 130 131 132 133 134 135 136 137
} SVnodesMgmt;

typedef struct {
  void    *serverRpc;
  void    *clientRpc;
  DndMsgFp msgFp[TDMT_MAX];
} STransMgmt;

typedef struct SDnode {
  EStat        stat;
  SDnodeObjCfg cfg;
  SDnodeDir    dir;
138
  TdFilePtr    pLockFile;
S
Shengliang Guan 已提交
139 140 141 142 143 144 145
  SDnodeMgmt   dmgmt;
  SMnodeMgmt   mmgmt;
  SQnodeMgmt   qmgmt;
  SSnodeMgmt   smgmt;
  SBnodeMgmt   bmgmt;
  SVnodesMgmt  vmgmt;
  STransMgmt   tmgmt;
S
Shengliang Guan 已提交
146
  STfs        *pTfs;
S
Shengliang Guan 已提交
147 148 149
  SStartupReq  startup;
} SDnode;

S
Shengliang Guan 已提交
150
int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo);
S
monitor  
Shengliang Guan 已提交
151

S
Shengliang Guan 已提交
152 153 154 155 156
#ifdef __cplusplus
}
#endif

#endif /*_TD_DND_ENV_H_*/