vnodeCommit.c 1.5 KB
Newer Older
H
refact  
Hongze Cheng 已提交
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/>.
 */

H
refact  
Hongze Cheng 已提交
16
#include "vnodeDef.h"
H
refact  
Hongze Cheng 已提交
17 18 19 20 21

static int vnodeStartCommit(SVnode *pVnode);
static int vnodeEndCommit(SVnode *pVnode);

int vnodeAsyncCommit(SVnode *pVnode) {
H
Hongze Cheng 已提交
22 23
  vnodeBufPoolSwitch(pVnode);
  SVnodeTask *pTask = (SVnodeTask *)malloc(sizeof(*pTask));
H
refact  
Hongze Cheng 已提交
24

H
Hongze Cheng 已提交
25 26
  pTask->execute = vnodeCommit;  // TODO
  pTask->arg = pVnode;           // TODO
H
refact  
Hongze Cheng 已提交
27

H
more  
Hongze Cheng 已提交
28 29 30 31
  tsdbPrepareCommit(pVnode->pTsdb);
  // metaPrepareCommit(pVnode->pMeta);
  // walPreapareCommit(pVnode->pWal);

H
Hongze Cheng 已提交
32 33 34
  vnodeScheduleTask(pTask);
  return 0;
}
H
refact  
Hongze Cheng 已提交
35

H
Hongze Cheng 已提交
36 37
int vnodeCommit(void *arg) {
  SVnode *pVnode = (SVnode *)arg;
H
refact  
Hongze Cheng 已提交
38

H
more  
Hongze Cheng 已提交
39 40
  metaCommit(pVnode->pMeta);
  tqCommit(pVnode->pTq);
H
more  
Hongze Cheng 已提交
41
  tsdbCommit(pVnode->pTsdb);
H
more  
Hongze Cheng 已提交
42

H
Hongze Cheng 已提交
43
  vnodeBufPoolRecycle(pVnode);
H
more  
Hongze Cheng 已提交
44
  tsem_post(&(pVnode->canCommit));
H
Hongze Cheng 已提交
45
  // TODO
H
refact  
Hongze Cheng 已提交
46 47 48 49 50 51 52 53 54 55 56 57
  return 0;
}

static int vnodeStartCommit(SVnode *pVnode) {
  // TODO
  return 0;
}

static int vnodeEndCommit(SVnode *pVnode) {
  // TODO
  return 0;
}