dndInt.h 3.4 KB
Newer Older
S
Shengliang Guan 已提交
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_DND_INT_H_
#define _TD_DND_INT_H_
S
Shengliang Guan 已提交
18 19 20 21

#ifdef __cplusplus
extern "C" {
#endif
S
Shengliang Guan 已提交
22 23

#include "cJSON.h"
S
Shengliang Guan 已提交
24
#include "os.h"
S
Shengliang Guan 已提交
25
#include "tep.h"
S
Shengliang Guan 已提交
26
#include "thash.h"
S
Shengliang Guan 已提交
27
#include "tlockfree.h"
S
Shengliang Guan 已提交
28
#include "tlog.h"
S
Shengliang Guan 已提交
29
#include "tmsg.h"
S
Shengliang Guan 已提交
30
#include "tqueue.h"
S
Shengliang Guan 已提交
31 32 33
#include "trpc.h"
#include "tthread.h"
#include "ttime.h"
S
Shengliang Guan 已提交
34
#include "tworker.h"
S
Shengliang Guan 已提交
35 36

#include "dnode.h"
S
Shengliang Guan 已提交
37 38
#include "mnode.h"
#include "vnode.h"
S
Shengliang Guan 已提交
39 40 41

extern int32_t dDebugFlag;

S
Shengliang Guan 已提交
42 43 44 45 46 47
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", 255, __VA_ARGS__); }}
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", 255, __VA_ARGS__); }}
#define dWarn(...)  { if (dDebugFlag & DEBUG_WARN)  { taosPrintLog("DND WARN ", 255, __VA_ARGS__); }}
#define dInfo(...)  { if (dDebugFlag & DEBUG_INFO)  { taosPrintLog("DND ", 255, __VA_ARGS__); }}
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
S
Shengliang Guan 已提交
48

S
Shengliang Guan 已提交
49 50
typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EStat;
typedef void (*DndMsgFp)(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEps);
S
Shengliang Guan 已提交
51 52 53 54

typedef struct {
  char *dnode;
  char *mnode;
S
Shengliang Guan 已提交
55 56 57
  char *qnode;
  char *snode;
  char *bnode;
S
Shengliang Guan 已提交
58 59 60 61
  char *vnodes;
} SDnodeDir;

typedef struct {
S
Shengliang Guan 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75
  int32_t     dnodeId;
  int32_t     dropped;
  int64_t     clusterId;
  int64_t     rebootTime;
  int64_t     updateTime;
  int8_t      statusSent;
  SEpSet      mnodeEpSet;
  char       *file;
  SHashObj   *dnodeHash;
  SDnodeEps  *dnodeEps;
  pthread_t  *threadId;
  SRWLatch    latch;
  taos_queue  pMgmtQ;
  SWorkerPool mgmtPool;
S
Shengliang Guan 已提交
76
} SDnodeMgmt;
S
Shengliang Guan 已提交
77 78

typedef struct {
S
Shengliang Guan 已提交
79 80 81
  int32_t     refCount;
  int8_t      deployed;
  int8_t      dropped;
82 83 84
  int8_t      replica;
  int8_t      selfIndex;
  SReplica    replicas[TSDB_MAX_REPLICA];
85 86 87
  char       *file;
  SMnode     *pMnode;
  SRWLatch    latch;
S
Shengliang Guan 已提交
88 89 90
  taos_queue  pReadQ;
  taos_queue  pWriteQ;
  taos_queue  pSyncQ;
91 92 93
  SWorkerPool readPool;
  SWorkerPool writePool;
  SWorkerPool syncPool;
S
Shengliang Guan 已提交
94
} SMnodeMgmt;
S
Shengliang Guan 已提交
95 96

typedef struct {
S
Shengliang Guan 已提交
97
  SHashObj    *hash;
98 99 100
  int32_t      openVnodes;
  int32_t      totalVnodes;
  SRWLatch     latch;
S
Shengliang Guan 已提交
101 102 103 104 105
  SWorkerPool  queryPool;
  SWorkerPool  fetchPool;
  SMWorkerPool syncPool;
  SMWorkerPool writePool;
} SVnodesMgmt;
S
Shengliang Guan 已提交
106 107

typedef struct {
S
Shengliang Guan 已提交
108 109
  void    *serverRpc;
  void    *clientRpc;
H
Hongze Cheng 已提交
110
  DndMsgFp msgFp[TDMT_MAX];
S
Shengliang Guan 已提交
111
} STransMgmt;
S
Shengliang Guan 已提交
112 113

typedef struct SDnode {
S
Shengliang Guan 已提交
114 115 116
  EStat       stat;
  SDnodeOpt   opt;
  SDnodeDir   dir;
S
Shengliang Guan 已提交
117
  FileFd      lockFd;
S
Shengliang Guan 已提交
118
  SDnodeMgmt  dmgmt;
S
Shengliang Guan 已提交
119
  SMnodeMgmt  mmgmt;
S
Shengliang Guan 已提交
120
  SVnodesMgmt vmgmt;
S
Shengliang Guan 已提交
121
  STransMgmt  tmgmt;
S
Shengliang Guan 已提交
122
  SStartupMsg startup;
S
Shengliang Guan 已提交
123 124
} SDnode;

S
Shengliang Guan 已提交
125 126 127
EStat dndGetStat(SDnode *pDnode);
void  dndSetStat(SDnode *pDnode, EStat stat);
char *dndStatStr(EStat stat);
S
Shengliang Guan 已提交
128

S
Shengliang Guan 已提交
129
void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc);
S
Shengliang Guan 已提交
130
void dndGetStartup(SDnode *pDnode, SStartupMsg *pStartup);
S
Shengliang Guan 已提交
131 132 133 134 135

#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
136
#endif /*_TD_DND_INT_H_*/