dmMgmt.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_MGMT_H_
#define _TD_DND_MGMT_H_
S
Shengliang Guan 已提交
18

S
Shengliang Guan 已提交
19 20 21
// tobe deleted
#include "uv.h"

S
Shengliang Guan 已提交
22
#include "dmInt.h"
S
Shengliang Guan 已提交
23 24 25 26 27

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
28
typedef struct SMgmtWrapper {
29
  SMgmtFunc      func;
30
  struct SDnode *pDnode;
31 32 33 34
  void          *pMgmt;
  const char    *name;
  char          *path;
  int32_t        refCount;
35
  TdThreadRwlock lock;
36 37 38 39
  EDndNodeType   ntype;
  bool           deployed;
  bool           required;
  NodeMsgFp      msgFps[TDMT_MAX];
S
Shengliang Guan 已提交
40 41 42 43 44
} SMgmtWrapper;

typedef struct {
  EDndNodeType defaultNtype;
  bool         needCheckVgId;
45
} SDnodeHandle;
S
Shengliang Guan 已提交
46 47

typedef struct {
48 49 50
  void        *serverRpc;
  void        *clientRpc;
  SDnodeHandle msgHandles[TDMT_MAX];
S
Shengliang Guan 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
} SDnodeTrans;

typedef struct {
  char name[TSDB_STEP_NAME_LEN];
  char desc[TSDB_STEP_DESC_LEN];
} SStartupInfo;

typedef struct SUdfdData {
  bool         startCalled;
  bool         needCleanUp;
  uv_loop_t    loop;
  uv_thread_t  thread;
  uv_barrier_t barrier;
  uv_process_t process;
  int          spawnErr;
  uv_pipe_t    ctrlPipe;
  uv_async_t   stopAsync;
  int32_t      stopCalled;
  int32_t      dnodeId;
} SUdfdData;

typedef struct SDnode {
73 74
  int8_t        once;
  bool          stop;
S
Shengliang Guan 已提交
75 76 77 78 79 80
  EDndRunStatus status;
  SStartupInfo  startup;
  SDnodeTrans   trans;
  SUdfdData     udfdData;
  TdThreadMutex mutex;
  TdFilePtr     lockfile;
S
Shengliang Guan 已提交
81
  SDnodeData    data;
S
Shengliang Guan 已提交
82 83 84
  SMgmtWrapper  wrappers[NODE_END];
} SDnode;

85 86 87
// dmEnv.c
SDnode *dmInstance();
void    dmReportStartup(const char *pName, const char *pDesc);
D
dapan1121 已提交
88
int64_t dmGetClusterId();
S
Shengliang Guan 已提交
89

90
// dmMgmt.c
91
int32_t       dmInitDnode(SDnode *pDnode);
92
void          dmCleanupDnode(SDnode *pDnode);
S
Shengliang Guan 已提交
93 94 95
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
int32_t       dmMarkWrapper(SMgmtWrapper *pWrapper);
void          dmReleaseWrapper(SMgmtWrapper *pWrapper);
S
Shengliang Guan 已提交
96
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
S
Shengliang Guan 已提交
97
void          dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
S
Shengliang Guan 已提交
98 99
void          dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
void          dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
100

101 102
// dmNodes.c
int32_t dmOpenNode(SMgmtWrapper *pWrapper);
103 104
int32_t dmStartNode(SMgmtWrapper *pWrapper);
void    dmStopNode(SMgmtWrapper *pWrapper);
105 106 107
void    dmCloseNode(SMgmtWrapper *pWrapper);
int32_t dmRunDnode(SDnode *pDnode);

S
Shengliang Guan 已提交
108
// dmTransport.c
S
Shengliang Guan 已提交
109 110 111 112
int32_t dmInitServer(SDnode *pDnode);
void    dmCleanupServer(SDnode *pDnode);
int32_t dmInitClient(SDnode *pDnode);
void    dmCleanupClient(SDnode *pDnode);
113
SMsgCb  dmGetMsgcb(SDnode *pDnode);
S
Shengliang Guan 已提交
114
int32_t dmInitMsgHandle(SDnode *pDnode);
S
Shengliang Guan 已提交
115
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
116

S
Shengliang Guan 已提交
117 118 119 120
// dmMonitor.c
void dmSendMonitorReport();
void dmGetVnodeLoads(SMonVloadInfo *pInfo);
void dmGetMnodeLoads(SMonMloadInfo *pInfo);
D
dapan1121 已提交
121
void dmGetQnodeLoads(SQnodeLoad *pInfo);
S
Shengliang Guan 已提交
122

S
Shengliang Guan 已提交
123 124 125 126
#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
127
#endif /*_TD_DND_MGMT_H_*/