vnodeWrite.c 1.7 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
refact  
Hongze Cheng 已提交
19 20 21 22
  /* TODO */
  return 0;
}

H
refact  
Hongze Cheng 已提交
23
int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
H
more  
Hongze Cheng 已提交
24
#if 0
H
refact  
Hongze Cheng 已提交
25 26 27 28
  int      reqType;        /* TODO */
  size_t   reqSize;        /* TODO */
  uint64_t reqVersion = 0; /* TODO */
  int      code = 0;
H
refact  
Hongze Cheng 已提交
29 30

  // Copy the request to vnode buffer
H
refact  
Hongze Cheng 已提交
31
  void *pReq = mMalloc(pVnode->inuse, reqSize);
H
refact  
Hongze Cheng 已提交
32 33 34 35
  if (pReq == NULL) {
    // TODO: handle error
  }

H
refact  
Hongze Cheng 已提交
36
  memcpy(pReq, pMsg, reqSize);
H
more  
Hongze Cheng 已提交
37

H
refact  
Hongze Cheng 已提交
38 39 40 41 42 43 44 45 46 47 48
  // Push the request to TQ so consumers can consume
  tqPushMsg(pVnode->pTq, pReq, 0);

  // Process the request
  switch (reqType) {
    case TSDB_MSG_TYPE_CREATE_TABLE:
      code = metaCreateTable(pVnode->pMeta, NULL /* TODO */);
      break;
    case TSDB_MSG_TYPE_DROP_TABLE:
      code = metaDropTable(pVnode->pMeta, 0 /* TODO */);
      break;
H
more  
Hongze Cheng 已提交
49
    case TSDB_MSG_TYPE_SUBMIT:
H
refact  
Hongze Cheng 已提交
50
      /* TODO */
H
more  
Hongze Cheng 已提交
51
      break;
H
refact  
Hongze Cheng 已提交
52 53 54 55 56 57 58 59 60 61 62
    default:
      break;
  }

  if (vnodeShouldCommit(pVnode)) {
    if (vnodeAsyncCommit(pVnode) < 0) {
      // TODO: handle error
    }
  }

  return code;
H
more  
Hongze Cheng 已提交
63 64
#endif
  return 0;
H
more  
Hongze Cheng 已提交
65 66
}

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