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 18
/*
 * 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"
#include "vmHandle.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 38
  //     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 已提交
39 40 41 42 43 44 45 46 47
  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 已提交
48

S
shm  
Shengliang Guan 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
  if (walInit() != 0) {
    dError("failed to init wal since %s", terrstr());
    dndCleanup();
    return -1;
  }

  return 0;
}

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

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

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

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