dndEnv.h 3.1 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 108 109 110
  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 {
  SHashObj    *hash;
  int32_t      openVnodes;
  int32_t      totalVnodes;
S
Shengliang Guan 已提交
111
  int32_t      masterNum;
S
Shengliang Guan 已提交
112
  SRWLatch     latch;
S
Shengliang Guan 已提交
113
  SQWorkerPool queryPool;
S
Shengliang Guan 已提交
114
  SFWorkerPool fetchPool;
S
Shengliang Guan 已提交
115 116
  SWWorkerPool syncPool;
  SWWorkerPool writePool;
S
Shengliang Guan 已提交
117 118 119 120 121 122 123 124 125 126 127 128
} SVnodesMgmt;

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

typedef struct SDnode {
  EStat        stat;
  SDnodeObjCfg cfg;
  SDnodeDir    dir;
129
  TdFilePtr    pLockFile;
S
Shengliang Guan 已提交
130 131 132 133 134 135 136
  SDnodeMgmt   dmgmt;
  SMnodeMgmt   mmgmt;
  SQnodeMgmt   qmgmt;
  SSnodeMgmt   smgmt;
  SBnodeMgmt   bmgmt;
  SVnodesMgmt  vmgmt;
  STransMgmt   tmgmt;
S
Shengliang Guan 已提交
137
  STfs        *pTfs;
S
Shengliang Guan 已提交
138 139 140
  SStartupReq  startup;
} SDnode;

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

S
Shengliang Guan 已提交
143 144 145 146 147
#ifdef __cplusplus
}
#endif

#endif /*_TD_DND_ENV_H_*/