dnode.h 2.1 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 32
/**
 * @brief Initialize the environment
 *
 * @return int32_t 0 for success and -1 for failure
 */
S
config  
Shengliang Guan 已提交
33
int32_t dndInit();
S
Shengliang Guan 已提交
34 35

/**
S
shm  
Shengliang Guan 已提交
36
 * @brief Clear the environment
S
Shengliang Guan 已提交
37 38 39 40
 */
void dndCleanup();

/* ------------------------ SDnode ----------------------- */
S
Shengliang Guan 已提交
41
typedef struct {
S
tfs cfg  
Shengliang Guan 已提交
42 43
  int32_t   numOfSupportVnodes;
  uint16_t  serverPort;
S
shm  
Shengliang Guan 已提交
44
  char      dataDir[PATH_MAX];
S
tfs cfg  
Shengliang Guan 已提交
45 46 47 48
  char      localEp[TSDB_EP_LEN];
  char      localFqdn[TSDB_FQDN_LEN];
  char      firstEp[TSDB_EP_LEN];
  char      secondEp[TSDB_EP_LEN];
S
Shengliang Guan 已提交
49
  SDiskCfg *disks;
S
tfs cfg  
Shengliang Guan 已提交
50
  int32_t   numOfDisks;
S
Shengliang Guan 已提交
51
  int8_t    ntype;
S
shm  
Shengliang Guan 已提交
52
} SDnodeOpt;
S
Shengliang Guan 已提交
53

S
Shengliang Guan 已提交
54
typedef enum { DND_EVENT_START, DND_EVENT_STOP = 1, DND_EVENT_CHILD } EDndEvent;
S
shm  
Shengliang Guan 已提交
55

S
Shengliang Guan 已提交
56 57 58
/**
 * @brief Initialize and start the dnode.
 *
S
shm  
Shengliang Guan 已提交
59
 * @param pOption Option of the dnode.
S
Shengliang Guan 已提交
60 61
 * @return SDnode* The dnode object.
 */
S
shm  
Shengliang Guan 已提交
62
SDnode *dndCreate(const SDnodeOpt *pOption);
S
Shengliang Guan 已提交
63 64

/**
65
 * @brief Stop and cleanup the dnode.
S
Shengliang Guan 已提交
66
 *
67
 * @param pDnode The dnode object to close.
S
Shengliang Guan 已提交
68
 */
S
Shengliang Guan 已提交
69
void dndClose(SDnode *pDnode);
S
Shengliang Guan 已提交
70

S
shm  
Shengliang Guan 已提交
71 72 73 74 75
/**
 * @brief Run dnode until specific event is receive.
 *
 * @param pDnode The dnode object to run.
 */
S
shm  
Shengliang Guan 已提交
76
int32_t dndRun(SDnode *pDnode);
S
shm  
Shengliang Guan 已提交
77 78 79 80 81 82 83

/**
 * @brief Handle event in the dnode.
 *
 * @param pDnode The dnode object to close.
 * @param event The event to handle.
 */
S
shm  
Shengliang Guan 已提交
84
void dndHandleEvent(SDnode *pDnode, EDndEvent event);
S
shm  
Shengliang Guan 已提交
85

86 87 88 89
#ifdef __cplusplus
}
#endif

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