dnode.h 2.2 KB
Newer Older
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_DNODE_H_
#define _TD_DNODE_H_
18

S
Shengliang Guan 已提交
19 20
#include "tdef.h"

21 22 23 24
#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
25
/* ------------------------ TYPES EXPOSED ---------------- */
S
Shengliang Guan 已提交
26
typedef struct SDnode SDnode;
27

S
Shengliang Guan 已提交
28 29 30 31
/* ------------------------ Environment ------------------ */
typedef struct {
  int32_t sver;
  int32_t numOfCores;
S
Shengliang Guan 已提交
32
  int16_t numOfCommitThreads;
S
Shengliang Guan 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  int8_t  enableTelem;
  char    timezone[TSDB_TIMEZONE_LEN];
  char    locale[TSDB_LOCALE_LEN];
  char    charset[TSDB_LOCALE_LEN];
  char    buildinfo[64];
  char    gitinfo[48];
} SDnodeEnvCfg;

/**
 * @brief Initialize the environment
 *
 * @param pOption Option of the environment
 * @return int32_t 0 for success and -1 for failure
 */
int32_t dndInit(const SDnodeEnvCfg *pCfg);

/**
 * @brief clear the environment
 *
 */
void dndCleanup();

/* ------------------------ SDnode ----------------------- */
S
Shengliang Guan 已提交
56
typedef struct {
S
Shengliang Guan 已提交
57
  int32_t  numOfSupportVnodes;
S
Shengliang Guan 已提交
58 59 60 61 62
  int32_t  statusInterval;
  float    numOfThreadsPerCore;
  float    ratioOfQueryCores;
  int32_t  maxShellConns;
  int32_t  shellActivityTimer;
S
Shengliang Guan 已提交
63
  uint16_t serverPort;
S
Shengliang Guan 已提交
64 65 66 67
  char     dataDir[TSDB_FILENAME_LEN];
  char     localEp[TSDB_EP_LEN];
  char     localFqdn[TSDB_FQDN_LEN];
  char     firstEp[TSDB_EP_LEN];
S
Shengliang Guan 已提交
68
} SDnodeObjCfg;
S
Shengliang Guan 已提交
69

S
Shengliang Guan 已提交
70 71 72
/**
 * @brief Initialize and start the dnode.
 *
S
Shengliang Guan 已提交
73
 * @param pCfg Config of the dnode.
S
Shengliang Guan 已提交
74 75
 * @return SDnode* The dnode object.
 */
S
Shengliang Guan 已提交
76
SDnode *dndCreate(SDnodeObjCfg *pCfg);
S
Shengliang Guan 已提交
77 78

/**
79
 * @brief Stop and cleanup the dnode.
S
Shengliang Guan 已提交
80
 *
81
 * @param pDnode The dnode object to close.
S
Shengliang Guan 已提交
82
 */
S
Shengliang Guan 已提交
83
void dndClose(SDnode *pDnode);
S
Shengliang Guan 已提交
84

85 86 87 88
#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
89
#endif /*_TD_DNODE_H_*/