vnodeWrite.c 1.6 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/>.
 */

H
refact  
Hongze Cheng 已提交
16 17
#include "vnodeDef.h"

H
refact  
Hongze Cheng 已提交
18
int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
H
more  
Hongze Cheng 已提交
19 20 21 22 23 24
  SRpcMsg *pReq;
  SRpcMsg *pRsp;

  for (size_t i = 0; i < taosArrayGetSize(pMsgs); i++) {
    pReq = taosArrayGet(pMsgs, i);

H
more  
Hongze Cheng 已提交
25
    vnodeApplyWMsg(pVnode, pReq, &pRsp);
H
more  
Hongze Cheng 已提交
26 27
  }

H
refact  
Hongze Cheng 已提交
28 29 30
  return 0;
}

H
refact  
Hongze Cheng 已提交
31
int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
H
more  
Hongze Cheng 已提交
32 33
  // TODO
  int code = 0;
H
refact  
Hongze Cheng 已提交
34

H
more  
Hongze Cheng 已提交
35
  switch (pMsg->msgType) {
H
refact  
Hongze Cheng 已提交
36
    case TSDB_MSG_TYPE_CREATE_TABLE:
H
more  
Hongze Cheng 已提交
37
      if (metaCreateTable(pVnode->pMeta, pMsg->pCont, pMsg->contLen) < 0) {
H
more  
Hongze Cheng 已提交
38 39 40
        /* TODO */
        return -1;
      }
H
refact  
Hongze Cheng 已提交
41 42
      break;
    case TSDB_MSG_TYPE_DROP_TABLE:
H
more  
Hongze Cheng 已提交
43
      if (metaDropTable(pVnode->pMeta, pMsg->pCont, pMsg->contLen) < 0) {
H
more  
Hongze Cheng 已提交
44 45 46
        /* TODO */
        return -1;
      }
H
refact  
Hongze Cheng 已提交
47
      break;
H
more  
Hongze Cheng 已提交
48
    case TSDB_MSG_TYPE_SUBMIT:
H
more  
Hongze Cheng 已提交
49
      if (tsdbInsertData(pVnode->pTsdb, pMsg->pCont, pMsg->contLen) < 0) {
H
more  
Hongze Cheng 已提交
50 51 52
        /* TODO */
        return -1;
      }
H
more  
Hongze Cheng 已提交
53
      break;
H
refact  
Hongze Cheng 已提交
54 55 56 57
    default:
      break;
  }

H
more  
Hongze Cheng 已提交
58
  return 0;
H
more  
Hongze Cheng 已提交
59 60
}

H
Hongze Cheng 已提交
61
/* ------------------------ STATIC METHODS ------------------------ */