dnodeInt.c 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * 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/>.
 */

#define _DEFAULT_SOURCE
#include "os.h"
18
#if 0
19 20 21 22
#include "qScript.h"
#include "tfile.h"
#include "tsync.h"
#include "twal.h"
23 24
#endif
#include "tstep.h"
25 26 27 28 29 30
#include "dnodeCfg.h"
#include "dnodeCheck.h"
#include "dnodeEps.h"
#include "dnodeMain.h"
#include "dnodeMnodeEps.h"
#include "dnodeStatus.h"
31
#include "dnodeTelem.h"
32 33 34 35
#include "dnodeTrans.h"
#include "mnode.h"
#include "vnode.h"

36
static struct SSteps *tsSteps;
37

38
static int32_t dnodeInitVnodeModule(void **unused) {
39 40 41 42 43
  SVnodePara para;
  para.fp.GetDnodeEp = dnodeGetDnodeEp;
  para.fp.SendMsgToDnode = dnodeSendMsgToDnode;
  para.fp.SendMsgToMnode = dnodeSendMsgToMnode;

44
  return vnodeInit(para);
45 46
}

47
static int32_t dnodeInitMnodeModule(void **unused) {
48
  SMnodePara para;
S
Shengliang Guan 已提交
49
  para.fp.GetDnodeEp = dnodeGetDnodeEp;
50 51 52
  para.fp.SendMsgToDnode = dnodeSendMsgToDnode;
  para.fp.SendMsgToMnode = dnodeSendMsgToMnode;
  para.fp.SendRedirectMsg = dnodeSendRedirectMsg;
53
  dnodeGetCfg(&para.dnodeId, para.clusterId);
54

55
  return mnodeInit(para);
56 57
}

58
int32_t dnodeInit() {
59 60
  tsSteps = taosStepInit(24, dnodeReportStartup);
  if (tsSteps == NULL) return -1;
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
  taosStepAdd(tsSteps, "dnode-main", dnodeInitMain, dnodeCleanupMain);
  taosStepAdd(tsSteps, "dnode-storage", dnodeInitStorage, dnodeCleanupStorage);
  //taosStepAdd(tsSteps, "dnode-tfs", tfInit, tfCleanup);
  taosStepAdd(tsSteps, "dnode-rpc", rpcInit, rpcCleanup);
  taosStepAdd(tsSteps, "dnode-check", dnodeInitCheck, dnodeCleanupCheck);
  taosStepAdd(tsSteps, "dnode-cfg", dnodeInitCfg, dnodeCleanupCfg);
  taosStepAdd(tsSteps, "dnode-deps", dnodeInitEps, dnodeCleanupEps);
  taosStepAdd(tsSteps, "dnode-meps", dnodeInitMnodeEps, dnodeCleanupMnodeEps);
  //taosStepAdd(tsSteps, "dnode-wal", walInit, walCleanUp);
  //taosStepAdd(tsSteps, "dnode-sync", syncInit, syncCleanUp);
  taosStepAdd(tsSteps, "dnode-vnode", dnodeInitVnodeModule, vnodeCleanup);
  taosStepAdd(tsSteps, "dnode-mnode", dnodeInitMnodeModule, mnodeCleanup);
  taosStepAdd(tsSteps, "dnode-trans", dnodeInitTrans, dnodeCleanupTrans);
  taosStepAdd(tsSteps, "dnode-status", dnodeInitStatus, dnodeCleanupStatus);
  taosStepAdd(tsSteps, "dnode-telem", dnodeInitTelem, dnodeCleanupTelem);
  //taosStepAdd(tsSteps, "dnode-script",scriptEnvPoolInit, scriptEnvPoolCleanup);
78

79
  taosStepExec(tsSteps);
80

S
Shengliang Guan 已提交
81
  dnodeSetRunStat(DN_RUN_STAT_RUNNING);
82 83
  dnodeReportStartupFinished("TDengine", "initialized successfully");
  dInfo("TDengine is initialized successfully");
84

85
  return 0;
86 87
}

88
void dnodeCleanup() {
S
Shengliang Guan 已提交
89 90
  if (dnodeGetRunStat() != DN_RUN_STAT_STOPPED) {
    dnodeSetRunStat(DN_RUN_STAT_STOPPED);
91 92
    taosStepCleanup(tsSteps);
    tsSteps = NULL;
93 94
  }
}