vmInt.c 2.0 KB
Newer Older
S
shm  
Shengliang Guan 已提交
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 "vmInt.h"
S
rename  
Shengliang Guan 已提交
18
#include "vmMsg.h"
S
shm  
Shengliang Guan 已提交
19
#include "vmMgmt.h"
S
shm  
Shengliang Guan 已提交
20

S
shm  
Shengliang Guan 已提交
21
static int32_t vmInit(SMgmtWrapper *pWrapper) {
S
shm  
Shengliang Guan 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  //     SDiskCfg dCfg = {0};
  // tstrncpy(dCfg.dir, pDnode->cfg.dataDir, TSDB_FILENAME_LEN);
  // dCfg.level = 0;
  // dCfg.primary = 1;
  // SDiskCfg *pDisks = pDnode->cfg.pDisks;
  // int32_t   numOfDisks = pDnode->cfg.numOfDisks;
  // if (numOfDisks <= 0 || pDisks == NULL) {
  //   pDisks = &dCfg;
  //   numOfDisks = 1;
  // }

  // pDnode->pTfs = tfsOpen(pDisks, numOfDisks);
  // if (pDnode->pTfs == NULL) {
  //   dError("failed to init tfs since %s", terrstr());
  //   return -1;
  // }
S
shm  
Shengliang Guan 已提交
38 39 40 41 42
  if (walInit() != 0) {
    dError("failed to init wal since %s", terrstr());
    dndCleanup();
    return -1;
  }
S
shm  
Shengliang Guan 已提交
43

S
shm  
Shengliang Guan 已提交
44 45 46 47 48 49 50 51 52
  SVnodeOpt vnodeOpt = {0};
  vnodeOpt.nthreads = tsNumOfCommitThreads;
  vnodeOpt.putReqToVQueryQFp = dndPutReqToVQueryQ;
  vnodeOpt.sendReqToDnodeFp = dndSendReqToDnode;
  if (vnodeInit(&vnodeOpt) != 0) {
    dError("failed to init vnode since %s", terrstr());
    dndCleanup();
    return -1;
  }
S
shm  
Shengliang Guan 已提交
53

S
shm  
Shengliang Guan 已提交
54 55 56 57 58 59 60 61
  return 0;
}

static void vmCleanup(SMgmtWrapper *pWrapper) {
  vnodeCleanup();
}

static bool vmRequire(SMgmtWrapper *pWrapper) { return false; }
S
shm  
Shengliang Guan 已提交
62

S
shm  
Shengliang Guan 已提交
63
void vmGetMgmtFp(SMgmtWrapper *pWrapper) {
S
shm  
Shengliang Guan 已提交
64
  SMgmtFp mgmtFp = {0};
S
shm  
Shengliang Guan 已提交
65 66 67
  mgmtFp.openFp = vmInit;
  mgmtFp.closeFp = vmCleanup;
  mgmtFp.requiredFp = vmRequire;
S
shm  
Shengliang Guan 已提交
68 69 70 71

  vmInitMsgHandles(pWrapper);
  pWrapper->name = "vnodes";
  pWrapper->fp = mgmtFp;
S
shm  
Shengliang Guan 已提交
72
}