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 25 26
#include "os.h"
#include "taosmsg.h"
#include "thash.h"
S
Shengliang Guan 已提交
27
#include "tlockfree.h"
S
Shengliang Guan 已提交
28
#include "tlog.h"
S
Shengliang Guan 已提交
29
#include "tqueue.h"
S
Shengliang Guan 已提交
30 31 32
#include "trpc.h"
#include "tthread.h"
#include "ttime.h"
S
Shengliang Guan 已提交
33
#include "tworker.h"
S
Shengliang Guan 已提交
34 35

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

extern int32_t dDebugFlag;

S
Shengliang Guan 已提交
41 42 43 44 45 46
#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 已提交
47

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

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

typedef struct {
S
Shengliang Guan 已提交
58 59
  int32_t    dnodeId;
  int32_t    dropped;
S
Shengliang Guan 已提交
60
  int32_t    clusterId;
61 62
  int64_t    rebootTime;
  int8_t     statusSent;
S
Shengliang Guan 已提交
63 64 65 66 67 68
  SEpSet     mnodeEpSet;
  char      *file;
  SHashObj  *dnodeHash;
  SDnodeEps *dnodeEps;
  pthread_t *threadId;
  SRWLatch   latch;
S
Shengliang Guan 已提交
69
} SDnodeMgmt;
S
Shengliang Guan 已提交
70 71

typedef struct {
S
Shengliang Guan 已提交
72 73 74
  int32_t     refCount;
  int8_t      deployed;
  int8_t      dropped;
75 76 77
  int8_t      replica;
  int8_t      selfIndex;
  SReplica    replicas[TSDB_MAX_REPLICA];
78 79 80
  char       *file;
  SMnode     *pMnode;
  SRWLatch    latch;
S
Shengliang Guan 已提交
81 82 83 84 85
  taos_queue  pReadQ;
  taos_queue  pWriteQ;
  taos_queue  pApplyQ;
  taos_queue  pSyncQ;
  taos_queue  pMgmtQ;
86 87 88 89
  SWorkerPool mgmtPool;
  SWorkerPool readPool;
  SWorkerPool writePool;
  SWorkerPool syncPool;
S
Shengliang Guan 已提交
90
} SMnodeMgmt;
S
Shengliang Guan 已提交
91 92

typedef struct {
S
Shengliang Guan 已提交
93
  SHashObj    *hash;
94 95 96 97
  int32_t      openVnodes;
  int32_t      totalVnodes;
  SRWLatch     latch;
  taos_queue   pMgmtQ;
S
Shengliang Guan 已提交
98 99 100 101 102 103
  SWorkerPool  mgmtPool;
  SWorkerPool  queryPool;
  SWorkerPool  fetchPool;
  SMWorkerPool syncPool;
  SMWorkerPool writePool;
} SVnodesMgmt;
S
Shengliang Guan 已提交
104 105

typedef struct {
S
Shengliang Guan 已提交
106 107 108 109
  void    *serverRpc;
  void    *clientRpc;
  DndMsgFp msgFp[TSDB_MSG_TYPE_MAX];
} STransMgmt;
S
Shengliang Guan 已提交
110 111

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

S
Shengliang Guan 已提交
122 123 124
EStat dndGetStat(SDnode *pDnode);
void  dndSetStat(SDnode *pDnode, EStat stat);
char *dndStatStr(EStat stat);
S
Shengliang Guan 已提交
125

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

#ifdef __cplusplus
}
#endif

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